bug-fileutils
[Top][All Lists]
Advanced

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

Fix for copy.c preserving st_author


From: Marcus Brinkmann
Subject: Fix for copy.c preserving st_author
Date: Sat, 17 Aug 2002 18:51:37 +0200
User-agent: Mutt/1.4i

Hi,

the copy.c change to preserve the author field that was submitted by Alfred
was broken.  It has a gross type error (getdport takes an fd and not a
string), so it was obviously never compiled with warnings enabled or tested.

Here is the correct one.  BTW, wouldn't it make more sense to open the file
once and then use fchmod etc?  Then Alfred's approach would be better, with
dst_path replaced by the appropriate file descriptor.

Thanks,
Marcus

2002-08-17  Marcus Brinkmann  <address@hidden>

        * src/copy.c (copy_internal): Fix athor preservation code.

--- fileutils-4.1.10.old/src/copy.c     Fri Jun 21 14:07:40 2002
+++ fileutils-4.1.10/src/copy.c Sat Aug 17 20:42:40 2002
@@ -1517,11 +1517,17 @@ copy_internal (const char *src_path, con
 #if HAVE_STRUCT_STAT_ST_AUTHOR
   /* Preserve the st_author field.  */
   {
-    file_t file = getdport (dst_path);
-    if (file_chauthor (file, src_sb.st_author))
-      error (0, errno, _("failed to preserve authorship for %s"),
-            quote (dst_path));
-    mach_port_deallocate (mach_task_self (), file);
+    file_t file = file_name_lookup (dst_path, O_NORW, 0);
+    if (file == MACH_PORT_NULL)
+      error (0, errno, _("failed to lookup file %s"), quote (dst_path));
+    else
+      {
+       int err = file_chauthor (file, src_sb.st_author);
+       if (err)
+         error (0, err, _("failed to preserve authorship for %s"),
+                quote (dst_path));
+       mach_port_deallocate (mach_task_self (), file);
+      }
   }
 #endif
 


-- 
`Rhubarb is no Egyptian god.' GNU      http://www.gnu.org    address@hidden
Marcus Brinkmann              The Hurd http://www.gnu.org/software/hurd/
address@hidden
http://www.marcus-brinkmann.de/




reply via email to

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