To solve bug #291916, /usr/bin/stat is used (to check if given directory is a mount point). Although we cannot rely on /usr/bin/stat at this very beginning of rc. Reproducible: Always Steps to Reproduce: 1. Move /usr to separate partition and append "/dev/foo /usr fs opts x y" to /etc/fstab. 2. Reboot Actual Results: Fails just before mounting /proc. Expected Results: Mount /proc, /sys (or skip if already mounted) and continue booting.
Created attachment 246715 [details, diff] functions.sh-is_mounted-is_clean.patch Provides functions 'is_mounted' and 'is_clean'. 'is_mounted' checks if specified device is really mounted under specified mount point. 'is_clean' checks if there are any files inside given directory (omits hidden ones).
Created attachment 246716 [details, diff] rc-is_mounted-instead-of-stat.patch We use new 'is_mounted' (see: functions.sh-is_mounted-is_clean.patch) instead of 'stat MOUNT_POINT -c %d' and new more generic 'is_clean' instead of check for individual files.
why does is_mounted need to check /proc/mounts ? seems like simply replacing the call to `stat` with `mountpoint` would be sufficient. assuming /proc/mounts needs to be checked, it should be done in one shot instead of reading it line by line: [[ $(</proc/mounts) =~ ... ]] the is_clean needs to declare "f" local,
Created attachment 247871 [details, diff] functions.sh-is_mounted-is_clean-corrected.patch I've corrected it according to SpanKY's suggestions. Thank you! Why I'm checking /proc/mounts? Previously there was check for files specific to particular file system, so I've done more universal check. As you can see it's optional, so invoking 'is_mounted /some/mount/point' just checks if it's a mount point.
i meant, why is "is_mounted" checking /proc/mounts ? why cant the func merely call `mountpoint` ? is_mounted() { mountpoint -q "$1" ; }
"is_mounted" is checking /proc/mounts if expected device is really mounted under that mount point and not something else. (Although I can imagine case when that check doesn't give full certainty.) I agree that just calling `mountpoint` would be sufficient. Checking /proc/mounts is paranoid a bit. I'll remove that unnecessary part from "is_mounted" then, OK?
yes, let's keep it simple for now. it seems to have worked so far for us, so let's avoid the paranoia until we have an actual use case.
Created attachment 248375 [details, diff] functions.sh-is_mounted-is_clean-simplified.patch Removed /proc/mounts check.
Created attachment 248377 [details, diff] rc-is_mounted-instead-of-stat-simplified.patch Updated to changes in 'functions.sh*' patch.
thanks, ive committed that http://sources.gentoo.org/baselayout/branches/baselayout-1_12/sbin/functions.sh?r1=3176&r2=3177 http://sources.gentoo.org/baselayout/branches/baselayout-1_12/sbin/rc?r1=3176&r2=3177