From 07edaa088c6a998ed0688acebdf264ee80124b6f Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 26 Oct 2019 11:43:34 -0600 Subject: [PATCH] drivers/Kconfig: Add an option, CONFIG_DRVR_MKRD, to control whether or not the mkrd() implementation is build. Otherwise, if mkrd() is built unconditionally, it will be drawn into every build whether it is used or not and will increase the build size. --- TODO | 9 ++++++--- boards/boardctl.c | 4 ++-- drivers/Kconfig | 9 +++++++++ drivers/Makefile | 5 ++++- drivers/mkrd.c | 4 ++-- include/nuttx/drivers/ramdisk.h | 2 +- include/sys/boardctl.h | 4 ++-- 7 files changed, 26 insertions(+), 11 deletions(-) diff --git a/TODO b/TODO index 1edffddb44..45e5e1f21a 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,4 @@ -NuttX TODO List (Last updated August 24, 2019) +NuttX TODO List (Last updated September 26, 2019) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This file summarizes known NuttX bugs, limitations, inconsistencies with @@ -2845,7 +2845,7 @@ o Other Applications & Tests (apps/examples/) Priority: Medium. Title: ILLEGAL CALLS TO romdisk_register() - Desription: Several examples (and other things under apps/) make illegal + Description: Several examples (and other things under apps/) make illegal calls to romdisk_register(). This both violates the portable POSIX OS interface and makes these applications un-usable in PROTECTED and KERNEL build modes. @@ -2856,7 +2856,10 @@ o Other Applications & Tests (apps/examples/) examples/nxflat, examples/posix_spawn, examples/romfs, examples/sotest, examples/thttpd, examples/unionfs - Other non-compliant logic: + These examples are simple demos and, hence, you could argue that + it is not so bad that they violate the interface for the purpose + of demonstration (although they do set a bad example because of + this). But there is other non-compliant logic: graphics/traveler/trv_romfs.c, nshlib/nsh_romfsetc.c diff --git a/boards/boardctl.c b/boards/boardctl.c index 0b90cd1bef..0494b8a837 100644 --- a/boards/boardctl.c +++ b/boards/boardctl.c @@ -358,11 +358,11 @@ int boardctl(unsigned int cmd, uintptr_t arg) break; #endif -#ifdef CONFIG_FS_WRITABLE +#ifdef CONFIG_DRVR_MKRD /* CMD: BOARDIOC_MKRD * DESCRIPTION: Create a RAM disk * ARG: Pointer to read-only instance of struct boardioc_mkrd_s. - * CONFIGURATION: CONFIG_FS_WRITABLE + * CONFIGURATION: CONFIG_DRVR_MKRD * DEPENDENCIES: None */ diff --git a/drivers/Kconfig b/drivers/Kconfig index caa3732536..5564537a5c 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -14,6 +14,15 @@ config DEV_ZERO source drivers/crypto/Kconfig source drivers/loop/Kconfig +config DRVR_MKRD + bool "RAM disk wrapper (mkrd)" + default n + ---help--- + Build the mkrd() function which serves as a wrapper to simplify + creation of RAM disks. If the boardctrl() interface is enabled, + the selecting this option will also enable the BOARDIOC_MKRD + command that will support creation of RAM disks from applications. + menu "Buffering" config DRVR_WRITEBUFFER diff --git a/drivers/Makefile b/drivers/Makefile index 90b3aec00f..c5c40db07b 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -90,7 +90,10 @@ endif CSRCS += dev_null.c dev_zero.c ifneq ($(CONFIG_DISABLE_MOUNTPOINT),y) - CSRCS += ramdisk.c mkrd.c + CSRCS += ramdisk.c +ifeq ($(CONFIG_DRVR_MKRD),y) + CSRCS += mkrd.c +endif ifeq ($(CONFIG_DRVR_WRITEBUFFER),y) CSRCS += rwbuffer.c else diff --git a/drivers/mkrd.c b/drivers/mkrd.c index 91e5be03e1..d95a0ba553 100644 --- a/drivers/mkrd.c +++ b/drivers/mkrd.c @@ -42,7 +42,7 @@ #include #include -#ifdef CONFIG_FS_WRITABLE +#ifdef CONFIG_DRVR_MKRD /**************************************************************************** * Public Functions @@ -99,4 +99,4 @@ int mkrd(int minor, uint32_t nsectors, uint16_t sectsize, uint8_t rdflags) return ret; } -#endif /* CONFIG_FS_WRITABLE */ +#endif /* CONFIG_DRVR_MKRD */ diff --git a/include/nuttx/drivers/ramdisk.h b/include/nuttx/drivers/ramdisk.h index 090a303a14..9706a4f625 100644 --- a/include/nuttx/drivers/ramdisk.h +++ b/include/nuttx/drivers/ramdisk.h @@ -122,7 +122,7 @@ int romdisk_register(int minor, FAR const uint8_t *buffer, uint32_t nsectors, * ****************************************************************************/ -#ifdef CONFIG_FS_WRITABLE +#ifdef CONFIG_DRVR_MKRD int mkrd(int minor, uint32_t nsectors, uint16_t sectsize, uint8_t rdflags); #endif diff --git a/include/sys/boardctl.h b/include/sys/boardctl.h index ed24a682aa..431099df66 100644 --- a/include/sys/boardctl.h +++ b/include/sys/boardctl.h @@ -99,7 +99,7 @@ * CMD: BOARDIOC_MKRD * DESCRIPTION: Create a RAM disk * ARG: Pointer to read-only instance of struct boardioc_mkrd_s. - * CONFIGURATION: CONFIG_FS_WRITABLE + * CONFIGURATION: CONFIG_DRVR_MKRD * DEPENDENCIES: None * * CMD: BOARDIOC_APP_SYMTAB @@ -213,7 +213,7 @@ /* Structures used with IOCTL commands */ -#ifdef CONFIG_FS_WRITABLE +#ifdef CONFIG_DRVR_MKRD /* Describes the RAM disk to be created */ struct boardioc_mkrd_s