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

Michael Biebl biebl at debian.org
Tue Jan 6 09:37:38 GMT 2015


Hi Martin,

thanks for the review!

Am 06.01.2015 um 08:23 schrieb Martin Pitt:
> 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?

/proc is an API fs and mounted pretty early during boot by systemd, so
/proc/mounts is available when the generators run. /etc/mtab should be a
symlink to /proc/mounts nowadays so it *should* be available.
But you are right, there might be cases when /etc/fstab is still a file
and possibly out-of-date, so using /proc/mounts might be safer.
I thought about that as well, but...


> 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);

.. this seems simpler indeed. So let's just use that. Thanks for the hint!

> 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).

Nod.

>> @@ -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.
> 

Will push an updated patch including your suggestion.

Michael


-- 
Why is it that all of the instruments seeking intelligent life in the
universe are pointed away from Earth?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://alioth-lists.debian.net/pipermail/pkg-systemd-maintainers/attachments/20150106/4058e34b/attachment-0002.sig>


More information about the Pkg-systemd-maintainers mailing list