Re: [PATCH] struct loop_info64

From: Linus Torvalds (torvalds@transmeta.com)
Date: Fri Apr 18 2003 - 11:26:08 EST


On Fri, 18 Apr 2003 Andries.Brouwer@cwi.nl wrote:
> +struct loop_info64 {
> + int lo_number; /* ioctl r/o */
> + unsigned long long lo_device; /* ioctl r/o */
> + unsigned long lo_inode; /* ioctl r/o */
> + unsigned long long lo_rdevice; /* ioctl r/o */

Make these be explicitly sized, and try to put the 64-bit members at the
beginning to avoid alignment and structure packing problems. Ie something
more like

        struct loop_info64 {
                u64 lo_device;
                u64 lo_rdevice;
                u64 lo_inode;
                u32 lo_number;
                ...

> + int lo_offset;

Any reason to keep an "offset" as "int"? It should probably be "u64" as
well.

If you call a structure "info64", make the fact that it's 64-bit
_explicit_. That way it will look and work the same on things like x86 and
x86-64, without the need to have translation layers for binary
compatibility.

We should literally have the rule that any user-visible data structures
cannot use _any_ types other than u8/u16/u32/u64 (and _maybe_ the signed
ones, if there is any real reason to).

                Linus

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed Apr 23 2003 - 22:00:24 EST