statvfs: do nothing if statvfs does not exist (android/bionic)

If statvfs does not exist, then don't recalculate mount flags
at remount.

If someone does need this, they could replace the code (only
if !HAVE_STATVFS) with code parsing /proc/self/mountinfo (which
exists in the recent git history)

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
This commit is contained in:
Serge Hallyn 2014-08-22 16:23:56 -05:00 committed by Stéphane Graber
parent e2a7e8dc47
commit 614305f397
2 changed files with 13 additions and 0 deletions

View File

@ -573,6 +573,7 @@ AC_CHECK_FUNCS([setns pivot_root sethostname unshare rand_r confstr faccessat])
# Check for some functions # Check for some functions
AC_CHECK_LIB(pthread, main) AC_CHECK_LIB(pthread, main)
AC_CHECK_FUNCS(pthread_atfork) AC_CHECK_FUNCS(pthread_atfork)
AC_CHECK_FUNCS(statvfs)
AC_CHECK_LIB(util, openpty) AC_CHECK_LIB(util, openpty)
AC_CHECK_FUNCS([openpty hasmntopt setmntent endmntent utmpxname]) AC_CHECK_FUNCS([openpty hasmntopt setmntent endmntent utmpxname])
AC_CHECK_FUNCS([getline], AC_CHECK_FUNCS([getline],

View File

@ -36,7 +36,9 @@
#include <pwd.h> #include <pwd.h>
#include <grp.h> #include <grp.h>
#include <time.h> #include <time.h>
#ifdef HAVE_STATVFS
#include <sys/statvfs.h> #include <sys/statvfs.h>
#endif
#if HAVE_PTY_H #if HAVE_PTY_H
#include <pty.h> #include <pty.h>
@ -696,6 +698,7 @@ int pin_rootfs(const char *rootfs)
static unsigned long add_required_remount_flags(const char *s, const char *d, static unsigned long add_required_remount_flags(const char *s, const char *d,
unsigned long flags) unsigned long flags)
{ {
#ifdef HAVE_STATVFS
struct statvfs sb; struct statvfs sb;
unsigned long required_flags = 0; unsigned long required_flags = 0;
@ -720,6 +723,9 @@ static unsigned long add_required_remount_flags(const char *s, const char *d,
required_flags |= MS_NOEXEC; required_flags |= MS_NOEXEC;
return flags | required_flags; return flags | required_flags;
#else
return flags;
#endif
} }
static int lxc_mount_auto_mounts(struct lxc_conf *conf, int flags, struct lxc_handler *handler) static int lxc_mount_auto_mounts(struct lxc_conf *conf, int flags, struct lxc_handler *handler)
@ -1993,7 +1999,9 @@ static int mount_entry(const char *fsname, const char *target,
const char *fstype, unsigned long mountflags, const char *fstype, unsigned long mountflags,
const char *data, int optional) const char *data, int optional)
{ {
#ifdef HAVE_STATVFS
struct statvfs sb; struct statvfs sb;
#endif
if (mount(fsname, target, fstype, mountflags & ~MS_REMOUNT, data)) { if (mount(fsname, target, fstype, mountflags & ~MS_REMOUNT, data)) {
if (optional) { if (optional) {
@ -2011,6 +2019,7 @@ static int mount_entry(const char *fsname, const char *target,
DEBUG("remounting %s on %s to respect bind or remount options", DEBUG("remounting %s on %s to respect bind or remount options",
fsname ? fsname : "(none)", target ? target : "(none)"); fsname ? fsname : "(none)", target ? target : "(none)");
#ifdef HAVE_STATVFS
if (statvfs(fsname, &sb) == 0) { if (statvfs(fsname, &sb) == 0) {
unsigned long required_flags = 0; unsigned long required_flags = 0;
if (sb.f_flag & MS_NOSUID) if (sb.f_flag & MS_NOSUID)
@ -2036,6 +2045,7 @@ static int mount_entry(const char *fsname, const char *target,
} }
mountflags |= required_flags; mountflags |= required_flags;
} }
#endif
if (mount(fsname, target, fstype, if (mount(fsname, target, fstype,
mountflags | MS_REMOUNT, data)) { mountflags | MS_REMOUNT, data)) {
@ -2052,7 +2062,9 @@ static int mount_entry(const char *fsname, const char *target,
} }
} }
#ifdef HAVE_STATVFS
skipremount: skipremount:
#endif
DEBUG("mounted '%s' on '%s', type '%s'", fsname, target, fstype); DEBUG("mounted '%s' on '%s', type '%s'", fsname, target, fstype);
return 0; return 0;