home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / os / minix / 4977 < prev    next >
Encoding:
Text File  |  1992-12-23  |  3.6 KB  |  76 lines

  1. Newsgroups: comp.os.minix
  2. Path: sparky!uunet!mcsun!news.funet.fi!hydra!klaava!torvalds
  3. From: torvalds@klaava.Helsinki.FI (Linus Torvalds)
  4. Subject: Re: Long filenames
  5. Message-ID: <1992Dec23.131313.10139@klaava.Helsinki.FI>
  6. Organization: University of Helsinki
  7. References: <a75d0246@mtlookitthat.chi.il.us>
  8. Date: Wed, 23 Dec 1992 13:13:13 GMT
  9. Lines: 65
  10.  
  11. In article <a75d0246@mtlookitthat.chi.il.us> chanson@mtlookitthat.chi.il.us (Chris Hanson) writes:
  12. >Hi!  Can anyone point me to some info (or tell me themselves) on how to
  13. >implement long filenames for minix?  [I know someone's done it -- one
  14. >of the dudes in the 'MINIX vs LINUX' discussion mentioned it.]  I'm
  15. >thinking that 30 chars or 62 chars shouldn't be that hard (we'd be
  16. >keeping a dir_entry at an even multiple of 16 bytes), but I know it'll
  17. >involve more than just recompiling the kernel with MAX_NAME changed.
  18.  
  19. The problem shouldn't be so much the kernel as all the binaries you are
  20. using: changing the directory structure will break everything that reads
  21. directory entries - this includes important binaries like 'ls'
  22. (obviously), the shell (for filename globbing, name completion etc),
  23. 'make', etc. 
  24.  
  25. >Will I need to make new filesystems and move everything to them?  Or is
  26. >a compatibility hack (such as puting an optional fstype flag or a
  27. >different magic number in a device's superblock to tell whether it has
  28. >long or standard pathnames) trivial?
  29.  
  30. I'd go for the compatability hack: creating a new filesystem from
  31. scratch for the new kernel is simply too painful (as well as making
  32. debugging pretty mcuh impossible...  much easier to start off with just
  33. one partition with the extended setup, and test out all the new binaries
  34. on that one first).  I'd also suggest you add a "readdir()" system call
  35. while you are at it, which checks the magic number and returns the
  36. correct type of directory entry.  That way binaries compiled to use it
  37. will be able to function correctly on both the new and old type of
  38. filesystem.
  39.  
  40. There are a couple of alternatives you could do:
  41.  
  42.  (a) go for a complete vfs (virtual filesystems) interface.  This would
  43. make it possible to later add totally different types of filesystems. 
  44. It's more general, but it's also a lot more coding.  This is the
  45. approach linux uses, and it gives the possibility to mount msdos etc
  46. filesystems transparently. 
  47.  
  48.  (b) do the long filenames by fooling around with several consecutive
  49. minix-type directory entries.  Depending on how you do it, you can make
  50. old binaries see only th first characters of a extended filename, while
  51. new binaries see them all.  Besides, this means you won't waste a full
  52. 64-char direntry for short files, but instead use several entries only
  53. when necessary.  The downside is that it's a bit more work in the
  54. kernel. 
  55.  
  56. The directory entries in (b) could be made to work by using a magic
  57. cookie at the end of a filename to mean that the filename continues in
  58. the next entry (which has a inode nr of 0 to make old programs ignore
  59. it).  It could look something like this:
  60.  
  61. file "really_long_name", use '\000\377' as continuation marker:
  62.  
  63.     .word inode_number
  64.     .byte 'really_long_\000\377'    /* first 12 chars */
  65.     .word 0x0000            /* next entry is a continuation */
  66.     .byte 'filename\0'        /* rest of the filename */
  67.  
  68. This can be extended to any filename length, and old programs will see
  69. only the first 12 characters, but they should work otherwise.  I think
  70. somebody implemented something like this.  Patches, anybody? Naturally,
  71. you'd have to make sure that none of your current filesystems happen to
  72. have the '\000\377' sequence at the end of a directory entry, but that
  73. should be simple enough. 
  74.  
  75.         Linus
  76.