i, args[i]));
DBG_FLUSH;
execv(cxt->helper, (char * const *) args);
- _exit(EXIT_FAILURE);
+ _exit(MNT_EX_EXEC);
}
default:
{
if (waitpid(pid, &st, 0) == (pid_t) -1) {
cxt->helper_status = -1;
rc = -errno;
+ DBG(CXT, ul_debugobj(cxt, "waitpid failed [errno=%d]", -rc));
} else {
cxt->helper_status = WIFEXITED(st) ? WEXITSTATUS(st) : -1;
cxt->helper_exec_status = rc = 0;
- }
- DBG(CXT, ul_debugobj(cxt, "%s executed [status=%d, rc=%d%s]",
+
+ if (cxt->helper_status == MNT_EX_EXEC) {
+ rc = -MNT_ERR_EXEC;
+ DBG(CXT, ul_debugobj(cxt, "%s exec failed", cxt->helper));
+ }
+
+ DBG(CXT, ul_debugobj(cxt, "%s forked [status=%d, rc=%d]",
cxt->helper,
- cxt->helper_status, rc,
- rc ? " waitpid failed" : ""));
+ cxt->helper_status, rc));
+ }
break;
}
/*
* /sbin/mount.<type> called, return status
*/
- if (rc == -MNT_ERR_APPLYFLAGS && buf)
- snprintf(buf, bufsz, _("WARNING: failed to apply propagation flags"));
+ if (buf) {
+ switch (rc) {
+ case -MNT_ERR_APPLYFLAGS:
+ snprintf(buf, bufsz, _("WARNING: failed to apply propagation flags"));
+ break;
+ case -MNT_ERR_EXEC:
+ snprintf(buf, bufsz, _("failed to execute %s"), cxt->helper);
+ break;
+ }
+ }
return mnt_context_get_helper_status(cxt);
}
i, args[i]));
DBG_FLUSH;
execv(cxt->helper, (char * const *) args);
- _exit(EXIT_FAILURE);
+ _exit(MNT_EX_EXEC);
}
default:
{
if (waitpid(pid, &st, 0) == (pid_t) -1) {
cxt->helper_status = -1;
rc = -errno;
+ DBG(CXT, ul_debugobj(cxt, "waitpid failed [errno=%d]", -rc));
} else {
cxt->helper_status = WIFEXITED(st) ? WEXITSTATUS(st) : -1;
cxt->helper_exec_status = rc = 0;
- }
- DBG(CXT, ul_debugobj(cxt, "%s executed [status=%d, rc=%d%s]",
+
+ if (cxt->helper_status == MNT_EX_EXEC) {
+ rc = -MNT_ERR_EXEC;
+ DBG(CXT, ul_debugobj(cxt, "%s exec failed", cxt->helper));
+ }
+
+ DBG(CXT, ul_debugobj(cxt, "%s forked [status=%d, rc=%d]",
cxt->helper,
- cxt->helper_status, rc,
- rc ? " waitpid failed" : ""));
+ cxt->helper_status, rc));
+ }
break;
}
char *buf,
size_t bufsz)
{
- if (mnt_context_helper_executed(cxt))
+ if (mnt_context_helper_executed(cxt)) {
/*
* /sbin/umount.<type> called, return status
*/
+ if (rc == -MNT_ERR_EXEC && buf)
+ snprintf(buf, bufsz, _("failed to execute %s"), cxt->helper);
+
return mnt_context_get_helper_status(cxt);
+ }
if (rc == 0 && mnt_context_get_status(cxt) == 1)
/*
* filesystem mounted, but subsequent X-mount.idmap= failed
*/
#define MNT_ERR_IDMAP 5013
+/**
+ * MNT_ERR_EXEC:
+ *
+ * failed to execute external program
+ */
+#define MNT_ERR_EXEC 5014
+
/*
*/
#define MNT_EX_SOMEOK 64
+/**
+ * MNT_EX_EXEC:
+ *
+ * [u]mount(8) exit code: external program execution failed
+ */
+#define MNT_EX_EXEC 126
#ifndef __GNUC_PREREQ
+
The command *mount -a* returns 0 (all succeeded), 32 (all failed), or 64 (some failed, some succeeded).
+*126*::
+failed to execute external /sbin/mount.<type> mount helper (since util-linux v2.41)
+
== EXTERNAL HELPERS
The syntax of external mount helpers is:
The command *mount* does not pass the mount options *unbindable*, *runbindable*, *private*, *rprivate*, *slave*, *rslave*, *shared*, *rshared*, *auto*, *noauto*, *comment*, *x-**, *loop*, *offset* and *sizelimit* to the mount.<suffix> helpers. All other options are used in a comma-separated list as an argument to the *-o* option.
+The exit status value of the helper is returned as the exit status of *mount*(8). The value 126 is sed if the mount helper program is found, but the execl() failed.
+
== ENVIRONMENT
*LIBMOUNT_FORCE_MOUNT2*={always|never|auto}::
In this case the device is initialized with "autoclear" flag (see *losetup*(8) output for more details), otherwise it's necessary to use the option *--detach-loop* or call *losetup -d* _device_. The autoclear feature is supported since Linux 2.6.25.
+== EXIT STATUS
+
+*umount* has the following exit status values (the bits can be ORed):
+
+*0*::
+success
+
+*1*::
+incorrect invocation or permissions
+
+*2*::
+system error (out of memory, cannot fork, no more loop devices)
+
+*4*::
+internal *mount* bug
+
+*8*::
+user interrupt
+
+*16*::
+problems writing or locking _/etc/mtab_
+
+*32*::
+mount failure
+
+*64*::
+some umount succeeded
++
+The command *umount -a* returns 0 (all succeeded), 32 (all failed), or 64 (some failed, some succeeded).
+
+*126*::
+failed to execute external /sbin/umount.<type> mount helper (since util-linux v2.41)
+
== EXTERNAL HELPERS
The syntax of external unmount helpers is:
Note that _/etc/mtab_ is currently deprecated and *helper=* and other userspace mount options are maintained by *libmount*.
+The exit status value of the helper is returned as the exit status of *umount*(8). The value 126 is used if the mount helper program is found, but the execl() failed.
+
== ENVIRONMENT
*LIBMOUNT_FSTAB*=<path>::