From: David Sterba <dsterba@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: David Sterba <dsterba@suse.com>
Subject: [PATCH 1/4] btrfs-progs: ioctl: pack structures
Date: Thu, 6 Oct 2016 15:41:38 +0200 [thread overview]
Message-ID: <20161006134141.837-2-dsterba@suse.com> (raw)
In-Reply-To: <20161006134141.837-1-dsterba@suse.com>
Add the packed attribute to several structures so we avoid any
accidental size changes due to compiler-dependent padding.
Expected alignment is 8 bytes, padded where needed.
Signed-off-by: David Sterba <dsterba@suse.com>
---
ioctl.h | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/ioctl.h b/ioctl.h
index a7235c00c1a0..d0c06657f0c0 100644
--- a/ioctl.h
+++ b/ioctl.h
@@ -149,7 +149,7 @@ struct btrfs_ioctl_scrub_args {
struct btrfs_scrub_progress progress; /* out */
/* pad to 1k */
__u64 unused[(1024-32-sizeof(struct btrfs_scrub_progress))/8];
-};
+} __attribute__((packed));
BUILD_ASSERT(sizeof(struct btrfs_ioctl_scrub_args) == 1024);
#define BTRFS_IOCTL_DEV_REPLACE_CONT_READING_FROM_SRCDEV_MODE_ALWAYS 0
@@ -160,7 +160,7 @@ struct btrfs_ioctl_dev_replace_start_params {
* above */
__u8 srcdev_name[BTRFS_DEVICE_PATH_NAME_MAX + 1]; /* in */
__u8 tgtdev_name[BTRFS_DEVICE_PATH_NAME_MAX + 1]; /* in */
-};
+} __attribute__((packed, aligned (8)));
BUILD_ASSERT(sizeof(struct btrfs_ioctl_dev_replace_start_params) == 2072);
#define BTRFS_IOCTL_DEV_REPLACE_STATE_NEVER_STARTED 0
@@ -175,7 +175,7 @@ struct btrfs_ioctl_dev_replace_status_params {
__u64 time_stopped; /* out, seconds since 1-Jan-1970 */
__u64 num_write_errors; /* out */
__u64 num_uncorrectable_read_errors; /* out */
-};
+} __attribute__((packed));
BUILD_ASSERT(sizeof(struct btrfs_ioctl_dev_replace_status_params) == 48);
#define BTRFS_IOCTL_DEV_REPLACE_CMD_START 0
@@ -556,7 +556,7 @@ BUILD_ASSERT(sizeof(struct btrfs_ioctl_qgroup_create_args) == 16);
struct btrfs_ioctl_timespec {
__u64 sec;
__u32 nsec;
-};
+} __attribute__((packed, aligned (8)));
struct btrfs_ioctl_received_subvol_args {
char uuid[BTRFS_UUID_SIZE]; /* in */
@@ -601,7 +601,7 @@ struct btrfs_ioctl_send_args {
__u64 parent_root; /* in */
__u64 flags; /* in */
__u64 reserved[4]; /* in */
-};
+} __attribute__((packed));
/*
* Size of structure depends on pointer width, was not caught. Kernel handles
* pointer width differences transparently
--
2.10.0
next prev parent reply other threads:[~2016-10-06 13:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-06 13:41 [PATCH 0/4] Btrfs-progs 4.8, fix build on 32bit, ioctl cleanups David Sterba
2016-10-06 13:41 ` David Sterba [this message]
2016-10-06 13:41 ` [PATCH 2/4] btrfs-progs: ioctl: add 32bit compat for SET_RECEIVED_SUBVOL David Sterba
2016-10-06 13:41 ` [PATCH 3/4] btrfs-progs: ioctl: add 64bit compat for SEND David Sterba
2016-10-06 13:41 ` [PATCH 4/4] btrfs-progs: tests: make the ioctl-test actually useful David Sterba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161006134141.837-2-dsterba@suse.com \
--to=dsterba@suse.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).