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

  1. Newsgroups: comp.os.linux
  2. Path: sparky!uunet!decwrl!world!jrs
  3. From: jrs@world.std.com (Rick Sladkey)
  4. Subject: Why GNU cp is flakey under Linux
  5. In-Reply-To: jwinstea@jarthur.claremont.edu's message of Wed, 12 Aug 1992 06:35:34 GMT
  6. Message-ID: <JRS.92Aug12190300@lepton.world.std.com>
  7. Lines: 48
  8. Sender: jrs@world.std.com (Rick Sladkey)
  9. Organization: The Internet
  10. References: <1992Aug12.043754.21260@ennews.eas.asu.edu>
  11.     <1992Aug12.053539.14825@mnemosyne.cs.du.edu>
  12.     <1992Aug12.060338.24805@ennews.eas.asu.edu>
  13.     <1992Aug12.063534.4178@muddcs.claremont.edu>
  14. Date: Wed, 12 Aug 1992 23:02:59 GMT
  15.  
  16. >>>>> On Wed, 12 Aug 1992 06:35:34 GMT, jwinstea@jarthur.claremont.edu
  17. >>>>> (Jim Winstead Jr.) said:
  18.  
  19. Jim> Not necessarily true - GNU cp contains the optimization that it will
  20. Jim> use lseek() to 'write' holes in a file instead of writing out all the
  21. Jim> individual null bits.  This is what causes shoelace to break for some
  22. Jim> people.  I'm not sure what effect this has on copying to a floppy with
  23. Jim> the cp command - but I *know* dd is safe.
  24.  
  25. An examination of the source code shows that GNU cp only performs this
  26. optimization if it thinks that the original file also had holes.  The
  27. way GNU cp determines this is by comparing the number of blocks used
  28. with the actual file size.  Furthermore, it only does this when it is
  29. compiled without ST_BLOCKS_MISSING defined.  Note that the kernel is
  30. created by build and does not have any holes.
  31.  
  32. So if your cp is creating holes ROUTINELY then:
  33.  
  34. * fstat is broken and returns incorrect values for st_blocks, or
  35. * you manually defined an incorrect value of DEV_BSIZE (i.e. too small)
  36.  
  37. Here is the relevant code from GNU cp.c:
  38.  
  39. +-----
  40. | #ifndef ST_BLOCKS_MISSING
  41. |   if (S_ISREG (sb.st_mode))
  42. |     {
  43. |       /* Find out whether the file contains any sparse blocks. */
  44. |
  45. |       if (fstat (source_desc, &sb))
  46. |       {
  47. |         error (0, errno, "%s", src_path);
  48. |         return_val = -1;
  49. |         goto ret;
  50. |       }
  51. |
  52. |      /* If the file has fewer blocks than would normally
  53. |       be needed for a file of its size, then
  54. |       at least one of the blocks in the file is a hole. */
  55. |         if (S_ISREG (sb.st_mode) &&
  56. |         sb.st_size - (sb.st_blocks * DEV_BSIZE) >= DEV_BSIZE)
  57. |       make_holes = 1;
  58. |     }
  59. | #endif
  60. +-----
  61. --
  62. Rick Sladkey
  63. jrs@world.std.com
  64.