Message-ID: <397F0384.D88CD100@softhome.net> Date: Wed, 26 Jul 2000 17:28:04 +0200 From: Laurynas Biveinis X-Mailer: Mozilla 4.73 [en] (Win98; U) X-Accept-Language: lt,en MIME-Version: 1.0 To: djgpp-workers AT delorie DOT com Subject: Re: Patch: lchown() References: <395606D5 DOT 1A0F26D AT softhome DOT net> <397C6816 DOT F91EEFD AT softhome DOT net> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp-workers AT delorie DOT com I wrote: > I wrote: > > this patch adds a doing-nothing lchown(), as > > a part of upcoming symlink support. > > I haven't received explicit approval in a month. If > nobody speaks up in a short time (say, a day or two), > I apply it. OK, so you've asked for it :) Here is what I've actually commited. Also I am thinking about testsuite for both chown and lchown, how about following: --8<---8<---- #include #include #include int main(void) { if (!lchown("/dev/env/DJDIR/bin/gcc.exe", 1, 2)) printf("OK! lchown() found existing file.\n"); else perror("lchown failed: "); if (lchown("/well/I/dont/think/this/would/exist/anywhere.exe", 2, 1)) { if (errno == ENOENT) printf("OK! lchown() failed for non-existing file.\n"); else perror("Huh? lchown() failed with wrong errno: "); } else printf("What? lchown() suceeded for non-existing file?\n"); } ---8<---8<--- Any suggestions for its implementation? Should I just follow the lead or do you have any ideas currently not implemented in testsuite? Laurynas Index: djgpp/include/unistd.h =================================================================== RCS file: /cvs/djgpp/djgpp/include/unistd.h,v retrieving revision 1.6 diff -u -r1.6 unistd.h --- unistd.h 2000/06/19 18:00:55 1.6 +++ unistd.h 2000/07/26 15:11:25 @@ -135,6 +135,7 @@ int gethostname(char *buf, int size); int getpagesize(void); char * getwd(char *__buffer); +int lchown(const char * file, int owner, int group); offset_t llseek(int _fildes, offset_t _offset, int _whence); int nice(int _increment); void * sbrk(int _delta); Index: djgpp/src/docs/kb/wc204.txi =================================================================== RCS file: /cvs/djgpp/djgpp/src/docs/kb/wc204.txi,v retrieving revision 1.13 diff -u -r1.13 wc204.txi --- wc204.txi 2000/07/24 15:52:47 1.13 +++ wc204.txi 2000/07/26 15:11:27 @@ -82,3 +82,6 @@ @findex stpncpy New function @code{stpncpy} has been added, thanks to @email{restone@@skypoint.com, Richard E. Stone}. + +@findex lchown +New function @code{lchown} has been added for UNIX compatibility. Index: djgpp/src/libc/libc.tex =================================================================== RCS file: /cvs/djgpp/djgpp/src/libc/libc.tex,v retrieving revision 1.5 diff -u -r1.5 libc.tex --- libc.tex 1999/11/28 11:20:47 1.5 +++ libc.tex 2000/07/26 15:11:28 @@ -115,6 +115,7 @@ * getgroups:: Trivial. * getpwnam:: Trivial. * getpwuid:: Trivial. +* lchown:: Trivial. * mkfifo:: Always fails. * mknod:: Trivial. * nice:: No-op. Index: djgpp/src/libc/compat/unistd/lchown.c =================================================================== RCS file: lchown.c diff -N lchown.c --- /dev/null Tue May 5 16:32:27 1998 +++ lchown.c Wed Jul 26 11:11:32 2000 @@ -0,0 +1,18 @@ +/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +/* MS-DOS couldn't care less about file ownerships, so we could + always succeed. At least fail for non-existent files + and for devices. */ + +int +lchown(const char *path, uid_t owner, gid_t group) +{ + if (!__file_exists(path)) /* non-existent file */ + { + errno = ENOENT; + return -1; + } + return 0; +} Index: djgpp/src/libc/compat/unistd/lchown.txh =================================================================== RCS file: lchown.txh diff -N lchown.txh --- /dev/null Tue May 5 16:32:27 1998 +++ lchown.txh Wed Jul 26 11:11:32 2000 @@ -0,0 +1,24 @@ +@node lchown, unix +@subheading Syntax + +@example +#include + +int lchown(const char *file, int owner, int group); +@end example + +@subheading Description + +This function does nothing under MS-DOS + +@subheading Return Value + +This function always returns zero if the file exists (it does not +follow symbolic links), else it returns -1 and sets @code{errno} +to @code{ENOENT}. + + +@subheading Portability + +@portability !ansi, !posix + Index: djgpp/src/libc/compat/unistd/makefile =================================================================== RCS file: /cvs/djgpp/djgpp/src/libc/compat/unistd/makefile,v retrieving revision 1.3 diff -u -r1.3 makefile --- makefile 2000/06/19 18:00:56 1.3 +++ makefile 2000/07/26 15:11:32 @@ -10,6 +10,7 @@ SRC += gethostn.c SRC += getpages.c SRC += getwd.c +SRC += lchown.c SRC += llseek.c SRC += nice.c SRC += sync.c