home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.wizards
- Path: sparky!uunet!gatech!news.byu.edu!ux1!fcom.cc.utah.edu!cs.weber.edu!terry
- From: terry@cs.weber.edu (A Wizard of Earth C)
- Subject: Re: Programmatic recgonition of sun floppy device
- Message-ID: <1992Sep11.015132.15399@fcom.cc.utah.edu>
- Sender: news@fcom.cc.utah.edu
- Organization: Weber State University (Ogden, UT)
- References: <1992Sep10.011122.23106@bellahs.com>
- Date: Fri, 11 Sep 92 01:51:32 GMT
- Lines: 37
-
- In article <1992Sep10.011122.23106@bellahs.com> gfong@bellahs.com (Gary Fong RD) writes:
- >
- >Wizards,
- > How can I programmatically determine if a given file descripter/pointer
- >belongs to a floppy device on a Sun 4/40? Detecting the file is special and
- >raw, I can do. But what function/macro will tell me it is a floppy device
- >or not?
-
- 1. If it's an fp, use the fileno() macro to get the fd. WARNING:
- stdio on SunOS and some other systems can only support a char
- worth of fd's!
- 2. fstat() the fd to get the major/minor numbers.
- 3. opendir() on "/dev".
- 4. Use readdir() to read each file name in "/dev". If you run out, it's
- not a floppy, and go to #8.
- 5. stat() the file to get major/minor.
- 6. If the major/minor numbers both match, this is your device. If
- not, go to #4.
- 7. If the file name you stat()'ed begins with "fd", it's a floppy. If
- not, then it isn't.
- 8. closedir().
-
- Or you could just recode your program so it knows what file names it opened
- and whether they were for a floppy or not. Save a lot of trouble.
-
-
- Terry Lambert
- terry_lambert@gateway.novell.com
- terry@icarus.weber.edu
- ---
- Any opinions in this posting are my own and not those of my present
- or previous employers.
- --
- -------------------------------------------------------------------------------
- "I have an 8 user poetic license" - me
- Get the 386bsd FAQ from agate.berkeley.edu:/pub/386BSD/386bsd-0.1/unofficial
- -------------------------------------------------------------------------------
-