mnt_fs_get_user_options
mnt_fs_get_vfs_options
mnt_fs_get_vfs_options_all
+mnt_fs_is_attached
+mnt_fs_is_detached
mnt_fs_is_kernel
+mnt_fs_is_moved
mnt_fs_is_netfs
mnt_fs_is_pseudofs
mnt_fs_is_regularfs
}
cxt->syscall_status = 0;
DBG(CXT, ul_debugobj(cxt, "read-only re-mount(2) success"));
+ mnt_fs_mark_attached(cxt->fs);
return 0;
}
}
cxt->syscall_status = 0;
+ mnt_fs_mark_detached(cxt->fs);
DBG(CXT, ul_debugobj(cxt, "umount(2) success"));
return 0;
}
return mnt_fs_get_flags(fs) & MNT_FS_KERNEL ? 1 : 0;
}
+/**
+ * mnt_fs_is_moved:
+ * @fs: filesystem
+ *
+ * The move/attach/detach status depends on how @fs has been used by the library.
+ * The status is not set when working with fstab, etc.
+ *
+ * Returns: 1 if the filesystem has been moved.
+ */
+int mnt_fs_is_moved(struct libmnt_fs *fs)
+{
+ return fs->flags & MNT_FS_STATUS_ATTACH &&
+ fs->flags & MNT_FS_STATUS_DETACH ? 1 : 0;
+}
+
+/**
+ * mnt_fs_is_attached:
+ * @fs: filesystem
+ *
+ * The move/attach/detach status depends on how @fs has been used by the library.
+ * The status is not set when working with fstab, etc.
+ *
+ * Returns: 1 if the filesystem has been attached.
+ */
+int mnt_fs_is_attached(struct libmnt_fs *fs)
+{
+ return fs->flags & MNT_FS_STATUS_ATTACH
+ && !(fs->flags & MNT_FS_STATUS_DETACH) ? 1 : 0;
+}
+
+/**
+ * mnt_fs_is_detached:
+ * @fs: filesystem
+ *
+ * The move/attach/detach status depends on how @fs has been used by the library.
+ * The status is not set when working with fstab, etc.
+ *
+ * Returns: 1 if the filesystem has been dettached.
+ */
+int mnt_fs_is_detached(struct libmnt_fs *fs)
+{
+ return fs->flags & MNT_FS_STATUS_DETACH &&
+ !(fs->flags & MNT_FS_STATUS_ATTACH) ? 1 : 0;
+}
+
/**
* mnt_fs_is_swaparea:
* @fs: filesystem
rc = move_mount(api->fd_tree, "", AT_FDCWD, target, MOVE_MOUNT_F_EMPTY_PATH);
hookset_set_syscall_status(cxt, "move_mount", rc == 0);
+ if (rc == 0) {
+ struct libmnt_optlist *ol = mnt_context_get_optlist(cxt);
+
+ if (ol && mnt_optlist_is_move(ol))
+ mnt_fs_mark_moved(cxt->fs);
+ else
+ mnt_fs_mark_attached(cxt->fs);
+ }
+
return rc == 0 ? 0 : -errno;
}
if (rc)
DBG(HOOK, ul_debugobj(hs, " mount(2) failed"
" [rc=%d errno=%d %m]", rc, errno));
+ else
+ mnt_fs_mark_attached(cxt->fs);
+
return rc;
}
return rc;
}
+ if (mnt_optlist_is_move(ol))
+ mnt_fs_mark_moved(cxt->fs);
+ else
+ mnt_fs_mark_attached(cxt->fs);
+
cxt->syscall_status = 0;
return rc;
}
extern int mnt_fs_is_pseudofs(struct libmnt_fs *fs);
extern int mnt_fs_is_regularfs(struct libmnt_fs *fs);
+extern int mnt_fs_is_moved(struct libmnt_fs *fs);
+extern int mnt_fs_is_attached(struct libmnt_fs *fs);
+extern int mnt_fs_is_detached(struct libmnt_fs *fs);
+
extern void mnt_free_mntent(struct mntent *mnt);
extern int mnt_fs_to_mntent(struct libmnt_fs *fs, struct mntent **mnt);
mnt_context_enable_exclusive;
mnt_context_is_exclusive;
mnt_monitor_event_next_fs;
+ mnt_fs_is_moved;
+ mnt_fs_is_attached;
+ mnt_fs_is_detached;
} MOUNT_2_41;
#define MNT_FS_KERNEL (1 << 4) /* data from /proc/{mounts,self/mountinfo} */
#define MNT_FS_MERGED (1 << 5) /* already merged data from /run/mount/utab */
+#define MNT_FS_STATUS_ATTACH (1 << 6)
+#define MNT_FS_STATUS_DETACH (1 << 7)
+
+static inline void mnt_fs_mark_attached(struct libmnt_fs *fs)
+{
+ fs->flags &= ~MNT_FS_STATUS_DETACH;
+ fs->flags |= MNT_FS_STATUS_ATTACH;
+}
+
+static inline void mnt_fs_mark_detached(struct libmnt_fs *fs)
+{
+ fs->flags &= ~MNT_FS_STATUS_ATTACH;
+ fs->flags |= MNT_FS_STATUS_DETACH;
+}
+
+static inline void mnt_fs_mark_moved(struct libmnt_fs *fs)
+{
+ fs->flags |= MNT_FS_STATUS_ATTACH | MNT_FS_STATUS_DETACH;
+}
+
#ifdef HAVE_STATMOUNT_API
# define mnt_fs_try_statmount(FS, MEMBER, FLAGS) __extension__ ({ \
if (!(FS)->MEMBER \
char *p;
fs->flags |= MNT_FS_KERNEL;
+ mnt_fs_mark_attached(fs);
/* (1) id */
s = next_s32(s, &fs->id, &rc);
* parser sets the flag properly
*/
if (tb->fmt == MNT_FMT_SWAPS)
- flags = MNT_FS_SWAP;
+ flags = MNT_FS_SWAP | MNT_FS_STATUS_ATTACH;
else if (filename && strcmp(filename, _PATH_PROC_MOUNTS) == 0)
- flags = MNT_FS_KERNEL;
+ flags = MNT_FS_KERNEL | MNT_FS_STATUS_ATTACH;
do {
struct libmnt_fs *fs;