mnt_context_disable_canonicalize
mnt_context_disable_helpers
mnt_context_disable_mtab
+mnt_context_disable_swapmatch
mnt_context_enable_fake
mnt_context_enable_force
mnt_context_enable_fork
mnt_context_enable_rdonly_umount
mnt_context_enable_sloppy
mnt_context_enable_verbose
-mnt_context_tab_applied
mnt_context_get_cache
mnt_context_get_fs
mnt_context_get_fstab
mnt_context_is_rdonly_umount
mnt_context_is_restricted
mnt_context_is_sloppy
+mnt_context_is_swapmatch
mnt_context_is_verbose
mnt_context_reset_status
mnt_context_set_cache
mnt_context_set_user_mflags
mnt_context_strerror
mnt_context_syscall_called
+mnt_context_tab_applied
mnt_context_wait_for_children
</SECTION>
}
/**
- * mnt_context_is_nomtab
+ * mnt_context_is_nomtab:
* @cxt: mount context
*
* Returns: 1 if no-mtab is enabled or 0
return cxt && (cxt->flags & MNT_FL_NOMTAB) ? 1 : 0;
}
+/**
+ * mnt_context_disable_swapmatch:
+ * @cxt: mount context
+ * @disable: TRUE or FALSE
+ *
+ * Disable/enable swap between source and target for mount(8) if only one path
+ * is specified.
+ *
+ * Returns: 0 on success, negative number in case of error.
+ */
+int mnt_context_disable_swapmatch(struct libmnt_context *cxt, int disable)
+{
+ return set_flag(cxt, MNT_FL_NOSWAPMATCH, disable);
+}
+
+/**
+ * mnt_context_is_swapmatch:
+ * @cxt: mount context
+ *
+ * Returns: 1 if swap between source and target is allowed (default is 1) or 0.
+ */
+int mnt_context_is_swapmatch(struct libmnt_context *cxt)
+{
+ return cxt && (cxt->flags & MNT_FL_NOSWAPMATCH) ? 0 : 1;
+}
+
/**
* mnt_context_enable_force:
* @cxt: mount context
else if (tgt)
fs = mnt_table_find_target(tb, tgt, direction);
- if (!fs) {
+ if (!fs && mnt_context_is_swapmatch(cxt)) {
/* swap source and target (if @src is not LABEL/UUID),
* for example in
*
try_loopdev:
fs = mnt_table_find_target(mtab, tgt, MNT_ITER_BACKWARD);
- if (!fs) {
+ if (!fs && mnt_context_is_swapmatch(cxt)) {
/* maybe the option is source rather than target (mountpoint) */
fs = mnt_table_find_source(mtab, tgt, MNT_ITER_BACKWARD);
extern int mnt_context_enable_verbose(struct libmnt_context *cxt, int enable);
extern int mnt_context_enable_loopdel(struct libmnt_context *cxt, int enable);
extern int mnt_context_enable_fork(struct libmnt_context *cxt, int enable);
+extern int mnt_context_disable_swapmatch(struct libmnt_context *cxt, int disable);
extern int mnt_context_get_optsmode(struct libmnt_context *cxt);
extern int mnt_context_is_lazy(struct libmnt_context *cxt);
extern int mnt_context_is_loopdel(struct libmnt_context *cxt);
extern int mnt_context_is_nohelpers(struct libmnt_context *cxt);
extern int mnt_context_is_nocanonicalize(struct libmnt_context *cxt);
+extern int mnt_context_is_swapmatch(struct libmnt_context *cxt);
extern int mnt_context_is_fork(struct libmnt_context *cxt);
extern int mnt_context_is_parent(struct libmnt_context *cxt);
mnt_fs_get_swaptype;
mnt_fs_get_tid;
mnt_fs_get_usedsize;
+ mnt_context_is_swapmatch;
+ mnt_context_disable_swapmatch;
} MOUNT_2.21;
#define MNT_FL_NOCANONICALIZE (1 << 9)
#define MNT_FL_RDONLY_UMOUNT (1 << 11) /* remount,ro after EBUSY umount(2) */
#define MNT_FL_FORK (1 << 12)
+#define MNT_FL_NOSWAPMATCH (1 << 13)
#define MNT_FL_EXTERN_FS (1 << 15) /* cxt->fs is not private */
#define MNT_FL_EXTERN_FSTAB (1 << 16) /* cxt->fstab is not private */