Disk Macros
[posted 2001/03/24]
Here are a couple of useful disk macros for Solaris that will give you a disk mount's block and character device files:
#if solaris devfile(M) $command("=ll `=dfk (M) | =tail +2 | =awk '{print \$1}'` | =awk '{print \$NF}' | =cut -c 9- | =sed '1 s/^vices/\\/devices/'") #endif #if solaris rawdevfile(M) $command("=ll `=dfk (M) | =tail +2 | =awk '{print \$1}' | =sed '1 s/dsk/rdsk/'` | =awk '{print \$NF}' | =cut -c 9- | =sed '1 s/^vices/\\/devices/'") #endif
(There's some extra stuff in those command sequences to deal with the additional directory layering that DiskSuite introduces.)
For example,
=rawdevfile("/opt")
might resolve to
/devices/sbus,0/SUNW,fas,8800000/sd,0:e,raw
An example use of these disk macros is from our revised DumpDatesChkWarning script:
rule // check rawdevfile ownerships and permissions set $rawdevfile = =rawdevfile($mount) # ifdef debug output $rawdevfile # endifdef if #fileuid($rawdevfile) != 0 // root output "$mount rawdevfile $rawdevfile not root-owned" fi if #filegid($rawdevfile) != #sysgid output "$mount rawdevfile $rawdevfile not sys-owned" fi if $filemode($rawdevfile) ne "020640" output "$mount rawdevfile $rawdevfile perms not 020640, are $filemode($rawdevfile)" fi
(We could 'exec wait' chown's and chmod's to fix bad ownerships and permissions, but caution dictates that PIKT just report, letting us investigate anomalies and fix what needs fixing by hand.)
For more examples, see Developer's Notes.