Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!husc6!think!ames!ucbcad!ucbvax!decvax!tektronix!tekcrl!terryl From: terryl@tekcrl.TEK.COM Newsgroups: comp.unix.questions Subject: Re: File descriptors Message-ID: <1673@tekcrl.TEK.COM> Date: Thu, 21-May-87 17:45:50 EDT Article-I.D.: tekcrl.1673 Posted: Thu May 21 17:45:50 1987 Date-Received: Sat, 23-May-87 14:13:06 EDT References: <2532@ncoast.UUCP> <5875@brl-smoke.ARPA> Reply-To: terryl@tekcrl.tek.com Organization: Tektronix, Inc., Beaverton, OR. Lines: 34 In article <5875@brl-smoke.ARPA> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) writes: >In article <2532@ncoast.UUCP> robertd@ncoast.UUCP (Rob DeMarco) writes: >> Can some one tell me what a "File Descriptor" is? Thank you. > >It's just an index into an open-file table maintained inside the >kernel; the open-file table is used to keep track of the state of >the open file (such as, where is the actual data, and how far into >the data is the file position pointer associated with this F.D.). >Think of it as a "handle" on the file that the kernel gives you when >you open it. For further information read Ken Thompson's "UNIX >Implementation" (used to be in Vol. 2 of the UNIX manual set). I can't believe this. Doug, you really blew it on this one. Close but no cigar. A file descriptor (since we haven't established an official definition of a file descriptor, let me propose one: A file descriptor is the value you get back from an "open" or "creat" system call. If that's not Doug's definition, then he could be right) is just an index into a data structure; this data struc- ture is part of the PER PROCESS information, not part of the system wide as what Doug is alluding to. Now, this data structure in the per process infor- mation does have pointers to the system wide data structures (what Doug refers to as the "open-file table"), and everything else is as Doug described it (well, there are a couple of other things, but they really don't have anything to do with the original question). All of this is true for Berkeley 4.2/4.3 (I just looked at the code just to make sure 4.3 didn't change what file descriptors mean). I have absolutely no idea if this is the way System V does things. Terry Laskodi of Tektronix