Hi Vin,
This all looks fine. I set X_OK to 0 on the basis that "if it exists, you
can execute it". I believe that testing for existence (0) is identical to
testing for read access (4). Detailed argument below.
According to the command "attrib /?" the valid file attributes are as
follows: -
S:\Dev\ConsoleTest>attrib /?
Displays or changes file attributes.
ATTRIB [+R | -R] [+A | -A ] [+S | -S] [+H | -H] [drive:][path][filename]
[/S [/D]]
+ Sets an attribute.
- Clears an attribute.
R Read-only file attribute.
A Archive file attribute.
S System file attribute.
H Hidden file attribute.
[drive:][path][filename]
Specifies a file or files for attrib to process.
/S Processes matching files in the current folder
and all subfolders.
/D Processes folders as well.
According to this, any file that exists allows read access.
Note that the WIN32 API does allow file permissions on a per file, per user
basis. File permissions do include "Read & Execute", "Read",
"Write" and
other permissions. According to MS, file permissions are only implemented
within the NTFS file system. They are not implemented within the FAT32 file
system.
Strictly speaking I believe this is incorrect. I believe that COM allows
developers to implement their own file systems that support File Permissions
(I haven't read the documentation for ages...). Therefore it may well be
possible to store an NTFS file (including permissions) inside a zip file
located on a FAT32 partition. I haven't tested this.
Opinion - I don't believe it is appropriate for the code we are discussing
to attempt to access file permissions. Please respond if you disagree.
Cheers,
Steve
-----Original Message-----
From: ethersoft(a)gmail.com [mailto:ethersoft@gmail.com] On Behalf Of Vin
Shelton
Sent: 03 May 2007 02:15
To: Steve Higham
Cc: Stephen J. Turnbull; Benson Margulies; xemacs-beta(a)xemacs.org
Subject: Re: [Bug: 21.4.20] Network Drives
Hi, Steve,
First, thanks for the patches on closing file descriptors. I took
your patches, made a few changes and will submit something to
xemacs-patches quickly. I'll CC: you when I submit.
On 4/30/07, Steve Higham <steve(a)sjlt.co.uk> wrote:
Your fix does not work. The stack dump is listed below. As you can
see,
mswindows_stat (...) is not being called. This is using version 21.4.20
code. The crash is invoked by temacs as it happens during the build
process.
Thanks for the stack trace - it was a big help.
mswindows_stat (...) is not being called
To be a bit more
precise, mswindows_stat() has already been called
before access() gets called. My thinko was that if the code had
already called ...stat(), a call to a function like access() would be
superfluous. After thinking it over a little bit, I'm back to
thinking that the right way to handle this (without significant code
surgery) is to redefine X_OK as you had previously suggested.
My fix of defining X_OK as 2 (under WIN32) is working fine and will
enable
me to debug my drive issue if / when it reappears.
... except you mean 4 (R_OK), right?
Here's the patch I'm currently trying out under Windows (native and
cygwin) and linux:
--- src/ChangeLog~ 2007-04-29 22:16:11.000000000 -0400
+++ src/ChangeLog 2007-05-01 22:20:19.218750000 -0400
@@ -0,0 +1,6 @@
+2007-05-01 Vin Shelton <acs(a)xemacs.org>
+
+ * nt.c (mswindows_stat): Tie _S_IEXEC permission to read access.
+ (mswindows_fstat): Ditto.
+ * sysfile.h: Under Windows, define X_OK to be the same as R_OK.
+
Index: src/sysfile.h
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/sysfile.h,v
retrieving revision 1.9.2.1
diff -a -u -r1.9.2.1 sysfile.h
--- src/sysfile.h 2001/07/25 07:45:39 1.9.2.1
+++ src/sysfile.h 2007/05/02 18:38:51
@@ -261,12 +261,18 @@
#endif
/* The following definitions are needed under Windows, at least */
-#ifndef X_OK
-# define X_OK 1
-#endif
-
#ifndef R_OK
# define R_OK 4
+#endif
+
+/* Under native Windows, there is no concept of execute permission,
+ so redefine execute permissions to be the same as read permission */
+#ifndef X_OK
+# ifdef WIN32_NATIVE
+# define X_OK R_OK
+# else
+# define X_OK 1
+# endif
#endif
#ifndef W_OK
Index: src/nt.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/nt.c,v
retrieving revision 1.21.2.4
diff -a -u -r1.21.2.4 nt.c
--- src/nt.c 2005/01/31 02:55:24 1.21.2.4
+++ src/nt.c 2007/05/02 18:39:05
@@ -1449,9 +1449,9 @@
/* determine rwx permissions */
if (info.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
- permission = _S_IREAD;
+ permission = _S_IREAD | _S_IEXEC;
else
- permission = _S_IREAD | _S_IWRITE;
+ permission = _S_IREAD | _S_IEXEC |_S_IWRITE;
if (info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
permission |= _S_IEXEC;
@@ -1638,22 +1638,12 @@
/* determine rwx permissions */
if (wfd.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
- permission = _S_IREAD;
+ permission = _S_IREAD | _S_IEXEC;
else
- permission = _S_IREAD | _S_IWRITE;
+ permission = _S_IREAD | _S_IEXEC |_S_IWRITE;
if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
permission |= _S_IEXEC;
- else
- {
- char * p = strrchr (name, '.');
- if (p != NULL &&
- (stricmp (p, ".exe") == 0 ||
- stricmp (p, ".com") == 0 ||
- stricmp (p, ".bat") == 0 ||
- stricmp (p, ".cmd") == 0))
- permission |= _S_IEXEC;
- }
buf->st_mode |= permission | (permission >> 3) | (permission >> 6);
Comments welcome.
- Vin
--
The Journey by Mary Oliver
http://www.poemhunter.com/p/m/poem.asp?poet=6771&poem=30506
_______________________________________________
XEmacs-Beta mailing list
XEmacs-Beta(a)xemacs.org
http://calypso.tux.org/cgi-bin/mailman/listinfo/xemacs-beta