delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2002/04/05/07:40:45

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-workers-bounces using -f
Sender: rich AT phekda DOT freeserve DOT co DOT uk
Message-ID: <3CAD96E3.586DBA4A@phekda.freeserve.co.uk>
Date: Fri, 05 Apr 2002 13:21:55 +0100
From: Richard Dawe <rich AT phekda DOT freeserve DOT co DOT uk>
X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.2.19 i586)
X-Accept-Language: de,fr
MIME-Version: 1.0
To: djgpp-workers AT delorie DOT com
Subject: Re: Patch: fchown()
References: <Pine DOT SUN DOT 3 DOT 91 DOT 1000119115250 DOT 9609S-100000 AT is> <3885B091 DOT 2A75187C AT softhome DOT net>
Reply-To: djgpp-workers AT delorie DOT com

Hello.

This is going back a while. Laurynas provided some code to add fchown to
DJGPP. The patch seems to have been approved, but not committed. I've included
the patch in full at the end of this mail. For those who want to find the
original mail, it's dated Wed, 19 Jan 2000 14:39:45 +0200.

NB: I've found that Fileutils 4.1 uses fchown.

Laurynas Biveinis wrote:
> 
> Eli Zaretskii wrote:
> > > --- djgpp.old/include/libc/stubs.h    Mon Sep  8 01:07:18 1997
> > > +++ djgpp/include/libc/stubs.h        Sun Jan  9 15:06:58 2000
> > > @@ -36,6 +36,7 @@
> > >  #define crlf2nl __crlf2nl
> > >  #define dosmemget __dosmemget
> > >  #define dosmemput __dosmemput
> > > +#define fchown __fchown
> >
> > Why did you need to add this?  This is only required if some ANSI or
> > Posix function calls fchown.  I don't think this is the case.
> 
> Deleted.

We actually need the line in libc/stubs.h, to get mkstubs to generate a stub,
so that we don't pollute the ANSI namespace with a POSIX/SUSv2 symbol.

[snip] 
> --- djgpp.old/src/libc/fsext/fsext.txh  Tue Jan 18 20:07:54 2000
> +++ djgpp/src/libc/fsext/fsext.txh      Tue Jan 18 20:08:58 2000
> @@ -109,6 +109,11 @@
>  A file fstat handler (@pxref{fstat}).  The extension should fill in
>  various status information about the emulated file.
> 
> +@item __FSEXT_fchown
> +
> +A file fchown handler (@pxref{fchown}). This is called when file
> +attributtes are changed for an open file.
> +
>  @end table

'attributtes' should be attributes.

Is it OK to commit, if I fix libc/stubs.h and the typo in the .txh file?

Bye, Rich =]

-- 
Richard Dawe [ http://www.phekda.freeserve.co.uk/richdawe/ ]


diff -u -r -N djgpp.old/include/sys/fsext.h djgpp/include/sys/fsext.h
--- djgpp.old/include/sys/fsext.h       Mon Jun 29 00:17:44 1998
+++ djgpp/include/sys/fsext.h   Fri Jan 14 13:33:20 2000
@@ -31,7 +31,8 @@
   __FSEXT_dup,
   __FSEXT_dup2,
   __FSEXT_fstat,
-  __FSEXT_stat
+  __FSEXT_stat,
+  __FSEXT_fchown,
 } __FSEXT_Fnumber;
 
 /* _ready gets passed a fd and should return a mask of these,
diff -u -r -N djgpp.old/include/unistd.h djgpp/include/unistd.h
--- djgpp.old/include/unistd.h  Sat Dec 25 00:08:40 1999
+++ djgpp/include/unistd.h      Tue Jan 18 20:19:42 2000
@@ -129,6 +129,7 @@
 int            brk(void *_heaptop);
 char *         dirname(const char *_fn);
 int            __file_exists(const char *_fn);
+int             fchown(int fd, uid_t owner, gid_t group);
 int            fsync(int _fd);
 int            ftruncate(int, off_t);
 int            getdtablesize(void);
diff -u -r -N djgpp.old/src/libc/fsext/fsext.txh
djgpp/src/libc/fsext/fsext.txh
--- djgpp.old/src/libc/fsext/fsext.txh  Tue Jan 18 20:07:54 2000
+++ djgpp/src/libc/fsext/fsext.txh      Tue Jan 18 20:08:58 2000
@@ -109,6 +109,11 @@
 A file fstat handler (@pxref{fstat}).  The extension should fill in
 various status information about the emulated file.
 
+@item __FSEXT_fchown
+
+A file fchown handler (@pxref{fchown}). This is called when file
+attributtes are changed for an open file.
+
 @end table
 
 
diff -u -r -N djgpp.old/src/libc/libc.tex djgpp/src/libc/libc.tex
--- djgpp.old/src/libc/libc.tex Sun Nov 28 13:20:48 1999
+++ djgpp/src/libc/libc.tex     Tue Jan 18 20:32:20 2000
@@ -107,6 +107,7 @@
 * cfsetispeed::              No-op.
 * cfsetospeed::              No-op.
 * chown::                    Trivial.
+* fchown::                   Trivial.
 * fcntl::                    Always fails for all operations except
                              @code{F_DUPFD} and @code{F_GETFD}.
 * fork::                     Always fails.
diff -u -r -N djgpp.old/src/libc/posix/unistd/fchown.c
djgpp/src/libc/posix/unistd/fchown.c
--- djgpp.old/src/libc/posix/unistd/fchown.c    Thu Jan  1 00:00:00 1970
+++ djgpp/src/libc/posix/unistd/fchown.c        Wed Jan 19 14:38:42 2000
@@ -0,0 +1,19 @@
+/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */
+#include <sys/fsext.h>
+#include <io.h>
+#include <unistd.h>
+ 
+/* MS-DOS couldn't care less about file ownerships, so we 
+   at least check if given handle is valid. */
+ 
+int fchown(int fd, uid_t owner, gid_t group)
+{
+  __FSEXT_Function * func = __FSEXT_get_function(fd);
+  if (func)
+  {
+    int rv;
+    if (func(__FSEXT_fchown, &rv, &fd))
+      return rv;
+  }
+  return (_get_dev_info(fd) == -1) ? 1 : 0;
+}
diff -u -r -N djgpp.old/src/libc/posix/unistd/fchown.txh
djgpp/src/libc/posix/unistd/fchown.txh
--- djgpp.old/src/libc/posix/unistd/fchown.txh  Thu Jan  1 00:00:00 1970
+++ djgpp/src/libc/posix/unistd/fchown.txh      Wed Jan 19 14:05:50 2000
@@ -0,0 +1,25 @@
+@node fchown, unix
+@subheading Syntax
+
+@example
+#include <unistd.h>
+
+int fchown(int fd, int owner, int group);
+@end example
+
+@subheading Description
+
+This function does almost nothing under MS-DOS, it just
+checks if the handle @code{fd} is valid. This function can 
+be hooked by the @xref{File System Extensions}.
+
+@subheading Return Value
+
+This function returns zero if the handle is valid, non-zero
+otherwise.
+
+
+@subheading Portability
+
+@portability !ansi, !posix
+
diff -u -r -N djgpp.old/src/libc/posix/unistd/makefile
djgpp/src/libc/posix/unistd/makefile
--- djgpp.old/src/libc/posix/unistd/makefile    Fri Sep 20 02:40:46 1996
+++ djgpp/src/libc/posix/unistd/makefile        Sun Jan  9 15:04:38 2000
@@ -18,6 +18,7 @@
 SRC += execve.c
 SRC += execvp.c
 SRC += execvpe.c
+SRC += fchown.c
 SRC += fork.c
 SRC += fpathcon.c
 SRC += getcwd.c

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019