On 07/10/2016 03:36 AM, Todd C. Miller wrote:
On Sat, 09 Jul 2016 18:25:08 +0200, Frank Scheiner wrote:
Running the command substitution alone after the machine has finished
booting - which takes a considerable extra amount of time as the
SPARCclassic is a slow machine and its root FS is mounted via NFS -
gives the following in my case:
```
# stat -L -f '%Sd' /usr/lib
??
# echo $?
0
```
That makes sense. What stat(1) actually does is call stat(2) on
/usr/lib and look up the resulting device number using devname(3).
Since it can't be found it returns "??" which is useful for ps but
not much else.
I see, thanks for the explanation. I was unsure if "??" is a regular
output of stat or just a side-effect of my diskless configuration.
We can simplify the check and simply treat a value of "??" as
non-local and skip the reorder.
- todd
Index: rc
===================================================================
RCS file: /cvs/src/etc/rc,v
retrieving revision 1.485
diff -u -p -u -r1.485 rc
--- rc 29 May 2016 15:36:06 -0000 1.485
+++ rc 10 Jul 2016 01:35:46 -0000
@@ -164,8 +164,8 @@ reorder_libs() {
local _dkdev=/dev/$(stat -L -f '%Sd' /usr/lib)
local _mp=$(mount | grep "^$_dkdev")
- # Skip if /usr/lib is on a nfs mounted filesystem.
- [[ $_mp == *' type nfs '* ]] && return
+ # Skip if /usr/lib is not on a local filesystem.
+ [ $_dkdev == '??' ] && return
echo -n 'reordering libraries:'
I just ran the line where _dkdev is set and when using the resulting
value with e.g. `echo` it looks like the "??" is expanded by the shell
if $_dkdev is not enclosed in double quotes. This also seems to happen
for the test clause:
```
# _dkdev=/dev/$(stat -L -f '%Sd' /usr/lib)
# echo $_dkdev
/dev/fd /dev/pf
# echo "$_dkdev"
/dev/??
# [ $_dkdev == '??' ]
ksh: [: /dev/pf: unexpected operator/operand
# [ "$_dkdev" == '/dev/??' ]
# echo $?
0
```
Hence I assume the double quotes are also needed in the test clause plus
_dkdev always starts with "/dev/". What do you think about:
```
Index: rc
===================================================================
RCS file: /cvs/src/etc/rc,v
retrieving revision 1.485
diff -u -p -u -r1.485 rc
--- rc 29 May 2016 15:36:06 -0000 1.485
+++ rc 10 Jul 2016 01:35:46 -0000
@@ -164,8 +164,8 @@ reorder_libs() {
local _dkdev=/dev/$(stat -L -f '%Sd' /usr/lib)
local _mp=$(mount | grep "^$_dkdev")
- # Skip if /usr/lib is on a nfs mounted filesystem.
- [[ $_mp == *' type nfs '* ]] && return
+ # Skip if /usr/lib is not on a local filesystem.
+ [ "$_dkdev" == '/dev/??' ] && return
echo -n 'reordering libraries:'
```
?
Bye
Frank