Message-ID: <3884B374.81D9DDF4@softhome.net> Date: Tue, 18 Jan 2000 20:39:48 +0200 From: Laurynas Biveinis X-Mailer: Mozilla 4.7 [en] (Win98; I) X-Accept-Language: en MIME-Version: 1.0 To: DJGPP Workers Subject: Patch: fchown() Content-Type: text/plain; charset=iso-8859-4 Content-Transfer-Encoding: 7bit Reply-To: djgpp-workers AT delorie DOT com I've implemented it and updated docs. FSEXT hook is also included, pleases check if it is correct. Laurynas Biveinis ------------- diff -u -r -N djgpp.old/include/libc/stubs.h djgpp/include/libc/stubs.h --- 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 #define filelength __filelength #define findfirst __findfirst #define findnext __findnext 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 Tue Jan 18 20:03:44 2000 @@ -0,0 +1,20 @@ +/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +/* MS-DOS couldn't care less about file ownerships, so we always succeed. */ + +int +fchown(int fd, uid_t owner, gid_t group) +{ + __FSEXT_Function * func = __FSEXT_get_function(fd); + if (func) + { + int rv; + if (func(__FSEXT_read, &rv, &handle)) + return rv; + } + return 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 Tue Jan 18 20:04:48 2000 @@ -0,0 +1,23 @@ +@node fchown, unix +@subheading Syntax + +@example +#include + +int fchown(int fd, int owner, int group); +@end example + +@subheading Description + +This function does nothing under MS-DOS. This function can +be hooked by the @xref{File System Extensions}. + +@subheading Return Value + +This function always returns zero. + + +@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