bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: summarizing gnulib changes for coreutils-7.7?


From: Eric Blake
Subject: Re: summarizing gnulib changes for coreutils-7.7?
Date: Wed, 23 Sep 2009 21:50:30 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Jim Meyering <jim <at> meyering.net> writes:

> > OK, I've pushed the NEWS change (including the typo fix
> > canonicalize=>readlink), then a separate commit to resync gnulib.
> 
> Thanks.

Here's another patch related to gnulib churn.  I am _NOT_ planning on 
attempting to port coreutils to mingw, so the mingw folks may still have a lot 
of work to make coreutils handle their platform's oddities nicely.  But this 
patch should be okay (it is a no-op if applied before my matching gnulib change 
to SAME_INODE to be tri-state [1]; and if applied afterwards, it should have no 
semantic changes for sane platforms where st_ino is never 0), and at least in 
theory will make life more bearable for the poor guy who does try to port 
coreutils to mingw.  OK to apply?

[1] http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/18854


From: Eric Blake <address@hidden>
Date: Wed, 23 Sep 2009 15:42:05 -0600
Subject: [PATCH] build: reflect same-inode changes from gnulib

On mingw, st_ino is always 0, so SAME_INODE returns -1.  Also,
st_nlink is always 1, so even though the link module can
create hard links, we can't detect them.  Here is an analysis
of all uses of SAME_INODE in coreutils:

root-dev-ino - mingw can't delete root dir anyway
chown-core - can't rename in-use files
copy - can't rename in-use files, no way to detect hard links
  to protect them, and no symlinks; behavior on identical
  files may be non-compliant, but that's life for mingw users
cp-hash - using -1 may lead to more hash collisions, but still
  correct behavior
du - no way to detect hard links, so they will be double-counted
ln - trying ln -f k k will delete k, but that's life for mingw
  and complies with POSIX
ls - no directory cycles, so no problem
pwd - getpwd is always accurate, and no symlinks so no -L needed
sort - will always use temporary file, but still correct

* gl/lib/root-dev-ino.h (ROOT_DEV_INO_CHECK): Update caller.
* src/du.c (entry_compare): Likewise.
* src/ln.c (do_link): Likewise.
* src/ls.c (dev_ino_compare): Likewise.
* src/pwd.c (robust_getcwd, logical_getcwd): Likewise.

Signed-off-by: Eric Blake <address@hidden>
---
 gl/lib/root-dev-ino.h |    2 +-
 src/copy.c            |    2 +-
 src/du.c              |    2 +-
 src/ln.c              |    2 +-
 src/ls.c              |    2 +-
 src/pwd.c             |    5 +++--
 6 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/gl/lib/root-dev-ino.h b/gl/lib/root-dev-ino.h
index bec27f0..3ee1d88 100644
--- a/gl/lib/root-dev-ino.h
+++ b/gl/lib/root-dev-ino.h
@@ -28,7 +28,7 @@ get_root_dev_ino (struct dev_ino *root_d_i);
    --preserve-root and --no-preserve-root options.  */

 # define ROOT_DEV_INO_CHECK(Root_dev_ino, Dir_statbuf) \
-    (Root_dev_ino && SAME_INODE (*Dir_statbuf, *Root_dev_ino))
+    (Root_dev_ino && SAME_INODE (*Dir_statbuf, *Root_dev_ino) == 1)

 # define ROOT_DEV_INO_WARN(Dirname)                                    \
   do                                                                   \
diff --git a/src/copy.c b/src/copy.c
index e3c5c52..7d26b59 100644
--- a/src/copy.c
+++ b/src/copy.c
@@ -1971,7 +1971,7 @@ copy_internal (char const *src_name, char const *dst_name,
                                directory.  Other things will fail later.  */
                             || stat (".", &dot_sb) != 0
                             || stat (dst_parent, &dst_parent_sb) != 0
-                            || SAME_INODE (dot_sb, dst_parent_sb));
+                            || SAME_INODE (dot_sb, dst_parent_sb) == 1);
           free (dst_parent);

           if (! in_current_dir)
diff --git a/src/du.c b/src/du.c
index 9831a17..7382ff1 100644
--- a/src/du.c
+++ b/src/du.c
@@ -354,7 +354,7 @@ entry_compare (void const *x, void const *y)
 {
   struct entry const *a = x;
   struct entry const *b = y;
-  return SAME_INODE (*a, *b) ? true : false;
+  return SAME_INODE (*a, *b) == 1 ? true : false;
 }

 /* Try to insert the INO/DEV pair into the global table, HTAB.
diff --git a/src/ln.c b/src/ln.c
index 0c35338..6e1ecdc 100644
--- a/src/ln.c
+++ b/src/ln.c
@@ -214,7 +214,7 @@ do_link (const char *source, const char *dest)
          misleading.  */
       && (backup_type == no_backups || !symbolic_link)
       && (!symbolic_link || stat (source, &source_stats) == 0)
-      && SAME_INODE (source_stats, dest_stats)
+      && SAME_INODE (source_stats, dest_stats) == 1
       /* The following detects whether removing DEST will also remove
          SOURCE.  If the file has only one link then both are surely
          the same link.  Otherwise check whether they point to the same
diff --git a/src/ls.c b/src/ls.c
index 1bb6873..45543e4 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -1076,7 +1076,7 @@ dev_ino_compare (void const *x, void const *y)
 {
   struct dev_ino const *a = x;
   struct dev_ino const *b = y;
-  return SAME_INODE (*a, *b) ? true : false;
+  return SAME_INODE (*a, *b) == 1 ? true : false;
 }

 static void
diff --git a/src/pwd.c b/src/pwd.c
index cfbf5b7..a2e7a2b 100644
--- a/src/pwd.c
+++ b/src/pwd.c
@@ -280,7 +280,7 @@ robust_getcwd (struct file_name *file_name)
   while (1)
     {
       /* If we've reached the root, we're done.  */
-      if (SAME_INODE (dot_sb, *root_dev_ino))
+      if (SAME_INODE (dot_sb, *root_dev_ino) == 1)
         break;

       find_dir_entry (&dot_sb, file_name, height++);
@@ -315,7 +315,8 @@ logical_getcwd (void)
     }

   /* System call validation.  */
-  if (stat (wd, &st1) == 0 && stat (".", &st2) == 0 && SAME_INODE(st1, st2))
+  if (stat (wd, &st1) == 0 && stat (".", &st2) == 0
+      && SAME_INODE(st1, st2) == 1)
     return wd;
   return NULL;
 }
-- 
1.6.4.2







reply via email to

[Prev in Thread] Current Thread [Next in Thread]