[parted-devel] Queries/doubts regarding linux_swap.c
David Cantrell
dcantrell at redhat.com
Mon Nov 20 20:36:16 CET 2006
Otavio Salvador wrote:
> David Cantrell <dcantrell at redhat.com> writes:
>
>>> 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?
> <...>
>> We never use these in libparted, but there's no harm in syncing up the
>> definitions to match current standards. We should not directly
>> include swap.h because including kernel headers in userspace code is
>> deemed bad by kernel developers at the moment. This is fine as it
>> gives them more control over those headers. It presents problems for
>> applications like parted that do need those things. The stop gap is
>> to duplicate the definition in our code.
>
> Right but then would be better to just copy their header somewhere so
> will be easier to us sync with them from time to time.
No, because swap.h is technically a private kernel header. It includes
other private kernel headers. We just need the struct definitions, so
we can just pick those out.
The better solution would be for us to get the swap header definition in
to the group of kernel header files that are userspace-safe. These are
usually provided alongside glibc in your distribution of choice. It
would require some header changes on the kernel side, but nothing too
terrible.
--
David Cantrell
Red Hat / Westford, MA
More information about the parted-devel
mailing list