From: David Sterba <dsterba@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: David Sterba <dsterba@suse.com>
Subject: [PATCH 2/3] btrfs-progs: add getters for ioctl search_header
Date: Tue, 3 May 2016 18:12:40 +0200 [thread overview]
Message-ID: <99993863d5906bb4987502ea08411fab56b64f35.1462291729.git.dsterba@suse.com> (raw)
In-Reply-To: <cover.1462291729.git.dsterba@suse.com>
The search header is usually accessed in an unaligned way, we could
trigger errors (SIGBUS) on architectures that do not support that.
Signed-off-by: David Sterba <dsterba@suse.com>
---
ctree.h | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/ctree.h b/ctree.h
index 2da6f7786a78..13ed05052301 100644
--- a/ctree.h
+++ b/ctree.h
@@ -2196,6 +2196,32 @@ static inline u32 btrfs_file_extent_inline_item_len(struct extent_buffer *eb,
return btrfs_item_size(eb, e) - offset;
}
+/* struct btrfs_ioctl_search_header */
+static inline u64 btrfs_search_header_transid(struct btrfs_ioctl_search_header *sh)
+{
+ return get_unaligned_64(&sh->transid);
+}
+
+static inline u64 btrfs_search_header_objectid(struct btrfs_ioctl_search_header *sh)
+{
+ return get_unaligned_64(&sh->objectid);
+}
+
+static inline u64 btrfs_search_header_offset(struct btrfs_ioctl_search_header *sh)
+{
+ return get_unaligned_64(&sh->offset);
+}
+
+static inline u32 btrfs_search_header_type(struct btrfs_ioctl_search_header *sh)
+{
+ return get_unaligned_32(&sh->type);
+}
+
+static inline u32 btrfs_search_header_len(struct btrfs_ioctl_search_header *sh)
+{
+ return get_unaligned_32(&sh->len);
+}
+
/* this returns the number of file bytes represented by the inline item.
* If an item is compressed, this is the uncompressed size
*/
--
2.7.1
next prev parent reply other threads:[~2016-05-03 16:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-03 16:12 [PATCH 0/3] Btrfs-progs: fix unaligned acces for ioctl search header David Sterba
2016-05-03 16:12 ` [PATCH 1/3] btrfs-progs: kerncompat: introduce get_unaligned helpers David Sterba
2016-05-03 16:12 ` David Sterba [this message]
2016-05-03 16:12 ` [PATCH 3/3] btrfs-progs: use ioctl search headers everywhere 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=99993863d5906bb4987502ea08411fab56b64f35.1462291729.git.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).