Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!clyde!cbosgd!ihnp4!homxb!houxm!hropus!jgy From: jgy@hropus.UUCP (John Young) Newsgroups: comp.unix.questions Subject: Re: Identify file name given file descriptor Message-ID: <1037@hropus.UUCP> Date: Tue, 19-May-87 11:21:27 EDT Article-I.D.: hropus.1037 Posted: Tue May 19 11:21:27 1987 Date-Received: Sat, 23-May-87 13:25:38 EDT References: <710@twitch.UUCP> <877@killer.UUCP> Organization: Bell Labs, Holmdel, NJ Lines: 41 Keywords: mount, ncheck, partly tested > main > find_file_name ("/", your_fstat_structure) -- start from root directory > -- with fstat(2) values. > end > > procedure find_file_name (current_directory, file_fstat) > > if current_directory.file_stat = file_fstat then > -- was FD this directory? > putstring (current_directory) > return > fi > for each file_entry in current_directory -- stat(2) each slot > if file_entry.file_type = directory_type then > -- recursively call directories > find_file_name (current_directory + file_entry.file_name, > file_fstat) > elif file_entry.file_stat = file_fstat then > -- else check to see if it is the file > -- by checking st_ino and st_dev fields. > putstring (current_directory + file_entry.file_name) > -- and print the name if you found one. > return > fi > end > > > There you have it. All accessible files are checked, which should include > yourown since you should be able to read you own directory. The ones you > can't access can't be accessed :-(. st_ino and st_dev are all you need to > compare to see if the files are the same ones. This should (once written > in C or something) be as fast or faster than find(1) since find(1) has atleast > this much work to do. > > - John. > This doesn't seem to handle the case of having a filesystem mounted on anything but a root level directory. - John Young