A question on the implementation of /dev/stdin, etc.
Kevin Schoedel
akcs.kevin at wcbcs
Sun May 6 23:10:50 AEST 1990
This discussion has prompted me to try to implement /dev/fd/... for
System V 3.2 on a 386. I don't have kernel source, so I can't use the
case IFCHR:
if( major( dev ) == fd_dev ){
dup minor(dev)
return;
}
(*cdevsw[ ....
technique that was mentioned here. I don't want to use a file system
for /dev/fd/... because that would prevent me using the synonyms
/dev/stdin, etc. So... is there any fundamental problem with having
a device, consisting only of an open routine, that gets rid of the
file descriptor just created for /dev/fd/N and then dup's N?
Specifically, I tried an open function containing, roughly,
f = ...file descriptor for /dev/fd/...
close( f )
dup( minor( dev ) )
As I said, I don't have source, and my knowledge of the kernel implementation
is restricted to having read John Lions' book, and perhaps things have
changed a bit since version 6. First, I tried looking in u.u_ar0[0] for
the file descriptor, but that was zero, which didn't seem right.
Then I tried searching u.u_ofile[] for a file whose inode was that of the
special file -- and sure enough, it was in u.u_ofile[0]. So now I'm
confused. Am I doing something slightly wrong or fundamentally wrong?
-kevin
More information about the Comp.unix.wizards
mailing list