From 0c188bb238bf5c2a2cd3403b27c91426f60cbe07 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Fri, 6 Aug 2010 11:50:39 +0200 Subject: [PATCH] libmount: fix datatype for mountflags Signed-off-by: Karel Zak --- shlibs/mount/src/mount.h.in | 2 +- shlibs/mount/src/mtab.c | 6 +++--- shlibs/mount/src/optstr.c | 18 ++++++++++-------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/shlibs/mount/src/mount.h.in b/shlibs/mount/src/mount.h.in index 329ec8f1..3283630c 100644 --- a/shlibs/mount/src/mount.h.in +++ b/shlibs/mount/src/mount.h.in @@ -157,7 +157,7 @@ extern int mnt_split_optstr(const char *optstr, char **user, char **vfs, char **fs, int ifnore_user, int ignore_vfs); -extern int mnt_optstr_get_mountflags(const char *optstr); +extern int mnt_optstr_get_mountflags(const char *optstr, unsigned long *flags); /* iter.c */ enum { diff --git a/shlibs/mount/src/mtab.c b/shlibs/mount/src/mtab.c index 81b01f2b..eeef8a0c 100644 --- a/shlibs/mount/src/mtab.c +++ b/shlibs/mount/src/mtab.c @@ -57,7 +57,7 @@ */ struct _mnt_mtab { int action; /* MNT_ACT_{MOUNT,UMOUNT} */ - int mountflags; /* MS_* flags */ + unsigned long mountflags; /* MS_* flags */ char *filename; /* usually /etc/mtab or /var/run/mount/mountinfo */ char *old_target; /* for MS_MOVE */ int format; /* MNT_FMT_{MTAB,MOUNTINFO} */ @@ -205,7 +205,7 @@ int mnt_mtab_set_optstr(mnt_mtab *mt, const char *optstr) * * Returns: 0 on success, -1 in case of error. */ -int mnt_mtab_set_mountflags(mnt_mtab *mt, int flags) +int mnt_mtab_set_mountflags(mnt_mtab *mt, unsigned long flags) { assert(mt); if (!mt) @@ -596,7 +596,7 @@ int mnt_mtab_prepare_update(mnt_mtab *mt) o = mnt_fs_get_optstr(mt->fs); if (o) - mt->mountflags |= mnt_optstr_get_mountflags(o); + mnt_optstr_get_mountflags(o, &mt->mountflags); /* umount */ if (mt->action == MNT_ACT_UMOUNT) diff --git a/shlibs/mount/src/optstr.c b/shlibs/mount/src/optstr.c index c2581be6..3308a1a0 100644 --- a/shlibs/mount/src/optstr.c +++ b/shlibs/mount/src/optstr.c @@ -410,6 +410,7 @@ int mnt_split_optstr(const char *optstr, char **user, char **vfs, char **fs, /** * mnt_optstr_get_mountflags: * @optstr: string with comma separated list of options + * @flags: returns mount flags * * The mountflags are IDs from all MNT_MFLAG options from MNT_LINUX_MAP options * map. See "struct mnt_optmap". For more details about mountflags see @@ -421,18 +422,19 @@ int mnt_split_optstr(const char *optstr, char **user, char **vfs, char **fs, * * "bind,noexec,foo,bar" --returns-> MS_BIND|MS_NOEXEC * - * Returns: mount flags or 0. + * Note that @flags are not zeroized by this function. + * + * Returns: 0 on success or -1 in case of error */ -int mnt_optstr_get_mountflags(const char *optstr) +int mnt_optstr_get_mountflags(const char *optstr, unsigned long *flags) { - int flags = 0; struct mnt_optmap const *maps[1]; char *name, *str = (char *) optstr; size_t namesz = 0; assert(optstr); - if (!optstr) + if (!optstr || !flags) return -1; maps[0] = mnt_get_builtin_optmap(MNT_LINUX_MAP); @@ -445,15 +447,15 @@ int mnt_optstr_get_mountflags(const char *optstr) if (!(ent->mask & MNT_MFLAG)) continue; if (ent->mask & MNT_INVERT) - flags &= ~ent->id; + *flags &= ~ent->id; else - flags |= ent->id; + *flags |= ent->id; } } DBG(DEBUG_OPTIONS, fprintf(stderr, - "libmount: optstr '%s': mountflags 0x%08x\n", optstr, flags)); - return flags; + "libmount: optstr '%s': mountflags 0x%08lx\n", optstr, *flags)); + return 0; } #ifdef TEST_PROGRAM -- 2.39.5