cxt->table_fltrcb_data);
mnt_table_set_cache(cxt->mtab, mnt_context_get_cache(cxt));
+ }
+
+ /* Read the table; it's empty, because this first mnt_context_get_mtab()
+ * call, or because /proc was not accessible in previous calls */
+ if (mnt_table_is_empty(cxt->mtab)) {
+ if (!ns_old) {
+ ns_old = mnt_context_switch_target_ns(cxt);
+ if (!ns_old)
+ return -MNT_ERR_NAMESPACE;
+ }
/*
* Note that mtab_path is NULL if mtab is useless or unsupported
struct libmnt_fs *fs, int *mounted)
{
struct libmnt_table *mtab, *orig;
- int rc;
+ int rc = 0;
struct libmnt_ns *ns_old;
if (!cxt || !fs || !mounted)
cxt->mtab = NULL;
}
*mounted = 0;
- return 0; /* /proc not mounted */
- }
+ rc = 0; /* /proc not mounted */
- if (rc)
- return rc;
-
- *mounted = __mnt_table_is_fs_mounted(mtab, fs,
+ } else if (rc == 0) {
+ *mounted = __mnt_table_is_fs_mounted(mtab, fs,
mnt_context_get_target_prefix(cxt));
+ }
+
if (!mnt_context_switch_ns(cxt, ns_old))
return -MNT_ERR_NAMESPACE;
- return 0;
+ return rc;
}
static int mnt_context_add_child(struct libmnt_context *cxt, pid_t pid)
/* ignore already mounted filesystems */
rc = mnt_context_is_fs_mounted(cxt, *fs, &mounted);
- if (rc)
+ if (rc) {
+ if (mnt_table_is_empty(cxt->mtab)) {
+ DBG(CXT, ul_debugobj(cxt, "next-mount: no mount table [rc=%d], ignore", rc));
+ rc = 0;
+ if (ignored)
+ *ignored = 1;
+ }
return rc;
+ }
if (mounted) {
if (ignored)
*ignored = 2;
*-a*, *--all*::
Mount all filesystems (of the given types) mentioned in _fstab_ (except for those whose line contains the *noauto* keyword). The filesystems are mounted following their order in _fstab_. The *mount* command compares filesystem source, target (and fs root for bind mount or btrfs) to detect already mounted filesystems. The kernel table with already mounted filesystems is cached during *mount --all*. This means that all duplicated _fstab_ entries will be mounted.
+
-The correct functionality depends on /proc (to detect already mounted filesystems) and on /sys (to evaluate filesystem tags like UUID= or LABEL=). It's strongly recommended to mount /proc and /sys filesystems before *mount -a* is executed on system boot.
+The correct functionality depends on /proc (to detect already mounted filesystems) and on /sys (to evaluate filesystem tags like UUID= or LABEL=). It's strongly recommended to mount /proc and /sys filesystems before *mount -a* is executed, or keep /proc and /sys at the beginning of fstab.
+
The option *--all* is possible to use for remount operation too. In this case all filters (*-t* and *-O*) are applied to the table of already mounted filesystems.
+