Mail Archives: djgpp-workers/1997/01/22/06:28:41
On 21 Jan 1997, Peter Gerwinski wrote:
> when applying the `access' function to DOS device files like `prn'
> or `lpt1', it returns "not writeable":
I replied to the poster, but I'm unsure whether we need to fix this and
if so, how exactly. The problem is that DOS fails the `_chmod' call.
This can be remedied with `findfirst', as the patch below shows, but then
all devices come out both readable and writeable, since there is no way
to tell if a device can be written to or read from without opening it
first (which will make `access' much slower).
Please tell me whether you think the patch below is a Good Thing.
*** src/libc/posix/unistd/access.c~0 Wed Jan 22 10:12:40 1997
--- src/libc/posix/unistd/access.c Wed Jan 22 10:28:02 1997
*************** int access(const char *fn, int flags)
*** 32,37 ****
--- 32,44 ----
return 0;
}
+ /* Devices also fail `_chmod'; some programs won't write to
+ a device unless `access' tells them they are writeable. */
+ if (findfirst(fn, &ff, FA_RDONLY | FA_ARCH) == 0
+ && (ff.ff_attrib & 0x40) == 0x40
+ && (flags & (X_OK | D_OK)) == 0)
+ return 0;
+
errno = ENOENT;
return -1;
}
- Raw text -