hi i know the chkfsys utility and know how to check through command line . but i want to check in script .
i have cf having 4 partition . 1st partition having qnx image . after booting i have to check filesystem on other partition . if any error having those partition i have to display the error and shutdown . i don’t how to do it. please help me to check filesystem in scipting and take decission .
questions:
if error on any partition ,chkfsys utility returns anythink?
how to take decissions if errors occur?
how i kow this partition is error?.
note:i have partition type- hd0t77,hd0t78,hd0t79,hd0t80
First, I think it’s worth noting that chkfsys only works on a QNX 4 initialized partition.
QNX 6 partitions seem to have no equivalent checking program. Maybe it doesn’t need one?
Second, your request seems quite strange, to detect that a partition has corruption and the shut down.
The function of chkfsys is to fix a partition, so why shut down afterwards?
Your question about whether chkfsys sends a meaningful return code is a good one that you can determine by testing.
The default ksh that QNX uses has a variable you can check after a program runs that is set to the return code, so I would
just create a simple script that runs chkfsys and then prints it out.
For testing it’s fairly easy to create some corruption. Create a program that opens a file, writes some data, and then goes to sleep.
After the program goes to sleep, power down.
#!/bin/sh
######
# My Test Script
######
echo Test Chkfsys Output
chkfsys -u MountPoint $1
STATUS=$?
if test STATUS -ne 0; then
echo "An error occured while running chkfsys!"
shutdown -bf
fi
# end of Test Script
Where MountPoint is the mount info for your partitions (use the df command). On my system for example I have
/dev/hd0t79 mounted as /
/dev/hd1t77 mounted as /fs/ram
You’ve done something wrong. ‘status: not found’ usually indicates the program can’t be found. For example if I just type garbage at the command prompt like ‘foo’ I see: ‘sh: foo: not found’. Do you have the proper path specified for chkfsys. This is especially important if you are checking in a boot image. You must have chkfsys in the boot image itself.
It does. 0 = success and !0 = error.
I know this because if I run my script as a non-root user I get the error case because non-root users can’t run chkfsys. Once I switch to root user I run successfully (since I don’t have any errors on my Ram disk). You can test corruption in the manner that Maschoen described.
this script is working good…
but after executing this script it is asking yes/no questions(corruption occur do u want to continue? , bitmap clear) if corruptions occur in partition.