diff options
author | Daniil Baturin <daniil@baturin.org> | 2014-03-10 03:57:50 +0100 |
---|---|---|
committer | Daniil Baturin <daniil@baturin.org> | 2014-03-10 03:57:50 +0100 |
commit | 70adcee7b6561c4e9122858c4dca0fa5ee6af52a (patch) | |
tree | 6522eb5b6754fd045d15155b5a45599adb892c37 | |
parent | c1ecd5aca9d7ad1dfbf036d3d1f0da8a99ef1ac5 (diff) | |
download | vyatta-cfg-70adcee7b6561c4e9122858c4dca0fa5ee6af52a.tar.gz vyatta-cfg-70adcee7b6561c4e9122858c4dca0fa5ee6af52a.zip |
Import and adapt Kim Hagen's changes for union-fs support.
-rw-r--r-- | Makefile.am | 8 | ||||
-rw-r--r-- | configure.ac | 6 | ||||
-rw-r--r-- | debian/control | 1 | ||||
-rwxr-xr-x | debian/rules | 1 | ||||
-rw-r--r-- | src/common/unionfs.c | 14 | ||||
-rw-r--r-- | src/cstore/unionfs/cstore-unionfs.cpp | 18 |
6 files changed, 46 insertions, 2 deletions
diff --git a/Makefile.am b/Makefile.am index c02dc43..963450e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -9,8 +9,12 @@ etc_shell_leveldir = $(sysconfdir)/shell/level dhcphookdir = /etc/dhcp3/dhclient-exit-hooks.d enumdir = $(datadir)/enumeration -AM_CFLAGS = -I src -Wall -I /usr/include/glib-2.0 -I /usr/lib/glib-2.0/include -AM_CXXFLAGS = -I src -Wall -Werror +if USE_UNIONFSFUSE +USE_UNIONFSFUSE = -DUSE_UNIONFSFUSE=1 +endif + +AM_CFLAGS = -I src -Wall -I /usr/include/glib-2.0 -I /usr/lib/glib-2.0/include $(USE_UNIONFSFUSE) +AM_CXXFLAGS = -I src -Wall -Werror $(USE_UNIONFSFUSE) AM_CXXFLAGS += -I /usr/include/glib-2.0 -I /usr/lib/glib-2.0/include AM_YFLAGS = -d --name-prefix=yy_`basename $* .y`_ AM_LFLAGS = --prefix=yy_`basename $* .l`_ -olex.yy.c diff --git a/configure.ac b/configure.ac index 04210fd..f71cea0 100644 --- a/configure.ac +++ b/configure.ac @@ -29,6 +29,12 @@ AC_ARG_ENABLE([nostrip], [include -nostrip option during packaging]), [NOSTRIP=-nostrip], [NOSTRIP=]) +AC_ARG_ENABLE([unionfsfuse], + AC_HELP_STRING([--enable-unionfsfuse], + [use unionfsfuse instead of unionfs (default is no)]), + [enable_unionfsfuse=yes], [enable_unionfsfuse=no]) +AM_CONDITIONAL([USE_UNIONFSFUSE], [test "$enable_unionfsfuse" != no]) + AC_CONFIG_FILES( [Makefile] [perl_dmod/Makefile] diff --git a/debian/control b/debian/control index 9862b18..9aee3eb 100644 --- a/debian/control +++ b/debian/control @@ -26,6 +26,7 @@ Depends: sed (>= 4.1.5), curl, libsocket6-perl, libvyatta-cfg1 (=${binary:Version}), + unionfs-fuse, ${perl:Depends}, ${shlibs:Depends} Replaces: vyatta-cfg-firewall, vyatta-cfg-quagga diff --git a/debian/rules b/debian/rules index f2c57b7..6666366 100755 --- a/debian/rules +++ b/debian/rules @@ -8,6 +8,7 @@ cfg_opts += --libdir=/usr/lib cfg_opts += --includedir=/usr/include cfg_opts += --mandir=\$${prefix}/share/man cfg_opts += --infodir=\$${prefix}/share/info +cfg_opts += --enable-unionfsfuse cfg_opts += CFLAGS="$(CFLAGS)" cfg_opts += LDFLAGS="-Wl,-z,defs" cfg_opts += CXXFLAGS="$(CXXFLAGS)" diff --git a/src/common/unionfs.c b/src/common/unionfs.c index d8b7626..dff20e6 100644 --- a/src/common/unionfs.c +++ b/src/common/unionfs.c @@ -70,12 +70,26 @@ sys_umount_session(void) static inline void sys_mount_session(void) { +#ifdef USE_UNIONFSFUSE + char mopts[MAX_LENGTH_DIR_PATH * 2]; + const char *fstype; + const char *moptfmt; + int local_errno; + fstype = "/usr/bin/unionfs-fuse -o cow -o allow_other"; + moptfmt = "%s %s=RW:%s=RO %s"; + snprintf(mopts, MAX_LENGTH_DIR_PATH * 4, moptfmt, + fstype, get_cdirp(), get_adirp(), get_mdirp()); + if (system(mopts) != 0) { + perror("system"); + } +#else char mopts[MAX_LENGTH_DIR_PATH * 2]; snprintf(mopts, MAX_LENGTH_DIR_PATH * 2, "dirs=%s=rw:%s=ro", get_cdirp(), get_adirp()); if (mount("unionfs", get_mdirp(), "unionfs", 0, mopts) != 0) { perror("mount"); } +#endif } void diff --git a/src/cstore/unionfs/cstore-unionfs.cpp b/src/cstore/unionfs/cstore-unionfs.cpp index e21e660..938436e 100644 --- a/src/cstore/unionfs/cstore-unionfs.cpp +++ b/src/cstore/unionfs/cstore-unionfs.cpp @@ -1477,6 +1477,23 @@ bool UnionfsCstore::do_mount(const FsPath& rwdir, const FsPath& rdir, const FsPath& mdir) { +#ifdef USE_UNIONFSFUSE + string mopts = "/usr/bin/unionfs-fuse "; + mopts += "-o cow -o allow_other "; + mopts += rwdir.path_cstr(); + mopts += "=RW:"; + mopts += rdir.path_cstr(); + mopts += "=RO"; + mopts += " "; + mopts += mdir.path_cstr(); + + if (system(mopts.c_str()) != 0) + { + output_internal("union mount failed [%s][%s][%s]\n", + strerror(errno), mdir.path_cstr(), mopts.c_str()); + return false; + } +#else string mopts = "dirs="; mopts += rwdir.path_cstr(); mopts += "=rw:"; @@ -1487,6 +1504,7 @@ UnionfsCstore::do_mount(const FsPath& rwdir, const FsPath& rdir, strerror(errno), mdir.path_cstr()); return false; } +#endif return true; } |