Add support for a union file system that can be used to overlay and merge the content of two mounted file systems.
This commit is contained in:
parent
1c6c76033a
commit
1d370178fb
12 changed files with 2284 additions and 10 deletions
|
@ -8,7 +8,7 @@
|
|||
<tr align="center" bgcolor="#e4e4e4">
|
||||
<td>
|
||||
<h1><big><font color="#3c34ec"><i>NuttX README Files</i></font></big></h1>
|
||||
<p>Last Updated: May 7, 2015</p>
|
||||
<p>Last Updated: June 5, 2015</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
@ -299,8 +299,10 @@
|
|||
| | | `- <a href="http://sourceforge.net/p/nuttx/git/ci/master/tree/nuttx/fs/nxffs/README.txt"><b><i>README.txt</i></b></a>
|
||||
| | |- smartfs/
|
||||
| | | `- <a href="http://sourceforge.net/p/nuttx/git/ci/master/tree/nuttx/fs/smartfs/README.txt"><b><i>README.txt</i></b></a>
|
||||
| | `- procfs/
|
||||
| | `- <a href="http://sourceforge.net/p/nuttx/git/ci/master/tree/nuttx/fs/procfs/README.txt"><b><i>README.txt</i></b></a>
|
||||
| | |- procfs/
|
||||
| | | `- <a href="http://sourceforge.net/p/nuttx/git/ci/master/tree/nuttx/fs/procfs/README.txt"><b><i>README.txt</i></b></a>
|
||||
| | `- unionfs/
|
||||
| | `- <a href="http://sourceforge.net/p/nuttx/git/ci/master/tree/nuttx/fs/unionfs/README.txt"><b><i>README.txt</i></b></a>
|
||||
| |- graphics/
|
||||
| | `- <a href="http://sourceforge.net/p/nuttx/git/ci/master/tree/nuttx/graphics/README.txt"><b><i>README.txt</i></b></a>
|
||||
| |- lib/
|
||||
|
|
|
@ -1358,7 +1358,9 @@ nuttx
|
|||
| | `- README.txt
|
||||
| |- smartfs/
|
||||
| | `- README.txt
|
||||
| `- procfs/
|
||||
| |- procfs/
|
||||
| | `- README.txt
|
||||
| `- unionfs/
|
||||
| `- README.txt
|
||||
|- graphics/
|
||||
| `- README.txt
|
||||
|
|
|
@ -1131,8 +1131,10 @@ Configuration Sub-Directories
|
|||
|
||||
STATUS:
|
||||
2015-06-02. This configuration was added in an attempt to replace
|
||||
thttpd-nxflat (see below). It concurrent does not run properly.
|
||||
It looks like I get out-of-memory errors during execution of CGI.
|
||||
thttpd-nxflat (see below). I concurrently get out-of-memory errors
|
||||
during execution of CGI. The 32KiB SRAM may be insufficient for
|
||||
this configuration; this might be fixed with some carefult tuning
|
||||
of stack usage.
|
||||
|
||||
thttpd-nxflat:
|
||||
This builds the THTTPD web server example using the THTTPD and
|
||||
|
|
|
@ -60,6 +60,7 @@ source fs/romfs/Kconfig
|
|||
source fs/smartfs/Kconfig
|
||||
source fs/binfs/Kconfig
|
||||
source fs/procfs/Kconfig
|
||||
source fs/unionfs/Kconfig
|
||||
|
||||
comment "System Logging"
|
||||
|
||||
|
|
|
@ -69,6 +69,7 @@ include nfs/Make.defs
|
|||
include smartfs/Make.defs
|
||||
include binfs/Make.defs
|
||||
include procfs/Make.defs
|
||||
include unionfs/Make.defs
|
||||
|
||||
endif
|
||||
endif
|
||||
|
@ -80,8 +81,6 @@ OBJS = $(AOBJS) $(COBJS)
|
|||
|
||||
BIN = libfs$(LIBEXT)
|
||||
|
||||
SUBDIRS = mmap fat romfs nxffs nfs binfs procfs
|
||||
|
||||
all: $(BIN)
|
||||
|
||||
$(AOBJS): %$(OBJEXT): %.S
|
||||
|
|
28
fs/unionfs/Kconfig
Normal file
28
fs/unionfs/Kconfig
Normal file
|
@ -0,0 +1,28 @@
|
|||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see misc/tools/kconfig-language.txt.
|
||||
#
|
||||
|
||||
config FS_UNIONFS
|
||||
bool "Union File System"
|
||||
default n
|
||||
---help---
|
||||
The Union file system is provides a mechanism to overlay two
|
||||
different, mounted file systems so that they appear as one. In
|
||||
general this works like this:
|
||||
|
||||
1) Mount file system 1 at some location, say /mnt/file1
|
||||
2) Mount file system 2 at some location, say /mnt/file2
|
||||
3) Call unionfs_mount() to combine and overly /mnt/file1 and
|
||||
mnt/file2 as a new mount point, say /mnt/unionfs.
|
||||
|
||||
/mnt/file1 and /mnt/file2 will disappear and be replaced by the
|
||||
single mountpoint /mnut/unionfs. The previous contents under
|
||||
/mnt/file1 and /mnt/file2 will appear merged under /mnt/unionfs.
|
||||
Files at the same relative path in file system1 will take presence.
|
||||
If another file of the same name and same relative location exists
|
||||
in file system 2, it will not be visible because it will be occluded
|
||||
by the file in file system1.
|
||||
|
||||
See include/nutts/unionfs.h for additional information.
|
||||
|
47
fs/unionfs/Make.defs
Normal file
47
fs/unionfs/Make.defs
Normal file
|
@ -0,0 +1,47 @@
|
|||
############################################################################
|
||||
# fs/unionfs/Make.defs
|
||||
#
|
||||
# Copyright (C) 2015 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
#
|
||||
# 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_FS_UNIONFS),y)
|
||||
# Files required for Union file system support
|
||||
|
||||
ASRCS +=
|
||||
CSRCS += fs_unionfs.c
|
||||
|
||||
# Include Union File System build support
|
||||
|
||||
DEPPATH += --dep-path unionfs
|
||||
VPATH += :unionfs
|
||||
|
||||
endif
|
39
fs/unionfs/README.txt
Executable file
39
fs/unionfs/README.txt
Executable file
|
@ -0,0 +1,39 @@
|
|||
fs/unionfs/README.txt
|
||||
=====================
|
||||
|
||||
This directory contains the NuttX Union File System. The Union file
|
||||
system is provides a mechanism to overlay two different, mounted file
|
||||
systems so that they appear as one. In general this works like this:
|
||||
|
||||
1) Mount file system 1 at some location, say /mnt/file1
|
||||
2) Mount file system 2 at some location, say /mnt/file2
|
||||
3) Call unionfs_mount() to combine and overly /mnt/file1 and mnt/file2
|
||||
as a new mount point, say /mnt/unionfs.
|
||||
|
||||
/mnt/file1 and /mnt/file2 will disappear and be replaced by the single
|
||||
mountpoint /mnut/unionfs. The previous contents under /mnt/file1 and
|
||||
/mnt/file2 will appear merged under /mnt/unionfs. Files at the same
|
||||
relative path in file system1 will take presence. If another file of the
|
||||
same name and same relative location exists in file system 2, it will
|
||||
not be visible because it will be occluded by the file in file system1.
|
||||
|
||||
See include/nutts/unionfs.h for additional information.
|
||||
|
||||
The Union File Sysem is enabled by selecting the CONFIG_FS_UNIONFS option
|
||||
in the NuttX configruation file.
|
||||
|
||||
The original motivation for this file was for the use of the built-in
|
||||
function file system (BINFS) with a web server. In that case, the built
|
||||
in functions provide CGI programs. But the BINFS file system cannot hold
|
||||
content. Fixed content would need to be retained in a more standard file
|
||||
system such as ROMFS. With this Union File System, you can overly the
|
||||
BINFS mountpoint on the the ROMFS mountpoint, providing a single directory
|
||||
that appears to contain the executables from the BINFS file system along
|
||||
with the web content from the ROMFS file system.
|
||||
|
||||
Another possible use for the Union File System could be to augment or
|
||||
replace files in a FLASH file system. For example, suppose that you have
|
||||
a product that ships with content in a ROMFS file system provided by the
|
||||
on-board FLASH. Later, you overlay that ROMFS file system with additional
|
||||
files from an SD card by using the Union File System to overlay, and
|
||||
perhaps replace, the ROMFS files.
|
2034
fs/unionfs/fs_unionfs.c
Normal file
2034
fs/unionfs/fs_unionfs.c
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* include/nuttx/fs/dirent.h
|
||||
*
|
||||
* Copyright (C) 2007, 2009, 2011-2013 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007, 2009, 2011-2013, 2015 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -144,7 +144,20 @@ struct fs_smartfsdir_s
|
|||
{
|
||||
uint16_t fs_firstsector; /* First sector of directory list */
|
||||
uint16_t fs_currsector; /* Current sector of directory list */
|
||||
uint16_t fs_curroffset; /* Current offset withing current sector */
|
||||
uint16_t fs_curroffset; /* Current offset within current sector */
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_FS_UNIONFS
|
||||
/* The Union File System can be used to merge to different mountpoints so
|
||||
* that they appear as a single merged directory.
|
||||
*/
|
||||
|
||||
struct fs_dirent_s; /* Forward reference */
|
||||
struct fs_unionfsdir_s
|
||||
{
|
||||
uint8_t fu_ndx; /* Index of file system being enumerated */
|
||||
FAR struct fs_dirent_s *fu_lower[2]; /* dirent struct used by contained file system */
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -208,6 +221,9 @@ struct fs_dirent_s
|
|||
#ifdef CONFIG_FS_SMARTFS
|
||||
struct fs_smartfsdir_s smartfs;
|
||||
#endif
|
||||
#ifdef CONFIG_FS_UNIONFS
|
||||
struct fs_unionfsdir_s unionfs;
|
||||
#endif
|
||||
#endif /* !CONFIG_DISABLE_MOUNTPOINT */
|
||||
} u;
|
||||
|
||||
|
|
103
include/nuttx/fs/unionfs.h
Normal file
103
include/nuttx/fs/unionfs.h
Normal file
|
@ -0,0 +1,103 @@
|
|||
/****************************************************************************
|
||||
* include/nuttx/fs/unionfs.h
|
||||
*
|
||||
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_NUTTX_FS_UNIONFS_H
|
||||
#define __INCLUDE_NUTTX_FS_UNIONFS_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#ifdef CONFIG_FS_UNIONFS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Type Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: unionfs_mount
|
||||
*
|
||||
* Description:
|
||||
* Create and mount a union file system
|
||||
*
|
||||
* Input Parameters:
|
||||
* fspath1 - The full path to the first file system mountpoint
|
||||
* prefix1 - An optiona prefix that may be applied to make the first
|
||||
* file system appear a some path below the unionfs mountpoint,
|
||||
* fspath2 - The full path to the second file system mountpoint
|
||||
* prefix2 - An optiona prefix that may be applied to make the first
|
||||
* file system appear a some path below the unionfs mountpoint,
|
||||
* mountpt - The full path to the mountpoint for the union file system
|
||||
*
|
||||
* Returned value:
|
||||
* Zero (OK) is returned if the union file system was correctly created and
|
||||
* mounted. On any failure, a negated error value will be returned to
|
||||
* indicate the nature of the failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int unionfs_mount(FAR const char *fspath1, FAR const char *prefix1,
|
||||
FAR const char *fspath2, FAR const char *prefix2,
|
||||
FAR const char *mountpt);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_FS_UNIONFS */
|
||||
#endif /* __INCLUDE_NUTTX_FS_UNIONFS_H */
|
|
@ -102,6 +102,7 @@
|
|||
#define PROCFS_MAGIC 0x434f5250
|
||||
#define NXFFS_MAGIC 0x4747
|
||||
#define SMARTFS_MAGIC 0x54524D53
|
||||
#define UNIONFS_MAGIC 0x53464e55
|
||||
|
||||
/****************************************************************************
|
||||
* Type Definitions
|
||||
|
|
Loading…
Reference in a new issue