home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / unix / programm / 4309 < prev    next >
Encoding:
Internet Message Format  |  1992-08-14  |  3.6 KB

  1. Xref: sparky comp.unix.programmer:4309 comp.unix.internals:1693 comp.sys.hp:9307
  2. Path: sparky!uunet!dtix!darwin.sura.net!mips!sdd.hp.com!caen!hellgate.utah.edu!fcom.cc.utah.edu!gateway.univel.com!ns.Novell.COM!gateway.novell.com!ithaca.Eng.Sandy.Novell.COM!terry
  3. From: terry@ithaca.Eng.Sandy.Novell.COM (Terry Lambert)
  4. Newsgroups: comp.unix.programmer,comp.unix.internals,comp.sys.hp
  5. Subject: Re: inode to filename
  6. Message-ID: <1992Aug14.223505.13853@gateway.novell.com>
  7. Date: 14 Aug 92 22:35:05 GMT
  8. References: <1992Aug12.181707.23506@gateway.novell.com> <1992Aug13.135735.6607@bwdls61.bnr.ca> <JIM.92Aug14122954@hunter.cs.strath.ac.uk>
  9. Sender: news@gateway.novell.com (NetNews)
  10. Organization: Novell NPD -- Sandy, UT
  11. Lines: 56
  12. Nntp-Posting-Host: ithaca.eng.sandy.novell.com
  13.  
  14. In article <JIM.92Aug14122954@hunter.cs.strath.ac.uk> jim@cs.strath.ac.uk (Jim Reid) writes:
  15. >In article <1992Aug13.135735.6607@bwdls61.bnr.ca> mleech@bnr.ca (Marcus Leech) writes:
  16. >
  17. >   Granted there isn't always a 1 to 1 relationship between a files internal
  18. >     "handle", and its name.  In the real world, programs refer to files by
  19. >     name, and in the real world, system managers frequently need this
  20. >     information either to debug some system process, or because they want to
  21. >     take a disk offline, and they need to know which processes have *which*
  22. >     files open on the disk.  You can avoid having to do the reverse mapping
  23. >     simply by storing the name information in such a way as to be generally
  24. >     useful, and not cost very much.
  25. >
  26. >Hmmm. On some machine there could be thousands of active files. Having
  27. >the kernel maintain a list of those filenames might cost more than you
  28. >think. [If it's a choice between assigning 100K of kernel memory to
  29. >I/O buffers or process page tables or a list of active filenames, I
  30. >wouldn't choose the list of filenames.]
  31. >
  32. >What would such a scheme do in the case of a process which unlinks an
  33. >open file?
  34.  
  35. *Very* good point against keeping the data in the kernel.  There is also
  36. the worse case of a file having been moved.  Not only is there not a file
  37. where the kernel says it is, theres a file open that the kernel knows
  38. is open but can't know it's new name.
  39.  
  40. If we return to the question of taking a device offline, I have to argue
  41. that it is irrelevant whether or not you know the name of the file; you
  42. only need to know the name of the processes which have files open on the
  43. device; you could care less what the names of the files are.  Killing
  44. the processes will kill the references.  You don't really care what *files*
  45. are referenced ... you care what *devices* are referenced.
  46.  
  47. By traversing all active process structs in the kernel, one can get the u
  48. structs for each process, and thus the pointer to the locked vnodes for that
  49. process (this will be in the per process fd table and in the current working
  50. directory pointer).  It's easy to find out what device or file system a
  51. vnode is open to.  From this, you determine if you want to kill a particular
  52. process that's holding your FS open.
  53.  
  54. Alternatively, most file systems support forcible unmount; you should
  55. probably wall to tell your users to logout/kill their program/change to
  56. a safe directory so as to give them fair warning that you may destroy one
  57. or more of their files.  This is probably inferior to killing off the
  58. processes and umounting, and killing again if that fails, repeating until
  59. the thing unmounts, but it will certainly take less code (ie: no code)
  60. in enough cases that it will be worthwhile.
  61.  
  62.  
  63.                     Terry Lambert
  64.                     terry_lambert@gateway.novell.com
  65.                     terry@icarus.weber.edu
  66.  
  67. ---
  68. Disclaimer:  Any opinions in this posting are my own and not those of
  69. my present or previous employers.
  70.