Quoting Stéphane Graber (stgra...@ubuntu.com): > Bionic (at least) is missing some of the usual mntent functions. > This adds code defining those that we need when they're missing from the C > library. > > Signed-off-by: Stéphane Graber <stgra...@ubuntu.com> > --- > src/include/mntent.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ > src/include/mntent.h | 18 ++++++++++++++++++ > src/lxc/Makefile.am | 8 ++++++-- > src/lxc/cgroup.c | 12 ++++++++++++ > src/lxc/conf.c | 8 ++++++++ > 5 files changed, 93 insertions(+), 2 deletions(-) > create mode 100644 src/include/mntent.c > create mode 100644 src/include/mntent.h > > diff --git a/src/include/mntent.c b/src/include/mntent.c > new file mode 100644 > index 0000000..cd22a89 > --- /dev/null > +++ b/src/include/mntent.c > @@ -0,0 +1,49 @@ > +#include <mntent.h> > +#include <stdio.h> > +#include <string.h> > + > +/* Prepare to begin reading and/or writing mount table entries from the > + beginning of FILE. MODE is as for `fopen'. */ > +FILE *setmntent (const char *file, const char *mode) > +{ > + /* Extend the mode parameter with "c" to disable cancellation in the > + I/O functions and "e" to set FD_CLOEXEC. */
Do these actually work on android? They're listed as GNU C extensions... Anyway, looks good long as it works for you Acked-by: Serge E. Hallyn <serge.hal...@ubuntu.com> > + size_t modelen = strlen (mode); > + char newmode[modelen + 3]; > + memcpy (newmode, mode, modelen); > + memcpy (newmode + modelen, "ce", 3); > + FILE *result = fopen (file, newmode); > + > + return result; > +} > + > + > +/* Close a stream opened with `setmntent'. */ > +int endmntent (FILE *stream) > +{ > + if (stream) /* SunOS 4.x allows for NULL stream */ > + fclose (stream); > + return 1; /* SunOS 4.x says to always return 1 */ > +} > + > +/* Search MNT->mnt_opts for an option matching OPT. > + Returns the address of the substring, or null if none found. */ > +char *hasmntopt (const struct mntent *mnt, const char *opt) > +{ > + const size_t optlen = strlen (opt); > + char *rest = mnt->mnt_opts, *p; > + > + while ((p = strstr (rest, opt)) != NULL) > + { > + if ((p == rest || p[-1] == ',') > + && (p[optlen] == '\0' || p[optlen] == '=' || p[optlen] == ',')) > + return p; > + > + rest = strchr (p, ','); > + if (rest == NULL) > + break; > + ++rest; > + } > + > + return NULL; > +} > diff --git a/src/include/mntent.h b/src/include/mntent.h > new file mode 100644 > index 0000000..0a0398a > --- /dev/null > +++ b/src/include/mntent.h > @@ -0,0 +1,18 @@ > +#ifndef _mntent_h > +#define _mntent_h > + > +#include <../config.h> > + > +#ifndef HAVE_SETMNTENT > +FILE *setmntent (const char *file, const char *mode); > +#endif > + > +#ifndef HAVE_ENDMNTENT > +int endmntent (FILE *stream); > +#endif > + > +#ifndef HAVE_HASMNTOPT > +extern char *hasmntopt (const struct mntent *mnt, const char *opt); > +#endif > + > +#endif > diff --git a/src/lxc/Makefile.am b/src/lxc/Makefile.am > index c82ee76..a6bfa9b 100644 > --- a/src/lxc/Makefile.am > +++ b/src/lxc/Makefile.am > @@ -18,7 +18,9 @@ pkginclude_HEADERS = \ > lxclock.h > > if IS_BIONIC > -pkginclude_HEADERS += ../include/openpty.h > +pkginclude_HEADERS += \ > + ../include/openpty.h \ > + ../include/mntent.h > endif > > sodir=$(libdir) > @@ -66,7 +68,9 @@ liblxc_so_SOURCES = \ > lxccontainer.c lxccontainer.h > > if IS_BIONIC > -liblxc_so_SOURCES += ../include/openpty.c ../include/openpty.h > +liblxc_so_SOURCES += \ > + ../include/openpty.c ../include/openpty.h \ > + ../include/mntent.c ../include/mntent.h > endif > > AM_CFLAGS=-I$(top_srcdir)/src \ > diff --git a/src/lxc/cgroup.c b/src/lxc/cgroup.c > index f6243b8..88d8ff8 100644 > --- a/src/lxc/cgroup.c > +++ b/src/lxc/cgroup.c > @@ -44,6 +44,18 @@ > #include <lxc/cgroup.h> > #include <lxc/start.h> > > +#ifndef HAVE_HASMNTOPT > +#include <../include/mntent.h> > +#endif > + > +#ifndef HAVE_SETMNTENT > +#include <../include/mntent.h> > +#endif > + > +#ifndef HAVE_ENDMNTENT > +#include <../include/mntent.h> > +#endif > + > lxc_log_define(lxc_cgroup, lxc); > > #define MTAB "/proc/mounts" > diff --git a/src/lxc/conf.c b/src/lxc/conf.c > index 7963b00..21a5cbb 100644 > --- a/src/lxc/conf.c > +++ b/src/lxc/conf.c > @@ -77,6 +77,14 @@ > #include <sys/personality.h> > #endif > > +#ifndef HAVE_SETMNTENT > +#include <../include/mntent.h> > +#endif > + > +#ifndef HAVE_ENDMNTENT > +#include <../include/mntent.h> > +#endif > + > #include "lxcseccomp.h" > > lxc_log_define(lxc_conf, lxc); > -- > 1.8.0 > > > ------------------------------------------------------------------------------ > Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, > MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current > with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft > MVPs and experts. ON SALE this month only -- learn more at: > http://p.sf.net/sfu/learnmore_122712 > _______________________________________________ > Lxc-devel mailing list > Lxc-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/lxc-devel ------------------------------------------------------------------------------ Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. ON SALE this month only -- learn more at: http://p.sf.net/sfu/learnmore_122712 _______________________________________________ Lxc-devel mailing list Lxc-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-devel