About the volume header: one solution
Shoshana Abrass
shoshana at pdi.UUCP
Fri Feb 22 08:15:04 AEST 1991
Dave Olsen (olson at anchor.esd.sgi.com) writes:
>> | I'm writing my own version of 'hinv'. Having the disk serial #'s appear
>> | in the listing would be VERY useful.
>>
>> You can certainly do this, but if you call it hinv, you may break
>> SGI programs that use it and expect known output. If you must
>> call it hinv, put it in /usr/local/bin, or something like that.
I was speaking euphemistically. The program I'm writing has the basic
functionality of hinv but will not be used the same way, and certainly
won't have the same name. I guess I sounded stupider than I like to
think :).
>> The sgilabel file has the serial number in it for some disks, and
>> the input is pretty free form.
I looked at the sgilabel once (using dvhtool to get it into a file) and
all I know is that it wasn't an ascii file, and I rated my chances of
getting the file format out of the Hotline to be close to nil.
>> ... the volhdr only has room for 16 files, so make sure you
>> don't put too many files there. In particular, inst puts a temporary
>> file there during miniroot installs.
This is good to know, though we're not anywhere close to 15 files yet.
I'll leave room for inst.
>> You could simply get the file out with 'dvhtool -v g vhfile file'
>> if you are doing a shell script. Otherwise look at sys/dkio.h
>> and sys/dvh.h.
I am *not* writing a shell script. I must have sounded *really* stupid.
Why would I write a shell script to replace hinv? Anyway, I will
(hopefully) make up for the shortcomings of my question by posting
the answer. By the way, I understand that this was discussed a few
months ago - sorry to repeat a recent topic, but I was off the list
for a while.
This is a fragment from a program that uses the volume header to read
the partition table. Finding all the necessary include files is left
as an exercise to the reader :). I do not guarantee that this is the
best way to tackle this problem.
read_partition_table(char* file) <=== "file" is a disk path
{ e.g., /dev/rdsk/dks0d1vh
int fd;
struct volume_header *buf;
buf = (struct volume_header *)malloc(512);<=== Seems like there should be
some explanation of how
this number was calculated
if ( (fd = open(file, O_RDONLY)) == -1 ) {
perror(file);
return(0);
}
if ( (ioctl(fd, DIOCGETVH, buf)) == -1 ) {
perror(file);
return(0);
}
/* buf is now a pointer to the volume header data */
/* Do whatever you want with the volume header here... */
}
-------------
-shoshana
shoshana at pdi.com
More information about the Comp.sys.sgi
mailing list