[comp.unix.questions] Which is more efficient...

pda@stiatl.UUCP (Paul D. Anderson) (02/21/90)

Which is more efficient (ie: cheaper and faster) in a program?
 - to chdir("/path") and then unlink("file") for each file in the 
	directory
	-OR-
 - to explicity unlink("/path/file") for dozens of files in each 
	directory?
And does the recommended method used vary based on Sys V or BSD 4.2/3  ??

I will be removing hundreds of files in hundreds of directories
at a shot with this approach.

Please E-Mail to me and I will summarize and re-post.
-- 
--
Paul Anderson * h:404-565-0761 w:841-4000
{mathcs.emory,gatech}.edu!stiatl!pda  ||  pda@SalesTech.Com

pda@stiatl.UUCP (Paul D. Anderson) (02/21/90)

pda@stiatl.UUCP (Paul D. Anderson) writes:
>Which is more efficient (ie: cheaper and faster) in a program?
> - to chdir("/path") and then unlink("file") for each file in the 

Let me clarify my question from the previous posting:
I know of namei() in the kernal, it has been suggested that doing
the chdir() first will mean namei() will not have to be invoked as
often.  But does not unlink() have to chase back up the directory
structures (re-construct the directory tree) in order to ascertain
if the correct permissions exist to allow removal of the file?  Therefore,
would not calling unlink() with the full pathname be more efficient,
since all information is provided to unlink() about the path?

>Please E-Mail to me and I will summarize and re-post.
thanks,
paul
-- 
--
Paul Anderson * h:404-565-0761 w:841-4000
{mathcs.emory,gatech}.edu!stiatl!pda  ||  pda@SalesTech.Com