if (!rc)
rc = mnt_context_call_hooks(cxt, MNT_STAGE_MOUNT);
+ if (rc == 0 && mnt_context_is_fake(cxt)) {
+ DBG(CXT, ul_debugobj(cxt, "FAKE (-f) set status=0"));
+ cxt->syscall_status = 0;
+ }
+
if (org_type && rc != 0)
__mnt_fs_set_fstype_ptr(cxt->fs, org_type);
org_type = NULL;
if (!api)
return -ENOMEM;
- if (mnt_context_is_fake(cxt))
- goto fake;
-
if (path) {
api->fd_tree = open_mount_tree(cxt, path, flags);
if (api->fd_tree < 0)
fail:
DBG(HOOK, ul_debugobj(hs, "init fs/tree failed [errno=%d %m]", errno));
return -errno;
-fake:
- DBG(CXT, ul_debugobj(cxt, " FAKE (-f)"));
- cxt->syscall_status = 0;
- return 0;
}
static int force_classic_mount(struct libmnt_context *cxt)
hd->flags,
hd->flags & MS_REC ? " (recursive)" : ""));
- if (mnt_context_is_fake(cxt)) {
- DBG(CXT, ul_debugobj(cxt, " FAKE (-f)"));
- cxt->syscall_status = 0;
- return 0;
- }
-
/*
* hd->flags are propagation flags as set in prepare_propagation()
*
hd->flags,
hd->flags & MS_REC ? " (recursive)" : ""));
- if (mnt_context_is_fake(cxt)) {
- DBG(CXT, ul_debugobj(cxt, " FAKE (-f)"));
- cxt->syscall_status = 0;
- return 0;
- }
-
if (mnt_optlist_is_silent(cxt->optlist))
extra |= MS_SILENT;
options ? (cxt->flags & MNT_FL_MOUNTDATA) ? "binary" :
options : "<none>"));
- if (mnt_context_is_fake(cxt)) {
- DBG(HOOK, ul_debugobj(hs, " FAKE (-f)"));
- cxt->syscall_status = 0;
- return 0;
- }
-
if (mount(src, target, type, flags, options)) {
cxt->syscall_status = -errno;
cxt->syscall_name = "mount";
static int call_hook(struct libmnt_context *cxt, struct hookset_hook *hook)
{
- int rc = hook->func(cxt, hook->hookset, hook->data);
+ int rc = 0;
+
+ if (mnt_context_is_fake(cxt))
+ DBG(CXT, ul_debugobj(cxt, " FAKE call"));
+ else
+ rc = hook->func(cxt, hook->hookset, hook->data);
hook->executed = 1;
if (!rc)
DBG(CXT, ul_debugobj(cxt, "calling %s [first]", hs->name));
- rc = hs->firstcall(cxt, hs, NULL);
+ if (mnt_context_is_fake(cxt))
+ DBG(CXT, ul_debugobj(cxt, " FAKE call"));
+ else
+ rc = hs->firstcall(cxt, hs, NULL);
if (!rc)
rc = call_depend_hooks(cxt, hs->name, stage);
if (rc < 0)
(Used in conjunction with *-a*.) Fork off a new incarnation of *mount* for each device. This will do the mounts on different devices or different NFS servers in parallel. This has the advantage that it is faster; also NFS timeouts proceed in parallel. A disadvantage is that the order of the mount operations is undefined. Thus, you cannot use this option if you want to mount both _/usr_ and _/usr/spool_.
*-f, --fake*::
-Causes everything to be done except for the actual system call; if it's not obvious, this "fakes" mounting the filesystem. This option is useful in conjunction with the *-v* flag to determine what the *mount* command is trying to do. It can also be used to add entries for devices that were mounted earlier with the *-n* option. The *-f* option checks for an existing record in _/etc/mtab_ and fails when the record already exists (with a regular non-fake mount, this check is done by the kernel).
+Causes everything to be done except for the mount-related system calls. The --fake option was originally designed to write an entry to /etc/mtab without actually mounting.
++
+The /etc/mtab is no longer maintained in userspace, and starting from version 2.39, the mount operation can be a complex chain of operations with dependencies between the syscalls. The --fake option forces libmount to skip all mount source preparation, mount option analysis, and the actual mounting process.
++
+The difference between fake and non-fake execution is huge. This is the reason why the --fake option has minimal significance for the current mount(8) implementation and it is maintained mostly for backward compatibility.
*-i, --internal-only*::
Don't call the **/sbin/mount.**__filesystem__ helper even if it exists.