Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!uunet!mcrware!davely From: davely@mcrware.UUCP (Dave Lyons) Newsgroups: comp.os.os9 Subject: Re: directory help Message-ID: <4501@mcrware.UUCP> Date: 20 Dec 90 17:09:28 GMT References: Reply-To: davely@mcrware.UUCP (Dave Lyons) Organization: Microware Systems Corp., Des Moines, Iowa Lines: 41 In article rh2y+@andrew.cmu.edu (Russell E. Hoffman, II) writes: +Thanks to those of you who replied. It turns out that (after doing an +#include ) the error returned by _gs_gfd was 000:201 - Invalid +path number. Further investigation revealed that this was caused by the fact +that when you attempt to open a directory using open (file,00), it returns +a -1 as the path, indicating an error of sorts. Now here's my real question, +after having resolved this. + There's GOT to be a faster way to get the file descriptors for every file +in a given directory than simply opening each file individually then doing +a _gs_gfd() on the individual files. I have thought about reading all the +directory entries, storing the addresses of each of their FDs in an array +and then opening the physical device (/h0@ or whatever) and grabbing the +FDs all at once, thereny saving a LOT of seek time on the disk, but +the problem is, as Mr. Larson pointed out, you can only run such a program +if you are the superuser, which kind of defeats the whole purpose. There +simply has to be yet some other way, because when I do a 'dir -e', it +takes about one-fifth the amount of time it takes my program to accomplish +the same thing. Any hints/suggestions? Dir uses a getstat called SS_FdInf that lets you tell it the block number of the FD you want. This probably won't be a lot faster than opening the raw device, but it's a little cleaner. And if the file is open, RBF gets the FD from memory instead of from the disk. You do have to be super user to make this call but as someone else pointed out, if your program module was created by the super user, it can change it's user id to super user even if it was forked by a non-super user. I don't think there is a C binding function for this call though, so you would have to write that. +Thanks in advance, + +Russell Hoffman +rh2y+@andrew.cmu.edu +Carnegie Mellon Univ. Hope this helps, davely -- |Dave Lyons - uunet!mcrware!davely | Just like a V8 under the hood | |-------------------------------------| of a car made of nails and wood | | The opinions of the party of the | Your big heart's gonna break | | first part shall not be taken as... | your little body |