delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/12/11/06:41:47

To: elf AT netcom DOT com (Marc Singer)
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu (DJGPP List Alias)
Subject: Re: chmod and fchmod
Date: Sun, 11 Dec 94 12:20:28 +0200
From: "Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il>

> If I have a file open and I chmod on that file, my open file handle is
> invalidated.  How do I know?  If I close the file handle after doing
> the chmod, I get an error about an illegal file handle.  Is this
> expected behavior from DJGPP?  The other option would be to use
> fchmod, but this call responds with the error that it is
> unimplemented.

DJGPP's chmod just jumps to the extender, which then just calls
chmod() in Turbo C library.  What does Borland's chmod() do in
a similar case?

fchmod() isn't implemented in DJGPP because there is no such DOS
call, and once file is opened its pathname cannot be retrieved
under DOS in any way short of searching the entire disk.

> In addition, I am not clear if the mode bits in the stat structure are
> set according to the mode bits in DOS.  I believe I was seeing a file
> as read only if I opened it for reading even though that file was RW
> on disk.

If you called fstat() on that file, then it figures, because DJGPP's
fstat() just calls Turbo C fstat() via the go32 extender, and TC's
fstat() indeed returns access bits in struct stat as if *every*
file were read-only, not only those you open in read-only mode.  The
reason is it is *very* hard under DOS to get attribute bits for a
file given only its handle, so Borland didn't bother to try harder.
Take a look at the version of f?stat() I've written for DJGPP, which
does bring correct access bits.  It should be included in DJGPP v2.0,
but for now you can get at it by anonymous ftp to
omnigate.clarkson.edu:/pub/msdos/djgpp/pub/djstat02.zip.

- Raw text -


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