getcwd() and friends.
Peter da Silva
peter at ficc.uu.net
Sat Apr 8 01:34:45 AEST 1989
In article <2001 at unisoft.UUCP>, greywolf at unisoft.UUCP (The Grey Wolf) writes:
> Do you really mean "rather than" as "instead of"? I like the idea of
> being able to do either/or, depending on what you wanted to do. I mean,
> if they were "instead of", and chmod() were eliminated so that only
> fchmod remained, how would you change the mode of a file that was mode
> 000? You wouldn't be able to O_RDWR or O_EXEC the file/directory and
> therefore couldn't gain a valid file descriptor to pass to fchmod().
> I think that the option of f() commands should remain open.
How about O_TOKEN which returns a fd you can't do anything to until you
do another open on it. Soirt of like an RMX file token or an AmigaDOS
file lock. Have to call the fd version of open something other than
fopen or fdopen, though.
This would make 'dup' into fd_open(fd, O_CLONE), where O_CLONE means
'same flags as the first fd'...
Do this cleverly enough and almost all the regular calls can actually use
the new calls... you just need to keep 'open' around so you can get the
fd in the first place:
link(name, newname)
char *name, *newname;
{
int fd;
fd = open(name, O_TOKEN);
if(fd >= 0)
{
retval = fd_link(fd, newname);
close(fd);
}
else
return -1;
}
--
Peter da Silva, Xenix Support, Ferranti International Controls Corporation.
Business: uunet.uu.net!ficc!peter, peter at ficc.uu.net, +1 713 274 5180.
Personal: ...!texbell!sugar!peter, peter at sugar.hackercorp.com.
More information about the Comp.unix.wizards
mailing list