Bug#742048: systemd-remount-fs.service fails for split-usr

Martin Pitt mpitt at debian.org
Tue Jan 6 07:23:12 GMT 2015


Hey Michael,

thanks for dealing with this!

Michael Biebl [2015-01-06  1:34 +0100]:
> +static bool is_mounted(const char *dev_path) {
> +        _cleanup_endmntent_ FILE *mtab = NULL;
> +        struct mntent *me = NULL;
> +
> +        mtab = setmntent("/etc/mtab", "r");

Can we rely on /etc/mtab at this point? Should we rather look at
/proc/mounts here?

Also, I think there is a simpler way to check if a dir is a
mountpoint: s1 = stat(dir), s2 = stat(parent(dir))
(i. e. dir + "/.."), and check

 is_mount = (st.st_dev != st2.st_dev) ||
            (st.st_dev == st2.st_dev && st.st_ino == st2.st_ino);

That's the approach that /bin/mountpoint uses, and it avoids relying
on having /etc/mtab, /proc mounted, and doing the iteration.

The first check is obvious; I think the second check is only needed
for bind mounts, which we could probably even ignore here (but then
again it doesn't hurt to keep it).

> @@ -83,6 +103,11 @@ int main(int argc, char *argv[]) {
>                      !path_equal(me->mnt_dir, "/usr"))
>                          continue;
>  
> +                /* Don't remount /usr if it hasn't been mounted by the initrd */
> +                if (path_equal(me->mnt_dir, "/usr") &&
> +                    !is_mounted("/usr"))
> +                        continue;
> +

That looks like a good approach to me indeed.

Thanks,

Martin
-- 
Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://alioth-lists.debian.net/pipermail/pkg-systemd-maintainers/attachments/20150106/a5214239/attachment-0002.sig>


More information about the Pkg-systemd-maintainers mailing list