Subject: Re: install/37521: qemu install from NetBSD-current install floppiesfails
To: None <install-manager@netbsd.org, gnats-admin@netbsd.org,>
From: David Laight <david@l8s.co.uk>
List: netbsd-bugs
Date: 12/12/2007 20:20:02
The following reply was made to PR install/37521; it has been noted by GNATS.

From: David Laight <david@l8s.co.uk>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: install/37521: qemu install from NetBSD-current install floppiesfails
Date: Wed, 12 Dec 2007 20:25:34 +0000

 On Wed, Dec 12, 2007 at 02:00:04PM +0000, Stephen Borrill wrote:
 >  
 >  > -	err = stat(BOOTCONF, &st);
 >  > -	if (err == -1)
 >  > -		return;
 >  > -
 >  >  	fd = open(BOOTCONF, 0);
 >  >  	if (fd < 0)
 >  >  		return;
 >  >  	
 >  > +	err = fstat(fd, &st);
 >  > +	if (err == -1) {
 >  > +		close(fd);
 >  > +		return;
 >  > +	}
 >  > +
 >  
 >  Why swap round stat and open?
 
 Well, stat() isn't any cheaper than open() and in general you want
 information from the file you opened, not the file (with the same name)
 that existed just before you did the open().
 
 I've not looked to see why this code calls stat() at all ....
 
 	David
 
 -- 
 David Laight: david@l8s.co.uk