]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: support /run/mount rather than /dev/.mount
authorKarel Zak <kzak@redhat.com>
Thu, 31 Mar 2011 19:26:57 +0000 (21:26 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 31 Mar 2011 19:26:57 +0000 (21:26 +0200)
The /run directory should be preferred on distributions where this
directory exists.

http://thread.gmane.org/gmane.linux.redhat.fedora.devel/146976

Signed-off-by: Karel Zak <kzak@redhat.com>
shlibs/mount/src/context.c
shlibs/mount/src/fs.c
shlibs/mount/src/libmount.h.in
shlibs/mount/src/mountP.h
shlibs/mount/src/tab_parse.c
shlibs/mount/src/tab_update.c
shlibs/mount/src/utils.c

index f24e90ebb9b6261fe1aca3a7f3c2d8e2bc42f161..eedb8234553f3e4b17bb0523bf55f952d2fb5d32 100644 (file)
@@ -71,7 +71,7 @@ struct libmnt_context *mnt_new_context(void)
        mnt_has_regular_mtab(&cxt->mtab_path, &cxt->mtab_writable);
 
        if (!cxt->mtab_writable)
-               /* use /dev/.mount/utab if /etc/mtab is useless */
+               /* use /run/mount/utab if /etc/mtab is useless */
                mnt_has_regular_utab(&cxt->utab_path, &cxt->utab_writable);
 
        return cxt;
@@ -1228,7 +1228,7 @@ int mnt_context_merge_mflags(struct libmnt_context *cxt)
 }
 
 /*
- * Prepare /etc/mtab or /dev/.mount/utab
+ * Prepare /etc/mtab or /run/mount/utab
  */
 int mnt_context_prepare_update(struct libmnt_context *cxt)
 {
index 75ec4b4766e8dd81b6124bc2af7dfeb19cd5d7c4..c7a4fce025bfdd25df8e5149c8669fb4c2a7c33f 100644 (file)
@@ -796,7 +796,7 @@ const char *mnt_fs_get_attributes(struct libmnt_fs *fs)
  *
  * Sets mount attributes. The attributes are mount(2) and mount(8) independent
  * options, these options are not send to kernel and are not interpreted by
- * libmount. The attributes are stored in /dev/.mount/utab only.
+ * libmount. The attributes are stored in /run/mount/utab only.
  *
  * The atrtributes are managed by libmount in userspace only. It's possible
  * that information stored in userspace will not be available for libmount
@@ -952,7 +952,7 @@ int mnt_fs_set_root(struct libmnt_fs *fs, const char *root)
 
 /**
  * mnt_fs_get_bindsrc:
- * @fs: /dev/.mount/utab entry
+ * @fs: /run/mount/utab entry
  *
  * Returns: full path that was used for mount(2) on MS_BIND
  */
index 61382246859b57b6e1fcca18c53966cab58e511b..1738726992b262d22e9acb54357c786444c480be 100644 (file)
@@ -91,7 +91,7 @@ struct libmnt_table;
 /**
  * libmnt_update
  *
- * /etc/mtab or /dev/.mount/utab update description
+ * /etc/mtab or utab update description
  */
 struct libmnt_update;
 
index 00ca8875f4fdb92eea66f5be46227a044488ce99..a72c2560dd0be7c98cc2a37064ff7cf761387682 100644 (file)
@@ -92,7 +92,11 @@ mnt_debug_h(void *handler, const char *mesg, ...)
 #define MNT_MNTTABDIR_EXT      ".fstab"
 
 /* library private paths */
-#define MNT_PATH_UTAB  "/dev/.mount/utab"
+#define MNT_RUNTIME_TOPDIR     "/run"
+#define MNT_RUNTIME_TOPDIR_OLD "/dev"
+
+#define MNT_PATH_UTAB          MNT_RUNTIME_TOPDIR "/mount/utab"
+#define MNT_PATH_UTAB_OLD      MNT_RUNTIME_TOPDIR_OLD "/.mount/utab"
 
 #define MNT_UTAB_HEADER        "# libmount utab file\n"
 
@@ -196,7 +200,7 @@ struct libmnt_fs {
 #define MNT_FS_NET     (1 << 2) /* network filesystem */
 #define MNT_FS_SWAP    (1 << 3) /* swap device */
 #define MNT_FS_KERNEL  (1 << 4) /* data from /proc/{mounts,self/mountinfo} */
-#define MNT_FS_MERGED  (1 << 5) /* already merged data from /dev/.mount/utab */
+#define MNT_FS_MERGED  (1 << 5) /* already merged data from /run/mount/utab */
 
 extern int __mnt_fs_get_flags(struct libmnt_fs *fs);
 extern int __mnt_fs_set_flags(struct libmnt_fs *fs, int flags);
index 43a2bf192dbf64285b048c72384cd9e7c5bae4c5..1bf88db56f1277360fc170316178036c8853790c 100644 (file)
@@ -673,7 +673,7 @@ static struct libmnt_fs *mnt_table_merge_user_fs(struct libmnt_table *tb, struct
  * @filename: overwrites default (/etc/mtab or $LIBMOUNT_MTAB) or NULL
  *
  * This function parses /etc/mtab or /proc/self/mountinfo +
- * /dev/.mount/utabs or /proc/mounts.
+ * /run/mount/utabs or /proc/mounts.
  *
  * See also mnt_table_set_parser_errcb().
  *
@@ -707,7 +707,7 @@ int mnt_table_parse_mtab(struct libmnt_table *tb, const char *filename)
        }
 
        /*
-        * try to read user specific information from /dev/.mount/utabs
+        * try to read user specific information from /run/mount/utabs
         */
        utab = mnt_get_utab_path();
        if (utab) {
index 71988f8a862b4408ab2cf13f471c998b97229de7..409568f9105b2c372f3ba9f636240e79ae462f6b 100644 (file)
@@ -13,7 +13,7 @@
  * The struct libmnt_update provides abstraction to manage mount options in userspace independently on
  * system configuration. This low-level API works on system with and without /etc/mtab. On 
  * systems without the regular /etc/mtab file are userspace mount options (e.g. user=)
- * stored to the /dev/.mount/utab file.
+ * stored to the /run/mount/utab file.
  *
  * It's recommended to use high-level struct libmnt_context API.
  */
@@ -107,7 +107,7 @@ int mnt_update_set_filename(struct libmnt_update *upd, const char *filename,
        if (upd->filename)
                return 0;
 
-       /* detect tab filename -- /etc/mtab or /dev/.mount/utab
+       /* detect tab filename -- /etc/mtab or /run/mount/utab
         */
        mnt_has_regular_mtab(&path, &rw);
        if (!rw) {
@@ -784,7 +784,7 @@ static int update_modify_options(struct libmnt_update *upd, struct libmnt_lock *
  * @upd: update
  * @lc: lock or NULL
  *
- * High-level API to update /etc/mtab (or private /dev/.mount/utab file).
+ * High-level API to update /etc/mtab (or private /run/mount/utab file).
  *
  * The @lc lock is optional and will be created if necessary. Note that
  * the automatically created lock blocks all signals.
index 27832b36a00ab911cb63530ab45bad626f506adb..8f0e49c9b2445f2d76617d84ac0ea66e30dec780 100644 (file)
@@ -600,9 +600,9 @@ done:
  * 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.
+ * try to create the directory (e.g. /run/mount) and the file.
  *
- * Returns: 1 if /dev/.mount/utab is a regular file, and 0 in case of
+ * Returns: 1 if utab is a regular file, and 0 in case of
  *          error (check errno for more details).
  */
 int mnt_has_regular_utab(const char **utab, int *writable)
@@ -682,12 +682,20 @@ const char *mnt_get_mtab_path(void)
 /*
  * Don't export this to libmount API -- utab is private library stuff.
  *
- * Returns: path to /dev/.mount/utab or $LIBMOUNT_UTAB.
+ * Returns: path to /run/mount/utab (or /dev/.mount/utab) or $LIBMOUNT_UTAB.
  */
 const char *mnt_get_utab_path(void)
 {
+       struct stat st;
        const char *p = safe_getenv("LIBMOUNT_UTAB");
-       return p ? : MNT_PATH_UTAB;
+
+       if (p)
+               return p;
+
+       if (stat(MNT_RUNTIME_TOPDIR, &st) == 0)
+               return MNT_PATH_UTAB;
+
+       return MNT_PATH_UTAB_OLD;
 }