From ae6868bf9e7bb53c2441ab7b2077c6b30b142c25 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 5 Jun 2015 14:23:07 -0600 Subject: [PATCH] Add a test of the union file system to apps/examaples. --- examples/Kconfig | 1 + examples/README.txt | 21 ++ examples/unionfs/.gitignore | 15 ++ examples/unionfs/Kconfig | 39 ++++ examples/unionfs/Make.defs | 38 ++++ examples/unionfs/Makefile | 159 ++++++++++++++ examples/unionfs/atestdir/adir/adirfile.txt | 2 + .../atestdir/adir/asubdir/asubdirfile.txt | 2 + examples/unionfs/atestdir/afile.txt | 1 + examples/unionfs/btestdir/adir/adirfile.txt | 2 + .../btestdir/adir/asubdir/asubdirfile.txt | 2 + examples/unionfs/btestdir/afile.txt | 1 + examples/unionfs/btestdir/bdir/adirfile.txt | 2 + .../btestdir/bdir/asubdir/asubdirfile.txt | 2 + examples/unionfs/btestdir/bfile.txt | 1 + examples/unionfs/unionfs_main.c | 200 ++++++++++++++++++ 16 files changed, 488 insertions(+) create mode 100644 examples/unionfs/.gitignore create mode 100644 examples/unionfs/Kconfig create mode 100644 examples/unionfs/Make.defs create mode 100644 examples/unionfs/Makefile create mode 100644 examples/unionfs/atestdir/adir/adirfile.txt create mode 100644 examples/unionfs/atestdir/adir/asubdir/asubdirfile.txt create mode 100644 examples/unionfs/atestdir/afile.txt create mode 100644 examples/unionfs/btestdir/adir/adirfile.txt create mode 100644 examples/unionfs/btestdir/adir/asubdir/asubdirfile.txt create mode 100644 examples/unionfs/btestdir/afile.txt create mode 100644 examples/unionfs/btestdir/bdir/adirfile.txt create mode 100644 examples/unionfs/btestdir/bdir/asubdir/asubdirfile.txt create mode 100644 examples/unionfs/btestdir/bfile.txt create mode 100644 examples/unionfs/unionfs_main.c diff --git a/examples/Kconfig b/examples/Kconfig index b24cfcca4..cb2f292be 100644 --- a/examples/Kconfig +++ b/examples/Kconfig @@ -74,6 +74,7 @@ source "$APPSDIR/examples/touchscreen/Kconfig" source "$APPSDIR/examples/udp/Kconfig" source "$APPSDIR/examples/discover/Kconfig" source "$APPSDIR/examples/webserver/Kconfig" +source "$APPSDIR/examples/unionfs/Kconfig" source "$APPSDIR/examples/usbserial/Kconfig" source "$APPSDIR/examples/usbterm/Kconfig" source "$APPSDIR/examples/udgram/Kconfig" diff --git a/examples/README.txt b/examples/README.txt index b302c6dc1..869451b2b 100644 --- a/examples/README.txt +++ b/examples/README.txt @@ -1852,6 +1852,27 @@ examples/udp CONFIG_NETUTILS_NETLIB=y +examples/unionfs +^^^^^^^^^^^^^^^^ + + This is at trivial test of the Union File System. See + nuttx/fs/unionfs/README.txt. Dependencies: + + CONFIG_DISABLE_MOUNTPOINT - Mountpoint support must not be disabled + CONFIG_NFILE_DESCRIPTORS < 4 - Some file descriptors must be allocated + CONFIG_FS_ROMFS - ROMFS support is required + CONFIG_FS_UNIONFS - Union File System support is required + + Configuration options. Use the defaults if you are unsure of what you are doing: + + CONFIG_EXAMPLES_UNIONFS - Enables the example + CONFIG_EXAMPLES_UNIONFS_MOUNTPT - Mountpoint path for the Union File System + CONFIG_EXAMPLES_UNIONFS_TMPA - Temporary mount point for file system 1 + CONFIG_EXAMPLES_UNIONFS_TMPB - Temporary mount point for file system 2 + CONFIG_EXAMPLES_UNIONFS_RAMDEVNO_A - ROMFS file system 1 RAM disk device number + CONFIG_EXAMPLES_UNIONFS_RAMDEVNO_B - ROMFS file system 2 RAM disk device number + CONFIG_EXAMPLES_UNIONFS_SECTORSIZE - ROM disk sector size. + examples/usbserial ^^^^^^^^^^^^^^^^^^ diff --git a/examples/unionfs/.gitignore b/examples/unionfs/.gitignore new file mode 100644 index 000000000..bfcd61d4f --- /dev/null +++ b/examples/unionfs/.gitignore @@ -0,0 +1,15 @@ +/Make.dep +/.depend +/.built +/atestdir.img +/btestdir.img +/romfs_atestdir.h +/romfs_btestdir.h +/*.asm +/*.obj +/*.rel +/*.lst +/*.sym +/*.adb +/*.lib +/*.src diff --git a/examples/unionfs/Kconfig b/examples/unionfs/Kconfig new file mode 100644 index 000000000..b971ba63b --- /dev/null +++ b/examples/unionfs/Kconfig @@ -0,0 +1,39 @@ +# +# For a description of the syntax of this configuration file, +# see misc/tools/kconfig-language.txt. +# + +config EXAMPLES_UNIONFS + bool "Union file system example" + default n + depends on FS_ROMFS || FS_UNIONFS + ---help--- + Enable the Union File System example + +if EXAMPLES_UNIONFS + +config EXAMPLES_UNIONFS_MOUNTPT + string "Union FS mount point" + default "/mnt/unionfs" + +config EXAMPLES_UNIONFS_RAMDEVNO_A + int "File system 1 RAM disk device number" + default 1 + +config EXAMPLES_UNIONFS_RAMDEVNO_B + int "File system 1 RAM disk device number" + default 2 + +config EXAMPLES_UNIONFS_SECTORSIZE + int "ROMFS sector size" + default 64 + +config EXAMPLES_UNIONFS_TMPA + string "File system 1 temporary point" + default "/mnt/a" + +config EXAMPLES_UNIONFS_TMPB + string "File system 2 temporary point" + default "/mnt/b" + +endif diff --git a/examples/unionfs/Make.defs b/examples/unionfs/Make.defs new file mode 100644 index 000000000..17bef5e19 --- /dev/null +++ b/examples/unionfs/Make.defs @@ -0,0 +1,38 @@ +############################################################################ +# apps/examples/unionfs/Make.defs +# +# Copyright (C) 2015 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +ifeq ($(CONFIG_EXAMPLES_UNIONFS),y) +CONFIGURED_APPS += examples/unionfs +endif diff --git a/examples/unionfs/Makefile b/examples/unionfs/Makefile new file mode 100644 index 000000000..f95a02f66 --- /dev/null +++ b/examples/unionfs/Makefile @@ -0,0 +1,159 @@ +############################################################################ +# apps/examples/unionfs/Makefile +# +# Copyright (C) 2015 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +-include $(TOPDIR)/.config +-include $(TOPDIR)/Make.defs +include $(APPDIR)/Make.defs + +# UNIONFS built-in application info + +APPNAME = unionfs +PRIORITY = SCHED_PRIORITY_DEFAULT +STACKSIZE = 2048 + +# UNIONFS File System Example + +ASRCS = +CSRCS = +MAINSRC = unionfs_main.c + +AOBJS = $(ASRCS:.S=$(OBJEXT)) +COBJS = $(CSRCS:.c=$(OBJEXT)) +MAINOBJ = $(MAINSRC:.c=$(OBJEXT)) + +SRCS = $(ASRCS) $(CSRCS) $(MAINSRC) +OBJS = $(AOBJS) $(COBJS) + +ifneq ($(CONFIG_BUILD_KERNEL),y) + OBJS += $(MAINOBJ) +endif + +ifeq ($(CONFIG_WINDOWS_NATIVE),y) + BIN = ..\..\libapps$(LIBEXT) +else +ifeq ($(WINTOOL),y) + BIN = ..\\..\\libapps$(LIBEXT) +else + BIN = ../../libapps$(LIBEXT) +endif +endif + +ifeq ($(WINTOOL),y) + INSTALL_DIR = "${shell cygpath -w $(BIN_DIR)}" +else + INSTALL_DIR = $(BIN_DIR) +endif + +CONFIG_XYZ_PROGNAME ?= unionfs$(EXEEXT) +PROGNAME = $(CONFIG_XYZ_PROGNAME) + +ROOTDEPPATH = --dep-path . + +# Common build + +VPATH = + +all: .built +.PHONY: checkgenromfs clean depend distclean + +$(AOBJS): %$(OBJEXT): %.S + $(call ASSEMBLE, $<, $@) + +$(COBJS) $(MAINOBJ): %$(OBJEXT): %.c + $(call COMPILE, $<, $@) + +checkgenromfs: + @genromfs -h 1>/dev/null 2>&1 || { \ + echo "Host executable genromfs not available in PATH"; \ + echo "You may need to download in from http://unionfs.sourceforge.net/"; \ + exit 1; \ + } + +atestdir.img : checkgenromfs + @genromfs -f $@ -d atestdir -V "UNIONFS_Test" || { echo "genromfs failed" ; exit 1 ; } + +romfs_atestdir.h : atestdir.img + @xxd -i $< >$@ || { echo "xxd of $< failed" ; exit 1 ; } + +btestdir.img : checkgenromfs + @genromfs -f $@ -d btestdir -V "UNIONFS_Test" || { echo "genromfs failed" ; exit 1 ; } + +romfs_btestdir.h : btestdir.img + @xxd -i $< >$@ || { echo "xxd of $< failed" ; exit 1 ; } + +.built: romfs_atestdir.h romfs_btestdir.h $(OBJS) + $(call ARCHIVE, $(BIN), $(OBJS)) + @touch .built + +ifeq ($(CONFIG_BUILD_KERNEL),y) +$(BIN_DIR)$(DELIM)$(PROGNAME): $(OBJS) $(MAINOBJ) + @echo "LD: $(PROGNAME)" + $(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $(INSTALL_DIR)$(DELIM)$(PROGNAME) $(ARCHCRT0OBJ) $(MAINOBJ) $(LDLIBS) + $(Q) $(NM) -u $(INSTALL_DIR)$(DELIM)$(PROGNAME) + +install: $(BIN_DIR)$(DELIM)$(PROGNAME) + +else +install: + +endif + +ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile + $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) + +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat +else +context: +endif + +.depend: Makefile $(SRCS) + @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep + @touch $@ + +depend: .depend + +clean: + $(call DELFILE, .built) + $(call CLEAN) + +distclean: clean + $(call DELFILE, Make.dep) + $(call DELFILE, .depend) + $(call DELFILE, atestdir.img) + $(call DELFILE, btestdir.img) + +-include Make.dep + diff --git a/examples/unionfs/atestdir/adir/adirfile.txt b/examples/unionfs/atestdir/adir/adirfile.txt new file mode 100644 index 000000000..9e35f0539 --- /dev/null +++ b/examples/unionfs/atestdir/adir/adirfile.txt @@ -0,0 +1,2 @@ +This is a file in directory adir on file system 1 + diff --git a/examples/unionfs/atestdir/adir/asubdir/asubdirfile.txt b/examples/unionfs/atestdir/adir/asubdir/asubdirfile.txt new file mode 100644 index 000000000..0ff2a0439 --- /dev/null +++ b/examples/unionfs/atestdir/adir/asubdir/asubdirfile.txt @@ -0,0 +1,2 @@ +This is a file in directory adir/asubdir on file system 1 + diff --git a/examples/unionfs/atestdir/afile.txt b/examples/unionfs/atestdir/afile.txt new file mode 100644 index 000000000..4d3fcfaab --- /dev/null +++ b/examples/unionfs/atestdir/afile.txt @@ -0,0 +1 @@ +This is a file in the root directory on file system 1 diff --git a/examples/unionfs/btestdir/adir/adirfile.txt b/examples/unionfs/btestdir/adir/adirfile.txt new file mode 100644 index 000000000..06cbff034 --- /dev/null +++ b/examples/unionfs/btestdir/adir/adirfile.txt @@ -0,0 +1,2 @@ +This is a file in directory adir on file system 2 + diff --git a/examples/unionfs/btestdir/adir/asubdir/asubdirfile.txt b/examples/unionfs/btestdir/adir/asubdir/asubdirfile.txt new file mode 100644 index 000000000..31f2188a1 --- /dev/null +++ b/examples/unionfs/btestdir/adir/asubdir/asubdirfile.txt @@ -0,0 +1,2 @@ +This is a file in directory adir/asubdir on file system 2 + diff --git a/examples/unionfs/btestdir/afile.txt b/examples/unionfs/btestdir/afile.txt new file mode 100644 index 000000000..e2a5315ba --- /dev/null +++ b/examples/unionfs/btestdir/afile.txt @@ -0,0 +1 @@ +This is a file in the root directory on file system 2 diff --git a/examples/unionfs/btestdir/bdir/adirfile.txt b/examples/unionfs/btestdir/bdir/adirfile.txt new file mode 100644 index 000000000..fd7fe0896 --- /dev/null +++ b/examples/unionfs/btestdir/bdir/adirfile.txt @@ -0,0 +1,2 @@ +This is a file in directory bdir on file system 2 + diff --git a/examples/unionfs/btestdir/bdir/asubdir/asubdirfile.txt b/examples/unionfs/btestdir/bdir/asubdir/asubdirfile.txt new file mode 100644 index 000000000..8b76f06b6 --- /dev/null +++ b/examples/unionfs/btestdir/bdir/asubdir/asubdirfile.txt @@ -0,0 +1,2 @@ +This is a file in directory bdir/asubdir on file system 2 + diff --git a/examples/unionfs/btestdir/bfile.txt b/examples/unionfs/btestdir/bfile.txt new file mode 100644 index 000000000..9218b09d4 --- /dev/null +++ b/examples/unionfs/btestdir/bfile.txt @@ -0,0 +1 @@ +This is another file in the root directory on file system 2 diff --git a/examples/unionfs/unionfs_main.c b/examples/unionfs/unionfs_main.c new file mode 100644 index 000000000..59bd442eb --- /dev/null +++ b/examples/unionfs/unionfs_main.c @@ -0,0 +1,200 @@ +/**************************************************************************** + * examples/unionfs/unionfs_main.c + * + * Copyright (C) 2015 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "romfs_atestdir.h" +#include "romfs_btestdir.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Configuration settings */ + +#ifdef CONFIG_DISABLE_MOUNTPOINT +# error "Mountpoint support is disabled" +#endif + +#if CONFIG_NFILE_DESCRIPTORS < 4 +# error "Not enough file descriptors" +#endif + +#ifndef CONFIG_FS_ROMFS +# error "ROMFS support not enabled" +#endif + +#ifndef CONFIG_FS_UNIONFS +# error "Union File System support not enabled" +#endif + +#ifndef CONFIG_EXAMPLES_UNIONFS_RAMDEVNO_A +# define CONFIG_EXAMPLES_UNIONFS_RAMDEVNO_A 1 +#endif + +#ifndef CONFIG_EXAMPLES_UNIONFS_RAMDEVNO_B +# define CONFIG_EXAMPLES_UNIONFS_RAMDEVNO_B 2 +#endif + +#ifndef CONFIG_EXAMPLES_UNIONFS_SECTORSIZE +# define CONFIG_EXAMPLES_UNIONFS_SECTORSIZE 64 +#endif + +#ifndef CONFIG_EXAMPLES_UNIONFS_MOUNTPT +# define "/mnt/unionfs" +#endif + +#ifndef CONFIG_EXAMPLES_UNIONFS_TMPA +# define "/mnt/a" +#endif + +#ifndef CONFIG_EXAMPLES_UNIONFS_TMPB +# define "/mnt/b" +#endif + +#define NSECTORS(b) (((b)+CONFIG_EXAMPLES_UNIONFS_SECTORSIZE-1)/CONFIG_EXAMPLES_UNIONFS_SECTORSIZE) +#define STR_RAMDEVNO(m) #m +#define MKMOUNT_DEVNAME(m) "/dev/ram" STR_RAMDEVNO(m) +#define MOUNT_DEVNAME_A MKMOUNT_DEVNAME(CONFIG_EXAMPLES_UNIONFS_RAMDEVNO_A) +#define MOUNT_DEVNAME_B MKMOUNT_DEVNAME(CONFIG_EXAMPLES_UNIONFS_RAMDEVNO_B) + +#define SCRATCHBUFFER_SIZE 1024 + +/* Test directory stuff */ + +#define WRITABLE_MODE (S_IWOTH|S_IWGRP|S_IWUSR) +#define READABLE_MODE (S_IROTH|S_IRGRP|S_IRUSR) +#define EXECUTABLE_MODE (S_IXOTH|S_IXGRP|S_IXUSR) + +#define DIRECTORY_MODE (S_IFDIR|READABLE_MODE|EXECUTABLE_MODE) +#define FILE_MODE (S_IFREG|READABLE_MODE) + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: unionfs_main + ****************************************************************************/ + +#ifdef CONFIG_BUILD_KERNEL +int main(int argc, FAR char *argv[]) +#else +int unionfs_main(int argc, char *argv[]) +#endif +{ + int ret; + + /* Create a RAM disk for file system 1 */ + + ret = romdisk_register(CONFIG_EXAMPLES_UNIONFS_RAMDEVNO_A, atestdir_img, + NSECTORS(atestdir_img_len), + CONFIG_EXAMPLES_UNIONFS_SECTORSIZE); + if (ret < 0) + { + printf("ERROR: Failed to create file system 1 RAM disk\n"); + return EXIT_FAILURE; + } + + /* Mount test file system 1 */ + + printf("Mounting ROMFS file system 1 at target=%s with source=%s\n", + CONFIG_EXAMPLES_UNIONFS_TMPA, MOUNT_DEVNAME_A); + + ret = mount(MOUNT_DEVNAME_A, CONFIG_EXAMPLES_UNIONFS_TMPA, "romfs", + MS_RDONLY, NULL); + if (ret < 0) + { + printf("ERROR: File system 1 mount failed: %d\n", errno); + return EXIT_FAILURE; + } + + /* Create a RAM disk for file system 2 */ + + ret = romdisk_register(CONFIG_EXAMPLES_UNIONFS_RAMDEVNO_B, btestdir_img, + NSECTORS(btestdir_img_len), + CONFIG_EXAMPLES_UNIONFS_SECTORSIZE); + if (ret < 0) + { + printf("ERROR: Failed to register file system 1: %d\n", ret); + return EXIT_FAILURE; + } + + /* Mount test file system 2 */ + + printf("Mounting ROMFS file system 2 at target=%s with source=%s\n", + CONFIG_EXAMPLES_UNIONFS_TMPB, MOUNT_DEVNAME_B); + + ret = mount(MOUNT_DEVNAME_B, CONFIG_EXAMPLES_UNIONFS_TMPB, "romfs", + MS_RDONLY, NULL); + if (ret < 0) + { + printf("ERROR: Failed to register file system 1: %d\n", ret); + return EXIT_FAILURE; + } + + /* Now create and mount the union file system */ + + ret = unionfs_mount(CONFIG_EXAMPLES_UNIONFS_TMPA, NULL, + CONFIG_EXAMPLES_UNIONFS_TMPB, NULL, + CONFIG_EXAMPLES_UNIONFS_MOUNTPT); + if (ret < 0) + { + printf("ERROR: Failed to crate the union file system 1: %d\n", ret); + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +}