Date: Wed, 22 Jan 1997 13:17:03 +0200 (IST) From: Eli Zaretskii To: djgpp-workers AT delorie DOT com Subject: Re: `access' function and `prn' etc. In-Reply-To: <5c2fls$a3s@sun3.uni-essen.de> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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; }