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;
}
/*
- * Prepare /etc/mtab or /dev/.mount/utab
+ * Prepare /etc/mtab or /run/mount/utab
*/
int mnt_context_prepare_update(struct libmnt_context *cxt)
{
*
* 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
/**
* 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
*/
/**
* libmnt_update
*
- * /etc/mtab or /dev/.mount/utab update description
+ * /etc/mtab or utab update description
*/
struct libmnt_update;
#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"
#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);
* @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().
*
}
/*
- * 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) {
* 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.
*/
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) {
* @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.
* 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)
/*
* 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;
}