]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: remove utab from API, update tests
authorKarel Zak <kzak@redhat.com>
Fri, 3 Dec 2010 20:13:52 +0000 (21:13 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 3 Jan 2011 11:28:47 +0000 (12:28 +0100)
The utab file is private libmount stuff. Anything about utab should
not be exported by library API.

Signed-off-by: Karel Zak <kzak@redhat.com>
14 files changed:
shlibs/mount/src/context.c
shlibs/mount/src/context_umount.c
shlibs/mount/src/fs.c
shlibs/mount/src/mount.h.in
shlibs/mount/src/mountP.h
shlibs/mount/src/tab_parse.c
shlibs/mount/src/tab_update.c
shlibs/mount/src/utils.c
tests/expected/libmount/tabfiles-parse-mountinfo
tests/expected/libmount/update-utab-mount
tests/expected/libmount/update-utab-move
tests/expected/libmount/update-utab-remount
tests/expected/libmount/update-utab-umount
tests/ts/libmount/update

index 069a88343e2666813da8ca68dec68468dbc6ea9d..4fe2eabf404be31194e02bbb31feb67ee8586081 100644 (file)
@@ -1067,9 +1067,13 @@ int mnt_context_prepare_update(mnt_context *cxt)
                return 0;
        }
        if (!cxt->update) {
-               cxt->update = mnt_new_update(!cxt->mtab_writable);
+               cxt->update = mnt_new_update();
                if (!cxt->update)
                        return -ENOMEM;
+
+               mnt_update_set_filename(cxt->update,
+                               cxt->mtab_writable ? cxt->mtab_path : cxt->utab_path,
+                               !cxt->mtab_writable);
        }
 
        rc = mnt_update_set_fs(cxt->update, cxt->mountflags,
@@ -1081,9 +1085,6 @@ int mnt_context_prepare_update(mnt_context *cxt)
 
 int mnt_context_update_tabs(mnt_context *cxt)
 {
-       const char *filename;
-       mnt_lock *lock = NULL;
-
        assert(cxt);
 
        if (cxt->flags & MNT_FL_NOMTAB) {
@@ -1102,15 +1103,8 @@ int mnt_context_update_tabs(mnt_context *cxt)
                DBG(CXT, mnt_debug_h(cxt, "don't update: syscall failed"));
                return 0;
        }
-       if (mnt_update_is_userspace_only(cxt->update))
-               filename = cxt->utab_path;
-       else {
-               filename = cxt->mtab_path;
-               lock = mnt_context_get_lock(cxt);
-       }
-       assert(filename);
 
-       return mnt_update_tab(cxt->update, filename, lock);
+       return mnt_update_tab(cxt->update, mnt_context_get_lock(cxt));
 }
 
 static int is_remount(mnt_context *cxt)
index ca9ca774912d9c3e94cf751f574a3f0d3316f99b..ec571300414d873cb9333b2d700e81a7e0810572 100644 (file)
@@ -502,9 +502,8 @@ int mnt_context_do_umount(mnt_context *cxt)
                if (!rc)
                        rc = __mnt_fs_set_optstr_ptr(cxt->fs, n, FALSE);
 
-               if (!rc && cxt->update &&
-                   !mnt_update_is_userspace_only(cxt->update))
-                       /* refresh options in /etc/mtab as well*/
+               /* refresh options in /etc/mtab as well */
+               if (!rc && cxt->update && cxt->mtab_writable)
                        rc = mnt_update_set_fs(cxt->update,
                                               cxt->mountflags, NULL, cxt->fs);
        }
index a11061d91a220a1d4e0de3a49cb42c9e8cc98c5c..30dabed7dc5cef9effd7db815c91f91e4f15fcec 100644 (file)
@@ -900,25 +900,25 @@ int mnt_fs_print_debug(mnt_fs *fs, FILE *file)
        if (!fs)
                return -EINVAL;
        fprintf(file, "------ fs: %p\n", fs);
-       fprintf(file, "source:  %s\n", mnt_fs_get_source(fs));
-       fprintf(file, "target:  %s\n", mnt_fs_get_target(fs));
-       fprintf(file, "fstype:  %s\n", mnt_fs_get_fstype(fs));
-       fprintf(file, "optstr:  %s\n", mnt_fs_get_optstr(fs));
+       fprintf(file, "source: %s\n", mnt_fs_get_source(fs));
+       fprintf(file, "target: %s\n", mnt_fs_get_target(fs));
+       fprintf(file, "fstype: %s\n", mnt_fs_get_fstype(fs));
+       fprintf(file, "optstr: %s\n", mnt_fs_get_optstr(fs));
 
        if (mnt_fs_get_root(fs))
-               fprintf(file, "root:    %s\n", mnt_fs_get_root(fs));
+               fprintf(file, "root:   %s\n", mnt_fs_get_root(fs));
        if (mnt_fs_get_bindsrc(fs))
                fprintf(file, "bindsrc: %s\n", mnt_fs_get_bindsrc(fs));
        if (mnt_fs_get_freq(fs))
-               fprintf(file, "freq:    %d\n", mnt_fs_get_freq(fs));
+               fprintf(file, "freq:   %d\n", mnt_fs_get_freq(fs));
        if (mnt_fs_get_passno(fs))
-               fprintf(file, "pass:    %d\n", mnt_fs_get_passno(fs));
+               fprintf(file, "pass:   %d\n", mnt_fs_get_passno(fs));
        if (mnt_fs_get_id(fs))
-               fprintf(file, "id:      %d\n", mnt_fs_get_id(fs));
+               fprintf(file, "id:     %d\n", mnt_fs_get_id(fs));
        if (mnt_fs_get_parent_id(fs))
-               fprintf(file, "parent:  %d\n", mnt_fs_get_parent_id(fs));
+               fprintf(file, "parent: %d\n", mnt_fs_get_parent_id(fs));
        if (mnt_fs_get_devno(fs))
-               fprintf(file, "devno:   %d:%d\n", major(mnt_fs_get_devno(fs)),
+               fprintf(file, "devno:  %d:%d\n", major(mnt_fs_get_devno(fs)),
                                                 minor(mnt_fs_get_devno(fs)));
        return 0;
 }
index 03753f785f19ec1d62af322bf353698ac5e5f484..74cdf0e760b3fdd28dee5f764b07506dc07aa5e2 100644 (file)
@@ -124,13 +124,11 @@ extern int mnt_match_fstype(const char *type, const char *pattern);
 extern int mnt_match_options(const char *optstr, const char *pattern);
 extern const char *mnt_get_fstab_path(void);
 extern const char *mnt_get_mtab_path(void);
-extern const char *mnt_get_utab_path(void);
 
 extern int mnt_get_filesystems(char ***filesystems, const char *pattern);
 extern void mnt_free_filesystems(char **filesystems);
 
 extern int mnt_has_regular_mtab(const char **mtab, int *writable);
-extern int mnt_has_regular_utab(const char **utab, int *writable);
 
 /* cache.c */
 extern mnt_cache *mnt_new_cache(void);
@@ -286,13 +284,12 @@ extern int mnt_tab_find_next_fs(mnt_tab *tb, mnt_iter *itr,
                        mnt_fs **fs);
 
 /* tab_update.c */
-extern mnt_update *mnt_new_update(int userspace_only);
+extern mnt_update *mnt_new_update(void);
 extern void mnt_free_update(mnt_update *upd);
 extern int mnt_update_is_ready(mnt_update *upd);
 extern int mnt_update_set_fs(mnt_update *upd, int mountflags,
                              const char *target, mnt_fs *fs);
-extern int mnt_update_tab(mnt_update *upd, const char *filename, mnt_lock *lc);
-extern int mnt_update_is_userspace_only(mnt_update *upd);;
+extern int mnt_update_tab(mnt_update *upd, mnt_lock *lc);
 
 
 /* context.c */
index df451b771ded02bd3603a84d6996bfaca5a030dc..7eebb2094e89c79c0eb51ce2a9bf5e570747ebad 100644 (file)
@@ -103,7 +103,7 @@ struct mtest {
        const char      *usage;
 };
 
-/* utils.c */
+/* test.c */
 extern int mnt_run_test(struct mtest *tests, int argc, char *argv[]);
 #endif
 
@@ -120,6 +120,8 @@ extern int mnt_in_group(gid_t gid);
 extern char *mnt_get_mountpoint(const char *path);
 extern char *mnt_get_fs_root(const char *path, const char *mountpoint);
 extern int mnt_open_uniq_filename(const char *filename, char **name, int flags);
+extern int mnt_has_regular_utab(const char **utab, int *writable);
+extern const char *mnt_get_utab_path(void);
 
 /*
  * Generic iterator
@@ -315,5 +317,6 @@ extern int mnt_context_update_tabs(mnt_context *cxt);
 
 /* tab_update.c */
 extern mnt_fs *mnt_update_get_fs(mnt_update *upd);
+extern int mnt_update_set_filename(mnt_update *upd, const char *filename, int userspace_only);
 
 #endif /* _LIBMOUNT_PRIVATE_H */
index c69a064fff46619987151f48485bf31be8f724e7..16fab89d8543ce74fa591c6beab6d28dc507e31d 100644 (file)
@@ -555,7 +555,7 @@ mnt_tab *mnt_new_tab_from_file(const char *filename)
 
 /**
  * mnt_new_tab_from_dir
- * @dirname: for example /etc/fstab.d or /dev/.mount/utabs
+ * @dirname: for example /etc/fstab.d
  *
  * Returns: newly allocated tab on success and NULL in case of error.
  */
@@ -707,7 +707,7 @@ static mnt_fs *mnt_tab_merge_userspace_fs(mnt_tab *tb, mnt_fs *uf)
  * @filename: overwrites default (/etc/mtab or $LIBMOUNT_MTAB) or NULL
  *
  * This function parses /etc/mtab or /proc/self/mountinfo +
- * /dev/.mount/utabs/<*>.mtab or /proc/mounts.
+ * /dev/.mount/utabs or /proc/mounts.
  *
  * See also mnt_tab_set_parser_errcb().
  *
index baf5b0b612f24ca0b533d67ebcda706af89f0a1e..e9f6609ea06ccad982de1b6d0f421a19b4d2241c 100644 (file)
@@ -29,6 +29,7 @@
 struct _mnt_update {
        char            *target;
        mnt_fs          *fs;
+       char            *filename;
        unsigned long   mountflags;
        int             userspace_only;
        int             ready;
@@ -39,11 +40,10 @@ static int set_fs_root(mnt_fs *result, mnt_fs *fs, unsigned long mountflags);
 
 /**
  * mnt_new_update:
- * @userspace_only: TRUE/FALSE -- maintain userspace mount options only
  *
  * Returns: newly allocated update handler
  */
-mnt_update *mnt_new_update(int userspace_only)
+mnt_update *mnt_new_update(void)
 {
        mnt_update *upd;
 
@@ -51,7 +51,6 @@ mnt_update *mnt_new_update(int userspace_only)
        if (!upd)
                return NULL;
 
-       upd->userspace_only = userspace_only;
        DBG(UPDATE, mnt_debug_h(upd, "allocate"));
 
        return upd;
@@ -72,9 +71,51 @@ void mnt_free_update(mnt_update *upd)
 
        mnt_free_fs(upd->fs);
        free(upd->target);
+       free(upd->filename);
        free(upd);
 }
 
+/*
+ * Returns 0 on success, 1 if not file available, -1 in case of error.
+ */
+int mnt_update_set_filename(mnt_update *upd, const char *filename, int userspace_only)
+{
+       const char *path = NULL;
+       int rw = 0;
+
+       assert(upd);
+
+       /* filename explicitly defined */
+       if (filename) {
+               char *p = strdup(filename);
+               if (!p)
+                       return -ENOMEM;
+
+               upd->userspace_only = userspace_only;
+               free(upd->filename);
+               upd->filename = p;
+       }
+
+       if (upd->filename)
+               return 0;
+
+       /* detect tab filename -- /etc/mtab or /dev/.mount/utab
+        */
+       mnt_has_regular_mtab(&path, &rw);
+       if (!rw) {
+               path = NULL;
+               mnt_has_regular_utab(&path, &rw);
+               if (!rw)
+                       return 1;
+               upd->userspace_only = TRUE;
+       }
+       upd->filename = strdup(path);
+       if (!upd->filename)
+               return -ENOMEM;
+
+       return 0;
+}
+
 /**
  * mnt_update_is_ready:
  * @upd: update handler
@@ -87,19 +128,6 @@ int mnt_update_is_ready(mnt_update *upd)
        return upd ? upd->ready : FALSE;
 }
 
-/**
- * mnt_update_is_userspace_only:
- * @upd: update handler
- *
- * Returns: 1 if @upd cares about userspace mount options only (see
- *          mnt_new_update().
- */
-int mnt_update_is_userspace_only(mnt_update *upd)
-{
-       return upd ? upd->userspace_only : FALSE;
-}
-
-
 /**
  * mnt_update_set_fs:
  * @upd: update handler
@@ -112,6 +140,8 @@ int mnt_update_is_userspace_only(mnt_update *upd)
 int mnt_update_set_fs(mnt_update *upd, int mountflags,
                      const char *target, mnt_fs *fs)
 {
+       int rc;
+
        assert(upd);
        assert(target || fs);
 
@@ -129,6 +159,10 @@ int mnt_update_set_fs(mnt_update *upd, int mountflags,
        upd->target = NULL;
        upd->mountflags = mountflags;
 
+       rc = mnt_update_set_filename(upd, NULL, 0);
+       if (rc)
+               return rc;      /* error or no file available (rc = 1) */
+
        if (fs) {
                if (upd->userspace_only && !(mountflags & MS_MOVE)) {
                        int rc = utab_new_entry(fs, mountflags, &upd->fs);
@@ -405,18 +439,18 @@ static int fprintf_utab_fs(FILE *f, mnt_fs *fs)
        return 0;
 }
 
-static int update_tab(mnt_update *upd, const char *filename, mnt_tab *tb)
+static int update_tab(mnt_update *upd, mnt_tab *tb)
 {
        FILE *f;
        int rc, fd;
        char *uq = NULL;
 
-       if (!tb || !filename)
+       if (!tb || !upd->filename)
                return -EINVAL;
 
-       DBG(UPDATE, mnt_debug_h(upd, "%s: updating", filename));
+       DBG(UPDATE, mnt_debug_h(upd, "%s: updating", upd->filename));
 
-       fd = mnt_open_uniq_filename(filename, &uq, O_WRONLY);
+       fd = mnt_open_uniq_filename(upd->filename, &uq, O_WRONLY);
        if (fd < 0)
                return fd;      /* error */
 
@@ -437,12 +471,12 @@ static int update_tab(mnt_update *upd, const char *filename, mnt_tab *tb)
                fd = fileno(f);
                rc = fchmod(fd, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) ? -errno : 0;
 
-               if (!rc &&stat(filename, &st) == 0)
+               if (!rc && stat(upd->filename, &st) == 0)
                        /* Copy uid/gid from the present file before renaming. */
                        rc = fchown(fd, st.st_uid, st.st_gid) ? -errno : 0;
 
                fclose(f);
-               rc = rename(uq, filename) ? -errno : 0;
+               rc = rename(uq, upd->filename) ? -errno : 0;
        } else {
                rc = -errno;
                close(fd);
@@ -487,7 +521,7 @@ static void utab_unlock(int fd)
        }
 }
 
-static int update_add_entry(mnt_update *upd, const char *filename, mnt_lock *lc)
+static int update_add_entry(mnt_update *upd, mnt_lock *lc)
 {
        FILE *f;
        int rc = 0, u_lc = -1;
@@ -495,21 +529,21 @@ static int update_add_entry(mnt_update *upd, const char *filename, mnt_lock *lc)
        assert(upd);
        assert(upd->fs);
 
-       DBG(UPDATE, mnt_debug_h(upd, "%s: add entry", filename));
+       DBG(UPDATE, mnt_debug_h(upd, "%s: add entry", upd->filename));
 
        if (lc)
                mnt_lock_file(lc);
        else if (upd->userspace_only)
-               u_lc = utab_lock(filename);
+               u_lc = utab_lock(upd->filename);
 
-       f = fopen(filename, "a+");
+       f = fopen(upd->filename, "a+");
        if (f) {
                rc = upd->userspace_only ? fprintf_utab_fs(f, upd->fs) :
                                           fprintf_mtab_fs(f, upd->fs);
-               DBG(UPDATE, mnt_debug_h(upd, "%s: add [rc=%d]", filename, rc));
+               DBG(UPDATE, mnt_debug_h(upd, "%s: add [rc=%d]", upd->filename, rc));
                fclose(f);
        } else {
-               DBG(UPDATE, mnt_debug_h(upd, "%s: failed: %m", filename));
+               DBG(UPDATE, mnt_debug_h(upd, "%s: failed: %m", upd->filename));
                rc = -errno;
        }
        if (lc)
@@ -519,7 +553,7 @@ static int update_add_entry(mnt_update *upd, const char *filename, mnt_lock *lc)
        return rc;
 }
 
-static int update_remove_entry(mnt_update *upd, const char *filename, mnt_lock *lc)
+static int update_remove_entry(mnt_update *upd, mnt_lock *lc)
 {
        mnt_tab *tb;
        int rc = 0, u_lc = -1;
@@ -527,20 +561,20 @@ static int update_remove_entry(mnt_update *upd, const char *filename, mnt_lock *
        assert(upd);
        assert(upd->target);
 
-       DBG(UPDATE, mnt_debug_h(upd, "%s: remove entry", filename));
+       DBG(UPDATE, mnt_debug_h(upd, "%s: remove entry", upd->filename));
 
        if (lc)
                mnt_lock_file(lc);
        else if (upd->userspace_only)
-               u_lc = utab_lock(filename);
+               u_lc = utab_lock(upd->filename);
 
-       tb = __mnt_new_tab_from_file(filename,
+       tb = __mnt_new_tab_from_file(upd->filename,
                        upd->userspace_only ? MNT_FMT_UTAB : MNT_FMT_MTAB);
        if (tb) {
                mnt_fs *rem = mnt_tab_find_target(tb, upd->target, MNT_ITER_BACKWARD);
                if (rem) {
                        mnt_tab_remove_fs(tb, rem);
-                       rc = update_tab(upd, filename, tb);
+                       rc = update_tab(upd, tb);
                        mnt_free_fs(rem);
                }
                mnt_free_tab(tb);
@@ -552,26 +586,26 @@ static int update_remove_entry(mnt_update *upd, const char *filename, mnt_lock *
        return rc;
 }
 
-static int update_modify_target(mnt_update *upd, const char *filename, mnt_lock *lc)
+static int update_modify_target(mnt_update *upd, mnt_lock *lc)
 {
        mnt_tab *tb = NULL;
        int rc = 0, u_lc = -1;
 
-       DBG(UPDATE, mnt_debug_h(upd, "%s: modify target", filename));
+       DBG(UPDATE, mnt_debug_h(upd, "%s: modify target", upd->filename));
 
        if (lc)
                mnt_lock_file(lc);
        else if (upd->userspace_only)
-               u_lc = utab_lock(filename);
+               u_lc = utab_lock(upd->filename);
 
-       tb = __mnt_new_tab_from_file(filename,
+       tb = __mnt_new_tab_from_file(upd->filename,
                        upd->userspace_only ? MNT_FMT_UTAB : MNT_FMT_MTAB);
        if (tb) {
                mnt_fs *cur = mnt_tab_find_target(tb, upd->target, MNT_ITER_BACKWARD);
                if (cur) {
                        rc = mnt_fs_set_target(cur, mnt_fs_get_target(upd->fs));
                        if (!rc)
-                               rc = update_tab(upd, filename, tb);
+                               rc = update_tab(upd, tb);
                }
                mnt_free_tab(tb);
        }
@@ -582,7 +616,7 @@ static int update_modify_target(mnt_update *upd, const char *filename, mnt_lock
        return rc;
 }
 
-static int update_modify_options(mnt_update *upd, const char *filename, mnt_lock *lc)
+static int update_modify_options(mnt_update *upd, mnt_lock *lc)
 {
        mnt_tab *tb = NULL;
        int rc = 0, u_lc = -1;
@@ -590,14 +624,14 @@ static int update_modify_options(mnt_update *upd, const char *filename, mnt_lock
        assert(upd);
        assert(upd->fs);
 
-       DBG(UPDATE, mnt_debug_h(upd, "%s: modify options", filename));
+       DBG(UPDATE, mnt_debug_h(upd, "%s: modify options", upd->filename));
 
        if (lc)
                mnt_lock_file(lc);
        else if (upd->userspace_only)
-               u_lc = utab_lock(filename);
+               u_lc = utab_lock(upd->filename);
 
-       tb = __mnt_new_tab_from_file(filename,
+       tb = __mnt_new_tab_from_file(upd->filename,
                        upd->userspace_only ? MNT_FMT_UTAB : MNT_FMT_MTAB);
        if (tb) {
                mnt_fs *cur = mnt_tab_find_target(tb,
@@ -606,7 +640,7 @@ static int update_modify_options(mnt_update *upd, const char *filename, mnt_lock
                if (cur) {
                        rc = mnt_fs_set_optstr(cur, mnt_fs_get_optstr(upd->fs));
                        if (!rc)
-                               rc = update_tab(upd, filename, tb);
+                               rc = update_tab(upd, tb);
                }
                mnt_free_tab(tb);
        }
@@ -620,38 +654,37 @@ static int update_modify_options(mnt_update *upd, const char *filename, mnt_lock
 
 /**
  * mnt_update_tab:
- * @filename: mtab of utab filename
  * @lc: lock
  *
- * High-level API to update /etc/mtab or /dev/.mount/utab.
+ * High-level API to update /etc/mtab (or private /dev/.mount/utab file).
  *
  * Returns: 0 on success, negative number on error.
  */
-int mnt_update_tab(mnt_update *upd, const char *filename, mnt_lock *lc)
+int mnt_update_tab(mnt_update *upd, mnt_lock *lc)
 {
        int rc = -EINVAL;
 
        assert(upd);
-       assert(filename);
-
-       DBG(UPDATE, mnt_debug_h(upd, "%s: update tab", filename));
 
-       if (!filename || !upd)
+       if (!upd->filename || !upd)
                return -EINVAL;
        if (!upd->ready)
                return 0;
 
+       DBG(UPDATE, mnt_debug_h(upd, "%s: update tab", upd->filename));
+
        if (!upd->fs && upd->target)
-               rc = update_remove_entry(upd, filename, lc);    /* umount */
+               rc = update_remove_entry(upd, lc);      /* umount */
        else if (upd->mountflags & MS_MOVE)
-               rc = update_modify_target(upd, filename, lc);   /* move */
+               rc = update_modify_target(upd, lc);     /* move */
        else if (upd->mountflags & MS_REMOUNT)
-               rc = update_modify_options(upd, filename, lc);  /* remount */
+               rc = update_modify_options(upd, lc);    /* remount */
        else if (upd->fs)
-               rc = update_add_entry(upd, filename, lc);       /* mount */
+               rc = update_add_entry(upd, lc); /* mount */
 
        upd->ready = FALSE;
-       DBG(UPDATE, mnt_debug_h(upd, "%s: update tab: done [rc=%d]", filename, rc));
+       DBG(UPDATE, mnt_debug_h(upd, "%s: update tab: done [rc=%d]",
+                               upd->filename, rc));
        return rc;
 }
 
@@ -672,33 +705,19 @@ static int update(const char *target, mnt_fs *fs, unsigned long mountflags)
        int rc, writable = 0;
        const char *filename = NULL;
        mnt_update *upd;
-       mnt_lock *lock = NULL;
 
        DBG(UPDATE, mnt_debug("update test"));
 
        rc = mnt_has_regular_mtab(&filename, &writable);
        if (rc && writable) {
-               upd = mnt_new_update(FALSE);
+               /* normal mtab, lock required */
                lock = mnt_new_lock(filename, 0);
-
-               /* note that proper solution is to call mnt_unlock_file() from
-                * signal handler. The atexit() could be ignore if program ends
-                * by _exit(). The _exit() function is usually used in signal
-                * handlers.
-                */
-               atexit(lock_fallback);
-
-       } else {
-               filename = NULL;
-               rc = mnt_has_regular_utab(&filename, &writable);
-
-               if (rc && writable)
-                       upd = mnt_new_update(TRUE);
-               else {
-                       fprintf(stderr, "utab useless: %m\n");
-                       return -1;
-               }
+               if (lock)
+                       atexit(lock_fallback);
        }
+       upd = mnt_new_update();
+       if (!upd)
+               return -ENOMEM;
 
        rc = mnt_update_set_fs(upd, mountflags, target, fs);
        if (rc == 1) {
@@ -713,7 +732,7 @@ static int update(const char *target, mnt_fs *fs, unsigned long mountflags)
 
        /* [... here should be mount(2) call ...]  */
 
-       rc = mnt_update_tab(upd, filename, lock);
+       rc = mnt_update_tab(upd, lock);
 done:
        return rc;
 }
index 2f62313c542f901e8e69d5816baaab9abcce05a5..96ce7ddb10fe84db49f7542575b40c9e835d5cf0 100644 (file)
@@ -569,11 +569,8 @@ done:
        return 0;
 }
 
-/**
- *
- * mnt_has_regular_utab:
- * @utab: returns path to utab (usually /dev/.mount/utab)
- * @writable: returns 1 if the file is writable
+/*
+ * Don't export this to libmount API -- utab is private library stuff.
  *
  * If the file does not exist and @writable argument is not NULL then it will
  * try to create the directory (e.g. /dev/.mount) and the file.
@@ -656,10 +653,8 @@ const char *mnt_get_mtab_path(void)
        return p ? : _PATH_MOUNTED;
 }
 
-/**
- * mnt_get_utab_path:
- *
- * This function returns *default* location of the utab file.
+/*
+ * Don't export this to libmount API -- utab is private library stuff.
  *
  * Returns: path to /dev/.mount/utab or $LIBMOUNT_UTAB.
  */
index 66f69425fd191ae0b9c087c3984b0895b36f8934..a2de2ae7e27cfc16f25e88bdc8629f2fe74cb07d 100644 (file)
@@ -3,6 +3,7 @@ source: /proc
 target: /proc
 fstype: proc
 optstr: rw,relatime
+root:   /
 id:     15
 parent: 20
 devno:  0:3
@@ -11,6 +12,7 @@ source: /sys
 target: /sys
 fstype: sysfs
 optstr: rw,relatime
+root:   /
 id:     16
 parent: 20
 devno:  0:15
@@ -19,6 +21,7 @@ source: udev
 target: /dev
 fstype: devtmpfs
 optstr: rw,relatime,size=1983516k,nr_inodes=495879,mode=755
+root:   /
 id:     17
 parent: 20
 devno:  0:5
@@ -27,6 +30,7 @@ source: devpts
 target: /dev/pts
 fstype: devpts
 optstr: rw,relatime,gid=5,mode=620,ptmxmode=000
+root:   /
 id:     18
 parent: 17
 devno:  0:10
@@ -35,6 +39,7 @@ source: tmpfs
 target: /dev/shm
 fstype: tmpfs
 optstr: rw,relatime
+root:   /
 id:     19
 parent: 17
 devno:  0:16
@@ -43,6 +48,7 @@ source: /dev/sda4
 target: /
 fstype: ext3
 optstr: rw,noatime,errors=continue,user_xattr,acl,barrier=0,data=ordered
+root:   /
 id:     20
 parent: 1
 devno:  8:4
@@ -51,6 +57,7 @@ source: tmpfs
 target: /sys/fs/cgroup
 fstype: tmpfs
 optstr: rw,nosuid,nodev,noexec,relatime,mode=755
+root:   /
 id:     21
 parent: 16
 devno:  0:17
@@ -59,6 +66,7 @@ source: cgroup
 target: /sys/fs/cgroup/systemd
 fstype: cgroup
 optstr: rw,nosuid,nodev,noexec,relatime,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd
+root:   /
 id:     22
 parent: 21
 devno:  0:18
@@ -67,6 +75,7 @@ source: cgroup
 target: /sys/fs/cgroup/cpuset
 fstype: cgroup
 optstr: rw,nosuid,nodev,noexec,relatime,cpuset
+root:   /
 id:     23
 parent: 21
 devno:  0:19
@@ -75,6 +84,7 @@ source: cgroup
 target: /sys/fs/cgroup/ns
 fstype: cgroup
 optstr: rw,nosuid,nodev,noexec,relatime,ns
+root:   /
 id:     24
 parent: 21
 devno:  0:20
@@ -83,6 +93,7 @@ source: cgroup
 target: /sys/fs/cgroup/cpu
 fstype: cgroup
 optstr: rw,nosuid,nodev,noexec,relatime,cpu
+root:   /
 id:     25
 parent: 21
 devno:  0:21
@@ -91,6 +102,7 @@ source: cgroup
 target: /sys/fs/cgroup/cpuacct
 fstype: cgroup
 optstr: rw,nosuid,nodev,noexec,relatime,cpuacct
+root:   /
 id:     26
 parent: 21
 devno:  0:22
@@ -99,6 +111,7 @@ source: cgroup
 target: /sys/fs/cgroup/memory
 fstype: cgroup
 optstr: rw,nosuid,nodev,noexec,relatime,memory
+root:   /
 id:     27
 parent: 21
 devno:  0:23
@@ -107,6 +120,7 @@ source: cgroup
 target: /sys/fs/cgroup/devices
 fstype: cgroup
 optstr: rw,nosuid,nodev,noexec,relatime,devices
+root:   /
 id:     28
 parent: 21
 devno:  0:24
@@ -115,6 +129,7 @@ source: cgroup
 target: /sys/fs/cgroup/freezer
 fstype: cgroup
 optstr: rw,nosuid,nodev,noexec,relatime,freezer
+root:   /
 id:     29
 parent: 21
 devno:  0:25
@@ -123,6 +138,7 @@ source: cgroup
 target: /sys/fs/cgroup/net_cls
 fstype: cgroup
 optstr: rw,nosuid,nodev,noexec,relatime,net_cls
+root:   /
 id:     30
 parent: 21
 devno:  0:26
@@ -131,6 +147,7 @@ source: cgroup
 target: /sys/fs/cgroup/blkio
 fstype: cgroup
 optstr: rw,nosuid,nodev,noexec,relatime,blkio
+root:   /
 id:     31
 parent: 21
 devno:  0:27
@@ -139,6 +156,7 @@ source: systemd-1
 target: /sys/kernel/security
 fstype: autofs
 optstr: rw,relatime,fd=22,pgrp=1,timeout=300,minproto=5,maxproto=5,direct
+root:   /
 id:     32
 parent: 16
 devno:  0:28
@@ -147,6 +165,7 @@ source: systemd-1
 target: /dev/hugepages
 fstype: autofs
 optstr: rw,relatime,fd=23,pgrp=1,timeout=300,minproto=5,maxproto=5,direct
+root:   /
 id:     33
 parent: 17
 devno:  0:29
@@ -155,6 +174,7 @@ source: systemd-1
 target: /sys/kernel/debug
 fstype: autofs
 optstr: rw,relatime,fd=24,pgrp=1,timeout=300,minproto=5,maxproto=5,direct
+root:   /
 id:     34
 parent: 16
 devno:  0:30
@@ -163,6 +183,7 @@ source: systemd-1
 target: /proc/sys/fs/binfmt_misc
 fstype: autofs
 optstr: rw,relatime,fd=25,pgrp=1,timeout=300,minproto=5,maxproto=5,direct
+root:   /
 id:     35
 parent: 15
 devno:  0:31
@@ -171,6 +192,7 @@ source: systemd-1
 target: /dev/mqueue
 fstype: autofs
 optstr: rw,relatime,fd=26,pgrp=1,timeout=300,minproto=5,maxproto=5,direct
+root:   /
 id:     36
 parent: 17
 devno:  0:32
@@ -179,6 +201,7 @@ source: /proc/bus/usb
 target: /proc/bus/usb
 fstype: usbfs
 optstr: rw,relatime
+root:   /
 id:     37
 parent: 15
 devno:  0:14
@@ -187,6 +210,7 @@ source: hugetlbfs
 target: /dev/hugepages
 fstype: hugetlbfs
 optstr: rw,relatime
+root:   /
 id:     38
 parent: 33
 devno:  0:33
@@ -195,6 +219,7 @@ source: mqueue
 target: /dev/mqueue
 fstype: mqueue
 optstr: rw,relatime
+root:   /
 id:     39
 parent: 36
 devno:  0:12
@@ -203,6 +228,7 @@ source: /dev/sda6
 target: /boot
 fstype: ext3
 optstr: rw,noatime,errors=continue,barrier=0,data=ordered
+root:   /
 id:     40
 parent: 20
 devno:  8:6
@@ -211,6 +237,7 @@ source: /dev/mapper/kzak-home
 target: /home/kzak
 fstype: ext4
 optstr: rw,noatime,barrier=1,data=ordered
+root:   /
 id:     41
 parent: 20
 devno:  253:0
@@ -219,6 +246,7 @@ source: (null)
 target: /proc/sys/fs/binfmt_misc
 fstype: binfmt_misc
 optstr: rw,relatime
+root:   /
 id:     42
 parent: 35
 devno:  0:34
@@ -227,6 +255,7 @@ source: fusectl
 target: /sys/fs/fuse/connections
 fstype: fusectl
 optstr: rw,relatime
+root:   /
 id:     43
 parent: 16
 devno:  0:35
@@ -235,6 +264,7 @@ source: gvfs-fuse-daemon
 target: /home/kzak/.gvfs
 fstype: fuse.gvfs-fuse-daemon
 optstr: rw,nosuid,nodev,relatime,user_id=500,group_id=500
+root:   /
 id:     44
 parent: 41
 devno:  0:36
@@ -243,6 +273,7 @@ source: sunrpc
 target: /var/lib/nfs/rpc_pipefs
 fstype: rpc_pipefs
 optstr: rw,relatime
+root:   /
 id:     45
 parent: 20
 devno:  0:37
@@ -251,6 +282,7 @@ source: //foo.home/bar/
 target: /mnt/sounds
 fstype: cifs
 optstr: rw,relatime,unc=\\foo.home\bar,username=kzak,domain=SRGROUP,uid=0,noforceuid,gid=0,noforcegid,addr=192.168.111.1,posixpaths,serverino,acl,rsize=16384,wsize=57344
+root:   /
 id:     47
 parent: 20
 devno:  0:38
index 0464c74974816844b2c30984defd21c285986996..520324acf55470a0b249e4019ab328344ee7033c 100644 (file)
@@ -1,2 +1,2 @@
-0 0 0:0 / /mnt/bar user - ext3 /dev/sdb1 none
-0 0 0:0 / /mnt/xyz loop=/dev/loop0,uhelper=hal - ext3 /dev/sda2 none
+SRC=/dev/sdb1 TARGET=/mnt/bar ROOT=/ OPTS=user
+SRC=/dev/sda2 TARGET=/mnt/xyz ROOT=/ OPTS=loop=/dev/loop0,uhelper=hal
index bdcf9cb385d54811d0e56f910a689be5d460c996..316d129f1cdd6651e857c401c2b8348b01721a04 100644 (file)
@@ -1,2 +1,2 @@
-0 0 0:0 / /mnt/newbar user - ext3 /dev/sdb1 none
-0 0 0:0 / /mnt/newxyz loop=/dev/loop0,uhelper=hal - ext3 /dev/sda2 none
+SRC=/dev/sdb1 TARGET=/mnt/newbar ROOT=/ OPTS=user
+SRC=/dev/sda2 TARGET=/mnt/newxyz ROOT=/ OPTS=loop=/dev/loop0,uhelper=hal
index 853d9fbe64fec88855c0edf10721fff655fbd1ad..c5573eaadcf94a27a7c4fbaa8b3c7072af44ad3c 100644 (file)
@@ -1,2 +1,2 @@
-0 0 0:0 / /mnt/newbar user - ext3 /dev/sdb1 none
-0 0 0:0 / /mnt/newxyz user - ext3 /dev/sda2 none
+SRC=/dev/sdb1 TARGET=/mnt/newbar ROOT=/ OPTS=user
+SRC=/dev/sda2 TARGET=/mnt/newxyz ROOT=/ OPTS=user
index b8c096bf5c35cc374b69241450a06af8c5eaa868..4c07d7448e1dbaaeec424a96be9c1a5f078b0b31 100644 (file)
@@ -1 +1 @@
-0 0 0:0 / /mnt/newxyz user - ext3 /dev/sda2 none
+SRC=/dev/sda2 TARGET=/mnt/newxyz ROOT=/ OPTS=user
index b895ba05accf7f41a279713cdac04e130d54a19d..65e0ea5277c68fa201f633c432167e90fb7cc6d0 100755 (executable)
@@ -23,6 +23,7 @@ TESTPROG="$TS_HELPER_LIBMOUNT_UPDATE"
 # Traditional /etc/mtab
 #
 export LIBMOUNT_MTAB=$TS_OUTPUT.mtab
+rm -f $LIBMOUNT_MTAB
 > $LIBMOUNT_MTAB
 
 ts_init_subtest "mtab-mount"
@@ -58,6 +59,7 @@ rm -f $LIBMOUNT_MTAB
 ln -s /proc/mounts $LIBMOUNT_MTAB
 
 export LIBMOUNT_UTAB=$TS_OUTPUT.utab
+rm -f $LIBMOUNT_UTAB
 > $LIBMOUNT_UTAB
 
 ts_init_subtest "utab-mount"