README for VMS::Device2Copyright (c) 1998 Dan Sugalski JYou may distribute under the terms of the Artistic License, as distributed with Perl.KThis module lets you fetch a list of devices, get info on those devices, asEwell as mount, unmount, allocate, deallocate, and initialize devices.perl Makefile.plmmsmms test5to build and test the extension. If it tests OK, then mms installto install it.HThis beta release is fully functional, but not thoroughly tested. It mayHwell misbehave under some circumstances, leak memory, or die gracelessly>when passed truly bogus parameters. Use with appropriate care.WHAT'S CHANGED IN THIS RELEASE:H0.06: Fixed a C thinko (had && where I should have had &) which rendered# decode_device_bitmap useless.{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` ` . ds C' ' 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" If the F register is turned on, we'll generate index entries on stderr .\" for titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and .\" index entries marked with X<> in POD. Of course, you'll have to process .\" the output yourself in some meaningful fashion. .if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" . . . nr % 0 . rr F .\} .\" .\" For nroff, turn off justification. Always turn off hyphenation; it .\" makes way too many mistakes in technical documents. .hy 0 .if n .na .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. .bd B 3 . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ====================================================================== .\" .IX Title "device 3" .TH device 3 "perl v5.6.0" "2000-08-24" "User Contributed Perl Documentation" .UC .SH "NAME" \&\s-1VMS:\s0:Device \- Perl interface to \s-1VMS\s0 device system calls ($GETDVI and friends) .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 11 \& use VMS::Device; \& @type_list = device_types(); \& @class_list = device_classes(); \& @dev_list = device_list($DeviceName[, $DeviceClass[, $DeviceType]]); \& $DevInfoHashRef = device_info($DeviceName); \& $BitmapHashRef = decode_device_bitmap($InfoName, $BitmapValue) \& $Status = mount(\e%Device_properties); \& $Status = dismount($DevName[, \e%Dismount_flags]); [Unimplemented] \& $DeviceAllocated = allocate($DevName[, $FirstAvail[, $AccMode]]); \& $Status = deallocate($DevName[, $AccMode]); \& $Status = initialize($DevName[, $VolumeName[, \e%DevProperties]]); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\s-1VMS:\s0:Device mounts and dismounts, allocates and deallocates, initializes, and lists and gets info on devices. It subsumes the \s-1DCL\s0 commands \s-1MOUNT\s0, \&\s-1DISMOUNT\s0, \s-1ALLOCATE\s0, \s-1DEALLOCATE\s0, and \s-1INITIALIZE\s0, as well as the lexical functions F$DEVICE and F$GETDVI. .Sh "Functions" .IX Subsection "Functions" .Ip "device_types" .IX Item "device_types" This function returns a list of all the valid device types that can be specified for the \f(CW\*(C`device_list\*(C'\fR function. .Ip "device_classes" .IX Item "device_classes" This function returns a list of all the valid device classes that can be specified for the \f(CW\*(C`device_list\*(C'\fR function. .Ip "device_list" .IX Item "device_list" The \f(CW\*(C`device_list\*(C'\fR function returns a list of all devices whose names match the passed device name (Standard \s-1VMS\s0 wildcards of * and % are \s-1OK\s0) and that meets the criteria in the optional device type and device class. .PP Both the device class and device type may be ommitted if you want, or passed as \f(CW\*(C`undef\*(C'\fR. If you use the type and not the class, class must be passed as \f(CW\*(C`undef\*(C'\fR. .Ip "device_info" .IX Item "device_info" The \f(CW\*(C`device_info\*(C'\fR function returns a reference to a hash containing all the information available about the device you asked about. .Ip "decode_device_bitmap" .IX Item "decode_device_bitmap" The \f(CW\*(C`decode_device_bitmap\*(C'\fR takes an item code and an integer, and returns a reference to a hash. The function assumes the integer is a bitmap as returned for that particular item, and decodes it. Each element in the returned hash is equivalent to one of the bits in the integer\*(--its value will be true or false depending on the setting of the bit. .Ip "mount" .IX Item "mount" \&\f(CW\*(C`mount\*(C'\fR takes a reference to a hash with the parameters for the mount, and attempts to mount the device. At the very least you want a \f(CW\*(C`DEVNAM\*(C'\fR parameter to specify the device being mounted. .Ip "dismount" .IX Item "dismount" \&\f(CW\*(C`dismount\*(C'\fR dismounts the specified device. The optional reference to a flag hash governs how the dismount behaves (whether it's a cluster-wide dismount, for example) .Ip "allocate" .IX Item "allocate" \&\f(CW\*(C`allocate\*(C'\fR allocates the named device. .PP If the \f(CW\*(C`$FirstAvail\*(C'\fR flag is true, then the device name is treated as a device type rather than an actual device, and the first device matching the type that's available will be allocated. .PP \&\f(CW\*(C`$AccMode\*(C'\fR is the access mode that the device is allocated in. This can be one of: .PP .Vb 4 \& KERNEL \& EXEC \& SUPER \& USER .Ve to indicate the mode the device should be allocated in. .Ip "deallocate" .IX Item "deallocate" \&\f(CW\*(C`deallocate\*(C'\fR deallocates a previously allocated device. The optional second parameter can be one of: .PP .Vb 4 \& KERNEL \& EXEC \& SUPER \& USER .Ve to indicate the mode the device should be deallocated in. .Ip "initialize" .IX Item "initialize" Initializes the specified device. If the second parameter isn't \f(CW\*(C`undef\*(C'\fR, it's taken to be the name the initialized volume should have. If the third parameter isn't \f(CW\*(C`undef\*(C'\fR, it's taken to be a reference to a hash that has the properties the newly-initialized volume should have. .SH "EXAMPLES" .IX Header "EXAMPLES" Here's a sample that returns the total amount of free space on all disk devices: .PP .Vb 2 \& #! perl -w \& use VMS::Device qw(device_list device_info); .Ve .Vb 4 \& $TotalFreeBlocks = 0; \& foreach my $devname (device_list("*", "DISK")) { \& $TotalFreeBlocks += device_info($devname)->{FREEBLOCKS}; \& } .Ve .Vb 1 \& print "Total free is $TotalFreeBlocks\en"; .Ve here's one that prints out the disk with the largest amount of free space: .PP .Vb 2 \& #! perl -w \& use VMS::Device qw(device_list device_info); .Ve .Vb 9 \& $FreeBlocks = 0; \& $FreeName = "DUAWHOKNOWS"; \& foreach my $devname (device_list("*", "DISK")) { \& $CheckBlocks = device_info($devname)->{FREEBLOCKS}; \& if ($CheckBlocks > $FreeBlocks) { \& $FreeBlocks = $CheckBlocks; \& $FreeName = $devname; \& } \& } .Ve .Vb 1 \& print "$FreeBlocks on $FreeName\en"; .Ve and here's one that shows all disks with less than 10% free: .PP .Vb 2 \& #! perl -w \& use VMS::Device qw(device_list device_info decode_device_bitmap); .Ve .Vb 11 \& foreach my $devname (device_list("*", "DISK")) { \& $DevHash = device_info($devname); \& $FreeBlocks = $DevHash->{FREEBLOCKS}; \& $MaxBlocks = $DevHash->{MAXBLOCK}; \& next unless $DevHash->{MOUNTCNT}; \& next unless $MaxBlocks; \& $PctFree = int(($FreeBlocks/$MaxBlocks) * 100); \& if ($PctFree < 10) { \& print "Only $PctFree\e% on $devname ($FreeBlocks of $MaxBlocks)\en"; \& } \& } .Ve .SH "AUTHOR" .IX Header "AUTHOR" Dan Sugalski .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIperl\fR\|(1). r02 ...-¨Rebuild index ISUBJECT for Record 16602 ...d+¨Rebuild index SOURCE for Record 16603 ... %¨770 ANCESTOR: total=4, value 0 = 37d$¨770 ANCESTOR: total=4, value 1 = 9%¨770 ANCESTOR: total=4, value 2 = 20O(¨770 ANCESTOR: total=4, value 3 = 18500,¨Rebuild index SUBJECT for Record 16603 ...%¨88 ANCESTOR: total=1, value 0 = 261=,¨Rebuild index WEBSITE for Record 16603 ...-¨Rebuild index ISUBJECT for Record 16603 ...d+¨Rebuild index SOURCE for Record 16604 ... &¨1139 ANCESTOR: total=3, value 0 = 37%¨1139 ANCESTOR: total=3, value 1 = 9r&¨1139 ANCESTOR: total=3, value 2 = 20,¨Rebuild index SUBJECT for Record 16604 ...,¨Rebuild index WEBSITE for Record 16604 ...-¨Rebuild index ISUBJECT for Record 16604 ...2+¨Rebuild index SOURCE for Record 16605 ...&¨1139 ANCESTOR: total=3, value 0 = 37%¨1139 ANCESTOR: total=3, value 1 = 9 &¨1139 ANCESTOR: total=3, value 2 = 20,¨Rebuild index SUBJECT for Record 16605 ...,¨Rebuild index WEBSITE for Record 16605 ...-¨Rebuild index ISUBJECT for Record 16605 ...:+¨Rebuild index SOURCE for Record 16606 ...t&¨1139 ANCESTOR: total=3, value 0 = 37%¨1139 ANCESTOR: total=3, value 1 = 9t&¨1139 ANCESTOR: total=3, value 2 = 20,¨Rebuild index SUBJECT for Record 16606 ...'¨626 ANCESTOR: total=13, value 0 = 663n'¨626 ANCESTOR: total=13, value 1 = 141N'¨626 ANCESTOR: total=13, value 2 = 264E)¨626 ANCESTOR: total=13, value 3 = 17415 '¨626 ANCESTOR: total=13, value 4 = 113o'¨626 ANCESTOR: total=13, value 5 = 263U)¨626 ANCESTOR: total=13, value 6 = 26372:)¨626 ANCESTOR: total=13, value 7 = 26297t&¨626 ANCESTOR: total=13, value 8 = 88'¨626 ANCESTOR: total=13, value 9 = 261t*¨626 ANCESTOR: total=13, value 10 = 27012(¨626 ANCESTOR: total=13, value 11 = 149'¨626 ANCESTOR: total=13, value 12 = 98n,¨Rebuild index WEBSITE for Record 16606 ...-¨Rebuild index ISUBJECT for Record 16606 ...a+¨Rebuild index SOURCE for Record 16607 ...l%¨834 ANCESTOR: total=4, value 0 = 37l$¨834 ANCESTOR: total=4, value 1 = 9%¨834 ANCESTOR: total=4, value 2 = 20 (¨834 ANCESTOR: total=4, value 3 = 18500,¨Rebuild index SUBJECT for Record 16607 ...%¨88 ANCESTOR: total=1, value 0 = 261R,¨Rebuild index WEBSITE for Record 16607 ...-¨Rebuild index ISUBJECT for Record 16607 ...=+¨Rebuild index SOURCE for Record 16608 ...v%¨834 ANCESTOR: total=4, value 0 = 37v$¨834 ANCESTOR: total=4, value 1 = 9%¨834 ANCESTOR: total=4, value 2 = 20 (¨834 ANCESTOR: total=4, value 3 = 18500,¨Rebuild index SUBJECT for Record 16608 ...%¨88 ANCESTOR: total=1, value 0 = 261T,¨Rebuild index WEBSITE for Record 16608 ...-¨Rebuild index ISUBJECT for Record 16608 ...l+¨Rebuild index SOURCE for Record 16609 ...=%¨864 ANCESTOR: total=4, value 0 = 37o$¨864 ANCESTOR: total=4, value 1 = 9%¨864 ANCESTOR: total=4, value 2 = 20o(¨864 ANCESTOR: total=4, value 3 = 18500,¨Rebuild index SUBJECT for Record 16609 ...*¨13684 ANCESTOR: total=4, value 0 = 13669*¨13684 ANCESTOR: total=4, value 1 = 13557'¨13684 ANCESTOR: total=4, value 2 = 70a(¨13684 ANCESTOR: total=4, value 3 = 262%¨88 ANCESTOR: total=1, value 0 = 261t,¨Rebuild index WEBSITE for Record 16609 ...-¨Rebuild index ISUBJECT for Record 16609 ...T+¨Rebuild index SOURCE for Record 16610 ...E%¨834 ANCESTOR: total=4, value 0 = 37 $¨834 ANCESTOR: total=4, value 1 = 9%¨834 ANCESTOR: total=4, value 2 = 20 (¨834 ANCESTOR: total=4, value 3 = 18500,¨Rebuild index SUBJECT for Record 16610 ...%¨88 ANCESTOR: total=1, value 0 = 261R,¨Rebuild index WEBSITE for Record 16610 ...-¨Rebuild index ISUBJECT for Record 16610 ...a+¨Rebuild index SOURCE for Record 16611 ...=%¨825 ANCESTOR: total=4, value 0 = 37a$¨825 ANCESTOR: total=4, value 1 = 9%¨825 ANCESTOR: total=4, value 2 = 20T(¨825 ANCESTOR: total=4, value 3 = 18500,¨Rebuild index SUBJECT for Record 16611 ...%¨88 ANCESTOR: total=1, value 0 = 261e,¨Rebuild index WEBSITE for Record 16611 ...-¨Rebuild index ISUBJECT for Record 16611 ...e+¨Rebuild index SOURCE for Record 16612 ...O%¨834 ANCESTOR: total=4, value 0 = 37O$¨834 ANCESTOR: total=4, value 1 = 9%¨834 ANCESTOR: total=4, value 2 = 20n(¨834 ANCESTOR: total=4, value 3 = 18500,¨Rebuild index SUBJECT for Record 16612 ...+¨10267 ANCESTOR: total=11, value 0 = 102768+¨10267 ANCESTOR: total=11, value 1 = 10270u(¨10267 ANCESTOR: total=11, value 2 = 99*¨10267 ANCESTOR: total=11, value 3 = 9678)¨10267 ANCESTOR: total=11, value 4 = 153 )¨10267 ANCESTOR: total=11, value 5 = 264R+¨10267 ANCESTOR: total=11, value 6 = 22425¨+¨10267 ANCESTOR: total=11, value 7 = 39373A)¨10267 ANCESTOR: total=11, value 8 = 269O)¨10267 ANCESTOR: total=11, value 9 = 265t*¨10267 ANCESTOR: total=11, value 10 = 154%¨88 ANCESTOR: total=1, value 0 = 261l,¨Rebuild index WEBSITE for Record 16612 ...-¨Rebuild index ISUBJECT for Record 16612 ...d+¨Rebuild index SOURCE for Record 16613 ...r%¨834 ANCESTOR: total=4, value 0 = 37r$¨834 ANCESTOR: total=4, value 1 = 9%¨834 ANCESTOR: total=4, value 2 = 20o(¨834 ANCESTOR: total=4, value 3 = 18500,¨Rebuild index SUBJECT for Record 16613 ...*¨35821 ANCESTOR: total=8, value 0 = 26387*¨35821 ANCESTOR: total=8, value 1 = 26323*¨35821 ANCESTOR: total=8, value 2 = 26297'¨35821 ANCESTOR: total=8, value 3 = 88=(¨35821 ANCESTOR: total=8, value 4 = 261*¨35821 ANCESTOR: total=8, value 5 = 27012*¨35821 ANCESTOR: total=8, value 6 = 26439*¨35821 ANCESTOR: total=8, value 7 = 26375%¨88 ANCESTOR: total=1, value 0 = 261R,¨Rebuild index WEBSITE for Record 16613 ...-¨Rebuild index ISUBJECT for Record 16613 ... +¨Rebuild index SOURCE for Record 16614 ...o&¨1139 ANCESTOR: total=3, value 0 = 37%¨1139 ANCESTOR: total=3, value 1 = 9 &¨1139 ANCESTOR: total=3, value 2 = 20,¨Rebuild index SUBJECT for Record 16614 ...,¨Rebuild index WEBSITE for Record 16614 ...-¨Rebuild index ISUBJECT for Record 16614 ... +¨Rebuild index SOURCE for Record 16615 ...,%¨834 ANCESTOR: total=4, value 0 = 37,$¨834 ANCESTOR: total=4, value 1 = 9%¨834 ANCESTOR: total=4, value 2 = 20:(¨834 ANCESTOR: total=4, value 3 = 18500,¨Rebuil