]> 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>
Tue, 19 Apr 2011 11:09:53 +0000 (13:09 +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 9b35e5306d979e5c061dfe61c9a759ca86dbf160..bde1f3910ad97ac61f6a66dc82af23aed87d7ff2 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 c2deff5f1f992561c5935fb3b27aaff3e99c8446..91d8d22420472c13cf63c75e0f7ef60d8c823b2d 100644 (file)
@@ -948,7 +948,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
@@ -1104,7 +1104,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 e27b63f95b5abb364d9a15ed3cf6f1f689cba15a..25a020f0018ec395a1fa5fcd8253f940a8cf9eb7 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 71314a542ed5eaa376911250cf8c6d5b2c8e7e2f..fa01bd57a2287150c9200492a8a39657bd02ac6f 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"
 
@@ -194,7 +198,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 4eb32eb63dc267b3242047c802194739d27d6308..b0007fa393e530ba0f40c906c2aaf3b48f45c723 100644 (file)
@@ -668,7 +668,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().
  *
@@ -702,7 +702,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 ecd5b199568ee9739f5eb94b80cd052f8b9f324c..b795be6e6db49b7d00f8a90118874911939be9b6 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) {
@@ -789,7 +789,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 1dc5025acf2666f3b2ea6ec241e32a6ca49853b8..686f54572212600ca6e63d9fa9725509f9d05019 100644 (file)
@@ -548,9 +548,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 reqular 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).
  */
 
@@ -631,12 +631,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;
 }