Re: [PATCH] ls: print ?, not 0 as inode of dereferenced dangling symlink

2009-09-29 Thread Jim Meyering
Jim Meyering wrote:
 Here's another corner-case fix.
 I'll push something like this as soon as I've updated NEWS
 and added a test.

From 26a1306a0a9028eceed388dad0d8916aeeb00233 Mon Sep 17 00:00:00 2001
 From: Jim Meyering meyer...@redhat.com
 Date: Mon, 28 Sep 2009 20:24:41 +0200

Here's a more complete patch, though I still have
to add a mention in NEWS about the origin.


From f4d682808c6c8d2e1871278f3e81d0d0766f792b Mon Sep 17 00:00:00 2001
From: Jim Meyering meyer...@redhat.com
Date: Mon, 28 Sep 2009 20:24:41 +0200
Subject: [PATCH] ls: print ?, not 0 as inode of dereferenced dangling 
symlink

ls prints inode numbers two ways: for long (-l) listings,
and for short ones, e.g., ls -li and ls -i.  The code to print
long listings properly printed ? when the inode was unknown,
but the code for handling short listings would print 0 instead.
Factor out the formatting code into a new function so ls prints
the right string (?) from both places:
* NEWS (Bug fixes): Mention it.
* src/ls.c (format_inode): New function.
(print_long_format): Use it here.
(print_file_name_and_frills): Use it here, too.
* tests/ls/dangle: Exercise this fix.
Reported by Yang Ren in http://bugzilla.redhat.com/525400
---
 NEWS|8 
 src/ls.c|   18 +-
 tests/ls/dangle |8 
 3 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/NEWS b/NEWS
index d0a9a7d..1a0c847 100644
--- a/NEWS
+++ b/NEWS
@@ -18,6 +18,14 @@ GNU coreutils NEWS-*- 
outline -*-

   ls -LR exits with status 2, not 0, when it encounters a cycle

+  ls -L now print ?, not 0 as the inode of a dangling symlink.
+  For example, before, mkdir d; ln -s no-such d/s; ls -Li d would print
+ls: cannot access d/s: No such file or directory
+0 s
+  now it prints this:
+ls: cannot access d/s: No such file or directory
+? s
+
 ** Portability

   On Solaris 9, many commands would mistakenly treat file/ the same as
diff --git a/src/ls.c b/src/ls.c
index 86f5c32..c8e8abb 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -3556,9 +3556,19 @@ format_group_width (gid_t g)
   return format_user_or_group_width (numeric_ids ? NULL : getgroup (g), g);
 }

+/* Return a pointer to a formatted version of F-stat.st_ino,
+   possibly using buffer, BUF, of length BUFLEN, which must be at least
+   INT_BUFSIZE_BOUND (uintmax_t) bytes.  */
+static char *
+format_inode (char *buf, size_t buflen, const struct fileinfo *f)
+{
+  assert (INT_BUFSIZE_BOUND (uintmax_t) = buflen);
+  return (f-stat.st_ino == NOT_AN_INODE_NUMBER
+  ? (char *) ?
+  : umaxtostr (f-stat.st_ino, buf));
+}

 /* Print information about F in long format.  */
-
 static void
 print_long_format (const struct fileinfo *f)
 {
@@ -3615,9 +3625,7 @@ print_long_format (const struct fileinfo *f)
 {
   char hbuf[INT_BUFSIZE_BOUND (uintmax_t)];
   sprintf (p, %*s , inode_number_width,
-   (f-stat.st_ino == NOT_AN_INODE_NUMBER
-? ?
-: umaxtostr (f-stat.st_ino, hbuf)));
+   format_inode (hbuf, sizeof hbuf, f));
   /* Increment by strlen (p) here, rather than by inode_number_width + 1.
  The latter is wrong when inode_number_width is zero.  */
   p += strlen (p);
@@ -4004,7 +4012,7 @@ print_file_name_and_frills (const struct fileinfo *f, 
size_t start_col)

   if (print_inode)
 printf (%*s , format == with_commas ? 0 : inode_number_width,
-umaxtostr (f-stat.st_ino, buf));
+format_inode (buf, sizeof buf, f));

   if (print_block_size)
 printf (%*s , format == with_commas ? 0 : block_size_width,
diff --git a/tests/ls/dangle b/tests/ls/dangle
index b2f8539..6abad92 100755
--- a/tests/ls/dangle
+++ b/tests/ls/dangle
@@ -26,6 +26,9 @@ fi
 ln -s no-such-file dangle || framework_failure
 mkdir -p dir/sub || framework_failure
 ln -s dir slink-to-dir || framework_failure
+mkdir d || framework_failure
+ln -s no-such d/dangle || framework_failure
+echo '? dangle'  subdir_exp || framework_failure

 fail=0

@@ -50,4 +53,9 @@ EOF

 compare out exp || fail=1

+# Ensure that ls -Li prints ? as the inode of a dangling symlink.
+rm -f out
+ls -Li d  out 2/dev/null  fail=1
+compare out subdir_exp || fail=1
+
 Exit $fail
--
1.6.5.rc2.177.ga9dd6




Re: [PATCH] ls: with -LR, exit with status 2 upon detecting a cycle

2009-09-29 Thread Jim Meyering
Pádraig Brady wrote:
 Jim Meyering wrote:
 Jim Meyering wrote:
 Here's a fix to make ls -LR work the same way Solaris 10's /bin/ls
 does in the presence of a cycle.

 It makes sense to exit(2) along with the printed error.
 The patch looks good.

Thanks for the review.




Re: [PATCH] ls: don't use an undefined struct stat after failed stat/lstat

2009-09-29 Thread Pádraig Brady
Jim Meyering wrote:
 Nearly missed this one.
 ls initializes a struct stat to all NUL bytes.
 It calls stat or lstat on a dangling symlink, and that fails.
 ls then tests stat.st_ino.
 
 Sometimes, it's 0, but sometimes it's the inode of the symlink,
 possibly depending on how the package was configured/built or
 the environment.
 I haven't determined precisely what makes the difference,
 but ls (from coreutils-7.6) built some way prints 0 as the inode
 number, and other ways, it prints the inode of the dangling symlink.
 
 
From f7db178fdff1ebb113841035b55b103e074b5f6f Mon Sep 17 00:00:00 2001
 From: Jim Meyering meyer...@redhat.com
 Date: Tue, 29 Sep 2009 07:28:01 +0200
 Subject: [PATCH] ls: don't use an undefined struct stat after failed 
 stat/lstat
 
 * src/ls.c (gobble_file): After a failed stat/lstat call,
 clear the f-stat buffer, since the syscall may have modified it,
 and we may need to know that stat.st_ino is zero.

Well spotted. By the same token is this useful?

diff --git a/src/ls.c b/src/ls.c
index 4531b94..fe51bb8 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -4001,8 +4001,9 @@ print_file_name_and_frills (const struct fileinfo *f, 
size_t start_col)

   if (print_block_size)
 printf (%*s , format == with_commas ? 0 : block_size_width,
-human_readable (ST_NBLOCKS (f-stat), buf, human_output_opts,
-ST_NBLOCKSIZE, output_block_size));
+! f-stat_ok ? ?
+: human_readable (ST_NBLOCKS (f-stat), buf, human_output_opts,
+  ST_NBLOCKSIZE, output_block_size));

   if (print_scontext)
 printf (%*s , format == with_commas ? 0 : scontext_width, f-scontext);
@@ -4219,9 +4220,10 @@ length_of_file_name_and_frills (const struct fileinfo *f)

   if (print_block_size)
 len += 1 + (format == with_commas
-? strlen (human_readable (ST_NBLOCKS (f-stat), buf,
-  human_output_opts, ST_NBLOCKSIZE,
-  output_block_size))
+? strlen (! f-stat_ok ? ?
+  : human_readable (ST_NBLOCKS (f-stat), buf,
+human_output_opts, ST_NBLOCKSIZE,
+output_block_size))
 : block_size_width);

   if (print_scontext)






Re: [PATCH] ls: don't use an undefined struct stat after failed stat/lstat

2009-09-29 Thread Jim Meyering
Pádraig Brady wrote:

 Jim Meyering wrote:
 Nearly missed this one.
 ls initializes a struct stat to all NUL bytes.
 It calls stat or lstat on a dangling symlink, and that fails.
 ls then tests stat.st_ino.

 Sometimes, it's 0, but sometimes it's the inode of the symlink,
 possibly depending on how the package was configured/built or
 the environment.
 I haven't determined precisely what makes the difference,
 but ls (from coreutils-7.6) built some way prints 0 as the inode
 number, and other ways, it prints the inode of the dangling symlink.


From f7db178fdff1ebb113841035b55b103e074b5f6f Mon Sep 17 00:00:00 2001
 From: Jim Meyering meyer...@redhat.com
 Date: Tue, 29 Sep 2009 07:28:01 +0200
 Subject: [PATCH] ls: don't use an undefined struct stat after failed 
 stat/lstat

 * src/ls.c (gobble_file): After a failed stat/lstat call,
 clear the f-stat buffer, since the syscall may have modified it,
 and we may need to know that stat.st_ino is zero.

 Well spotted. By the same token is this useful?

Well spotted yourself!
I should have remembered to use the stat_ok member.

I'll merge something like this into my patch.

Thanks!

diff --git a/src/ls.c b/src/ls.c
index dc2f86e..03ef9b0 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -2777,11 +2777,7 @@ gobble_file (char const *name, enum filetype type, ino_t 
inode,

   if (err != 0)
 {
-  /* The failed stat/lstat may have modified f-stat.  Clear it,
- since we may use at least its st_ino member, e.g.,
- when trying to print the inode of dangling symlink:
- mkdir d; ln -s no-such d/s; ls -Li d  */
-  memset (f-stat, 0, sizeof (f-stat));
+  f-stat.st_ino = 22;

   /* Failure to stat a command line argument leads to
  an exit status of 2.  For other files, stat failure
@@ -3569,9 +3565,9 @@ static char *
 format_inode (char *buf, size_t buflen, const struct fileinfo *f)
 {
   assert (INT_BUFSIZE_BOUND (uintmax_t) = buflen);
-  return (f-stat.st_ino == NOT_AN_INODE_NUMBER
-  ? (char *) ?
-  : umaxtostr (f-stat.st_ino, buf));
+  return (f-stat_ok  f-stat.st_ino != NOT_AN_INODE_NUMBER
+  ? umaxtostr (f-stat.st_ino, buf)
+  : (char *) ?);
 }

 /* Print information about F in long format.  */




Re: [PATCH] ls: don't use an undefined struct stat after failed stat/lstat

2009-09-29 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

According to Jim Meyering on 9/29/2009 5:13 AM:
 -  /* The failed stat/lstat may have modified f-stat.  Clear it,
 - since we may use at least its st_ino member, e.g.,
 - when trying to print the inode of dangling symlink:
 - mkdir d; ln -s no-such d/s; ls -Li d  */
 -  memset (f-stat, 0, sizeof (f-stat));
 +  f-stat.st_ino = 22;

Why 22?  Is this debugging leftovers?

- --
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/

iEYEARECAAYFAkrB8f4ACgkQ84KuGfSFAYAh0ACgrKtuS+Eg9QMsjOQAa2LrMWAm
XkQAn2rHcJzA1p22poZd0kviMH0dbKWH
=hb9Q
-END PGP SIGNATURE-




Re: [PATCH] ls: don't use an undefined struct stat after failed stat/lstat

2009-09-29 Thread Jim Meyering
Eric Blake wrote:

 According to Jim Meyering on 9/29/2009 5:13 AM:
 -  /* The failed stat/lstat may have modified f-stat.  Clear it,
 - since we may use at least its st_ino member, e.g.,
 - when trying to print the inode of dangling symlink:
 - mkdir d; ln -s no-such d/s; ls -Li d  */
 -  memset (f-stat, 0, sizeof (f-stat));
 +  f-stat.st_ino = 22;

 Why 22?  Is this debugging leftovers?

haha, yes.  Thanks ;-)




Re: [PATCH] ls: don't use an undefined struct stat after failed stat/lstat

2009-09-29 Thread Jim Meyering
Eric Blake wrote:
 According to Jim Meyering on 9/29/2009 5:13 AM:
 -  /* The failed stat/lstat may have modified f-stat.  Clear it,
 - since we may use at least its st_ino member, e.g.,
 - when trying to print the inode of dangling symlink:
 - mkdir d; ln -s no-such d/s; ls -Li d  */
 -  memset (f-stat, 0, sizeof (f-stat));
 +  f-stat.st_ino = 22;

 Why 22?  Is this debugging leftovers?

Thanks for the review.
BTW, here's the merged version:

From b7aaa0da8b47f4f373d3e0876bd540986278c6e2 Mon Sep 17 00:00:00 2001
From: Jim Meyering meyer...@redhat.com
Date: Tue, 29 Sep 2009 07:28:01 +0200
Subject: [PATCH] ls: don't use an undefined struct stat after failed stat/lstat
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* src/ls.c (format_inode): Access f-stat only if f-stat_ok is set.
* NEWS (Bug fixes): Mention it.
Improved-by: Pádraig Brady p...@draigbrady.com
---
 NEWS |4 
 src/ls.c |6 +++---
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/NEWS b/NEWS
index 68ac24b..075c0fa 100644
--- a/NEWS
+++ b/NEWS
@@ -21,6 +21,10 @@ GNU coreutils NEWS-*- 
outline -*-
   ls -Li is now consistent with ls -Lil in printing ?, not 0 as the
   inode of a dangling symlink.

+  ls -Li no longer relies on unspecified behavior of stat/lstat.
+  Before this change, ls -Li dangling-symlink would mistakenly
+  print the inode number of the symlink under some conditions.
+
 ** Portability

   On Solaris 9, many commands would mistakenly treat file/ the same as
diff --git a/src/ls.c b/src/ls.c
index c8e8abb..801e717 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -3563,9 +3563,9 @@ static char *
 format_inode (char *buf, size_t buflen, const struct fileinfo *f)
 {
   assert (INT_BUFSIZE_BOUND (uintmax_t) = buflen);
-  return (f-stat.st_ino == NOT_AN_INODE_NUMBER
-  ? (char *) ?
-  : umaxtostr (f-stat.st_ino, buf));
+  return (f-stat_ok  f-stat.st_ino != NOT_AN_INODE_NUMBER
+  ? umaxtostr (f-stat.st_ino, buf)
+  : (char *) ?);
 }

 /* Print information about F in long format.  */
--
1.6.5.rc2.177.ga9dd6




Re: stat vs. -

2009-09-29 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

According to Jim Meyering on 9/15/2009 5:49 AM:
 But couldn't, because stat didn't accept - as meaning standard input.
 Here's a patch to make it do that (and make the above print what's displayed):
 
 This is just FYI.
 Of course I'll add the usual NEWS, log and tests and post again later.

Any progress on this?  It sounded like a nice idea.

- --
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/

iEYEARECAAYFAkrB/toACgkQ84KuGfSFAYDU2ACfVZp307iAUuJKUh6v0947FWWj
gAIAniMXLHj9W6x6ZT+KQoEasOro4+3C
=lKrI
-END PGP SIGNATURE-




Re: stat vs. -

2009-09-29 Thread Jim Meyering
Eric Blake wrote:

 According to Jim Meyering on 9/15/2009 5:49 AM:
 But couldn't, because stat didn't accept - as meaning standard input.
 Here's a patch to make it do that (and make the above print what's 
 displayed):

 This is just FYI.
 Of course I'll add the usual NEWS, log and tests and post again later.

 Any progress on this?  It sounded like a nice idea.

Thanks for the reminder.  Here's why I've put it off:

stat has two modes of operation: the default is to interpret each
argument as a file on which to call stat or lstat.
Then there's the --file-system (-f) option.

The - == stdin approach makes sense for the first case.
Since I couldn't think of a use case for the second,
I was debating to implement it there regardless,
for the sake of consistency.  Otherwise, I'd have to
document that it works only *without* -f.

As I write this, however, I'm inclined to be consistent,
even a plausible use case for -f.
Besides, before I encountered the need for stat -, I might not
have been able to come up with a good use case either.




Re: stat vs. -

2009-09-29 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

According to Jim Meyering on 9/29/2009 6:44 AM:
 stat has two modes of operation: the default is to interpret each
 argument as a file on which to call stat or lstat.
 Then there's the --file-system (-f) option.
 
 The - == stdin approach makes sense for the first case.
 Since I couldn't think of a use case for the second,
 I was debating to implement it there regardless,
 for the sake of consistency.  Otherwise, I'd have to
 document that it works only *without* -f.

But how would you make it work *with* -f?  You don't know the path of the
file used to create stdin (and in the case of a pipe, there is no path),
so what would you pass to statvfs?  I don't see any option other than to
go with documenting that -f and - do not work together; and we should make
attempts to mix them fail with an error.

- --
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/

iEYEARECAAYFAkrCBXQACgkQ84KuGfSFAYCbbQCeKyEgTeEFxvEKunG8ym81CzUm
BEcAoJrOZnNTzhNyKtStgytphS2FJOlg
=XTbm
-END PGP SIGNATURE-




Re: stat vs. -

2009-09-29 Thread Jim Meyering
Eric Blake wrote:

 According to Jim Meyering on 9/29/2009 6:44 AM:
 stat has two modes of operation: the default is to interpret each
 argument as a file on which to call stat or lstat.
 Then there's the --file-system (-f) option.

 The - == stdin approach makes sense for the first case.
 Since I couldn't think of a use case for the second,
 I was debating to implement it there regardless,
 for the sake of consistency.  Otherwise, I'd have to
 document that it works only *without* -f.

 But how would you make it work *with* -f?  You don't know the path of the
 file used to create stdin (and in the case of a pipe, there is no path),

There is no need for an actual file name, since fstatfs
takes a file descriptor.  Of course, there's the issue
that some systems don't have a usable fstatfs...

 so what would you pass to statvfs?  I don't see any option other than to
 go with documenting that -f and - do not work together; and we should make
 attempts to mix them fail with an error.




[PATCH] stat: interpret - as standard input

2009-09-29 Thread Jim Meyering
Per recent discussion, here's all but the documentation update.

From a033e28737c1f6320bfc56b484253b61051bad85 Mon Sep 17 00:00:00 2001
From: Jim Meyering meyer...@redhat.com
Date: Tue, 15 Sep 2009 23:07:18 +0200
Subject: [PATCH] stat: interpret - as standard input

* src/stat.c (do_stat): Interpret a command line argument of -
to mean standard input, like many other tools do.
(do_statfs): Fail upon any attempt to use -.
* NEWS (Changes in behavior): Mention it.
* tests/misc/stat-hyphen: New test, to exercise the above.
* tests/Makefile.am (TESTS): Add misc/stat-hyphen.
---
 NEWS   |5 +
 src/stat.c |   17 -
 tests/Makefile.am  |1 +
 tests/misc/stat-hyphen |   35 +++
 4 files changed, 57 insertions(+), 1 deletions(-)
 create mode 100755 tests/misc/stat-hyphen

diff --git a/NEWS b/NEWS
index 075c0fa..f1f7347 100644
--- a/NEWS
+++ b/NEWS
@@ -48,6 +48,11 @@ GNU coreutils NEWS-*- 
outline -*-
   GNU/Linux where link(2) creates hard links to symlinks, and -L on
   BSD systems where link(2) follows symlinks.

+  stat: without -f, a command-line argument of - now means standard input.
+  With --file-system (-f), an argument of - is now rejected.
+  If you really must operate on a file named -, specify it as
+  ./- or use -- to separate options from arguments.
+
 ** Improvements

   rm: rewrite to use gnulib's fts
diff --git a/src/stat.c b/src/stat.c
index 7d42598..14654b1 100644
--- a/src/stat.c
+++ b/src/stat.c
@@ -829,6 +829,13 @@ do_statfs (char const *filename, bool terse, char const 
*format)
 {
   STRUCT_STATVFS statfsbuf;

+  if (STREQ (filename, -))
+{
+  error (0, 0, _(using %s to denote standard input does not work
+  in file system mode), quote (filename));
+  return false;
+}
+
   if (STATFS (filename, statfsbuf) != 0)
 {
   error (0, errno, _(cannot read file system information for %s),
@@ -857,7 +864,15 @@ do_stat (char const *filename, bool terse, char const 
*format)
 {
   struct stat statbuf;

-  if ((follow_links ? stat : lstat) (filename, statbuf) != 0)
+  if (STREQ (filename, -))
+{
+  if (fstat (STDIN_FILENO, statbuf) != 0)
+{
+  error (0, errno, _(cannot stat standard input));
+  return false;
+}
+}
+  else if ((follow_links ? stat : lstat) (filename, statbuf) != 0)
 {
   error (0, errno, _(cannot stat %s), quote (filename));
   return false;
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 2acad6b..5fd541a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -216,6 +216,7 @@ TESTS = \
   misc/split-fail  \
   misc/split-l \
   misc/stat-fmt\
+  misc/stat-hyphen \
   misc/stat-printf \
   misc/stdbuf  \
   misc/stty\
diff --git a/tests/misc/stat-hyphen b/tests/misc/stat-hyphen
new file mode 100755
index 000..f0757fe
--- /dev/null
+++ b/tests/misc/stat-hyphen
@@ -0,0 +1,35 @@
+#!/bin/sh
+# demonstrate that stat - works and stat -f - does not.
+
+# 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 http://www.gnu.org/licenses/.
+
+if test $VERBOSE = yes; then
+  set -x
+  stat --version
+fi
+
+. $srcdir/test-lib.sh
+
+printf -- '-\n'  exp || framework_failure
+touch f || framework_failure
+
+fail=0
+stat --format=%n -  f  out || fail=1
+stat -f -  f  fail=1
+
+compare out exp || fail=1
+
+Exit $fail
--
1.6.5.rc2.177.ga9dd6




Re: stat vs. -

2009-09-29 Thread Eric Blake
Jim Meyering jim at meyering.net writes:

  But how would you make it work *with* -f?  You don't know the path of the
  file used to create stdin (and in the case of a pipe, there is no path),
 
 There is no need for an actual file name, since fstatfs
 takes a file descriptor.  Of course, there's the issue
 that some systems don't have a usable fstatfs...

Or fstatvfs, if you go by POSIX.  I stand corrected; it looks like we _can_ try 
to implement 'stat -f -', so I agree that we ought to do so for the consistency 
aspect.  I'm okay with failing with ENOSYS or ENOTSUP on platforms that lack a 
working fstat[v]fs.

-- 
Eric Blake






Re: stat vs. -

2009-09-29 Thread Jim Meyering
Eric Blake wrote:
 Jim Meyering jim at meyering.net writes:
  But how would you make it work *with* -f?  You don't know the path of the
  file used to create stdin (and in the case of a pipe, there is no path),

 There is no need for an actual file name, since fstatfs
 takes a file descriptor.  Of course, there's the issue
 that some systems don't have a usable fstatfs...

 Or fstatvfs, if you go by POSIX.  I stand corrected; it looks like we _can_ 
 try
 to implement 'stat -f -', so I agree that we ought to do so for the 
 consistency
 aspect.  I'm okay with failing with ENOSYS or ENOTSUP on platforms that lack a
 working fstat[v]fs.

I don't have time to do that right now.
If you feel like doing it, you're welcome to straighten it out.
I've just pushed what I just posted.




Re: [PATCH]: ls: do not show long iso time format for en_* locales

2009-09-29 Thread Paul Eggert
Jim Meyering j...@meyering.net writes:

 However, I'm a little reluctant to change back.
 Let's wait a day or two, in case Paul Eggert has an objection.

Here are some objections to the change, under the assumption that
we're in a poorly-configured environment (as the behavior is
unaffected in well-configured ones):

* The change will cause column-alignment problems in non-English
  locales where %b generates different numbers of columns for
  different months.

* There are more users in non-English locales than in non-C English
  locales, and the harm in the non-English case (incomprehensible
  dates) is much greater than the harm in the English case
  (comprehensible but ugly dates).

* The existing code is better for the poorly-configured case where
  only one of the two translations is missing.

Unless I'm missing something, I'd leave it alone, as it sounds like
the change will cause more trouble than it'll cure.




Petit: log analysis tool, very unix-ish

2009-09-29 Thread Scott McCarty
All, 
Woudl this tool be useful/interesting to the coreutils group? It's not 
in C, 
but has some unique/novel features. When I saw the program uniq, I did a man 
and saw this list. I thought it might be worth a look for the group. If you 
are interested, I wrote it in python over the last couple of months and 
licensed it under GPL3. There is a video that should show you what it does in 
about 2 minutes.

http://opensource.eyemg.com/Petit

Thanks
Scott M
-- 
Scott McCarty
EYEMG.com LLC - Interactive Media Group
190 North Union St.
Akron, Oh 44304
Office: 330-434-7873 ext 214