diff options
author | James Davidson <james.davidson@vyatta.com> | 2012-10-19 12:11:03 -0700 |
---|---|---|
committer | James Davidson <james.davidson@vyatta.com> | 2012-10-19 13:47:02 -0700 |
commit | 5ffad3ec21332a7cd8b967231b84d5eecee5be92 (patch) | |
tree | c89335c695e4608fe38d6110138549058c89720c | |
parent | 72c915729c7d98a23db8415119283808110d0972 (diff) | |
download | vyatta-cfg-5ffad3ec21332a7cd8b967231b84d5eecee5be92.tar.gz vyatta-cfg-5ffad3ec21332a7cd8b967231b84d5eecee5be92.zip |
Add support for overlayfs and start using it
-rw-r--r-- | Makefile.am | 7 | ||||
-rw-r--r-- | configure.ac | 6 | ||||
-rwxr-xr-x | debian/rules | 1 | ||||
-rw-r--r-- | src/common/unionfs.c | 15 | ||||
-rw-r--r-- | src/cstore/unionfs/cstore-unionfs.cpp | 20 |
5 files changed, 41 insertions, 8 deletions
diff --git a/Makefile.am b/Makefile.am index 8f84603..3376c41 100644 --- a/Makefile.am +++ b/Makefile.am @@ -9,8 +9,11 @@ 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_OVERLAYFS +USE_OVERLAYFS = -DUSE_OVERLAYFS=1 +endif +AM_CFLAGS = -I src -Wall -I /usr/include/glib-2.0 -I /usr/lib/glib-2.0/include $(USE_OVERLAYFS) +AM_CXXFLAGS = -I src -Wall -Werror $(USE_OVERLAYFS) 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..088461a 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([overlayfs], + AC_HELP_STRING([--enable-overlayfs], + [use overlayfs instead of unionfs (default is no)]), + [enable_overlayfs=yes], [enable_overlayfs=no]) +AM_CONDITIONAL([USE_OVERLAYFS], [test "$enable_overlayfs" != no]) + AC_CONFIG_FILES( [Makefile] [perl_dmod/Makefile] diff --git a/debian/rules b/debian/rules index f2c57b7..47a1d16 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-overlayfs 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..c1752ac 100644 --- a/src/common/unionfs.c +++ b/src/common/unionfs.c @@ -71,9 +71,20 @@ static inline void sys_mount_session(void) { char mopts[MAX_LENGTH_DIR_PATH * 2]; - snprintf(mopts, MAX_LENGTH_DIR_PATH * 2, "dirs=%s=rw:%s=ro", + const char *fstype; + const char *moptfmt; + int local_errno; + +#ifdef USE_OVERLAYFS + fstype = "overlayfs"; + moptfmt = "upperdir=%s,lowerdir=%s"; +#else + fstype = "unionfs"; + moptfmt = "dirs=%s=rw:%s=ro"; +#endif + snprintf(mopts, MAX_LENGTH_DIR_PATH * 2, moptfmt, get_cdirp(), get_adirp()); - if (mount("unionfs", get_mdirp(), "unionfs", 0, mopts) != 0) { + if (mount(fstype, get_mdirp(), fstype, 0, mopts) != 0) { perror("mount"); } } diff --git a/src/cstore/unionfs/cstore-unionfs.cpp b/src/cstore/unionfs/cstore-unionfs.cpp index e21e660..c53e443 100644 --- a/src/cstore/unionfs/cstore-unionfs.cpp +++ b/src/cstore/unionfs/cstore-unionfs.cpp @@ -1477,14 +1477,26 @@ bool UnionfsCstore::do_mount(const FsPath& rwdir, const FsPath& rdir, const FsPath& mdir) { - string mopts = "dirs="; + const char *fstype; + string mopts; + +#ifdef USE_OVERLAYFS + fstype = "overlayfs"; + mopts = "upperdir="; + mopts += rwdir.path_cstr(); + mopts += ",lowerdir="; + mopts += rdir.path_cstr(); +#else + fstype = "unionfs"; + mopts = "dirs="; mopts += rwdir.path_cstr(); mopts += "=rw:"; mopts += rdir.path_cstr(); mopts += "=ro"; - if (mount("unionfs", mdir.path_cstr(), "unionfs", 0, mopts.c_str()) != 0) { - output_internal("union mount failed [%s][%s]\n", - strerror(errno), mdir.path_cstr()); +#endif + if (mount(fstype, mdir.path_cstr(), fstype, 0, mopts.c_str()) != 0) { + output_internal("union mount failed [%s][%s][%s]\n", + strerror(errno), mdir.path_cstr(), mopts.c_str()); return false; } return true; |