This is the mail archive of the cygwin-developers@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Patch: access


And then there were three... patches.

I have patched access(2) to provide exacter results.

Bye,
Corinna


ChangeLog:
==========

Sun Dec 26 23:47:00 1999  Corinna Vinschen  <corinna@vinschen.de>

	* syscalls.cc (access): Refined implementation.
--- syscalls.cc.orig	Sun Dec 26 23:38:02 1999
+++ syscalls.cc	Sun Dec 26 23:37:38 1999
@@ -1027,6 +1027,7 @@ access (const char *fn, int flags)
   r = stat (fn, &st);
   if (r)
     return -1;
+#if 0
   if (flags & W_OK)
     {
       if (st.st_mode & S_IWRITE)
@@ -1036,6 +1037,53 @@ access (const char *fn, int flags)
       set_errno (EACCES);
       return -1;
     }
+#else
+  if (flags & R_OK)
+    {
+      if (st.st_uid == myself->uid)
+        {
+          if (!(st.st_mode & S_IRUSR))
+            return -1;
+        }
+      else if (st.st_gid == myself->gid)
+        {
+          if (!(st.st_mode & S_IRGRP))
+            return -1;
+        }
+      else if (!(st.st_mode & S_IROTH))
+        return -1;
+    }
+  if (flags & W_OK)
+    {
+      if (st.st_uid == myself->uid)
+        {
+          if (!(st.st_mode & S_IWUSR))
+            return -1;
+        }
+      else if (st.st_gid == myself->gid)
+        {
+          if (!(st.st_mode & S_IWGRP))
+            return -1;
+        }
+      else if (!(st.st_mode & S_IWOTH))
+        return -1;
+    }
+  if (flags & X_OK)
+    {
+      if (st.st_uid == myself->uid)
+        {
+          if (!(st.st_mode & S_IXUSR))
+            return -1;
+        }
+      else if (st.st_gid == myself->gid)
+        {
+          if (!(st.st_mode & S_IXGRP))
+            return -1;
+        }
+      else if (!(st.st_mode & S_IXOTH))
+        return -1;
+    }
+#endif
   return 0;
 }
 



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]