/* ignore filesystems without source or filesystems
* where the source is quasi-path (//foo/bar)
*/
- if (!src || (cxt->fs->flags & MNT_FS_NET))
+ if (!src || mnt_fs_is_netfs(cxt->fs))
return 0;
DBG(CXT, mnt_debug_h(cxt, "srcpath '%s'", src));
rc = path ? mnt_fs_set_source(cxt->fs, path) : -EINVAL;
- } else if (cache && !(cxt->fs->flags & MNT_FS_PSEUDO)) {
+ } else if (cache && !mnt_fs_is_pseudofs(cxt->fs)) {
/*
* Source is PATH (canonicalize)
*/
path = src;
if ((cxt->mountflags & (MS_BIND | MS_MOVE | MS_PROPAGATION)) ||
- (cxt->fs->flags & MNT_FS_PSEUDO)) {
+ mnt_fs_is_pseudofs(cxt->fs)) {
DBG(CXT, mnt_debug_h(cxt, "PROPAGATION/pseudo FS source: %s", path));
return rc;
}
type = mnt_fs_get_fstype(cxt->fs);
if ((cxt->flags & MNT_FL_NOHELPERS) || !type ||
- !strcmp(type, "none") || (cxt->fs->flags & MNT_FS_SWAP))
+ !strcmp(type, "none") || mnt_fs_is_swaparea(cxt->fs))
return 0;
path = strtok_r(search_path, ":", &p);
int mnt_context_is_loopdev(struct libmnt_context *cxt)
{
const char *type, *src;
- int fl;
assert(cxt);
/* The mount flags have to be merged, otherwise we have to use
* regular files could be implemented.
*/
type = mnt_fs_get_fstype(cxt->fs);
- fl = __mnt_fs_get_flags(cxt->fs);
- if (!(fl & (MNT_FS_PSEUDO | MNT_FS_NET | MNT_FS_SWAP)) &&
+ if (mnt_fs_is_regular(cxt->fs) &&
(!type || strcmp(type, "auto") == 0 || blkid_known_fstype(type))) {
struct stat st;
assert(cxt->helper_exec_status == 1);
assert(cxt->syscall_status == 1);
- if (!cxt || !cxt->fs || (cxt->fs->flags & MNT_FS_SWAP))
+ if (!cxt || !cxt->fs || mnt_fs_is_swaparea(cxt->fs))
return -EINVAL;
if (!mnt_fs_get_source(cxt->fs) && !mnt_fs_get_target(cxt->fs))
return -EINVAL;
DBG(CXT, mnt_debug_h(cxt, "next-mount: trying %s", tgt));
/* ignore swap */
- if (((*fs)->flags & MNT_FS_SWAP) ||
+ if (mnt_fs_is_swaparea(*fs) ||
/* ignore root filesystem */
- (tgt && (strcmp(tgt, "/") == 0 || strcmp(tgt, "root") == 0)) ||
+ (tgt && (strcmp(tgt, "/") == 0 || strcmp(tgt, "root") == 0)) ||
/* ignore noauto filesystems */
(o && mnt_optstr_get_option(o, "noauto", NULL, NULL) == 0) ||
assert(cxt->helper_exec_status == 1);
assert(cxt->syscall_status == 1);
- if (!cxt || !cxt->fs || (cxt->fs->flags & MNT_FS_SWAP))
+ if (!cxt || !cxt->fs || mnt_fs_is_swaparea(cxt->fs))
return -EINVAL;
if (!mnt_context_get_source(cxt) && !mnt_context_get_target(cxt))
return -EINVAL;
return 0;
}
-int __mnt_fs_get_flags(struct libmnt_fs *fs)
+static int mnt_fs_get_flags(struct libmnt_fs *fs)
{
return fs ? fs->flags : 0;
}
-int __mnt_fs_set_flags(struct libmnt_fs *fs, int flags)
-{
- if (fs) {
- fs->flags = flags;
- return 0;
- }
- return -EINVAL;
-}
-
/**
* mnt_fs_is_kernel:
* @fs: filesystem
*/
int mnt_fs_is_kernel(struct libmnt_fs *fs)
{
- return __mnt_fs_get_flags(fs) & MNT_FS_KERNEL;
+ return mnt_fs_get_flags(fs) & MNT_FS_KERNEL;
+}
+
+/**
+ * mnt_fs_is_swaparea:
+ * @fs: filesystem
+ *
+ * Returns: 1 if the filesystem uses "swap" as a type
+ */
+int mnt_fs_is_swaparea(struct libmnt_fs *fs)
+{
+ return mnt_fs_get_flags(fs) & MNT_FS_SWAP;
+}
+
+/**
+ * mnt_fs_is_pseudofs:
+ * @fs: filesystem
+ *
+ * Returns: 1 if the filesystem is a pseudo fs type (proc, cgroups)
+ */
+int mnt_fs_is_pseudo(struct libmnt_fs *fs)
+{
+ return mnt_fs_get_flags(fs) & MNT_FS_PSEUDO;
+}
+
+/**
+ * mnt_fs_is_netfs:
+ * @fs: filesystem
+ *
+ * Returns: 1 if the filesystem is a network filesystem
+ */
+int mnt_fs_is_netfs(struct libmnt_fs *fs)
+{
+ return mnt_fs_get_flags(fs) & MNT_FS_NET;
}
/**
extern int mnt_fs_print_debug(struct libmnt_fs *fs, FILE *file);
extern int mnt_fs_is_kernel(struct libmnt_fs *fs);
+extern int mnt_fs_is_swaparea(struct libmnt_fs *fs);
+extern int mnt_fs_is_netfs(struct libmnt_fs *fs);
+extern int mnt_fs_is_pseudofs(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_is_parent;
mnt_context_next_umount;
mnt_context_wait_for_children;
+ mnt_fs_is_netfs;
+ mnt_fs_is_pseudofs;
+ mnt_fs_is_swaparea;
} MOUNT_2.20;
#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 */
-extern int __mnt_fs_get_flags(struct libmnt_fs *fs);
-extern int __mnt_fs_set_flags(struct libmnt_fs *fs, int flags);
-
+#define mnt_fs_is_regular(_f) (!(mnt_fs_is_pseudofs(_f) \
+ || mnt_fs_is_netfs(_f) \
+ || mnt_fs_is_swaparea(_f)))
/*
* mtab/fstab/mountinfo file
while(mnt_table_next_fs(tb, &itr, &fs) == 0) {
char *p;
- if (!fs->target || !(fs->flags & MNT_FS_SWAP) ||
+ if (!fs->target || !mnt_fs_is_swaparea(fs) ||
(*fs->target == '/' && *(fs->target + 1) == '\0'))
continue;
if (ntags <= mnt_table_get_nents(tb)) {
mnt_reset_iter(&itr, direction);
while(mnt_table_next_fs(tb, &itr, &fs) == 0) {
- if (fs->flags & (MNT_FS_NET | MNT_FS_PSEUDO))
+ if (mnt_fs_is_netfs(fs) || mnt_fs_is_pseudofs(fs))
continue;
p = mnt_fs_get_srcpath(fs);
if (p)
assert(tb);
assert(fstab_fs);
- if (fstab_fs->flags & MNT_FS_SWAP)
+ if (mnt_fs_is_swaparea(fstab_fs))
return 0;
if (mnt_fs_get_option(fstab_fs, "bind", NULL, NULL) == 0)
src_fs = mnt_table_get_fs_root(tb, fstab_fs, flags, &root);
if (src_fs)
src = mnt_fs_get_srcpath(src_fs);
- else if (fstab_fs->flags & MNT_FS_PSEUDO)
+ else if (mnt_fs_is_pseudofs(fstab_fs))
src = mnt_fs_get_source(fstab_fs);
else
src = xsrc = mnt_resolve_spec(mnt_fs_get_source(fstab_fs),