[parted-devel] Queries/doubts regarding linux_swap.c
Debarshi 'Rishi' Ray
debarshi.ray at gmail.com
Mon Nov 20 18:44:55 CET 2006
On 20/11/06, David Cantrell <dcantrell at redhat.com> wrote:
> > 1. libparted/fs/linux_swap/linux_swap, lines 42-69: The structure of
> > the swap header as a union of SwapOldHeader and SwapNewHeader is not
> > the same as defined in the vanilla Linux 2.6.18.2 kernel. Ref:
> > include/linux/swap.h, lines 52-67. Is SwapOldHeader defined the way it
> > is, because of the difficulty in knowing the page size while defining
> > the structure or for some other reason? Why were the sws_uuid and
> > sws_volume fields left out in SwapNewHeader?
>
> This code was taken from mkswap a while ago. It doesn't so much matter
> that the sws_uuid and sws_volume are not defined because the size of the
> header is still the same so that swap partitions are compatible across
> Linux revisions. In swap.h in the kernel, the padding is decreased to
> make room for sws_uuid and sws_volume.
Okay. That clears it up a bit. What are sws_uuid and sws_volume
supposed to do? Secondly, why is SwapOldHeader defined as a single
element character array instead of a full page (as in the kernel
header)?
> > 2. libparted/fs/linux_swap/linux_swap.h, lines 204-247: The function
> > swap_open calls swap_alloc, swap_init and ped_geometry read. Now
> > swap_init already does make an identical call to ped_geometry_read. If
> > swap_init could return the status of ped_geometry_read instead of a
> > void, then this second call to ped_geometry_read can be done away
> > with. Am I correct?
>
> Well, there in lies a problem. State is not guaranteed through the run
> of the application. Someone could have parted running and then go and
> muck with the system behind its back and then come back to parted to do
> stuff. We need the extra ped_geometry_read call to make sure we deal
> with the system state right then.
But the swap_init is done just 2 statements before the extra
ped_geometry_read call. Is there a significant chance for the system
state to change within that time? If yes, then I guess many other
functions would be affected in libparted, and hence a better solution
(as you said) must be found out.
Happy hacking,
Debarshi
--
I only work when I am not doing any assignments.
More information about the parted-devel
mailing list