home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / os / linux / 8109 < prev    next >
Encoding:
Text File  |  1992-08-13  |  3.1 KB  |  81 lines

  1. Newsgroups: comp.os.linux
  2. Path: sparky!uunet!mcsun!Germany.EU.net!news.netmbx.de!zrz.tu-berlin.de!math.fu-berlin.de!Sirius.dfn.de!chx400!bernina!almesber
  3. From: almesber@nessie.cs.id.ethz.ch (Werner Almesberger)
  4. Subject: Re: Can I use dd on my UNIX system instead of Rawrite?
  5. Message-ID: <1992Aug13.122323.13523@bernina.ethz.ch>
  6. Sender: news@bernina.ethz.ch (USENET News System)
  7. Organization: Swiss Federal Institute of Technology (ETH), Zurich, CH
  8. References: <1992Aug12.060338.24805@ennews.eas.asu.edu> <1992Aug12.063534.4178@muddcs.claremont.edu> <1992Aug13.003041.28918@mits.mdata.fi>
  9. Date: Thu, 13 Aug 1992 12:23:23 GMT
  10. Lines: 69
  11.  
  12. In article <1992Aug13.003041.28918@mits.mdata.fi> kennu@mits.mdata.fi (Kenneth Falck) writes:
  13. > How exactly does that lseek() writing work?
  14.  
  15. You lseek to some place beyond the current end of the file and write some
  16. data, e.g.
  17.  
  18.  
  19. +----------+--------------------------------------+----------+
  20. | Old data |                      | New data |
  21. +----------+--------------------------------------+----------+
  22.        ^                      ^         ^
  23.     old EOF                    lseek        new
  24.                         here        EOF
  25.  
  26. Because the file is physically stored as a sequence of blocks,
  27. those blocks that have been skipped don't have to be mapped:
  28.  
  29. +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
  30. |   |   |   | - | - | - | - | - | - | - | - | - |   |   |   |   |
  31. +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
  32.  
  33. By convention, reading an unmapped block returns a bunch of
  34. zero bytes.
  35.  
  36. > If you lseek() past
  37. > the end of file, do some I/O routines automatically append the
  38. > corresponding amount of nulls or what?
  39.  
  40. No, they just don't allocate blocks. (*)
  41.  
  42. > And why doesn't this work with shoelace then...
  43.  
  44. Because Shoelace seems to ignore this concept and loads garbage
  45. where it should load zeroes.
  46.  
  47. > (Btw, is this optimization possible only for the unix/minix/linux
  48. > filesystems, or is it fs-independant and can be used on MSDOS too?)
  49.  
  50. This works on UNIX-like systems, on CP/M, and several other systems
  51. (don't know about VMS - it proabably has it too) but it can't be used
  52. on an MS-DOS FS (*), because MS-DOS uses a chain of blocks instead of
  53. maps:
  54.  
  55.   UNIX          Data           MS-DOS     FAT          Data
  56.           blocks                      blocks
  57.  
  58. inode          +---+        dir ent.     +---+          +---+
  59. +----+      +---->|   |        +----+  +--->|   |-+   -----> |   |
  60. |    |      |     +---+        |    |  |    +---+ |          +---+
  61. | B1 |------+     +---+        |    |  |       |
  62. | B2 |----------->|   |        |strt|--+  +-------+
  63. | B3 |-----+      +---+        |    |       |
  64. | B4 |...  |      +---+        +----+       |  +---+          +---+
  65. | B5 |     +----->|   |               +->|   |--...  --> |   |
  66. |    |          +---+                  +---+          +---+
  67. +----+
  68.  
  69. These pictures are greatly simplified.
  70.  
  71. (*) The MS-DOS FS in Linux automatically fills any "holes" with zero
  72.     blocks. Therefore, the file contents are correct, but you don't
  73.     save any disk space.
  74.  
  75. - Werner
  76. -- 
  77.    _________________________________________________________________________
  78.   / Werner Almesberger, ETH Zuerich, CH      almesber@nessie.cs.id.ethz.ch /
  79.  / IFW A44  Tel. +41 1 254 7213                 almesberger@rzvax.ethz.ch /
  80. /_BITNET:_ALMESBER@CZHETH5A__HEPNET/CHADNET:_[20579::]57414::ALMESBERGER_/
  81.