diff options
author | Jim Meyering <meyering@redhat.com> | 2008-06-26 10:02:32 +0200 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2008-06-26 21:08:22 +0200 |
commit | 27311c9e8544b6b11e7e86dfa1b8597ff1d9eb75 (patch) | |
tree | 7dd4bb54094677085fa8018037f946c1c16a1a16 /src | |
parent | 556fbb57216b119155cdda824c98dc579b8121c8 (diff) | |
download | coreutils-27311c9e8544b6b11e7e86dfa1b8597ff1d9eb75.tar.xz |
shred: also ignore EISDIR upon failed fsync/fdatasync on HP-UX
* src/shred.c (ignorable_sync_errno): New function.
(dosync): Use it.
Based on a patch from Peter O'Gorman.
Diffstat (limited to 'src')
-rw-r--r-- | src/shred.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/shred.c b/src/shred.c index bfafa96f3..765e1b515 100644 --- a/src/shred.c +++ b/src/shred.c @@ -277,6 +277,17 @@ passname (unsigned char const *data, char name[PASS_NAME_SIZE]) memcpy (name, "random", PASS_NAME_SIZE); } +/* Return true when it's ok to ignore an fsync or fdatasync + failure that set errno to ERRNO_VAL. */ +static bool +ignorable_sync_errno (int errno_val) +{ + return (errno_val == EINVAL + || errno_val == EBADF + /* HP-UX does this */ + || errno_val == EISDIR); +} + /* Request that all data for FD be transferred to the corresponding storage device. QNAME is the file name (quoted for colons). Report any errors found. Return 0 on success, -1 @@ -292,7 +303,7 @@ dosync (int fd, char const *qname) if (fdatasync (fd) == 0) return 0; err = errno; - if (err != EINVAL && err != EBADF) + if ( ! ignorable_sync_errno (err)) { error (0, err, _("%s: fdatasync failed"), qname); errno = err; @@ -303,7 +314,7 @@ dosync (int fd, char const *qname) if (fsync (fd) == 0) return 0; err = errno; - if (err != EINVAL && err != EBADF) + if ( ! ignorable_sync_errno (err)) { error (0, err, _("%s: fsync failed"), qname); errno = err; |