home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / unix / wizards / 3882 < prev    next >
Encoding:
Text File  |  1992-09-10  |  1.9 KB  |  49 lines

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