From 3ab2aec4e83bdae44a0502826d3fe85e3e26073b Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 30 Jan 2017 09:04:01 -0600 Subject: [PATCH] New apps/examples/module and sotest configuration options --- examples/module/Kconfig | 77 ++++++++++++++++-------- examples/module/drivers/.gitignore | 2 +- examples/module/drivers/Makefile | 30 +++++---- examples/module/drivers/chardev/Makefile | 4 +- examples/module/module_main.c | 58 ++++++++++-------- examples/sotest/Kconfig | 76 ++++++++++++++++------- examples/sotest/Makefile | 2 +- examples/sotest/lib/.gitignore | 2 +- examples/sotest/lib/Makefile | 30 +++++---- examples/sotest/lib/modprint/Makefile | 4 +- examples/sotest/lib/sotest/Makefile | 4 +- examples/sotest/sotest_main.c | 69 ++++++++++++--------- 12 files changed, 222 insertions(+), 136 deletions(-) diff --git a/examples/module/Kconfig b/examples/module/Kconfig index 82a887214..50b9aeab0 100644 --- a/examples/module/Kconfig +++ b/examples/module/Kconfig @@ -6,20 +6,65 @@ config EXAMPLES_MODULE bool "Module Example" default n - depends on MODULE && LIB_BOARDCTL && BUILD_FLAT + depends on MODULE && LIB_BOARDCTL select BOARDCTL_OS_SYMTAB ---help--- Enable the module example - NOTE: This example can only be used in the FLAT build mode because - it makes illegal OS calls to ramdisk_register(), register_device(), - and unregister_device(). A proper solution would include the ROMFS - file system containing the test module file in the kernel address - space and would register it with logic in the configs/ board directory - at start-up. - if EXAMPLES_MODULE +config EXAMPLES_MODULE_BUILTINFS + bool "Built-in File System" + default y + depends on FS_ROMFS && BUILD_FLAT + ---help--- + This example supports a very, non-standard but also very convenient + way of testing with example using CONFIG_EXAMPLES_MODULE_BUILTINFS. + If this option is selected, the test modules will be built, + installed in the module/lib/fsroot, then converted to a built-in + ROMFS file system. + + When the test runs, it will automatically create the ROMFS block + device and mount the test modules for testing. + + If this option is not selected, then the modules will be left in + the fsroot/ directory. You can then copy them to, say an SD card, + for testing on the target. + + NOTE: This option can only be used in the FLAT build mode because + it makes an illegal OS call to ramdisk_register(). + +if EXAMPLES_MODULE_BUILTINFS + +config EXAMPLES_MODULE_DEVMINOR + int "ROMFS Minor Device Number" + default 0 + ---help--- + The minor device number of the ROMFS block. For example, the N in /dev/ramN. + Used for registering the RAM block driver that will hold the ROMFS file system + containing the MODULE executables to be tested. Default: 0 + +config EXAMPLES_MODULE_DEVPATH + string "ROMFS Device Path" + default "/dev/ram0" + ---help--- + The path to the ROMFS block driver device. This must match EXAMPLES_MODULE_DEVMINOR. + Used for registering the RAM block driver that will hold the ROMFS file system + containing the MODULE executables to be tested. Default: "/dev/ram0" + +endif # EXAMPLES_MODULE_BUILTINFS + +if !EXAMPLES_MODULE_BUILTINFS + +config EXAMPLES_MODULE_BINDIR + string "Path to Test Modules" + default "/mnt/sdcard" + ---help--- + The path to the directory on the mounted volume where the test + modules can found at runtime. + +endif # !EXAMPLES_MODULE_BUILTINFS + config EXAMPLES_MODULE_LIBC bool "Link with LIBC" default n @@ -44,20 +89,4 @@ config EXAMPLES_MODULE_LIBGCC default n depends on !BUILD_KERNEL && EXPERIMENTAL -config EXAMPLES_MODULE_DEVMINOR - int "ROMFS Minor Device Number" - default 0 - ---help--- - The minor device number of the ROMFS block. For example, the N in /dev/ramN. - Used for registering the RAM block driver that will hold the ROMFS file system - containing the MODULE executables to be tested. Default: 0 - -config EXAMPLES_MODULE_DEVPATH - string "ROMFS Device Path" - default "/dev/ram0" - ---help--- - The path to the ROMFS block driver device. This must match EXAMPLES_MODULE_DEVMINOR. - Used for registering the RAM block driver that will hold the ROMFS file system - containing the MODULE executables to be tested. Default: "/dev/ram0" - endif diff --git a/examples/module/drivers/.gitignore b/examples/module/drivers/.gitignore index 9dc7c5515..a9b56c17b 100644 --- a/examples/module/drivers/.gitignore +++ b/examples/module/drivers/.gitignore @@ -1,4 +1,4 @@ -/romfs +/fsroot /romfs.h /romfs.img /mod_symtab.c diff --git a/examples/module/drivers/Makefile b/examples/module/drivers/Makefile index a026f4b79..59573d2f4 100644 --- a/examples/module/drivers/Makefile +++ b/examples/module/drivers/Makefile @@ -1,7 +1,7 @@ ############################################################################ # apps/examples/module/drivers/Makefile # -# Copyright (C) 2015 Gregory Nutt. All rights reserved. +# Copyright (C) 2015, 2017 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -42,14 +42,14 @@ BUILD_SUBDIRS = chardev MODULE_DIR = $(APPDIR)/examples/module DRIVER_DIR = $(MODULE_DIR)/drivers -ROMFS_DIR = $(DRIVER_DIR)/romfs +FSROOT_DIR = $(DRIVER_DIR)/fsroot ROMFS_IMG = $(DRIVER_DIR)/romfs.img ROMFS_HDR = $(DRIVER_DIR)/romfs.h SYMTAB_SRC = $(DRIVER_DIR)/mod_symtab.c define DIR_template $(1)_$(2): - $(Q) $(MAKE) -C $(1) $(3) TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" ROMFS_DIR="$(ROMFS_DIR)" CROSSDEV=$(CROSSDEV) + $(Q) $(MAKE) -C $(1) $(3) TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" FSROOT_DIR="$(FSROOT_DIR)" CROSSDEV=$(CROSSDEV) endef all: $(ROMFS_HDR) $(DIRLIST_HDR) $(SYMTAB_SRC) @@ -63,36 +63,40 @@ $(foreach DIR, $(BUILD_SUBDIRS), $(eval $(call DIR_template,$(DIR),install,insta build: $(foreach DIR, $(BUILD_SUBDIRS), $(DIR)_build) -# Install each program in the romfs directory +# Install each program in the fsroot directory install: $(foreach DIR, $(BUILD_SUBDIRS), $(DIR)_install) -# Create the romfs directory +# Create the fsroot directory -$(ROMFS_DIR): - $(Q) mkdir $(ROMFS_DIR) +$(FSROOT_DIR): + $(Q) mkdir $(FSROOT_DIR) -# Populate the romfs directory +# Populate the fsroot directory -populate: $(ROMFS_DIR) build install +populate: $(FSROOT_DIR) build install -# Create the romfs.img file from the populated romfs directory +# Create the romfs.img file from the populated fsroot directory $(ROMFS_IMG): populate - $(Q) genromfs -f $@ -d $(ROMFS_DIR) -V "MODULETEST" +ifeq ($(CONFIG_EXAMPLES_MODULE_BUILTINFS),y) + $(Q) genromfs -f $@ -d $(FSROOT_DIR) -V "MODULETEST" +endif # Create the romfs.h header file from the romfs.img file $(ROMFS_HDR) : $(ROMFS_IMG) +ifeq ($(CONFIG_EXAMPLES_MODULE_BUILTINFS),y) $(Q) (cd $(DRIVER_DIR); xxd -i romfs.img | sed -e "s/^unsigned/static const unsigned/g" >$@) +endif # Create the exported symbol table $(SYMTAB_SRC): build - $(Q) $(DRIVER_DIR)/mksymtab.sh $(ROMFS_DIR) >$@ + $(Q) $(DRIVER_DIR)/mksymtab.sh $(FSROOT_DIR) >$@ # Clean each subdirectory clean: $(foreach DIR, $(ALL_SUBDIRS), $(DIR)_clean) $(Q) rm -f $(ROMFS_HDR) $(DIRLIST_HDR) $(ROMFS_IMG) $(SYMTAB_SRC) - $(Q) rm -rf $(ROMFS_DIR) + $(Q) rm -rf $(FSROOT_DIR) diff --git a/examples/module/drivers/chardev/Makefile b/examples/module/drivers/chardev/Makefile index 416f718ac..4154d9dd1 100644 --- a/examples/module/drivers/chardev/Makefile +++ b/examples/module/drivers/chardev/Makefile @@ -90,5 +90,5 @@ clean: $(call CLEAN) install: - $(Q) mkdir -p $(ROMFS_DIR) - $(Q) install $(BIN) $(ROMFS_DIR)/$(BIN) + $(Q) mkdir -p $(FSROOT_DIR) + $(Q) install $(BIN) $(FSROOT_DIR)/$(BIN) diff --git a/examples/module/module_main.c b/examples/module/module_main.c index c24b7957f..ccb75fcbe 100644 --- a/examples/module/module_main.c +++ b/examples/module/module_main.c @@ -40,9 +40,11 @@ #include #include -#include -#include +#ifdef CONFIG_EXAMPLES_MODULE_BUILTINFS +# include +#endif +#include #include #include #include @@ -52,11 +54,13 @@ #include #include -#include #include #include -#include "drivers/romfs.h" +#ifdef CONFIG_EXAMPLES_MODULE_BUILTINFS +# include +# include "drivers/romfs.h" +#endif /**************************************************************************** * Pre-processor Definitions @@ -74,27 +78,31 @@ # error "You must select CONFIG_MODULE in your configuration file" #endif -#ifndef CONFIG_FS_ROMFS -# error "You must select CONFIG_FS_ROMFS in your configuration file" -#endif +#ifdef CONFIG_EXAMPLES_MODULE_BUILTINFS +# ifndef CONFIG_FS_ROMFS +# error "You must select CONFIG_FS_ROMFS in your configuration file" +# endif -#ifdef CONFIG_DISABLE_MOUNTPOINT -# error "You must not disable mountpoints via CONFIG_DISABLE_MOUNTPOINT in your configuration file" -#endif +# ifdef CONFIG_DISABLE_MOUNTPOINT +# error "You must not disable mountpoints via CONFIG_DISABLE_MOUNTPOINT in your configuration file" +# endif -/* Describe the ROMFS file system */ + /* Describe the ROMFS file system */ -#define SECTORSIZE 64 -#define NSECTORS(b) (((b)+SECTORSIZE-1)/SECTORSIZE) -#define MOUNTPT "/mnt/romfs" +# define SECTORSIZE 64 +# define NSECTORS(b) (((b)+SECTORSIZE-1)/SECTORSIZE) +# define BINDIR "/mnt/romfs" -#ifndef CONFIG_EXAMPLES_MODULE_DEVMINOR -# define CONFIG_EXAMPLES_MODULE_DEVMINOR 0 -#endif +# ifndef CONFIG_EXAMPLES_MODULE_DEVMINOR +# define CONFIG_EXAMPLES_MODULE_DEVMINOR 0 +# endif -#ifndef CONFIG_EXAMPLES_MODULE_DEVPATH -# define CONFIG_EXAMPLES_MODULE_DEVPATH "/dev/ram0" -#endif +# ifndef CONFIG_EXAMPLES_MODULE_DEVPATH +# define CONFIG_EXAMPLES_MODULE_DEVPATH "/dev/ram0" +# endif +#else +# define BINDIR CONFIG_EXAMPLES_MODULE_BINDIR +#endif /* CONFIG_EXAMPLES_MODULE_BUILTINFS */ /**************************************************************************** * Private data @@ -141,6 +149,7 @@ int module_main(int argc, char *argv[]) exit(EXIT_FAILURE); } +#ifdef CONFIG_EXAMPLES_MODULE_BUILTINFS /* Create a ROM disk for the ROMFS filesystem */ printf("main: Registering romdisk at /dev/ram%d\n", @@ -164,19 +173,20 @@ int module_main(int argc, char *argv[]) /* Mount the file system */ printf("main: Mounting ROMFS filesystem at target=%s with source=%s\n", - MOUNTPT, CONFIG_EXAMPLES_MODULE_DEVPATH); + BINDIR, CONFIG_EXAMPLES_MODULE_DEVPATH); - ret = mount(CONFIG_EXAMPLES_MODULE_DEVPATH, MOUNTPT, "romfs", MS_RDONLY, NULL); + ret = mount(CONFIG_EXAMPLES_MODULE_DEVPATH, BINDIR, "romfs", MS_RDONLY, NULL); if (ret < 0) { fprintf(stderr, "ERROR: mount(%s,%s,romfs) failed: %s\n", - CONFIG_EXAMPLES_MODULE_DEVPATH, MOUNTPT, errno); + CONFIG_EXAMPLES_MODULE_DEVPATH, BINDIR, errno); exit(EXIT_FAILURE); } +#endif /* CONFIG_EXAMPLES_MODULE_BUILTINFS */ /* Install the character driver */ - handle = insmod(MOUNTPT "/chardev", "chardev"); + handle = insmod(BINDIR "/chardev", "chardev"); if (handle == NULL) { int errcode = errno; diff --git a/examples/sotest/Kconfig b/examples/sotest/Kconfig index ad19869a0..b2a647003 100644 --- a/examples/sotest/Kconfig +++ b/examples/sotest/Kconfig @@ -6,18 +6,64 @@ config EXAMPLES_SOTEST bool "Shared Library Example" default n - depends on LIBC_DLLFCN && BUILD_FLAT + depends on LIBC_DLLFCN ---help--- Enable the shared library example - NOTE: This example can only be used in the FLAT build mode because - it makes an illegal OS call to ramdisk_register(). A proper solution - would include the ROMFS file system containing the test shared - library in the kernel address space and would register it with logic - in the configs/ board directory at start-up. - if EXAMPLES_SOTEST +config EXAMPLES_SOTEST_BUILTINFS + bool "Built-in File System" + default y + depends on FS_ROMFS && BUILD_FLAT + ---help--- + This example supports a very, non-standard but also very convenient + way of testing with example using CONFIG_EXAMPLES_SOTEST_BUILTINFS. + If this option is selected, the test shared libraries will be built, + installed in the sotest/lib/fsroot, then converted to a built-in + ROMFS file system. + + When the test runs, it will automatically create the ROMFS block + device and mount the test shared libraries for testing. + + If this option is not selected, then the shared libraries will be + left in the fsroot/ directory. You can then copy them to, say an SD + card, for testing on the target. + + NOTE: This option can only be used in the FLAT build mode because + it makes an illegal OS call to ramdisk_register(). + +if EXAMPLES_SOTEST_BUILTINFS + +config EXAMPLES_SOTEST_DEVMINOR + int "ROMFS Minor Device Number" + default 0 + ---help--- + The minor device number of the ROMFS block. For example, the N in /dev/ramN. + Used for registering the RAM block driver that will hold the ROMFS file system + containing the SOTEST executables to be tested. Default: 0 + +config EXAMPLES_SOTEST_DEVPATH + string "ROMFS Device Path" + default "/dev/ram0" + ---help--- + The path to the ROMFS block driver device. This must match EXAMPLES_SOTEST_DEVMINOR. + Used for registering the RAM block driver that will hold the ROMFS file system + containing the SOTEST executables to be tested. Default: "/dev/ram0" + +endif # EXAMPLES_SOTEST_BUILTINFS + +if !EXAMPLES_SOTEST_BUILTINFS + +config EXAMPLES_SOTEST_BINDIR + string "Path to Test Shared Libraries" + default "/mnt/sdcard" + ---help--- + The path to the directoy on the mounted volume where the test shared + libraries can found at runtime. + +endif # !EXAMPLES_SOTEST_BUILTINFS + config EXAMPLES_SOTEST_LIBC bool "Link with LIBC" default n @@ -42,20 +88,4 @@ config EXAMPLES_SOTEST_LIBGCC default n depends on !BUILD_KERNEL && EXPERIMENTAL -config EXAMPLES_SOTEST_DEVMINOR - int "ROMFS Minor Device Number" - default 0 - ---help--- - The minor device number of the ROMFS block. For example, the N in /dev/ramN. - Used for registering the RAM block driver that will hold the ROMFS file system - containing the SOTEST executables to be tested. Default: 0 - -config EXAMPLES_SOTEST_DEVPATH - string "ROMFS Device Path" - default "/dev/ram0" - ---help--- - The path to the ROMFS block driver device. This must match EXAMPLES_SOTEST_DEVMINOR. - Used for registering the RAM block driver that will hold the ROMFS file system - containing the SOTEST executables to be tested. Default: "/dev/ram0" - endif diff --git a/examples/sotest/Makefile b/examples/sotest/Makefile index e02889b34..f62fd900a 100644 --- a/examples/sotest/Makefile +++ b/examples/sotest/Makefile @@ -1,7 +1,7 @@ ############################################################################ # apps/examples/sotest/Makefile # -# Copyright (C) 2015-2016 Gregory Nutt. All rights reserved. +# Copyright (C) 2017 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without diff --git a/examples/sotest/lib/.gitignore b/examples/sotest/lib/.gitignore index 1df62433e..2cc41f397 100644 --- a/examples/sotest/lib/.gitignore +++ b/examples/sotest/lib/.gitignore @@ -1,4 +1,4 @@ -/romfs +/fsroot /romfs.h /romfs.img /sot_symtab.c diff --git a/examples/sotest/lib/Makefile b/examples/sotest/lib/Makefile index fa4150580..f65edb743 100644 --- a/examples/sotest/lib/Makefile +++ b/examples/sotest/lib/Makefile @@ -1,7 +1,7 @@ ############################################################################ # apps/examples/sotest/lib/Makefile # -# Copyright (C) 2015 Gregory Nutt. All rights reserved. +# Copyright (C) 2015, 2017 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -47,14 +47,14 @@ endif SOTEST_DIR = $(APPDIR)/examples/sotest LIB_DIR = $(SOTEST_DIR)/lib -ROMFS_DIR = $(LIB_DIR)/romfs +FSROOT_DIR = $(LIB_DIR)/fsroot ROMFS_IMG = $(LIB_DIR)/romfs.img ROMFS_HDR = $(LIB_DIR)/romfs.h SYMTAB_SRC = $(LIB_DIR)/sot_symtab.c define DIR_template $(1)_$(2): - $(Q) $(MAKE) -C $(1) $(3) TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" ROMFS_DIR="$(ROMFS_DIR)" CROSSDEV=$(CROSSDEV) + $(Q) $(MAKE) -C $(1) $(3) TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" FSROOT_DIR="$(FSROOT_DIR)" CROSSDEV=$(CROSSDEV) endef all: $(ROMFS_HDR) $(DIRLIST_HDR) $(SYMTAB_SRC) @@ -68,36 +68,40 @@ $(foreach DIR, $(BUILD_SUBDIRS), $(eval $(call DIR_template,$(DIR),install,insta build: $(foreach DIR, $(BUILD_SUBDIRS), $(DIR)_build) -# Install each program in the romfs directory +# Install each program in the fsroot directory install: $(foreach DIR, $(BUILD_SUBDIRS), $(DIR)_install) -# Create the romfs directory +# Create the fsroot directory -$(ROMFS_DIR): - $(Q) mkdir $(ROMFS_DIR) +$(FSROOT_DIR): + $(Q) mkdir $(FSROOT_DIR) -# Populate the romfs directory +# Populate the fsroot directory -populate: $(ROMFS_DIR) build install +populate: $(FSROOT_DIR) build install -# Create the romfs.img file from the populated romfs directory +# Create the romfs.img file from the populated fsroot directory $(ROMFS_IMG): populate - $(Q) genromfs -f $@ -d $(ROMFS_DIR) -V "SOTESTTEST" +ifeq ($(CONFIG_EXAMPLES_SOTEST_BUILTINFS),y) + $(Q) genromfs -f $@ -d $(FSROOT_DIR) -V "SOTESTTEST" +endif # Create the romfs.h header file from the romfs.img file $(ROMFS_HDR) : $(ROMFS_IMG) +ifeq ($(CONFIG_EXAMPLES_SOTEST_BUILTINFS),y) $(Q) (cd $(LIB_DIR); xxd -i romfs.img | sed -e "s/^unsigned/static const unsigned/g" >$@) +endif # Create the exported symbol table $(SYMTAB_SRC): build - $(Q) $(LIB_DIR)/mksymtab.sh $(ROMFS_DIR) >$@ + $(Q) $(LIB_DIR)/mksymtab.sh $(FSROOT_DIR) >$@ # Clean each subdirectory clean: $(foreach DIR, $(ALL_SUBDIRS), $(DIR)_clean) $(Q) rm -f $(ROMFS_HDR) $(DIRLIST_HDR) $(ROMFS_IMG) $(SYMTAB_SRC) - $(Q) rm -rf $(ROMFS_DIR) + $(Q) rm -rf $(FSROOT_DIR) diff --git a/examples/sotest/lib/modprint/Makefile b/examples/sotest/lib/modprint/Makefile index 2a3b0c480..30403e7f3 100644 --- a/examples/sotest/lib/modprint/Makefile +++ b/examples/sotest/lib/modprint/Makefile @@ -90,5 +90,5 @@ clean: $(call CLEAN) install: - $(Q) mkdir -p $(ROMFS_DIR) - $(Q) install $(BIN) $(ROMFS_DIR)/$(BIN) + $(Q) mkdir -p $(FSROOT_DIR) + $(Q) install $(BIN) $(FSROOT_DIR)/$(BIN) diff --git a/examples/sotest/lib/sotest/Makefile b/examples/sotest/lib/sotest/Makefile index 216f6e202..54cde4a4d 100644 --- a/examples/sotest/lib/sotest/Makefile +++ b/examples/sotest/lib/sotest/Makefile @@ -90,5 +90,5 @@ clean: $(call CLEAN) install: - $(Q) mkdir -p $(ROMFS_DIR) - $(Q) install $(BIN) $(ROMFS_DIR)/$(BIN) + $(Q) mkdir -p $(FSROOT_DIR) + $(Q) install $(BIN) $(FSROOT_DIR)/$(BIN) diff --git a/examples/sotest/sotest_main.c b/examples/sotest/sotest_main.c index 92e9b9320..4a4be684b 100644 --- a/examples/sotest/sotest_main.c +++ b/examples/sotest/sotest_main.c @@ -39,7 +39,10 @@ #include -#include +#ifdef CONFIG_EXAMPLES_SOTEST_BUILTINFS +# include +#endif + #include #include #include @@ -47,10 +50,12 @@ #include #include -#include #include -#include "lib/romfs.h" +#ifdef CONFIG_EXAMPLES_SOTEST_BUILTINFS +# include +# include "lib/romfs.h" +#endif /**************************************************************************** * Pre-processor Definitions @@ -64,31 +69,31 @@ # error "You must select CONFIG_LIBC_DLLFCN in your configuration file" #endif -#ifndef CONFIG_FS_ROMFS -# error "You must select CONFIG_FS_ROMFS in your configuration file" -#endif +#ifdef CONFIG_EXAMPLES_SOTEST_BUILTINFS +# ifndef CONFIG_FS_ROMFS +# error "You must select CONFIG_FS_ROMFS in your configuration file" +# endif -#ifdef CONFIG_DISABLE_MOUNTPOINT -# error "You must not disable mountpoints via CONFIG_DISABLE_MOUNTPOINT in your configuration file" -#endif +# ifdef CONFIG_DISABLE_MOUNTPOINT +# error "You must not disable mountpoints via CONFIG_DISABLE_MOUNTPOINT in your configuration file" +# endif -/* Describe the ROMFS file system */ + /* Describe the ROMFS file system */ -#define SECTORSIZE 64 -#define NSECTORS(b) (((b)+SECTORSIZE-1)/SECTORSIZE) -#define MOUNTPT "/mnt/romfs" +# define SECTORSIZE 64 +# define NSECTORS(b) (((b)+SECTORSIZE-1)/SECTORSIZE) +# define BINDIR "/mnt/romfs" -#ifndef CONFIG_EXAMPLES_SOTEST_DEVMINOR -# define CONFIG_EXAMPLES_SOTEST_DEVMINOR 0 -#endif +# ifndef CONFIG_EXAMPLES_SOTEST_DEVMINOR +# define CONFIG_EXAMPLES_SOTEST_DEVMINOR 0 +# endif -#ifndef CONFIG_EXAMPLES_SOTEST_DEVPATH -# define CONFIG_EXAMPLES_SOTEST_DEVPATH "/dev/ram0" -#endif - -/**************************************************************************** - * Private data - ****************************************************************************/ +# ifndef CONFIG_EXAMPLES_SOTEST_DEVPATH +# define CONFIG_EXAMPLES_SOTEST_DEVPATH "/dev/ram0" +# endif +#else +# define BINDIR CONFIG_EXAMPLES_SOTEST_BINDIR +#endif /* CONFIG_EXAMPLES_SOTEST_BUILTINFS */ /**************************************************************************** * Symbols from Auto-Generated Code @@ -128,6 +133,7 @@ int sotest_main(int argc, char *argv[]) exit(EXIT_FAILURE); } +#ifdef CONFIG_EXAMPLES_SOTEST_BUILTINFS /* Create a ROM disk for the ROMFS filesystem */ printf("main: Registering romdisk at /dev/ram%d\n", @@ -152,15 +158,16 @@ int sotest_main(int argc, char *argv[]) /* Mount the file system */ printf("main: Mounting ROMFS filesystem at target=%s with source=%s\n", - MOUNTPT, CONFIG_EXAMPLES_SOTEST_DEVPATH); + BINDIR, CONFIG_EXAMPLES_SOTEST_DEVPATH); - ret = mount(CONFIG_EXAMPLES_SOTEST_DEVPATH, MOUNTPT, "romfs", MS_RDONLY, NULL); + ret = mount(CONFIG_EXAMPLES_SOTEST_DEVPATH, BINDIR, "romfs", MS_RDONLY, NULL); if (ret < 0) { fprintf(stderr, "ERROR: mount(%s,%s,romfs) failed: %s\n", - CONFIG_EXAMPLES_SOTEST_DEVPATH, MOUNTPT, errno); + CONFIG_EXAMPLES_SOTEST_DEVPATH, BINDIR, errno); exit(EXIT_FAILURE); } +#endif /* CONFIG_EXAMPLES_SOTEST_BUILTINFS */ #if CONFIG_MODLIB_MAXDEPEND > 0 /* Install the first test shared library. The first shared library only @@ -170,7 +177,7 @@ int sotest_main(int argc, char *argv[]) /* Install the second test shared library */ - handle1 = dlopen(MOUNTPT "/modprint", RTLD_NOW | RTLD_LOCAL); + handle1 = dlopen(BINDIR "/modprint", RTLD_NOW | RTLD_LOCAL); if (handle1 == NULL) { fprintf(stderr, "ERROR: dlopen(/modprint) failed\n"); @@ -180,7 +187,7 @@ int sotest_main(int argc, char *argv[]) /* Install the second test shared library */ - handle2 = dlopen(MOUNTPT "/sotest", RTLD_NOW | RTLD_LOCAL); + handle2 = dlopen(BINDIR "/sotest", RTLD_NOW | RTLD_LOCAL); if (handle2 == NULL) { fprintf(stderr, "ERROR: dlopen(/sotest) failed\n"); @@ -278,13 +285,15 @@ int sotest_main(int argc, char *argv[]) } #endif - ret = umount(MOUNTPT); +#ifdef CONFIG_EXAMPLES_SOTEST_BUILTINFS + ret = umount(BINDIR); if (ret < 0) { fprintf(stderr, "ERROR: umount(%s) failed: %d\n", - MOUNTPT, errno); + BINDIR, errno); exit(EXIT_FAILURE); } +#endif /* CONFIG_EXAMPLES_SOTEST_BUILTINFS */ return EXIT_SUCCESS; }