summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2015-06-05 17:33:54 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2015-06-06 00:46:13 -0700
commit079652ee6b5d3987525ce225518a15253fc9d319 (patch)
treec2a88e9eb7e42aa802dd9312cb80c70872a9fbfc /src
parent95413f7dff7ccc0595c93c30850446b8ea4d2f49 (diff)
downloadcoreutils-079652ee6b5d3987525ce225518a15253fc9d319.tar.xz
build: port to AIX
Problems reported by Michael Felt, and and part of this fix taken from code suggested by Pádraig Brady in: http://bugs.gnu.org/20733#112 * configure.ac (stdbuf_supported): Check for warnings, and for -fPIC and -shared, for AIX. * src/stat.c (STRUCT_STATVFS): Define to struct statvfs64 if STATFS is statvfs64. * src/sync.c (sync_arg) [_AIX]: Open in write mode, since AIX fsync doesn't work on read-only file descriptors. * tests/misc/wc-parallel.sh: Skip test if xargs -P does not work.
Diffstat (limited to 'src')
-rw-r--r--src/stat.c3
-rw-r--r--src/sync.c18
2 files changed, 16 insertions, 5 deletions
diff --git a/src/stat.c b/src/stat.c
index 4b5aff71f..6d2366539 100644
--- a/src/stat.c
+++ b/src/stat.c
@@ -74,15 +74,16 @@
#include "xvasprintf.h"
#if USE_STATVFS
-# define STRUCT_STATVFS struct statvfs
# define STRUCT_STATXFS_F_FSID_IS_INTEGER STRUCT_STATVFS_F_FSID_IS_INTEGER
# define HAVE_STRUCT_STATXFS_F_TYPE HAVE_STRUCT_STATVFS_F_TYPE
# if HAVE_STRUCT_STATVFS_F_NAMEMAX
# define SB_F_NAMEMAX(S) ((S)->f_namemax)
# endif
# if ! STAT_STATVFS && STAT_STATVFS64
+# define STRUCT_STATVFS struct statvfs64
# define STATFS statvfs64
# else
+# define STRUCT_STATVFS struct statvfs
# define STATFS statvfs
# endif
# define STATFS_FRSIZE(S) ((S)->f_frsize)
diff --git a/src/sync.c b/src/sync.c
index 85d77c092..5e1dbb8c6 100644
--- a/src/sync.c
+++ b/src/sync.c
@@ -91,24 +91,34 @@ static bool
sync_arg (enum sync_mode mode, char const *file)
{
bool ret = true;
+ int open_flags = O_RDONLY | O_NONBLOCK;
int fd;
+#ifdef _AIX
+ /* AIX 7.1 fsync requires write access to file. */
+ if (mode == MODE_FILE)
+ open_flags = O_WRONLY | O_NONBLOCK;
+#endif
+
/* Note O_PATH might be supported with syncfs(),
though as of Linux 3.18 is not. */
- if ((fd = open (file, O_RDONLY | O_NONBLOCK)) < 0)
+ fd = open (file, open_flags);
+ if (fd < 0)
{
/* Use the O_RDONLY errno, which is significant
with directories for example. */
int rd_errno = errno;
- if ((fd = open (file, O_WRONLY | O_NONBLOCK)) < 0)
+ if (open_flags != (O_WRONLY | O_NONBLOCK))
+ fd = open (file, O_WRONLY | O_NONBLOCK);
+ if (fd < 0)
error (0, rd_errno, _("error opening %s"), quote (file));
return false;
}
/* We used O_NONBLOCK above to not hang with fifos,
so reset that here. */
- int fdflags;
- if ((fdflags = fcntl (fd, F_GETFL)) == -1
+ int fdflags = fcntl (fd, F_GETFL);
+ if (fdflags == -1
|| fcntl (fd, F_SETFL, fdflags & ~O_NONBLOCK) < 0)
{
error (0, errno, _("couldn't reset non-blocking mode %s"), quote (file));