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  <[EMAIL PROTECTED]>

        * 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    [EMAIL PROTECTED]
Marcus Brinkmann              The Hurd http://www.gnu.org/software/hurd/
[EMAIL PROTECTED]
http://www.marcus-brinkmann.de/


_______________________________________________
Bug-fileutils mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/bug-fileutils

Reply via email to