[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Sizes and Packages in dselect



iwj10@cus.cam.ac.uk said:
> I can't think of a good way to support this, so I don't intend to. 
> There will be one disk usage figure per package; users with several 
> filesystems are presumed to know what they're doing. 

I think I have the algorithm to do this. Please see if the following makes
sense. I can give you pseudocode (or real code) if necessary.

For each file in the files list, find the deepest existing directory
that matches the pathname. This will often be something like
"/usr", "/etc", and so on. Cache the name of this directory and information
about it so that subsequent
lookups will run quickly. Get the block device number from stat.st_dev of the
directory, to disambiguate this filesystem from other filesystems. Cost the
file to the indicated filesystem, and go on to the next file.

When done processing the file list, use the block device number to find the
block device name, and then use getmntent() to find the mount point for
display to the user. Use fsstat() to find the free space count for the 
filesystem.

When replacing packages, subtract the cost of the old package file list before
adding the cost of the new one. When overwriting files that are not part of a
package being replaced, subtract their cost before adding the new file cost.

Use fsstat.f_bsize and fsstat.f_frsize to figure out how many blocks/fragments
a file will take up, so that your block count will be more accurate than if you
simply counted bytes.

Does this make sense? I can elaborate if you like.

	Bruce

--
-- Attention Radio Amateurs: For information on "Linux for Hams",
-- read the WWW page http://www.hams.com/LinuxForHams, 
-- or e-mail the word "help" to info@hams.com


Reply to: