hokey@plus5.UUCP (Hokey) (05/11/85)
It has been my experience that the file descriptor returned from a successful invocation of creat() is writaable but not readable, regardless of the mode specified to creat(). Does anybody know of a way to change this (kernel mods are unacceptable)? One problem is that I occasionally need r/w access to a creat()ed fd which must have a mode of 0444 for exclusive lock purposes. I need this functionality for Unix implementations which do not have the 3 argument form of open(). Is the only solution to use temporary files, link()s, and chmod()s? -- Hokey ..ihnp4!plus5!hokey 314-725-9492
guy@sun.uucp (Guy Harris) (05/15/85)
> It has been my experience that the file descriptor returned from a > successful invocation of creat() is writaable but not readable, regardless > of the mode specified to creat(). > > Does anybody know of a way to change this (kernel mods are unacceptable)? There isn't any which doesn't involve changing the kernel, except for closing and reopening the file (which won't work in your case). > One problem is that I occasionally need r/w access to a creat()ed fd which > must have a mode of 0444 for exclusive lock purposes. Try using "link" and "unlink" to/from a file for locking purposes; it means the file doesn't have to be unwritable, and also means you can lock out the superuser. Guy Harris
alan@drivax.UUCP (Alan Fargusson) (05/16/85)
> It has been my experience that the file descriptor returned from a successful > invocation of creat() is writaable but not readable, regardless of the mode > specified to creat(). I have thought that this characteristic is nieve. You can get around it by doing a creat followed by an open. Of course you can only have 10 open files unless you remember to close the fd returned by the create. Now for my question (in the same vain). Why do things like chmod, and link, take a path name, not a fd? I understand that unlink needs a path name because it is an operation on a directory as much as on a file. But link has to take a path name and open it in a way, then make the link. I have had one case where I had to save a file name so I could pass it to link where I had the fd. But this could fail if someone unlinked the file while I had it open. -- Alan Fargusson. { ihnp4, sftig, amdahl, ucscc, ucbvax!unisoft }!drivax!alan