Re: truncate.c fails to compile on make distcheck
Jim Meyering wrote: > Pádraig Brady <[EMAIL PROTECTED]> wrote: >> Jim Meyering wrote: >>> Here's a tentative patch: > ... >> I reviewed all uses of off_t in the code and came up with >> an almost identical patch, so I'm happy to go with the above. > > Hi Pádraig, > Thanks for checking. > Here's what I've pushed: > [I added the IF_LINT initializer] Hmm, it's probably cleaner to assign *size unconditionally, as I had done in my patch, but it doesn't really matter. I also noticed this morning that some format specifiers also assumed sizeof(off_t) == sizeof(intmax_t) and thus would print garbage off the stack if this wasn't the case. Attached is my current patch for reference. thanks, Pádraig. >From 6e44a9d43a9c88cb943c5583c63b2c81bbb17e64 Mon Sep 17 00:00:00 2001 From: =?utf-8?q?P=C3=A1draig=20Brady?= <[EMAIL PROTECTED]> Date: Wed, 25 Jun 2008 19:27:40 +0100 Subject: [PATCH] truncate: Add support for systems without large file support * src/truncate.c: don't assume off_t is same size as intmax_t Signed-off-by: Pádraig Brady <[EMAIL PROTECTED]> --- src/truncate.c | 12 1 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/truncate.c b/src/truncate.c index f26fd45..044ae4e 100644 --- a/src/truncate.c +++ b/src/truncate.c @@ -73,8 +73,12 @@ static int parse_len (char const *str, off_t *size) { enum strtol_error e; - /* OFF_T_MAX = INTMAX_MAX */ - e = xstrtoimax (str, NULL, 10, size, "EgGkKmMPtTYZ0"); + intmax_t tmp_size; /* OFF_T_MAX <= INTMAX_MAX */ + e = xstrtoimax (str, NULL, 10, &tmp_size, "EgGkKmMPtTYZ0"); + if (e == LONGINT_OK && + (tmp_size < OFF_T_MIN || tmp_size > OFF_T_MAX)) +e = LONGINT_OVERFLOW; + *size = tmp_size; errno = (e == LONGINT_OVERFLOW) ? EOVERFLOW : 0; return (e == LONGINT_OK) ? 0 : -1; } @@ -148,7 +152,7 @@ do_ftruncate (int fd, char const *fname, off_t ssize, rel_mode_t rel_mode) { error (0, 0, _("overflow in %" PRIdMAX - " * %zu byte blocks for file %s"), ssize, blksize, + " * %zu byte blocks for file %s"), (intmax_t) ssize, blksize, quote (fname)); return 1; } @@ -229,7 +233,7 @@ do_ftruncate (int fd, char const *fname, off_t ssize, rel_mode_t rel_mode) { error (0, ftruncate_errno, _("truncating %s at %" PRIdMAX " bytes"), quote (fname), - nsize); + (intmax_t) nsize); return 1; } return 0; -- 1.5.3.6 ___ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils
Re: truncate.c fails to compile on make distcheck
Pádraig Brady <[EMAIL PROTECTED]> wrote: > Jim Meyering wrote: >> Pádraig Brady <[EMAIL PROTECTED]> wrote: >>> Jim Meyering wrote: Here's a tentative patch: >> ... >>> I reviewed all uses of off_t in the code and came up with >>> an almost identical patch, so I'm happy to go with the above. >> >> Hi Pádraig, >> Thanks for checking. >> Here's what I've pushed: >> [I added the IF_LINT initializer] > > Hmm, it's probably cleaner to assign *size unconditionally, > as I had done in my patch, but it doesn't really matter. But this statement > + *size = tmp_size; would set *size to an uninitialized value upon failure. It's just that gcc doesn't detect it (yet). > I also noticed this morning that some format specifiers also > assumed sizeof(off_t) == sizeof(intmax_t) and thus would > print garbage off the stack if this wasn't the case. ... By the way, does %zu work reliably everywhere now? In the past, we've converted such values to strings via umaxtostr, to accommodate older systems. For ssize and nsize, I have a slight preference for the cast-free approach of using %s with imaxtostr. Do you feel like making those changes? > @@ -148,7 +152,7 @@ do_ftruncate (int fd, char const *fname, off_t ssize, > rel_mode_t rel_mode) > { >error (0, 0, > _("overflow in %" PRIdMAX > - " * %zu byte blocks for file %s"), ssize, blksize, > + " * %zu byte blocks for file %s"), (intmax_t) ssize, > blksize, > quote (fname)); >return 1; > } > @@ -229,7 +233,7 @@ do_ftruncate (int fd, char const *fname, off_t ssize, > rel_mode_t rel_mode) > { >error (0, ftruncate_errno, > _("truncating %s at %" PRIdMAX " bytes"), quote (fname), > - nsize); > + (intmax_t) nsize); >return 1; > } >return 0; ___ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils
Re: truncate.c fails to compile on make distcheck
Jim Meyering wrote: > By the way, does %zu work reliably everywhere now? > In the past, we've converted such values to strings via umaxtostr, > to accommodate older systems. > > For ssize and nsize, I have a slight preference for the > cast-free approach of using %s with imaxtostr. Yes I suppose %z and PRIdMAX are C99 specific. How about the attached patch? cheers, Pádraig. >From f06afe7a149c3d0340eeddd67718b3f7254a8251 Mon Sep 17 00:00:00 2001 From: =?utf-8?q?P=C3=A1draig=20Brady?= <[EMAIL PROTECTED]> Date: Thu, 26 Jun 2008 11:10:13 +0100 Subject: [PATCH] truncate: Fix portability issues with printing numbers in error messages * src/truncate.c: Remove C99 specific format specifiers, and explicitly convert from off_t to intmax_t which may be a different type. --- src/truncate.c | 12 1 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/truncate.c b/src/truncate.c index 2435a12..f5bcfdc 100644 --- a/src/truncate.c +++ b/src/truncate.c @@ -32,6 +32,7 @@ #include "system.h" #include "error.h" +#include "inttostr.h" #include "posixver.h" #include "quote.h" #include "xstrtol.h" @@ -158,9 +159,11 @@ do_ftruncate (int fd, char const *fname, off_t ssize, rel_mode_t rel_mode) size_t const blksize = ST_BLKSIZE (sb); if (ssize < OFF_T_MIN / blksize || ssize > OFF_T_MAX / blksize) { + char jbuf[INT_BUFSIZE_BOUND (intmax_t)]; + char zbuf[INT_BUFSIZE_BOUND (uintmax_t)]; error (0, 0, - _("overflow in %" PRIdMAX - " * %zu byte blocks for file %s"), ssize, blksize, + _("overflow in %s * %s byte blocks for file %s"), + imaxtostr (ssize, jbuf), umaxtostr (blksize, zbuf), quote (fname)); return 1; } @@ -239,9 +242,10 @@ do_ftruncate (int fd, char const *fname, off_t ssize, rel_mode_t rel_mode) else if (S_ISREG (sb.st_mode) || S_ISDIR (sb.st_mode) || S_TYPEISSHM (&sb)) { + char jbuf[INT_BUFSIZE_BOUND (intmax_t)]; error (0, ftruncate_errno, - _("truncating %s at %" PRIdMAX " bytes"), quote (fname), - nsize); + _("truncating %s at %s bytes"), quote (fname), + imaxtostr (nsize, jbuf)); return 1; } return 0; -- 1.5.3.6 ___ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils
6.12.70-4f470 with 64-bit gcc and gnu ld on Solaris 9 - timeout-parameters.log
compiling 6.12.70-4f470 with 64-bit gcc (with -m64) and 64-bit gnu ld on Solaris 9: === 1 of 346 tests failed (46 tests were not run) See tests/test-suite.log Please report it to bug-coreutils@gnu.org === === GNU coreutils 6.12.70-4f470: tests/test-suite.log === 1 of 346 tests failed. (46 tests were not run). .. contents:: :depth: 2 FAIL: misc/timeout-parameters.log (exit: 1) timeout-parameters.log attached. -- Yorick ___ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils
Re: 6.12.70-4f470 with 64-bit gcc and gnu ld on Solaris 9 - timeout-parameters.log
> From: Poor Yorick <> > compiling 6.12.70-4f470 with 64-bit gcc (with -m64) and 64-bit gnu ld on > Solaris 9: > > === > 1 of 346 tests failed > (46 tests were not run) > See tests/test-suite.log > Please report it to bug-coreutils@gnu.org > === > > === > GNU coreutils 6.12.70-4f470: tests/test-suite.log > === > > 1 of 346 tests failed. (46 tests were not run). > > .. contents:: :depth: 2 > > FAIL: misc/timeout-parameters.log (exit: 1) > > timeout-parameters.log attached. > *yorick remembers this time to attach the file* -- Yorick timeout-parameters.log Description: Binary data ___ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils
Re: truncate.c fails to compile on make distcheck
Pádraig Brady <[EMAIL PROTECTED]> wrote: > Jim Meyering wrote: >> By the way, does %zu work reliably everywhere now? >> In the past, we've converted such values to strings via umaxtostr, >> to accommodate older systems. >> >> For ssize and nsize, I have a slight preference for the >> cast-free approach of using %s with imaxtostr. > > Yes I suppose %z and PRIdMAX are C99 specific. > How about the attached patch? Thanks! However, I'd prefer to keep the use of PRIdMAX, since gnulib's inttypes.h replacement lets us rely on that, if you don't mind. ___ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils
Re: truncate.c fails to compile on make distcheck
Pádraig Brady <[EMAIL PROTECTED]> writes: > Yes I suppose %z and PRIdMAX are C99 specific. %z is C99 specific, and should not be relied on, but PRIdMAX is fine, since the inttypes module backports PRIdMAX to older hosts. More generally, there's not that much use for imaxtostr nowadays, since the inttypes module and newer versions of gettext allow things like _("truncating %s at %" PRIdMAX " bytes") to work portably. I suspect that (if someone cares to take the time) we can remove all instances of imaxtostr and umaxtostr in coreutils and gnulib. ___ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils
Re: Small patch for AIX & HP-UX
"Peter O'Gorman" <[EMAIL PROTECTED]> wrote: > When building coreutils-6.12 with some patches from git, we noticed that > the mkdir/selinux test fails. AIX-5.3 output: > > failed to set default file creation context to `invalid-selinux-context': > Unsupported attribute value > > The misc/shred-exact test failed on hp-ux because fdatasync failed with > EISDIR for '.' multiple times. Thanks for the reports and patches. I've applied those with minor changes. When submitting patches in the future, please look at the relatively new guidelines in HACKING. The goal is that you'd format each patches you send with something like this: git format-patch --stdout -1 > DIFF And then, I can apply (preserving authorship and file permissions, additions and removals) with a simple "git am DIFF". >From 27311c9e8544b6b11e7e86dfa1b8597ff1d9eb75 Mon Sep 17 00:00:00 2001 From: Jim Meyering <[EMAIL PROTECTED]> Date: Thu, 26 Jun 2008 10:02:32 +0200 Subject: [PATCH] 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. --- src/shred.c | 15 +-- 1 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/shred.c b/src/shred.c index bfafa96..765e1b5 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; -- 1.5.6.66.g30faa >From 58b2e1204a000fdcbdac42e427c5556dddf40aea Mon Sep 17 00:00:00 2001 From: Peter O'Gorman <[EMAIL PROTECTED]> Date: Thu, 26 Jun 2008 20:57:11 +0200 Subject: [PATCH] tests: accommodate difference in an AIX 5.3 diagnostic * tests/mkdir/selinux: Handle different strerror (ENOTSUP) spelling. --- tests/mkdir/selinux |2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/tests/mkdir/selinux b/tests/mkdir/selinux index 291d62d..4a01a43 100755 --- a/tests/mkdir/selinux +++ b/tests/mkdir/selinux @@ -43,12 +43,14 @@ for cmd_w_arg in 'mkdir dir' 'mknod b p' 'mkfifo f'; do # Some systems fail with ENOTSUP, EINVAL, ENOENT, or even # "Unknown system error", or "Function not implemented". + # For AIX 5.3: "Unsupported attribute value" sed \ -e 's/ Not supported$//' \ -e 's/ Invalid argument$//'\ -e 's/ Unknown system error$//'\ -e 's/ Operation not supported$//' \ -e 's/ Function not implemented$//'\ +-e 's/ Unsupported attribute value$//' \ -e 's/ No such file or directory$//' out > k || fail=1 mv k out || fail=1 compare out exp || fail=1 -- 1.5.6.66.g30faa ___ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils
Re: truncate.c fails to compile on make distcheck
Paul Eggert <[EMAIL PROTECTED]> wrote: > Pádraig Brady <[EMAIL PROTECTED]> writes: > >> Yes I suppose %z and PRIdMAX are C99 specific. > > %z is C99 specific, and should not be relied on, but PRIdMAX is fine, > since the inttypes module backports PRIdMAX to older hosts. > > More generally, there's not that much use for imaxtostr nowadays, > since the inttypes module and newer versions of gettext allow things > like _("truncating %s at %" PRIdMAX " bytes") to work portably. > I suspect that (if someone cares to take the time) we can remove > all instances of imaxtostr and umaxtostr in coreutils and gnulib. Good point. I've just added your second paragraph to TODO. ___ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils
Re: truncate.c fails to compile on make distcheck
Jim Meyering wrote: > Pádraig Brady <[EMAIL PROTECTED]> wrote: >> Jim Meyering wrote: >>> By the way, does %zu work reliably everywhere now? >>> In the past, we've converted such values to strings via umaxtostr, >>> to accommodate older systems. >>> >>> For ssize and nsize, I have a slight preference for the >>> cast-free approach of using %s with imaxtostr. >> Yes I suppose %z and PRIdMAX are C99 specific. >> How about the attached patch? > > Thanks! > However, I'd prefer to keep the use of PRIdMAX, > since gnulib's inttypes.h replacement lets us rely on that, > if you don't mind. I'm a little confused. Did you change your mind and you now want to keep the (intmax_t) cast in my original patch? I also noticed that the use of size_t is buggy anyway in conjunction with off_t, so I've changed that. thanks, Pádraig. >From ee15430cb9b0de578269262ee149aa9350184354 Mon Sep 17 00:00:00 2001 From: =?utf-8?q?P=C3=A1draig=20Brady?= <[EMAIL PROTECTED]> Date: Thu, 26 Jun 2008 11:10:13 +0100 Subject: [PATCH] truncate: Fix integer portability issues * src/truncate.c: Explicitly convert from off_t to intmax_t when printing numbers as they may be different types. Also don't mix size_t and off_t types in operations as the latter will be promoted to unsigned when these types are the same size. --- src/truncate.c |7 --- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/truncate.c b/src/truncate.c index 2435a12..02d4102 100644 --- a/src/truncate.c +++ b/src/truncate.c @@ -155,12 +155,13 @@ do_ftruncate (int fd, char const *fname, off_t ssize, rel_mode_t rel_mode) } if (block_mode) { - size_t const blksize = ST_BLKSIZE (sb); + off_t const blksize = ST_BLKSIZE (sb); if (ssize < OFF_T_MIN / blksize || ssize > OFF_T_MAX / blksize) { error (0, 0, _("overflow in %" PRIdMAX - " * %zu byte blocks for file %s"), ssize, blksize, + " * %" PRIdMAX " byte blocks for file %s"), + (intmax_t) ssize, (intmax_t) blksize, quote (fname)); return 1; } @@ -241,7 +242,7 @@ do_ftruncate (int fd, char const *fname, off_t ssize, rel_mode_t rel_mode) { error (0, ftruncate_errno, _("truncating %s at %" PRIdMAX " bytes"), quote (fname), - nsize); + (intmax_t) nsize); return 1; } return 0; -- 1.5.3.6 ___ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils
Re: 6.12.70-4f470 with 64-bit gcc and gnu ld on Solaris 9 - timeout-parameters.log
Poor Yorick wrote: > compiling 6.12.70-4f470 with 64-bit gcc (with -m64) and 64-bit gnu ld on > Solaris 9: So on this system `timeout 4294967296 sleep 0` is invalid but `timeout 49711d sleep 0` is OK? The apply_time_suffix() function should be returning an error for the latter case but is not. I can't see the problem by inspection, so I need help from someone with a 64 bit system. I also noticed a couple of other problems in those parameter tests, fixes for which are attached. cheers, Pádraig. >From 1d974563bccae68c9b15c4b9df30b4d65bb2fb11 Mon Sep 17 00:00:00 2001 From: =?utf-8?q?P=C3=A1draig=20Brady?= <[EMAIL PROTECTED]> Date: Thu, 26 Jun 2008 23:09:28 +0100 Subject: [PATCH] timeout: fixup invalid parameter tests tests/misc/timeout-parameters: remove test for invalid signal number and I don't know what signal number are invalid on all systems. Also tweak the other invalid signal check so that the rest of the parameters are correct. --- tests/misc/timeout-parameters |5 + 1 files changed, 1 insertions(+), 4 deletions(-) diff --git a/tests/misc/timeout-parameters b/tests/misc/timeout-parameters index 091fbd7..e44ff98 100755 --- a/tests/misc/timeout-parameters +++ b/tests/misc/timeout-parameters @@ -41,10 +41,7 @@ timeout 4294967296 sleep 0 && fail=1 timeout 49711d sleep 0 && fail=1 # invalid signal spec -timeout --signal=invalid sleep 0 && fail=1 - -# invalid signal number -timeout --signal=128 sleep 0 && fail=1 +timeout --signal=invalid 1 sleep 0 && fail=1 # invalid command timeout 1 . && fail=1 -- 1.5.3.6 ___ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils
Re: truncate.c fails to compile on make distcheck
Jim Meyering asked: > By the way, does %zu work reliably everywhere now? gnulib's documentation contains the answer. From doc/posix-functions/printf.texi: This function does not support size specifiers as in C99 (@code{hh}, @code{ll}, @code{j}, @code{t}, @code{z}) on some platforms: AIX 5.1, HP-UX 11.23, IRIX 6.5, OSF/1 5.1, Solaris 9, Cygwin 2006, mingw, BeOS. Bruno ___ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils
Re: cp -p fails from zfs file system to other file system
Fabrizio Gabbiani wrote: > cp: preserving permissions for `/localdirectory/targetfile': Operation not > supported This is likely a consequence of the recent ACL related changes. ("cp -p" now attempts to copy the ACLs.) To make it easier for us to fix the issue, can you please say: - What is your syetem type? (Linux or Solaris? Which version?) - Can you show a trace of the library or system calls of the "cp -p ..." command? (ltrace on Linux, truss on Solaris.) - The output of "nm cp | grep acl" ? Thanks for your help. Bruno ___ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils
Re: truncate.c fails to compile on make distcheck
Pádraig Brady <[EMAIL PROTECTED]> wrote: > Jim Meyering wrote: >> Pádraig Brady <[EMAIL PROTECTED]> wrote: >>> Jim Meyering wrote: By the way, does %zu work reliably everywhere now? In the past, we've converted such values to strings via umaxtostr, to accommodate older systems. For ssize and nsize, I have a slight preference for the cast-free approach of using %s with imaxtostr. >>> Yes I suppose %z and PRIdMAX are C99 specific. >>> How about the attached patch? >> >> Thanks! >> However, I'd prefer to keep the use of PRIdMAX, >> since gnulib's inttypes.h replacement lets us rely on that, >> if you don't mind. > > I'm a little confused. Did you change your mind and you > now want to keep the (intmax_t) cast in my original patch? Sorry. I'm the one who was confused. The patch below is perfect. > I also noticed that the use of size_t is buggy anyway > in conjunction with off_t, so I've changed that. Good catch. >>From ee15430cb9b0de578269262ee149aa9350184354 Mon Sep 17 00:00:00 2001 > From: =?utf-8?q?P=C3=A1draig=20Brady?= <[EMAIL PROTECTED]> > Date: Thu, 26 Jun 2008 11:10:13 +0100 > Subject: [PATCH] truncate: Fix integer portability issues ... ___ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils