delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2000/06/28/04:59:26

Message-ID: <3959BF50.6FB7BB3E@softhome.net>
Date: Wed, 28 Jun 2000 11:03:12 +0200
From: Laurynas Biveinis <lauras AT softhome DOT net>
X-Mailer: Mozilla 4.73 [en] (Win98; U)
X-Accept-Language: lt,en
MIME-Version: 1.0
To: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
CC: djgpp-workers AT delorie DOT com
Subject: Re: Patch: chown() preparation for symlinks
References: <Pine DOT SUN DOT 3 DOT 91 DOT 1000627153406 DOT 19259I-100000 AT is>
Reply-To: djgpp-workers AT delorie DOT com

Eli Zaretskii wrote:
> If we want chown to support devices and root directories, you might
> as well use your original code with access instead of __file_exists.
> It doesn't make sense to add complexity to __file_exists just to make
> a no-op function such as chown be marginally simpler.

So __file_exists() is intentionally meant not to detect devices?
This sounds a little bit dangerous to me. At least it should be
documented. (I put it in my TODO which is dangerously increasing).

But in any case, chown() should use access(). OK to commit?

Laurynas

Index: chown.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/posix/unistd/chown.c,v
retrieving revision 1.1
diff -u -r1.1 chown.c
--- chown.c	1995/06/18 07:43:52	1.1
+++ chown.c	2000/06/28 08:58:27
@@ -1,7 +1,7 @@
+/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
 #include <libc/stubs.h>
 #include <unistd.h>
-#include <sys/stat.h>
 #include <errno.h>
  
 /* MS-DOS couldn't care less about file ownerships, so we could
@@ -9,9 +9,10 @@
    and for devices.  */
  
 int
-chown(const char *path, uid_t owner, gid_t group)
+chown(const char *path, uid_t owner __attribute__((__unused__)), 
+                        gid_t group __attribute__((__unused__)))
 {
-  if (!__file_exists(path))       /* non-existent file */
+  if (access(path, F_OK))       /* non-existent file */
   {
     errno = ENOENT;
     return -1;

- Raw text -


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