Commit 2558e3a7 authored by Steve Langasek's avatar Steve Langasek
Browse files

Allow multiple fstab entries with the same mountpoint: we still mask

any entries that came from a different source (i.e., /etc/fstab will
mask /lib/init/fstab), but if there are multiple entries in /etc/fstab,
treat them all as separate mounts instead of letting the last one win.
LP: #503003.
parent b695eb38
mountall (2.50) UNRELEASED; urgency=low
* Add support for pstore. Closes: #722212.
* Allow multiple fstab entries with the same mountpoint: we still mask
any entries that came from a different source (i.e., /etc/fstab will
mask /lib/init/fstab), but if there are multiple entries in /etc/fstab,
treat them all as separate mounts instead of letting the last one win.
LP: #503003.
-- Steve Langasek <vorlon@debian.org> Sun, 08 Sep 2013 23:12:35 -0700
......
......@@ -143,6 +143,7 @@ struct mount {
Mount * link_target;
NihList deps;
int needs_mtab;
char * src;
};
#define MOUNT_NAME(_mnt) (strcmp ((_mnt)->type, "swap") \
......@@ -167,7 +168,8 @@ typedef struct event_reply_data {
} EventReplyData;
Mount *new_mount (const char *mountpoint, const char *device,
int check, const char *type, const char *opts);
int check, const char *type, const char *opts,
const char *src);
Mount *find_mount (const char *mountpoint);
void update_mount (Mount *mnt, const char *device, int check,
const char *type, const char *opts);
......@@ -459,7 +461,8 @@ new_mount (const char *mountpoint,
const char *device,
int check,
const char *type,
const char *opts)
const char *opts,
const char *src)
{
Mount *mnt;
......@@ -509,6 +512,8 @@ new_mount (const char *mountpoint,
mnt->needs_mtab = FALSE;
if (src)
mnt->src = NIH_MUST (nih_strdup (mounts, src));
update_mount (mnt, device, check, type, opts);
return mnt;
......@@ -734,7 +739,7 @@ parse_fstab (const char *filename)
continue;
mnt = find_mount (mntent->mnt_dir);
if (mnt
if (mnt && (!mnt->src || strcmp (mnt->src, filename))
&& strcmp (mntent->mnt_type, "swap")) {
update_mount (mnt,
mntent->mnt_fsname,
......@@ -746,7 +751,8 @@ parse_fstab (const char *filename)
mntent->mnt_fsname,
mntent->mnt_passno != 0,
mntent->mnt_type,
mntent->mnt_opts);
mntent->mnt_opts,
filename);
}
}
......@@ -907,7 +913,8 @@ parse_mountinfo_file (int reparsed)
mnt->mounted = FALSE;
} else {
mnt = new_mount (mountpoint, device, FALSE, type, opts);
mnt = new_mount (mountpoint, device, FALSE, type, opts,
NULL);
mnt->mount_opts = opts;
}
......@@ -1163,7 +1170,7 @@ mount_policy (void)
}
}
NIH_LIST_FOREACH (mounts, iter) {
for (NihList *iter = mounts->prev; iter != mounts; iter = iter->prev) {
Mount *mnt = (Mount *)iter;
Mount *mount_parent = NULL;
Mount *device_parent = NULL;
......@@ -1175,11 +1182,23 @@ mount_policy (void)
*/
NIH_LIST_FOREACH (mounts, iter) {
Mount *other = (Mount *)iter;
int is_dep = 0;
/* Skip this mount entry */
if (other == mnt)
continue;
/* Since multiple mounts can have the same mount point,
* we check here if the target already has us as a
* dep to avoid a circular dependency. */
NIH_LIST_FOREACH (&(other->deps), iter) {
NihListEntry *dep = (NihListEntry *)iter;
if (dep->data == mnt)
is_dep = 1;
}
if (is_dep)
continue;
/* Is this a parent of our mountpoint? */
if (mnt->mountpoint
&& other->mountpoint
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment