new snapshot available: coreutils-7.6.63-addb6

2009-10-03 Thread Jim Meyering
There have been *many* changes in gnulib since the previous snapshot,
and the changes in coreutils are non-negligible, so please give
this a try.  I'd like to make the beta release on Monday.
I'll probably call it coreutils-8.0.


coreutils snapshot:
  http://meyering.net/cu/coreutils-ss.tar.gz  9.8 MB
  http://meyering.net/cu/coreutils-ss.tar.xz  4.1 MB
  http://meyering.net/cu/coreutils-ss.tar.gz.sig
  http://meyering.net/cu/coreutils-ss.tar.xz.sig
aka
  http://meyering.net/cu/coreutils-7.6.63-addb6.tar.gz
  http://meyering.net/cu/coreutils-7.6.63-addb6.tar.xz

Changes in coreutils since 7.6.24-99f59a:

Eric Blake (7):
  build: avoid compiler warnings on cygwin 1.5
  readlink: pick up gnulib changes to readlink -f
  maint: summarize gnulib changes
  build: update gnulib submodule to latest
  build: update gnulib submodule to latest
  ln: add -L/-P options
  cp, mv: use linkat to guarantee semantics

James R. Van Zandt (1):
  dircolors: highlight .cgm and .emf as images

Jim Meyering (20):
  dircolors: arrange to highlight names with the .lz suffix
  maint: automate the web-doc updating procedure
  doc: ls: add an article, "the"
  build: update gnulib submodule to latest
  maint: df.c: adapt to newer gnulib
  doc: ls: further improve --help message re --color
  maint: factor coreutils-specific code out of bootstrap
  ls: with -LR, exit with status 2 upon detecting a cycle
  ls: print "?", not "0" as inode of dereferenced dangling symlink
  ls: don't use an undefined struct stat after failed stat/lstat
  stat: interpret "-" as standard input
  build: use gnulib's freopen module
  build: now that we use the lock module, don't exclude lock.m4
  build: translate diagnostics from two new files
  build: update gnulib submodule to latest
  tests: tail-2/pid: use a 3-second timeout, not 1
  build: update gnulib submodule to latest
  maint: move gnu-web-doc-update script to gnulib
  maint: remove obsolete syntax-check exclusion
  build: update gnulib submodule to latest

Pádraig Brady (11):
  doc: mention the texinfo documentation in --help
  doc: normalize and add missing entries to texinfo menu
  doc: ls: make help for --color more concise and accurate
  ls: handle disabling of colors consistently for all tile types
  ls: fix a performance regression
  maint: uptime: fix a theoretical compile warning
  doc: stdbuf: mention it can have a non standard exit status
  maint: expr: avoid compiler warnings without GMP
  maint: Use logical rather than bitwise operators on bools
  ls: always print "?" for allocated size of a dereferenced dangling symlink
  tail: avoid a race where we could miss new data with --pid


Changes in gnulib since 7.6.24-99f59a:

* gnulib 6c9f1e8...881b91b (119):
  > fchdir: avoid compiler warning
  > test-open: support mingw errno values
  > open: fix opening directory on mingw
  > test-open: on GNU/Hurd, /dev/null is a directory
  > maint: cleanup whitespace in recent commits
  > rename, fchdir: don't ignore chdir failure
  > maint: cleanup whitespace in recent commits
  > relocatable-prog-wrapper: Add missing dependency on double-slash-root.
  > renameat: fix Solaris bugs
  > renameat: new module
  > rename: fix mingw bugs
  > rename: fix another cygwin 1.5 bug
  > rename-dest-slash: merge into rename module
  > rename: fix cygwin 1.5.x bugs
  > rename: fix Solaris 10 bug
  > rename: fix Solaris 9 bug
  > rename-dest-slash: fix NetBSD bug
  > rename-tests: new test, exposes several platform bugs
  > Assume version info is available.
  > gnu-web-doc-update: correct --help output
  > gnu-web-doc-update: add standard options
  > gnu-web-doc-update: New module.
  > link: LoadLibrary is not needed.
  > getopt: bump serial number
  > tests: tighten link, rmdir, and remove tests
  > maint.mk: requiring "make major" was annoying, for a "minor" release.
  > Fix broken build of replacement for Windows tmpfile().
  > Avoid identifier clash with POSIX function 'remove' defined as a macro.
  > doc: mention yet more cygwin 1.7 status
  > argp: fix test failure
  > test-yesno: work around sparc-dash here-document infelicity
  > Disable untested support for new flavours of ACLs on AIX.
  > Typo in comment.
  > Add support for new flavours of ACLs on AIX. (Untested.)
  > argp: fix compilation of getopt
  > doc: mention more cygwin 1.7 status
  > autoupdate
  > test-linkat: make test more robust
  > getopt: fix inclusion guards for cygwin
  > same-inode: revert prior change; it is not yet ready
  > linkat: new module
  > dirname: add library-safe mdir_name
  > fchdir: another mingw fix
  > same-inode: make SAME_INODE tri-state, to port to mingw
  > lstat: avoid mingw compilation error
  > autoupdate
  > link: fix test failure on Solaris 9
  > test-symlinkat: enhance test
  > readlink: document portability issue with symlink length
  > readlink: fix 

Re: new snapshot available: coreutils-7.6.63-addb6

2009-10-03 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

According to Jim Meyering on 10/3/2009 2:30 AM:
> There have been *many* changes in gnulib since the previous snapshot,
> and the changes in coreutils are non-negligible, so please give
> this a try.  I'd like to make the beta release on Monday.
> I'll probably call it coreutils-8.0.

I'm still wondering if we want one more patch: now that we document that

 readlink -f link/

succeeds, with the claim that 'mkdir link/' will also succeed, we should
make sure of that.  Right now, Solaris systems work (mkdir(2) follows
POSIX), but GNU/Linux reject it (since mkdir(2) fails with EEXIST on a
slashed symlink).

What's worse, I wonder if we have a bug on Solaris:

$ rm -Rf ?
$ ln -s a b
$ mkdir -p b/c
mkdir: cannot create directory `b': File exists
$ mkdir b/
$ mkdir b/c

or if it is a bug in POSIX, since it describes mkdir -p in terms of
"$(dirname dir)" rather than "$(dirname dir)/".  The native Solaris
/bin/mkdir also fails with mkdir -p b/c, but with ENOENT.

- --
Don't work too hard, make some time for fun as well!

Eric Blake e...@byu.net
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkrH1EsACgkQ84KuGfSFAYCmaACbBhcqzRFLpnZSo4A0z34ChWZL
TeMAn3Yz03L3srsPAEmxOkSWKWNmG7QT
=K2DB
-END PGP SIGNATURE-




Re: new snapshot available: coreutils-7.6.63-addb6

2009-10-04 Thread Jim Meyering
Eric Blake wrote:
> According to Jim Meyering on 10/3/2009 2:30 AM:
>> There have been *many* changes in gnulib since the previous snapshot,
>> and the changes in coreutils are non-negligible, so please give
>> this a try.  I'd like to make the beta release on Monday.
>> I'll probably call it coreutils-8.0.
>
> I'm still wondering if we want one more patch: now that we document that
>
>  readlink -f link/
>
> succeeds, with the claim that 'mkdir link/' will also succeed, we should
> make sure of that.

Yes, adding a test would be good.

> Right now, Solaris systems work (mkdir(2) follows
> POSIX), but GNU/Linux reject it (since mkdir(2) fails with EEXIST on a
> slashed symlink).

Such a test would be expected to fail on Linux.
It's tempting to say "let's make mkdir(1) work around it",
but I would like to avoid adding any more uses of
canonicalize_* functions, due to their inherent problems.

If you feel like addressing that right away, that would
be great.  Otherwise, I think it's safe to say that no one
will complain if it is deferred until 8.1.

Or, we could simply document the situation, changing the readlink(1)
claim to defer to "POSIX-conforming mkdir(2)" semantics.

> What's worse, I wonder if we have a bug on Solaris:
>
> $ rm -Rf ?
> $ ln -s a b
> $ mkdir -p b/c
> mkdir: cannot create directory `b': File exists
> $ mkdir b/
> $ mkdir b/c
>
> or if it is a bug in POSIX, since it describes mkdir -p in terms of
> "$(dirname dir)" rather than "$(dirname dir)/".  The native Solaris
> /bin/mkdir also fails with mkdir -p b/c, but with ENOENT.

Interesting.
That shows how dark and dusty this particular corner of the standard is.




Re: new snapshot available: coreutils-7.6.63-addb6

2009-10-04 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

According to Jim Meyering on 10/4/2009 2:10 AM:
>>  readlink -f link/
>>
>> succeeds, with the claim that 'mkdir link/' will also succeed, we should
>> make sure of that.
> 
> Yes, adding a test would be good.
> Such a test would be expected to fail on Linux.
> It's tempting to say "let's make mkdir(1) work around it",

and you even suggested that:
http://lists.gnu.org/archive/html/bug-coreutils/2009-09/msg00365.html

> but I would like to avoid adding any more uses of
> canonicalize_* functions, due to their inherent problems.
> 
> If you feel like addressing that right away, that would
> be great.  Otherwise, I think it's safe to say that no one
> will complain if it is deferred until 8.1.

At this point, it's enough of a corner case that I'm okay deferring any
mkdir(1) (or even mkdir(2) cleanups in gnulib) until after coreutils 8.0.
  No point adding a test if we don't even know what behavior we want to
promise.  So all that remains before 8.0 is:

> Or, we could simply document the situation, changing the readlink(1)
> claim to defer to "POSIX-conforming mkdir(2)" semantics.

Yes, we need to tweak the NEWS to clarify that the new readlink(1)
behavior does not (yet) match mkdir(1) behavior on Linux.

>> $ rm -Rf ?
>> $ ln -s a b
>> $ mkdir -p b/c
>> mkdir: cannot create directory `b': File exists
>> $ mkdir b/
>> $ mkdir b/c
>>
>> or if it is a bug in POSIX, since it describes mkdir -p in terms of
>> "$(dirname dir)" rather than "$(dirname dir)/".  The native Solaris
>> /bin/mkdir also fails with mkdir -p b/c, but with ENOENT.
> 
> Interesting.

I also noticed that 'mkdir -p dangling/' works, only 'mkdir -p
dangling/sub' fails.  So I went ahead and spawned a bug report against
POSIX; we'll see how it fares.  By the way, it is rather difficult to
strip exactly one byte from the end of input using only POSIX commands,
since 'head -c -1' is not standardized:
http://austingroupbugs.net/view.php?id=161
http://www.opengroup.org/austin/mailarchives/ag/msg41004.html
http://www.opengroup.org/austin/mailarchives/ag/msg41002.html
http://www.opengroup.org/austin/mailarchives/ag/msg41003.html

I ended up with the following monstrosity as a shell-based representation
for what I'm proposing as the equivalent for 'mkdir [-m mode] -p "$dir"':

mkdir -p -m $(umask -S),u+wx "$(dirname "$dir" |
  dd bs=1 count=$(($(dirname "$dir"|wc -c) - 1)) 2>/dev/null; echo /)" &&
mkdir [-m mode] "$dir"

- --
Don't work too hard, make some time for fun as well!

Eric Blake e...@byu.net
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkrIsVAACgkQ84KuGfSFAYB/sgCgiBXZaX3pWWFXchhGCwD489bq
IdEAoNlz56dKWFBH28tlrtD46dKGA9Vm
=gL9X
-END PGP SIGNATURE-




Re: new snapshot available: coreutils-7.6.63-addb6

2009-10-04 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

According to Eric Blake on 10/4/2009 8:29 AM:
>> If you feel like addressing that right away, that would
>> be great.  Otherwise, I think it's safe to say that no one
>> will complain if it is deferred until 8.1.
> 
> At this point, it's enough of a corner case that I'm okay deferring any
> mkdir(1) (or even mkdir(2) cleanups in gnulib) until after coreutils 8.0.

For the record, I tried the quick hack below to change things in just
coreutils for 'mkdir -p' (without even touching plain 'mkdir' for Linux),
all without modifying gnulib.  But it still fails on Solaris, because
gnulib's make_dir_parents fails on savewd_chdir if the trailing slash is
not present on a symlink to a directory.  So since fixing this requires
gnulib tweaks, and is more invasive than I originally suspected, I'd feel
more comfortable waiting for the Austin group ruling on mkdir -p before
changing any behavior.

- --
Don't work too hard, make some time for fun as well!

Eric Blake e...@byu.net
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkrIupwACgkQ84KuGfSFAYAdMgCgj7tYc5uetn1VADy+ENvlRnro
1YUAnjrNYenWD/EZ6dqlPGCiNY/qJi9V
=yJGI
-END PGP SIGNATURE-
diff --git a/NEWS b/NEWS
index aff0744..fe287f6 100644
--- a/NEWS
+++ b/NEWS
@@ -40,6 +40,9 @@ GNU coreutils NEWS-*- 
outline -*-
   id no longer prints SELinux " context=..." when the POSIXLY_CORRECT
   environment variable is set.

+  mkdir now reliably creates a directory through a dangling symlink
+  given with a trailing slash.
+
   readlink -f now ignores a trailing slash when deciding if the
   last component (possibly via a dangling symlink) can be created,
   since mkdir will succeed in that case.
diff --git a/src/mkdir.c b/src/mkdir.c
index 756cc40..ffdc0b1 100644
--- a/src/mkdir.c
+++ b/src/mkdir.c
@@ -29,6 +29,7 @@
 #include "prog-fprintf.h"
 #include "quote.h"
 #include "savewd.h"
+#include "canonicalize.h"

 /* The official name of this program (e.g., no `g' prefix).  */
 #define PROGRAM_NAME "mkdir"
@@ -105,6 +106,36 @@ announce_mkdir (char const *dir, void *options)
 prog_fprintf (stdout, o->created_directory_format, quote (dir));
 }

+/* Create an ancestor directory DIR with the given MODE.  If DIR is a
+   symlink, guarantee the POSIX semantics as if we had called
+   mkdir(DIR/).  */
+static int
+mkdir_follow (char const *dir, mode_t mode)
+{
+  int r = mkdir (dir, mode);
+  int saved_errno = errno;
+  if (r && saved_errno == EEXIST)
+{
+  /* If "dir" is a dangling symlink, create a directory at the
+ location pointed to by the link so that "dir/" will
+ resolve.  */
+  struct stat st;
+  if (stat (dir, &st) == -1 && errno == ENOENT)
+{
+  char *target = canonicalize_filename_mode (dir, CAN_ALL_BUT_LAST);
+  if (target)
+{
+  int saved_errno;
+  r = mkdir (target, mode);
+  saved_errno = errno;
+  free (target);
+}
+}
+}
+  errno = saved_errno;
+  return r;
+}
+
 /* Make ancestor directory DIR, whose last component is COMPONENT,
with options OPTIONS.  Assume the working directory is COMPONENT's
parent.  Return 0 if successful and the resulting directory is
@@ -114,7 +145,7 @@ static int
 make_ancestor (char const *dir, char const *component, void *options)
 {
   struct mkdir_options const *o = options;
-  int r = mkdir (component, o->ancestor_mode);
+  int r = mkdir_follow (component, o->ancestor_mode);
   if (r == 0)
 {
   r = ! (o->ancestor_mode & S_IRUSR);
diff --git a/tests/mkdir/p-thru-slink b/tests/mkdir/p-thru-slink
index 30df4fe..a1e792a 100755
--- a/tests/mkdir/p-thru-slink
+++ b/tests/mkdir/p-thru-slink
@@ -24,9 +24,14 @@ fi
 . $srcdir/test-lib.sh

 ln -s . slink || framework_failure
+ln -s dir slink2 || framework_failure

 fail=0
 mkdir -p slink/x || fail=1
 test -d x || fail=1

+# This test failed on GNU/Linux through coreutils 7.6.
+mkdir -p slink2/x || fail=1
+test -d dir/x || fail=1
+
 Exit $fail
diff --git a/tests/mkdir/t-slash b/tests/mkdir/t-slash
index 3214bf4..128fecd 100755
--- a/tests/mkdir/t-slash
+++ b/tests/mkdir/t-slash
@@ -33,4 +33,9 @@ test -d dir || fail=1
 mkdir d2/ || fail=1
 test -d d2 || fail=1

+# This test failed on GNU/Linux through coreutils 7.6.
+ln -s d3 link || framework_failure
+mkdir link/ || fail=1
+test -d d3 || fail=1
+
 Exit $fail


Re: new snapshot available: coreutils-7.6.63-addb6

2009-10-05 Thread Pádraig Brady
   Passed Skipped Failed
  \-
Fedora core 5 x86 |   352  43  1
Fedora 11 x86 |   351  45  0
Solaris 10 x86|   334  62  0
Solaris 9  x86|   331  64  1

FC5 test failure:
  ln/hard-to-sym
ln -P -L symlink3 hard-to-a
  ln: creating hard link `hard-to-a' => `symlink3': Invalid argument

Solaris builds fail with:
  Undefined   first referenced
   symbol in file
  eaccess ../lib/libcoreutils.a(euidaccess.o)
I worked around by undefining HAVE_EACCESS

Solaris 9 test failure (same as for coreutils 7.6)
  mv/part-symlink
mv loc_reg rem_sl
 mv: preserving permissions for `rem_sl': Invalid argument
   facl(4, SETACL, 4, 0x08097FA0) -> Err#22 EINVAL

cheers,
Pádraig.




Re: new snapshot available: coreutils-7.6.63-addb6

2009-10-05 Thread Jim Meyering
Pádraig Brady wrote:
>Passed Skipped Failed
>   \-
> Fedora core 5 x86 |   352  43  1
> Fedora 11 x86 |   351  45  0
> Solaris 10 x86|   334  62  0
> Solaris 9  x86|   331  64  1

Thanks for the testing!

> FC5 test failure:
>   ln/hard-to-sym
> ln -P -L symlink3 hard-to-a
>   ln: creating hard link `hard-to-a' => `symlink3': Invalid argument

This is a new test, but FC5 is s old,
that I'm not sure it's worth worrying about.

> Solaris builds fail with:
>   Undefined   first referenced
>symbol in file
>   eaccess ../lib/libcoreutils.a(euidaccess.o)

Can you look into why that failed?
I have just reconfirmed that the build succeeds for me on Solaris 10.

> I worked around by undefining HAVE_EACCESS
>
> Solaris 9 test failure (same as for coreutils 7.6)
>   mv/part-symlink
> mv loc_reg rem_sl
>  mv: preserving permissions for `rem_sl': Invalid argument
>facl(4, SETACL, 4, 0x08097FA0) -> Err#22 EINVAL
>
> cheers,
> Pádraig.




Re: new snapshot available: coreutils-7.6.63-addb6

2009-10-05 Thread Pádraig Brady
Jim Meyering wrote:
> Pádraig Brady wrote:
>>Passed Skipped Failed
>>   \-
>> Fedora core 5 x86 |   352  43  1
>> Fedora 11 x86 |   351  45  0
>> Solaris 10 x86|   334  62  0
>> Solaris 9  x86|   331  64  1
> 
> Thanks for the testing!
> 
>> FC5 test failure:
>>   ln/hard-to-sym
>> ln -P -L symlink3 hard-to-a
>>   ln: creating hard link `hard-to-a' => `symlink3': Invalid argument
> 
> This is a new test, but FC5 is s old,
> that I'm not sure it's worth worrying about.

March 2006?

>> Solaris builds fail with:
>>   Undefined   first referenced
>>symbol in file
>>   eaccess ../lib/libcoreutils.a(euidaccess.o)
> 
> Can you look into why that failed?
> I have just reconfirmed that the build succeeds for me on Solaris 10.

Hrm 7.6 builds fine here.

But with the latest snapshot the linker here looks like
it needs $LIB_EACCESS for all binaries.
I notice that euidaccess() is newly referenced by faccessat.c
Could that be the cause?

cheers,
Pádraig.




Re: new snapshot available: coreutils-7.6.63-addb6

2009-10-05 Thread Jim Meyering
Pádraig Brady wrote:

> Jim Meyering wrote:
>> Pádraig Brady wrote:
>>>Passed Skipped Failed
>>>   \-
>>> Fedora core 5 x86 |   352  43  1
>>> Fedora 11 x86 |   351  45  0
>>> Solaris 10 x86|   334  62  0
>>> Solaris 9  x86|   331  64  1
>>
>> Thanks for the testing!
>>
>>> FC5 test failure:
>>>   ln/hard-to-sym
>>> ln -P -L symlink3 hard-to-a
>>>   ln: creating hard link `hard-to-a' => `symlink3': Invalid argument
>>
>> This is a new test, but FC5 is s old,
>> that I'm not sure it's worth worrying about.
>
> March 2006?

The failure is probably a function of the kernel.
Which is it?

>>> Solaris builds fail with:
>>>   Undefined   first referenced
>>>symbol in file
>>>   eaccess ../lib/libcoreutils.a(euidaccess.o)
>>
>> Can you look into why that failed?
>> I have just reconfirmed that the build succeeds for me on Solaris 10.
>
> Hrm 7.6 builds fine here.
>
> But with the latest snapshot the linker here looks like
> it needs $LIB_EACCESS for all binaries.
> I notice that euidaccess() is newly referenced by faccessat.c
> Could that be the cause?

I wonder why it works for me and not for you.




Re: new snapshot available: coreutils-7.6.63-addb6

2009-10-05 Thread Eric Blake
Pádraig Brady  draigBrady.com> writes:

> FC5 test failure:
>   ln/hard-to-sym
> ln -P -L symlink3 hard-to-a
>   ln: creating hard link `hard-to-a' => `symlink3': Invalid argument

I'd be interested in the strace of
  ln -P -L symlink3 hard-to-a
as well as 'grep LINK_FOLLOWS config.log'.  It may be that the new gnulib 
linkat module can still work around this.

-- 
Eric Blake






Re: new snapshot available: coreutils-7.6.63-addb6

2009-10-05 Thread Pádraig Brady
Jim Meyering wrote:
> Pádraig Brady wrote:
> 
>> Jim Meyering wrote:
>>> Pádraig Brady wrote:
Passed Skipped Failed
   \-
 Fedora core 5 x86 |   352  43  1
 Fedora 11 x86 |   351  45  0
 Solaris 10 x86|   334  62  0
 Solaris 9  x86|   331  64  1
>>> Thanks for the testing!
>>>
 FC5 test failure:
   ln/hard-to-sym
 ln -P -L symlink3 hard-to-a
   ln: creating hard link `hard-to-a' => `symlink3': Invalid argument
>>> This is a new test, but FC5 is s old,
>>> that I'm not sure it's worth worrying about.
>> March 2006?
> 
> The failure is probably a function of the kernel.
> Which is it?

Right I was just looking at this.
I think it's an issue with the test rather than ln,
so you're right in it not requiring a fix. Saying
that though, we should probably at some stage skip
that part of the test rather than failing.

In summary this is what fails:

$ touch a
$ ln -s a symlink
$ ln -L symlink hardlink
ln: creating hard link `hardlink' => `symlink': Invalid argument

`man linkat` says that AT_SYMLINK_FOLLOW is only supported since 2.6.18
and my FC5 system is 2.6.17

> 
 Solaris builds fail with:
   Undefined   first referenced
symbol in file
   eaccess ../lib/libcoreutils.a(euidaccess.o)
>>> Can you look into why that failed?
>>> I have just reconfirmed that the build succeeds for me on Solaris 10.
>> Hrm 7.6 builds fine here.
>>
>> But with the latest snapshot the linker here looks like
>> it needs $LIB_EACCESS for all binaries.
>> I notice that euidaccess() is newly referenced by faccessat.c
>> Could that be the cause?
> 
> I wonder why it works for me and not for you.

I'll have another quick look tommorrow.

cheers,
Pádraig.





Re: new snapshot available: coreutils-7.6.63-addb6

2009-10-05 Thread Pádraig Brady
Eric Blake wrote:
> Pádraig Brady  draigBrady.com> writes:
> 
>> FC5 test failure:
>>   ln/hard-to-sym
>> ln -P -L symlink3 hard-to-a
>>   ln: creating hard link `hard-to-a' => `symlink3': Invalid argument
> 
> I'd be interested in the strace of
>   ln -P -L symlink3 hard-to-a

attached

> as well as 'grep LINK_FOLLOWS config.log'.  It may be that the new gnulib 
> linkat module can still work around this.
> 

grep LINK_FOLLOWS config.log | uniq -c
 76 | #define LINK_FOLLOWS_SYMLINKS 0
  1 #define LINK_FOLLOWS_SYMLINKS 0

cheers,
Pádraig.
__libc_start_main(0x8049e90, 4, 0xbfee8b14, 0x804e7d0, 0x804e7c8 
strrchr("ln", '/')  
= NULL
setlocale(6, "")
= "en_US.UTF-8"
bindtextdomain("coreutils", "/usr/local/share/locale")  
= "/usr/local/share/locale"
textdomain("coreutils") 
= "coreutils"
__cxa_atexit(0x804b6c0, 0, 0, 0x894ff4, 0xbfee8a78) 
= 0
getenv("SIMPLE_BACKUP_SUFFIX")  
= NULL
getopt_long(4, 0xbfee8b14, "bdfinst:vFLPS:T", 0x804f7a0, NULL)  
= 76
getopt_long(4, 0xbfee8b14, "bdfinst:vFLPS:T", 0x804f7a0, NULL)  
= -1
strlen("hardlink")  
= 8
__xstat64(3, "hardlink", 0xbfee8a04)
= -1
__errno_location()  
= 0xb7f2b68c
__xstat64(3, "symlink", 0xbfee893c) 
= 0
linkat(-100, 0xbfee8d3e, -100, 0xbfee8d46, 1024)
= -1
__errno_location()  
= 0xb7f2b68c
__errno_location()  
= 0xb7f2b68c
realloc(NULL, 16)   
= 0x8f13878
memset(0x8f13880, '\000', 8)
= 0x8f13880
__ctype_get_mb_cur_max(1, 0x894ff4, 2, 0, 0xbfee8784)   
= 6
dcgettext(0, 0x804fd62, 5, 0xbfee8d3e, 0)   
= 0x804fd62
dcgettext(0, 0x80500e4, 5, 0xbfee8d3e, 0)   
= 0x80500e4
strlen("'") 
= 1
free(NULL)  
= 
malloc(10)  
= 0x8f13890
__ctype_get_mb_cur_max(16, 0x896128, 2, 0, 0xbfee8784)  
= 6
dcgettext(0, 0x804fd62, 5, 0xbfee8d3e, 10)  
= 0x804fd62
dcgettext(0, 0x80500e4, 5, 0xbfee8d3e, 10)  
= 0x80500e4
strlen("'") 
= 1
__errno_location()  
= 0xb7f2b68c
__ctype_get_mb_cur_max(0x80500e4, 0x896128, 2, 0, 0xbfee8784)   
= 6
dcgettext(0, 0x804fd62, 5, 0xbfee8d3e, 256) 
= 0x804fd62
dcgettext(0, 0x80500e4, 5, 0xbfee8d3e, 256) 
= 0x80500e4
strlen("'") 
= 1
dcgettext(0, 0x804e966, 5, 0xbfee8d46, 1024)
= 0x804e966
error(0, 22, 0x804e966, 0x8051400, 0x8f13890ln: creating hard link `hardlink' 
=> `symlink': Invalid argument
)   = 0
free(NULL)  
= 
exit(1 
__fpending(0x895420, 0x770af4, 0xb7f3f3d0, 0, 0)
= 0
fclose(0x895420)
= 0
__fpending(0x8954c0, 0x770af4, 0xb7f3f3d0, 0x894ff4, 0) 
= 0
fclose(0x8954c0)
= 0
__fpending(0x895560, 0x770af4, 0xb7f3f3d0, 0x894ff4, 0) 
= 0
fclose(0x895560)
= 0
+++ exited (status 1) +++
execve("/home/p4/tt/coreutils-7.6.63-addb6/src/ln", ["ln", "-L", "symlink", 
"hardlink"], [/* 23 vars */]) = 0
brk(0)  = 0x8121000
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
0xb7f31000
access("/etc/ld.so.preload", R_OK)  = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)  = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=75128, ...}) = 0
mmap2(NULL, 75128, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7f1e000
close(3)= 0
open("/lib/libc.so.6", O_RDONLY)= 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0

Re: new snapshot available: coreutils-7.6.63-addb6

2009-10-05 Thread Eric Blake
Pádraig Brady  draigBrady.com> writes:

> ln: creating hard link `hardlink' => `symlink': Invalid argument
> 
> `man linkat` says that AT_SYMLINK_FOLLOW is only supported since 2.6.18
> and my FC5 system is 2.6.17

Bingo.  For FC5, I need to implement rpl_linkat in gnulib, which mimics the 
link_follow fallback used on systems that lack linkat altogether, if linkat
(,AT_SYMLINK_FOLLOW) fails with EINVAL.  And probably enable rpl_linkat 
unconditionally at configure time for Linux, for the benefit of people that 
compiled against newer headers but run against an older kernel; the replacement 
code would need a static variable that learns whether we expect success or 
failure, similar to how we've wrapped O_CLOEXEC support in recent modules when 
compiling against newer headers and older kernel.

Jim, do you want to wait for me to get that done in gnulib, or do we just state 
that since 8.0 will be beta that it is a known bug which will be fixed for 8.1?

-- 
Eric Blake






Re: new snapshot available: coreutils-7.6.63-addb6

2009-10-05 Thread Eric Blake
Pádraig Brady  draigBrady.com> writes:

> __xstat64(3, "symlink", 
0xbfee893c) = 0
> linkat(-100, 0xbfee8d3e, -100, 0xbfee8d46, 
1024)= -1

> stat64("symlink", {st_mode=S_IFREG|0664, st_size=0, ...}) = 0
> connect(-100, {sa_family=0x7973 /* AF_??? */, sa_data="mlink\0hardlink"}, 
4294967196) = -1 EINVAL

Cute - those two lines match between the two straces, but the second trace 
doesn't know about the linkat syscall, and tries to interpret it as a connect 
syscall instead.

But yep, definite proof that linkat(,AT_SYMLINK_FOLLOW) needs a rpl_linkat 
wrapper.

-- 
Eric Blake






Re: new snapshot available: coreutils-7.6.63-addb6

2009-10-05 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

According to Pádraig Brady on 10/5/2009 3:53 PM:
 This is a new test, but FC5 is s old,
 that I'm not sure it's worth worrying about.
>>> March 2006?
>> The failure is probably a function of the kernel.
>> Which is it?
> 
> In summary this is what fails:
> 
> $ touch a
> $ ln -s a symlink
> $ ln -L symlink hardlink
> ln: creating hard link `hardlink' => `symlink': Invalid argument
> 
> `man linkat` says that AT_SYMLINK_FOLLOW is only supported since 2.6.18
> and my FC5 system is 2.6.17

This should fix it.  I don't have access to FC5, but I tested the new code
path by priming the cache (gl_cv_func_linkat_follow=runtime ./configure)
along with a temporary setting of have_follow_really=-1 in linkat.c.  I
also verified that the replacement is not picked up on cygwin 1.7, where
AT_SYMLINK_FOLLOW was implemented at the same time as linkat.

The patch copies from areadlink.c, as well as link_follow earlier in
linkat.c, to create two new fd-relative helpers.  For now, I didn't see
any reason to expose them, but areadlinkat may someday be worth making
into a full-blown module.

- --
Don't work too hard, make some time for fun as well!

Eric Blake e...@byu.net
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkrKvywACgkQ84KuGfSFAYDpiACgkOS074Zvsnwu1tOc8z9YWClD
uM0AoLh4EpxWw8Y7FMYWNgi713r3hCMO
=A+pL
-END PGP SIGNATURE-
From cdba659e0746e0d7c6ecbcabfbb25132f5418a38 Mon Sep 17 00:00:00 2001
From: Eric Blake 
Date: Mon, 5 Oct 2009 21:30:33 -0600
Subject: [PATCH] linkat: support Linux 2.6.17
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* m4/linkat.m4 (gl_FUNC_LINKAT): Default to always replacing
linkat on Linux, but allow cache variable override.
* lib/linkat.c (rpl_linkat): Define override.
* modules/linkat (Depends-on): Add symlinkat.
* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Add new default.
* modules/unistd (Makefile.am): Substitute it.
* lib/unistd.in.h (linkat): Declare replacement.
Reported by Pádraig Brady.

Signed-off-by: Eric Blake 
---
 ChangeLog   |   10 +++
 lib/linkat.c|  201 --
 lib/unistd.in.h |6 ++-
 m4/linkat.m4|   24 ++-
 m4/unistd_h.m4  |3 +-
 modules/linkat  |1 +
 modules/unistd  |1 +
 7 files changed, 235 insertions(+), 11 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0782170..0362497 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2009-10-05  Eric Blake  

+   linkat: support Linux 2.6.17
+   * m4/linkat.m4 (gl_FUNC_LINKAT): Default to always replacing
+   linkat on Linux, but allow cache variable override.
+   * lib/linkat.c (rpl_linkat): Define override.
+   * modules/linkat (Depends-on): Add symlinkat.
+   * m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Add new default.
+   * modules/unistd (Makefile.am): Substitute it.
+   * lib/unistd.in.h (linkat): Declare replacement.
+   Reported by Pádraig Brady.
+
quotearg: port test to systems with C.UTF-8 locale
* tests/test-quotearg.c (struct result_strings): Add another
member, differentiating between C.ASCII and C.UTF-8 handling.
diff --git a/lib/linkat.c b/lib/linkat.c
index bda0627..f785d09 100644
--- a/lib/linkat.c
+++ b/lib/linkat.c
@@ -23,6 +23,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 

 #include "areadlink.h"
@@ -41,11 +43,13 @@
 # endif
 #endif

+#if !HAVE_LINKAT
+
 /* Create a link.  If FILE1 is a symlink, either create a hardlink to
that symlink, or fake it by creating an identical symlink.  */
-#if LINK_FOLLOWS_SYMLINKS == 0
-# define link_immediate link
-#else
+# if LINK_FOLLOWS_SYMLINKS == 0
+#  define link_immediate link
+# else
 static int
 link_immediate (char const *file1, char const *file2)
 {
@@ -88,13 +92,13 @@ link_immediate (char const *file1, char const *file2)
 return -1;
   return link (file1, file2);
 }
-#endif
+# endif /* LINK_FOLLOWS_SYMLINKS == 0 */

 /* Create a link.  If FILE1 is a symlink, create a hardlink to the
canonicalized file.  */
-#if 0 < LINK_FOLLOWS_SYMLINKS
-# define link_follow link
-#else
+# if 0 < LINK_FOLLOWS_SYMLINKS
+#  define link_follow link
+# else
 static int
 link_follow (char const *file1, char const *file2)
 {
@@ -159,7 +163,7 @@ link_follow (char const *file1, char const *file2)
 }
   return result;
 }
-#endif
+# endif /* 0 < LINK_FOLLOWS_SYMLINKS */

 /* Create a link to FILE1, in the directory open on descriptor FD1, to FILE2,
in the directory open on descriptor FD2.  If FILE1 is a symlink, FLAG
@@ -179,3 +183,184 @@ linkat (int fd1, char const *file1, int fd2, char const 
*file2, int flag)
   return at_func2 (fd1, file1, fd2, file2,
flag ? link_follow : link_immediate);
 }
+
+#else /* HAVE_LINKAT */

Re: new snapshot available: coreutils-7.6.63-addb6

2009-10-06 Thread Jim Meyering
Eric Blake wrote:
> Pádraig Brady  draigBrady.com> writes:
>
>> ln: creating hard link `hardlink' => `symlink': Invalid argument
>>
>> `man linkat` says that AT_SYMLINK_FOLLOW is only supported since 2.6.18
>> and my FC5 system is 2.6.17
>
> Bingo.  For FC5, I need to implement rpl_linkat in gnulib, which mimics the
> link_follow fallback used on systems that lack linkat altogether, if linkat
> (,AT_SYMLINK_FOLLOW) fails with EINVAL.  And probably enable rpl_linkat
> unconditionally at configure time for Linux, for the benefit of people that
> compiled against newer headers but run against an older kernel; the 
> replacement
> code would need a static variable that learns whether we expect success or
> failure, similar to how we've wrapped O_CLOEXEC support in recent modules when
> compiling against newer headers and older kernel.
>
> Jim, do you want to wait for me to get that done in gnulib, or do we just 
> state
> that since 8.0 will be beta that it is a known bug which will be fixed for 
> 8.1?

I'm ready to release today, and that failure is far enough out on
the fringe that I have no qualms.

This makes two known bugs.  The fix for the other will be
always-required l?getfilecon wrappers to avoid segfaulting
on old-kernel-munged disks and/or old versions of libselinux.




Re: new snapshot available: coreutils-7.6.63-addb6

2009-10-06 Thread Jim Meyering
Eric Blake wrote:
> According to Pádraig Brady on 10/5/2009 3:53 PM:
> This is a new test, but FC5 is s old,
> that I'm not sure it's worth worrying about.
 March 2006?
>>> The failure is probably a function of the kernel.
>>> Which is it?
>>
>> In summary this is what fails:
>>
>> $ touch a
>> $ ln -s a symlink
>> $ ln -L symlink hardlink
>> ln: creating hard link `hardlink' => `symlink': Invalid argument
>>
>> `man linkat` says that AT_SYMLINK_FOLLOW is only supported since 2.6.18
>> and my FC5 system is 2.6.17
>
> This should fix it.  I don't have access to FC5, but I tested the new code
> path by priming the cache (gl_cv_func_linkat_follow=runtime ./configure)
> along with a temporary setting of have_follow_really=-1 in linkat.c.  I
> also verified that the replacement is not picked up on cygwin 1.7, where
> AT_SYMLINK_FOLLOW was implemented at the same time as linkat.
>
> The patch copies from areadlink.c, as well as link_follow earlier in
> linkat.c, to create two new fd-relative helpers.  For now, I didn't see
> any reason to expose them, but areadlinkat may someday be worth making
> into a full-blown module.

Wow, that was quick.  Thanks.
I should have read this first.

I was just reviewing the changes in gnulib and
see a few that should be included in the imminent coreutils
beta release, so will probably take this one, too.




Re: new snapshot available: coreutils-7.6.63-addb6

2009-10-06 Thread Pádraig Brady
Jim Meyering wrote:
> Eric Blake wrote:
>> According to Pádraig Brady on 10/5/2009 3:53 PM:
>> This is a new test, but FC5 is s old,
>> that I'm not sure it's worth worrying about.
> March 2006?
 The failure is probably a function of the kernel.
 Which is it?
>>> In summary this is what fails:
>>>
>>> $ touch a
>>> $ ln -s a symlink
>>> $ ln -L symlink hardlink
>>> ln: creating hard link `hardlink' => `symlink': Invalid argument
>>>
>>> `man linkat` says that AT_SYMLINK_FOLLOW is only supported since 2.6.18
>>> and my FC5 system is 2.6.17
>> This should fix it.  I don't have access to FC5, but I tested the new code
>> path by priming the cache (gl_cv_func_linkat_follow=runtime ./configure)
>> along with a temporary setting of have_follow_really=-1 in linkat.c.  I
>> also verified that the replacement is not picked up on cygwin 1.7, where
>> AT_SYMLINK_FOLLOW was implemented at the same time as linkat.
>>
>> The patch copies from areadlink.c, as well as link_follow earlier in
>> linkat.c, to create two new fd-relative helpers.  For now, I didn't see
>> any reason to expose them, but areadlinkat may someday be worth making
>> into a full-blown module.
> 
> Wow, that was quick.  Thanks.
> I should have read this first.
> 
> I was just reviewing the changes in gnulib and
> see a few that should be included in the imminent coreutils
> beta release, so will probably take this one, too.

Needs a couple of tweaks..

This needs to be added to linkat.c
(seems like it should be refactored somewhere?)

#ifndef SIZE_MAX
# define SIZE_MAX ((size_t) -1)
#endif
#ifndef SSIZE_MAX
# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
#endif

Also a minor nit in s/Linux/Gnu\/Linux/

After that the test passes.

cheers,
Pádraig.




Re: new snapshot available: coreutils-7.6.63-addb6

2009-10-06 Thread Jim Meyering
Pádraig Brady wrote:

> Jim Meyering wrote:
>> Eric Blake wrote:
>>> According to Pádraig Brady on 10/5/2009 3:53 PM:
>>> This is a new test, but FC5 is s old,
>>> that I'm not sure it's worth worrying about.
>> March 2006?
> The failure is probably a function of the kernel.
> Which is it?
 In summary this is what fails:

 $ touch a
 $ ln -s a symlink
 $ ln -L symlink hardlink
 ln: creating hard link `hardlink' => `symlink': Invalid argument

 `man linkat` says that AT_SYMLINK_FOLLOW is only supported since 2.6.18
 and my FC5 system is 2.6.17
>>> This should fix it.  I don't have access to FC5, but I tested the new code
>>> path by priming the cache (gl_cv_func_linkat_follow=runtime ./configure)
>>> along with a temporary setting of have_follow_really=-1 in linkat.c.  I
>>> also verified that the replacement is not picked up on cygwin 1.7, where
>>> AT_SYMLINK_FOLLOW was implemented at the same time as linkat.
>>>
>>> The patch copies from areadlink.c, as well as link_follow earlier in
>>> linkat.c, to create two new fd-relative helpers.  For now, I didn't see
>>> any reason to expose them, but areadlinkat may someday be worth making
>>> into a full-blown module.
>>
>> Wow, that was quick.  Thanks.
>> I should have read this first.
>>
>> I was just reviewing the changes in gnulib and
>> see a few that should be included in the imminent coreutils
>> beta release, so will probably take this one, too.
>
> Needs a couple of tweaks..
>
> This needs to be added to linkat.c
> (seems like it should be refactored somewhere?)
>
> #ifndef SIZE_MAX
> # define SIZE_MAX ((size_t) -1)
> #endif
> #ifndef SSIZE_MAX
> # define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
> #endif

This should do it:

>From 6f6420cc9705dcfa545a28c674fddf5703e72c86 Mon Sep 17 00:00:00 2001
From: Jim Meyering 
Date: Tue, 6 Oct 2009 11:11:39 +0200
Subject: [PATCH] linkat: avoid compilation failure

* lib/linkat.c: Include  for use of SIZE_MAX.
---
 ChangeLog|5 +
 lib/linkat.c |1 +
 2 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0362497..c942631 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-10-06  Jim Meyering  
+
+   linkat: avoid compilation failure
+   * lib/linkat.c: Include  for use of SIZE_MAX.
+
 2009-10-05  Eric Blake  

linkat: support Linux 2.6.17
diff --git a/lib/linkat.c b/lib/linkat.c
index f785d09..e0dd8f2 100644
--- a/lib/linkat.c
+++ b/lib/linkat.c
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
--
1.6.5.rc2.204.g8ea19




Re: new snapshot available: coreutils-7.6.63-addb6

2009-10-06 Thread Paolo Bonzini

On 10/06/2009 11:05 AM, Pádraig Brady wrote:

Also a minor nit in s/Linux/Gnu\/Linux/


Definitely not when it's talking explicitly of a kernel version?

Paolo




Re: new snapshot available: coreutils-7.6.63-addb6

2009-10-06 Thread Pádraig Brady
Jim Meyering wrote:
> Pádraig Brady wrote:
> 
>> Jim Meyering wrote:
>>> Eric Blake wrote:
 According to Pádraig Brady on 10/5/2009 3:53 PM:
 This is a new test, but FC5 is s old,
 that I'm not sure it's worth worrying about.
>>> March 2006?
>> The failure is probably a function of the kernel.
>> Which is it?
> In summary this is what fails:
>
> $ touch a
> $ ln -s a symlink
> $ ln -L symlink hardlink
> ln: creating hard link `hardlink' => `symlink': Invalid argument
>
> `man linkat` says that AT_SYMLINK_FOLLOW is only supported since 2.6.18
> and my FC5 system is 2.6.17
 This should fix it.  I don't have access to FC5, but I tested the new code
 path by priming the cache (gl_cv_func_linkat_follow=runtime ./configure)
 along with a temporary setting of have_follow_really=-1 in linkat.c.  I
 also verified that the replacement is not picked up on cygwin 1.7, where
 AT_SYMLINK_FOLLOW was implemented at the same time as linkat.

 The patch copies from areadlink.c, as well as link_follow earlier in
 linkat.c, to create two new fd-relative helpers.  For now, I didn't see
 any reason to expose them, but areadlinkat may someday be worth making
 into a full-blown module.
>>> Wow, that was quick.  Thanks.
>>> I should have read this first.
>>>
>>> I was just reviewing the changes in gnulib and
>>> see a few that should be included in the imminent coreutils
>>> beta release, so will probably take this one, too.
>> Needs a couple of tweaks..
>>
>> This needs to be added to linkat.c
>> (seems like it should be refactored somewhere?)
>>
>> #ifndef SIZE_MAX
>> # define SIZE_MAX ((size_t) -1)
>> #endif
>> #ifndef SSIZE_MAX
>> # define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
>> #endif
> 
> This should do it:
> 
>>From 6f6420cc9705dcfa545a28c674fddf5703e72c86 Mon Sep 17 00:00:00 2001
> From: Jim Meyering 
> Date: Tue, 6 Oct 2009 11:11:39 +0200
> Subject: [PATCH] linkat: avoid compilation failure
> 
> * lib/linkat.c: Include  for use of SIZE_MAX.

That works thanks.

I suppose these should include stdint.h also?

areadlink.c:# define SIZE_MAX ((size_t) -1)
areadlink-with-size.c:# define SIZE_MAX ((size_t) -1)
backupfile.c:# define SIZE_MAX ((size_t) -1)
fnmatch.c:# define SIZE_MAX ((size_t) -1)
quotearg.c:# define SIZE_MAX ((size_t) -1)
striconv.c:# define SIZE_MAX ((size_t) -1)

While these already include stdint.h so should probably not redefine

fts.c:# define SIZE_MAX ((size_t) -1)
getdelim.c:# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
getndelim2.c:# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))

cheers,
Pádraig.




Re: new snapshot available: coreutils-7.6.63-addb6

2009-10-06 Thread Pádraig Brady
Paolo Bonzini wrote:
> On 10/06/2009 11:05 AM, Pádraig Brady wrote:
>> Also a minor nit in s/Linux/Gnu\/Linux/
> 
> Definitely not when it's talking explicitly of a kernel version?

Right, it could be "GNU/Linux" or "Linux kernels? (.*)?"

cheers,
Pádraig.




Re: new snapshot available: coreutils-7.6.63-addb6

2009-10-06 Thread Simon Josefsson
Pádraig Brady  writes:

> Jim Meyering wrote:
>> Pádraig Brady wrote:
>> 
>>> Jim Meyering wrote:
 Eric Blake wrote:
> According to Pádraig Brady on 10/5/2009 3:53 PM:
> This is a new test, but FC5 is s old,
> that I'm not sure it's worth worrying about.
 March 2006?
>>> The failure is probably a function of the kernel.
>>> Which is it?
>> In summary this is what fails:
>>
>> $ touch a
>> $ ln -s a symlink
>> $ ln -L symlink hardlink
>> ln: creating hard link `hardlink' => `symlink': Invalid argument
>>
>> `man linkat` says that AT_SYMLINK_FOLLOW is only supported since 2.6.18
>> and my FC5 system is 2.6.17
> This should fix it.  I don't have access to FC5, but I tested the new code
> path by priming the cache (gl_cv_func_linkat_follow=runtime ./configure)
> along with a temporary setting of have_follow_really=-1 in linkat.c.  I
> also verified that the replacement is not picked up on cygwin 1.7, where
> AT_SYMLINK_FOLLOW was implemented at the same time as linkat.
>
> The patch copies from areadlink.c, as well as link_follow earlier in
> linkat.c, to create two new fd-relative helpers.  For now, I didn't see
> any reason to expose them, but areadlinkat may someday be worth making
> into a full-blown module.
 Wow, that was quick.  Thanks.
 I should have read this first.

 I was just reviewing the changes in gnulib and
 see a few that should be included in the imminent coreutils
 beta release, so will probably take this one, too.
>>> Needs a couple of tweaks..
>>>
>>> This needs to be added to linkat.c
>>> (seems like it should be refactored somewhere?)
>>>
>>> #ifndef SIZE_MAX
>>> # define SIZE_MAX ((size_t) -1)
>>> #endif
>>> #ifndef SSIZE_MAX
>>> # define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
>>> #endif
>> 
>> This should do it:
>> 
>>>From 6f6420cc9705dcfa545a28c674fddf5703e72c86 Mon Sep 17 00:00:00 2001
>> From: Jim Meyering 
>> Date: Tue, 6 Oct 2009 11:11:39 +0200
>> Subject: [PATCH] linkat: avoid compilation failure
>> 
>> * lib/linkat.c: Include  for use of SIZE_MAX.
>
> That works thanks.
>
> I suppose these should include stdint.h also?
>
> areadlink.c:# define SIZE_MAX ((size_t) -1)
> areadlink-with-size.c:# define SIZE_MAX ((size_t) -1)
> backupfile.c:# define SIZE_MAX ((size_t) -1)
> fnmatch.c:# define SIZE_MAX ((size_t) -1)
> quotearg.c:# define SIZE_MAX ((size_t) -1)
> striconv.c:# define SIZE_MAX ((size_t) -1)

Note that stdint.h may not be sufficient to get SIZE_MAX, quoting
size_max.h:

/* Get SIZE_MAX declaration on systems like Solaris 7/8/9.  */
# include 
/* Get SIZE_MAX declaration on systems like glibc 2.  */
# if HAVE_STDINT_H
#  include 
# endif
/* On systems where these include files don't define it, SIZE_MAX is defined
   in config.h.  */

However given that SIZE_MAX should be in stdint.h according to POSIX,
maybe it makes more sense to make sure gnulib's stdint.h replacement is
enabled when SIZE_MAX is not provided by the system's stdint.h?  And
then deprecate size_max.h in favor of stdint.

> While these already include stdint.h so should probably not redefine
>
> fts.c:# define SIZE_MAX ((size_t) -1)
> getdelim.c:# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
> getndelim2.c:# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))

SSIZE_MAX should be provided by limit.h, see:

http://www.opengroup.org/onlinepubs/009695399/basedefs/limits.h.html

The stdint.h documentation doesn't mention SSIZE_MAX:

http://www.opengroup.org/onlinepubs/009695399/basedefs/stdint.h.html

/Simon




areadlinkat (was: new snapshot available: coreutils-7.6.63-addb6)

2009-10-07 Thread Eric Blake
Eric Blake  byu.net> writes:

> The patch copies from areadlink.c, as well as link_follow earlier in
> linkat.c, to create two new fd-relative helpers.  For now, I didn't see
> any reason to expose them, but areadlinkat may someday be worth making
> into a full-blown module.

Further looking shows that:

findutils' listfile.c currently uses a home-rolled get_link_name_at which 
blindly changes the working directory, and calls xalloc_die on allocation 
failure.  Perfect candidate for xreadlinkat, to be more efficient on platforms 
with native readlinkat.  And xreadlinkat implies areadlinkat.

coreutils' copy.c currently uses areadlink_with_size for copying/moving 
symlinks across partitions, but since we want to rewrite this to use fts, we 
will need an *at variant.

So, I've written three new modules: areadlinkat, areadlinkat-with-size, and 
xreadlinkat; mirroring the three existing modules areadlink, areadlink-with-
size, xreadlink.

Eric Blake (4):
  areadlink, areadlink-with-size: add tests
  areadlinkat: new module
  xreadlinkat: new module
  areadlinkat-with-size: new module


>From 9d21d0d57b72c90a8f2c1bcdef09eb888e58d71b Mon Sep 17 00:00:00 2001
From: Eric Blake 
Date: Wed, 7 Oct 2009 09:40:32 -0600
Subject: [PATCH 1/4] areadlink, areadlink-with-size: add tests

* modules/areadlink-tests: New test.
* modules/areadlink-with-size-tests: Likewise.
* tests/test-areadlink.h: New file.
* tests/test-areadlink.c: Likewise.
* tests/test-areadlink-with-size.c: Likewise.

Signed-off-by: Eric Blake 
---
 ChangeLog |7 +++
 modules/areadlink-tests   |   13 ++
 modules/areadlink-with-size-tests |   13 ++
 tests/test-areadlink-with-size.c  |   55 
 tests/test-areadlink.c|   62 +++
 tests/test-areadlink.h|   84 +
 6 files changed, 234 insertions(+), 0 deletions(-)
 create mode 100644 modules/areadlink-tests
 create mode 100644 modules/areadlink-with-size-tests
 create mode 100644 tests/test-areadlink-with-size.c
 create mode 100644 tests/test-areadlink.c
 create mode 100644 tests/test-areadlink.h

diff --git a/ChangeLog b/ChangeLog
index f69762a..ebdc931 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2009-10-07  Eric Blake  

+   areadlink, areadlink-with-size: add tests
+   * modules/areadlink-tests: New test.
+   * modules/areadlink-with-size-tests: Likewise.
+   * tests/test-areadlink.h: New file.
+   * tests/test-areadlink.c: Likewise.
+   * tests/test-areadlink-with-size.c: Likewise.
+
utimens: minor optimization
* lib/utimens.c (gl_futimens): Use one less system call.
* modules/utimens (Depends-on): Add dup2.
diff --git a/modules/areadlink-tests b/modules/areadlink-tests
new file mode 100644
index 000..0e7796e
--- /dev/null
+++ b/modules/areadlink-tests
@@ -0,0 +1,13 @@
+Files:
+tests/test-areadlink.h
+tests/test-areadlink.c
+
+Depends-on:
+stdbool
+symlink
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-areadlink
+check_PROGRAMS += test-areadlink
diff --git a/modules/areadlink-with-size-tests b/modules/areadlink-with-size-
tests
new file mode 100644
index 000..9752034
--- /dev/null
+++ b/modules/areadlink-with-size-tests
@@ -0,0 +1,13 @@
+Files:
+tests/test-areadlink.h
+tests/test-areadlink-with-size.c
+
+Depends-on:
+stdbool
+symlink
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-areadlink-with-size
+check_PROGRAMS += test-areadlink-with-size
diff --git a/tests/test-areadlink-with-size.c b/tests/test-areadlink-with-size.c
new file mode 100644
index 000..2a175a5
--- /dev/null
+++ b/tests/test-areadlink-with-size.c
@@ -0,0 +1,55 @@
+/* Tests of areadlink_with_size.
+   Copyright (C) 2009 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see .  */
+
+/* Written by Eric Blake , 2009.  */
+
+#include 
+
+#include "areadlink.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define ASSERT(expr) \
+  do \
+{\
+  if (!(expr))   \
+{\
+