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

  1. Newsgroups: comp.os.minix
  2. Path: sparky!uunet!mcsun!sun4nl!star.cs.vu.nl!kjb
  3. From: kjb@cs.vu.nl (Kees J. Bot)
  4. Subject: Re: Long filenames
  5. Message-ID: <Bzq8tv.9M7@cs.vu.nl>
  6. Sender: news@cs.vu.nl
  7. Organization: Fac. Wiskunde & Informatica, VU, Amsterdam
  8. References: <a75d0246@mtlookitthat.chi.il.us> <1992Dec23.131313.10139@klaava.Helsinki.FI>
  9. Date: Wed, 23 Dec 1992 19:29:55 GMT
  10. Lines: 114
  11.  
  12. torvalds@klaava.Helsinki.FI (Linus Torvalds) writes:
  13.  
  14. >In article <a75d0246@mtlookitthat.chi.il.us> chanson@mtlookitthat.chi.il.us (Chris Hanson) writes:
  15. >>Hi!  Can anyone point me to some info (or tell me themselves) on how to
  16. >>implement long filenames for minix?  [I know someone's done it -- one
  17. >>of the dudes in the 'MINIX vs LINUX' discussion mentioned it.]  I'm
  18. >>thinking that 30 chars or 62 chars shouldn't be that hard (we'd be
  19. >>keeping a dir_entry at an even multiple of 16 bytes), but I know it'll
  20. >>involve more than just recompiling the kernel with MAX_NAME changed.
  21.  
  22. I am the someone mentioned by this dude.
  23.  
  24. >The problem shouldn't be so much the kernel as all the binaries you are
  25. >using: changing the directory structure will break everything that reads
  26. >directory entries - this includes important binaries like 'ls'
  27. >(obviously), the shell (for filename globbing, name completion etc),
  28. >'make', etc. 
  29.  
  30. Precisely.  The changes I made to fs/path.c were only 100 lines long or
  31. so.  With another 100 lines for the include files.  The utilities were a
  32. major hassle, I even wrote my own ls.c.  Luckily almost all utilities in
  33. 1.6.23 use readdir now.  Only the use of d_reclen must be cut out of
  34. cp.c, POSIX only mentiones d_name.
  35.  
  36. >>Will I need to make new filesystems and move everything to them?  Or is
  37. >>a compatibility hack (such as puting an optional fstype flag or a
  38. >>different magic number in a device's superblock to tell whether it has
  39. >>long or standard pathnames) trivial?
  40.  
  41. >I'd go for the compatability hack: creating a new filesystem from
  42. >scratch for the new kernel is simply too painful (as well as making
  43. >debugging pretty mcuh impossible...  much easier to start off with just
  44. >one partition with the extended setup, and test out all the new binaries
  45. >on that one first).  I'd also suggest you add a "readdir()" system call
  46. >while you are at it, which checks the magic number and returns the
  47. >correct type of directory entry.  That way binaries compiled to use it
  48. >will be able to function correctly on both the new and old type of
  49. >filesystem.
  50.  
  51. I added a flag to the file system thereby creating a new filesystem
  52. type.  I did not change the magic number to keep df and such working.
  53. Readdir is still a library routine that makes a simple check on the
  54. first read, transforming the old directory entries to the new form.
  55.  
  56. >There are a couple of alternatives you could do:
  57.  
  58. > (a) go for a complete vfs (virtual filesystems) interface.  This would
  59. >make it possible to later add totally different types of filesystems. 
  60. >It's more general, but it's also a lot more coding.  This is the
  61. >approach linux uses, and it gives the possibility to mount msdos etc
  62. >filesystems transparently. 
  63.  
  64. One of the ideas on the waiting on shelf.  It would be nice to do it
  65. right.  (Your struct inode is way too big.)
  66.  
  67. > (b) do the long filenames by fooling around with several consecutive
  68. >minix-type directory entries.  Depending on how you do it, you can make
  69. >old binaries see only th first characters of a extended filename, while
  70. >new binaries see them all.  Besides, this means you won't waste a full
  71. >64-char direntry for short files, but instead use several entries only
  72. >when necessary.  The downside is that it's a bit more work in the
  73. >kernel. 
  74.  
  75. I changed everything to use use readdir, there can be too much backwards
  76. compatibility.  There are a lot of programs that did not even read
  77. directories, the C compiler to name one.
  78.  
  79. >The directory entries in (b) could be made to work by using a magic
  80. >cookie at the end of a filename to mean that the filename continues in
  81. >the next entry (which has a inode nr of 0 to make old programs ignore
  82. >it).  It could look something like this:
  83.  
  84. >file "really_long_name", use '\000\377' as continuation marker:
  85.  
  86. >    .word inode_number
  87. >    .byte 'really_long_\000\377'    /* first 12 chars */
  88. >    .word 0x0000            /* next entry is a continuation */
  89. >    .byte 'filename\0'        /* rest of the filename */
  90.  
  91. >This can be extended to any filename length, and old programs will see
  92. >only the first 12 characters, but they should work otherwise.  I think
  93. >somebody implemented something like this.  Patches, anybody? Naturally,
  94. >you'd have to make sure that none of your current filesystems happen to
  95. >have the '\000\377' sequence at the end of a directory entry, but that
  96. >should be simple enough. 
  97.  
  98. Not even your C code contains assembly, but your articles too. :-)
  99.  
  100. (Last time I tried Linux I installed it on a partition I had reserved
  101. as swap space for Minix.  What fun it was when Philip implemented
  102. swapping... (I wasn't too wild about Linux then (0.96), it kept
  103. crashing.)  Did you implement swapping on floppies Linus?  Try the Minix
  104. distribution disks. :-)  )
  105.  
  106. My directory entries look like this:
  107.  
  108.     struct _fl_direct {
  109.         ino_t    d_ino;
  110.         unsigned char d_extent;
  111.         char    d_name[5];
  112.     }
  113.  
  114. The d_extent field tells how many 8-byte slots follow the first.
  115. Readdir knows it has a new type if d_extent is 0 instead of '.'.
  116. struct dirent looks like _fl_direct (fl for flex), but with d_name at
  117. the maximum, 61.  The max is so low because fsck keeps one entry for
  118. each component in a deep path...  (I invented this for Minix 1.3 on my
  119. old 286.)  I decided that it was close enough to infinity.
  120.  
  121. I have to answer any questions at 2400 baud, so if you can wait until
  122. January 4 with the big ones...
  123. --
  124.                             Kees J. Bot  (kjb@cs.vu.nl)
  125.                   Systems Programmer, Vrije Universiteit Amsterdam
  126.