Summary: | baselayout-1_12 (rev. 3163): we cannot rely on stat (associated with #291916) | ||
---|---|---|---|
Product: | Gentoo Linux | Reporter: | Amadeusz Żołnowski (RETIRED) <aidecoe> |
Component: | [OLD] baselayout | Assignee: | Gentoo's Team for Core System packages <base-system> |
Status: | RESOLVED FIXED | ||
Severity: | major | ||
Priority: | High | ||
Version: | unspecified | ||
Hardware: | All | ||
OS: | Linux | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- | |
Bug Depends on: | 291916 | ||
Bug Blocks: | 336726 | ||
Attachments: |
functions.sh-is_mounted-is_clean.patch
rc-is_mounted-instead-of-stat.patch functions.sh-is_mounted-is_clean-corrected.patch functions.sh-is_mounted-is_clean-simplified.patch rc-is_mounted-instead-of-stat-simplified.patch |
Description
Amadeusz Żołnowski (RETIRED)
![]() 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.
|