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 mountall (2.50) UNRELEASED; urgency=low
* Add support for pstore. Closes: #722212. * 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 -- Steve Langasek <vorlon@debian.org> Sun, 08 Sep 2013 23:12:35 -0700
......
...@@ -143,6 +143,7 @@ struct mount { ...@@ -143,6 +143,7 @@ struct mount {
Mount * link_target; Mount * link_target;
NihList deps; NihList deps;
int needs_mtab; int needs_mtab;
char * src;
}; };
#define MOUNT_NAME(_mnt) (strcmp ((_mnt)->type, "swap") \ #define MOUNT_NAME(_mnt) (strcmp ((_mnt)->type, "swap") \
...@@ -167,7 +168,8 @@ typedef struct event_reply_data { ...@@ -167,7 +168,8 @@ typedef struct event_reply_data {
} EventReplyData; } EventReplyData;
Mount *new_mount (const char *mountpoint, const char *device, 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); Mount *find_mount (const char *mountpoint);
void update_mount (Mount *mnt, const char *device, int check, void update_mount (Mount *mnt, const char *device, int check,
const char *type, const char *opts); const char *type, const char *opts);
...@@ -459,7 +461,8 @@ new_mount (const char *mountpoint, ...@@ -459,7 +461,8 @@ new_mount (const char *mountpoint,
const char *device, const char *device,
int check, int check,
const char *type, const char *type,
const char *opts) const char *opts,
const char *src)
{ {
Mount *mnt; Mount *mnt;
...@@ -509,6 +512,8 @@ new_mount (const char *mountpoint, ...@@ -509,6 +512,8 @@ new_mount (const char *mountpoint,
mnt->needs_mtab = FALSE; mnt->needs_mtab = FALSE;
if (src)
mnt->src = NIH_MUST (nih_strdup (mounts, src));
update_mount (mnt, device, check, type, opts); update_mount (mnt, device, check, type, opts);
return mnt; return mnt;
...@@ -734,7 +739,7 @@ parse_fstab (const char *filename) ...@@ -734,7 +739,7 @@ parse_fstab (const char *filename)
continue; continue;
mnt = find_mount (mntent->mnt_dir); mnt = find_mount (mntent->mnt_dir);
if (mnt if (mnt && (!mnt->src || strcmp (mnt->src, filename))
&& strcmp (mntent->mnt_type, "swap")) { && strcmp (mntent->mnt_type, "swap")) {
update_mount (mnt, update_mount (mnt,
mntent->mnt_fsname, mntent->mnt_fsname,
...@@ -746,7 +751,8 @@ parse_fstab (const char *filename) ...@@ -746,7 +751,8 @@ parse_fstab (const char *filename)
mntent->mnt_fsname, mntent->mnt_fsname,
mntent->mnt_passno != 0, mntent->mnt_passno != 0,
mntent->mnt_type, mntent->mnt_type,
mntent->mnt_opts); mntent->mnt_opts,
filename);
} }
} }
...@@ -907,7 +913,8 @@ parse_mountinfo_file (int reparsed) ...@@ -907,7 +913,8 @@ parse_mountinfo_file (int reparsed)
mnt->mounted = FALSE; mnt->mounted = FALSE;
} else { } else {
mnt = new_mount (mountpoint, device, FALSE, type, opts); mnt = new_mount (mountpoint, device, FALSE, type, opts,
NULL);
mnt->mount_opts = opts; mnt->mount_opts = opts;
} }
...@@ -1163,7 +1170,7 @@ mount_policy (void) ...@@ -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 *mnt = (Mount *)iter;
Mount *mount_parent = NULL; Mount *mount_parent = NULL;
Mount *device_parent = NULL; Mount *device_parent = NULL;
...@@ -1175,11 +1182,23 @@ mount_policy (void) ...@@ -1175,11 +1182,23 @@ mount_policy (void)
*/ */
NIH_LIST_FOREACH (mounts, iter) { NIH_LIST_FOREACH (mounts, iter) {
Mount *other = (Mount *)iter; Mount *other = (Mount *)iter;
int is_dep = 0;
/* Skip this mount entry */ /* Skip this mount entry */
if (other == mnt) if (other == mnt)
continue; 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? */ /* Is this a parent of our mountpoint? */
if (mnt->mountpoint if (mnt->mountpoint
&& other->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