From ca3ad6589a96f6d5b03141813d89be4afb357454 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sun, 30 May 2004 08:43:35 +0000 Subject: (dosync): Ignore EBADF errors, as IRIX 6.5 fdatasync reports EBADF when syncing (unwritable) directories. Problem reported by Albert Chin-A-Young in: http://lists.gnu.org/archive/html/bug-coreutils/2004-05/msg00165.html --- src/shred.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/shred.c b/src/shred.c index 8208ca6b5..641cef8ee 100644 --- a/src/shred.c +++ b/src/shred.c @@ -774,10 +774,11 @@ passname (unsigned char const *data, char name[PASS_NAME_SIZE]) } /* Request that all data for FD be transferred to the corresponding - storage device. QNAME is the file name (quoted for colons), and - *ST its status. Report any errors found. Return 0 on success, -1 + storage device. QNAME is the file name (quoted for colons). + Report any errors found. Return 0 on success, -1 (setting errno) on failure. It is not an error if fdatasync and/or - fsync is not supported for this file. */ + fsync is not supported for this file, or if the file is not a + writable file descriptor. */ static int dosync (int fd, char const *qname) { @@ -787,7 +788,7 @@ dosync (int fd, char const *qname) if (fdatasync (fd) == 0) return 0; err = errno; - if (err != EINVAL) + if (err != EINVAL && err != EBADF) { error (0, err, _("%s: fdatasync failed"), qname); errno = err; @@ -798,7 +799,7 @@ dosync (int fd, char const *qname) if (fsync (fd) == 0) return 0; err = errno; - if (err != EINVAL) + if (err != EINVAL && err != EBADF) { error (0, err, _("%s: fsync failed"), qname); errno = err; @@ -1399,8 +1400,8 @@ incname (char *name, size_t len) * is ANSI-standard. * * To force the directory data out, we try to open the directory and - * invoke fdatasync on it. This is rather non-standard, so we don't - * insist that it works, just fall back to a global sync in that case. + * invoke fdatasync and/or fsync on it. This is non-standard, so don't + * insist that it works: just fall back to a global sync in that case. * This is fairly significantly Unix-specific. Of course, on any * filesystem with synchronous metadata updates, this is unnecessary. */ -- cgit v1.2.3-54-g00ecf