delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2000/01/19/07:59:29

Message-ID: <3885B091.2A75187C@softhome.net>
Date: Wed, 19 Jan 2000 14:39:45 +0200
From: Laurynas Biveinis <lauras AT softhome DOT net>
X-Mailer: Mozilla 4.7 [en] (Win98; I)
X-Accept-Language: en
MIME-Version: 1.0
To: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
CC: DJGPP Workers <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>
Reply-To: djgpp-workers AT delorie DOT com

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.

> > +    if (func(__FSEXT_read, &rv, &handle))
>                 ^^^^^^^^^^^^
> This should have been __FSEXT_fchown ;-).

:-) What a absent-mindeness :-) A result of taking
_read.c as a template for fchown.c. Another similar
thingie was extra (C) line with year 1995...

> I thought you wanted to check that the handle is valid, no?  As

Now I do check it.

Anyway, below is revised patch version.
Laurynas Biveinis
------------
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