All of lore.kernel.org
 help / color / mirror / Atom feed
* 32/64-bit structure alignment problem in receive
@ 2014-01-04 17:49 Hugo Mills
  0 siblings, 0 replies; only message in thread
From: Hugo Mills @ 2014-01-04 17:49 UTC (permalink / raw)
  To: Btrfs mailing list, Alexander Block

[-- Attachment #1: Type: text/plain, Size: 1719 bytes --]

   Sending the exact same send stream to two different machines, on
one of them I am getting:

ERROR: BTRFS_IOC_SET_RECEIVED_SUBVOL failed. Inappropriate ioctl for device

   The other machine is fine. Investigating, I find that the working
machine is 64-bit userspace and kernel. The failing machine is 32-bit
userspace and 64-bit kernel.

struct btrfs_ioctl_received_subvol_args {
        char    uuid[BTRFS_UUID_SIZE];  /* in */
        __u64   stransid;               /* in */
        __u64   rtransid;               /* out */
        struct btrfs_ioctl_timespec stime; /* in */
        struct btrfs_ioctl_timespec rtime; /* out */
        __u64   flags;                  /* in */
        __u64   reserved[16];           /* in */
};

struct btrfs_ioctl_timespec {
        __u64 sec;
        __u32 nsec;
};

   This latter struct is 16 bytes in a 64-bit environment (with 4
bytes wasted) and 12 bytes in a 32-bit environment. This means that on
my broken machine, the kernel is expecting ioctl(5, 0xc0c89425, ...)
and is being called with ioctl(5, 0xc0c09425, ...).

   As far as I can see, the best (only?) solution is to teach the
kernel to accept both

_IOWR(BTRFS_IOCTL_MAGIC, 37, struct btrfs_ioctl_received_subvol_args)

and

_IOWR(BTRFS_IOCTL_MAGIC, 37, struct btrfs_ioctl_received_subvol_args_32)

if it's compiled on a 64-bit architecture, where the _32 version of
the struct is otherwise identical to the struct(s) above, but declared
as __packed__.

   Patch to follow.

   Hugo.

-- 
=== Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk ===
  PGP key: 65E74AC0 from wwwkeys.eu.pgp.net or http://www.carfax.org.uk
      --- "Big data" doesn't just mean increasing the font size ---      

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-01-04 17:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-04 17:49 32/64-bit structure alignment problem in receive Hugo Mills

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.