Hello,
I have just encountered something strange regarding accessing the filesystem from rc.sysinit.
In rc.sysinit I wanted to test for the existance of a file and if there take specific action. So I put in the following code:
if test -a /home/MAD/.setPerms; then
/home/MAD/spm_upgrade_root
rm -f /home/MAD/.setPerms
fi
However, upon testing I noted that this always fails the test. That is, whether or not the file is there, it always reports as if it isn’t.
But if I instead tested for a directory using the same code:
if test -a /home/MAD; then
/home/MAD/spm_upgrade_root
rm -f /home/MAD/.setPerms
fi
This always passes successfully.
So I wrapped a waitfor() command call just in front of the test for /home/MAD/.setPerms in the initial code snippet. What I observed was that it always passes through the waitfor loop at least once when the file does exist (so it needs a 1 second delay). However if I test for /home/MAD it never passes through the waitfor loop because it always finds the directory.
My question is, why is it not able to find the .setPerms file right away while it can always find the /home/MAD directory that it resides in?
It’s not a huge issue because I’ve just added a wait for up to 3 seconds for the file but I am curious as to why I need it.
Tim
A copy of my rc.sysint:
#!/bin/sh
rc.sysinit
This script sets up your environment & starts system services
echo Executing rc.sysinit Ver 1.1
Add the system utilities to the path…
export PATH=/sbin:/usr/sbin:/bin:/usr/bin
A useful function
function waitfor {
typeset -i i=0
while test $i -lt $2 -a ! $1 -ef $1 ; do
sleep 1;
let i=i+1;
done
unset i
}
Start random, this is needed for things like OpenSSH
#random -t
make dir and allow all to use it
if ! test -d /var/dumps
then
mkdir -p /var/dumps
chmod -R 777 /var
fi
dumper -d /home/MAD/MAD/output
allow ftp to use /tmp
if ! test -d /tmp
then
mkdir /tmp
fi
chmod 777 /tmp
Start networking
Remove from here to…–>>
-------------------------------------------------
This is the setting for the ethernet chip on the MIC 3000 boards
Changed to Large tcpip stack since OS had networking problems
io-net -ptcpip -ppppmgr -dspeedo pci=0 -dspeedo pci=1 &
wait until io-net manifests itself and then start networkng manager
which uses /etc/net.cfg by default
waitfor /dev/io-net 60
netmanager
inetd &
Qnet
Enable qnet - can only be used on target systems
slay inetd
slay io-net
echo “Waiting for io-net to release sockets…”
sleep 5
io-net -ptcpip -ppppmgr -pqnet -dspeedo pci=0 -dspeedo pci=1 &
echo “Waiting for io-net to re-establish sockets…”
sleep 10
netmanager
inetd &
-----------------------------------------------------------
–>>…here if you do not require networking.
export TERM=qansi-m
Check to see if the permissions need to be set on the MADCurrent
directory. Ideally these would be set on every re-boot but in an
effort to save the life of the flash disk they will now only be
set once after S/W upgrade.
waitfor /home/MAD/.setPerms 3
if test -a /home/MAD/.setPerms; then
/home/MAD/spm_upgrade_root
rm -f /home/MAD/.setPerms
fi