[parted-devel] Stop trying to read "none, sunrpc..."
Joel Granados
jgranado at redhat.com
Tue Nov 11 14:15:08 UTC 2008
Hi list:
comments bellow.
----- "Bryn M. Reeves" <bmr at redhat.com> wrote:
> Joel Granados wrote:
> > Hey List:
> >
> > Parted, when trying to figure out what device is mounted reads
> > /proc/mounts, /proc/swaps and /etc/mtab. Problem is thta these
> > files sometimes contain lines tarting with "none", "sunrpc" and
> > others. This patch avoids these unnecessary IO operations.
>
> I can't think of a situation in which the fs_spec column of these
> files
> would not start with a '/' but where we would still want to continue
> to
> do the stat so ACK to this change.
>
> I had a couple of thoughts looking at this part of the code though -
> I
> wonder if it wouldn't be better to change this routine to use
> getmntent
> and friends instead, as this would avoid having to hard-code line
> buffer
> sizes and invent our own parsing as is currently done.
I've been talking to bmr and from my point of view I see that the man page for getmntent only mentions the the /etc/mtab and /etc/fstab files. It does not mention /proc/swaps nor /proc/mounts (which we also parse). This, to me, suggests that it might not be a good idea to use these routines. OTOH, I haven't used these routines at all, so it might be sane to use them with the proc files with no issues.
Anyone have any experience with these?
>
> Also, I think it might be possible to make the routine more robust -
> e.g. I think right now, calling ped_partition_is_busy() for a device
> that is not itself mounted, but which has a linear device-mapper
> device
> mapped over it will return false, even though it is not safe to
> operate
> on the content of the partition - need to test this & see if I can
> get
> parted to do anything nasty because of it.
>
This is a very good idea. I'll se what I can come up with. :)
> Regards,
> Bryn.
To add to my original patch I have created a test. The test captures the strace output of `parted -s DEV print free`. After the command exits, the test makes sure that there are no lines that follow this regular expression "stat(\"[^\/|^\.]" in the strace output. To the extent of my knowledge this is enough to ensure that there are no stats for "none, sunrpc, tmpfs..." for this specific test. If anyone can find a counter example please speak out :)
The patch is attached.
Regards.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Stop-searching-for-information-in-none-files.patch
Type: application/octet-stream
Size: 0 bytes
Desc: not available
Url : http://lists.alioth.debian.org/pipermail/parted-devel/attachments/20081111/863bb6d8/attachment.obj
More information about the parted-devel
mailing list