diff options
author | Jim Meyering <jim@meyering.net> | 2007-08-15 22:44:45 +0200 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2007-08-15 22:45:55 +0200 |
commit | 535a9fe5122808161398345f5ab317bd1ef6bde8 (patch) | |
tree | 833a5c6fd16059dc1fcfa56331b72857ea599dfd /src | |
parent | 9ee7933b5cdf40ed4fd82b21fc521db5135446bf (diff) | |
download | coreutils-535a9fe5122808161398345f5ab317bd1ef6bde8.tar.xz |
od --skip (-j) works even on files in /proc, when the kernel lies
* src/od.c (skip): Don't let kernel misinformation (nonempty files
in /proc with stat.st_size == 0) make "od -j N" misbehave.
Patch by Paul Eggert.
* NEWS: Document this work-around.
* tests/misc/od-zero-len: New file, test for the above.
Diffstat (limited to 'src')
-rw-r--r-- | src/od.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -1035,9 +1035,11 @@ skip (uintmax_t n_skip) /* The st_size field is valid only for regular files (and for symbolic links, which cannot occur here). If the number of bytes left to skip is larger than - the size of the current file, we can decrement - n_skip and go on to the next file. */ - if (S_ISREG (file_stats.st_mode) && 0 <= file_stats.st_size) + the size of the current file, we can decrement n_skip + and go on to the next file. Skip this optimization also + when st_size is 0, because some kernels report that + nonempty files in /proc have st_size == 0. */ + if (S_ISREG (file_stats.st_mode) && 0 < file_stats.st_size) { if ((uintmax_t) file_stats.st_size < n_skip) n_skip -= file_stats.st_size; |