bug-hurd
[Top][All Lists]
Advanced

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

Re: Getting a file_t from a file descriptor


From: Paul Eggert
Subject: Re: Getting a file_t from a file descriptor
Date: Thu, 20 Jul 2006 16:08:44 -0700
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

Thomas Schwinge <tschwinge@gnu.org> writes:

> While I'm not that proficient in these issues,

Nor am i.

> /* Return the io server port for file descriptor FD.
>    This adds a Mach user reference to the returned port.
>    On error, sets `errno' and returns MACH_PORT_NULL.  */

Thanks, that looks quite promising.  Is a "Mach user reference" the
sort of thing that mach_port_deallocate removes?  If so, does the
following patch work for you?  Is the diagnostic appropriate?

> Please tell if you (or anyone else, of course) need access to a GNU/Hurd
> system.

I'm afraid it's a lot to learn all at once; I was hoping you could
help with the minor porting problems.

--- copy.c      2006-07-05 02:08:42.000000000 -0700
+++ /home/eggert/junk/copy.c    2006-07-20 16:06:57.000000000 -0700
@@ -213,12 +213,17 @@ set_owner (const struct cp_options *x, c
 static void
 set_author (const char *dst_name, int dest_desc, const struct stat *src_sb)
 {
-  /* FIXME: Preserve the st_author field via the file descriptor dest_desc.  */
 #if HAVE_STRUCT_STAT_ST_AUTHOR
   /* Preserve the st_author field.  */
-  file_t file = file_name_lookup (dst_name, 0, 0);
+  file_t file = (dest_desc < 0
+                ? file_name_lookup (dst_name, 0, 0)
+                : getdport (dest_desc));
   if (file == MACH_PORT_NULL)
-    error (0, errno, _("failed to lookup file %s"), quote (dst_name));
+    error (0, errno,
+          _(dest_desc < 0
+            ? "failed to lookup file %s"
+            : "failed to get a dtable port for file %s"),
+          quote (dst_name));
   else
     {
       error_t err = file_chauthor (file, src_sb.st_author);




reply via email to

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