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@1f,0/SUNW,fas@e,8800000/sd@0,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.)

Open Hand For more examples, see Developer's Notes.

 
Home | FAQ | News | Intro | Samples | Tutorial | Reference | Software
Developer's Notes | Licensing | Authors | Pikt-Users | Pikt-Workers | Related Projects | Site Index | Privacy Policy | Contact Us
Page best viewed at 1024x768 or greater.   Page last updated 2008-02-27.   This site is PIKT® powered.
PIKT® is a registered trademark of the University of Chicago.   Copyright © 1998-2008 Robert Osterlund. All rights reserved.
Home FAQ News Intro Samples Tutorial Reference Software
PIKT Logo
PIKT Page Title
View sample
file &
disk management
macros