shoshana@pdi.UUCP (Shoshana Abrass) (02/22/91)
Dave Olsen (olson@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@pdi.com
olson@anchor.esd.sgi.com (Dave Olson) (02/22/91)
In <9102212115.AA20052@koko.pdi.com> shoshana@pdi.UUCP (Shoshana Abrass) writes: | Dave Olsen (olson@anchor.esd.sgi.com) writes: | >> 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 People do all kinds of things for various reasons. It isn't necessarily stupid to use a shell script. Often it is the appropriate answer. Sorry, I didn't mean to sound patronizing; I guess I've spent a bit too much time on the phone lately with people with people who had a different base understanding of the situation than I had... | 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 What is wrong with buf = (struct volume_header *)malloc(sizeof *buf); Seems pretty self documenting to me. Why would one ever hard code a constant for something like this!?! Of course, the fact that I copied some old comments and stupidly embedded the constant 512 in the dksc.7 man page couldn't have anything to do with it, could it? :) I'll fix the man page. -- Dave Olson Life would be so much easier if we could just look at the source code.