From patchwork Tue May 3 16:12:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Sterba X-Patchwork-Id: 9006151 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id AE65D9F1D3 for ; Tue, 3 May 2016 16:13:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D90D1202D1 for ; Tue, 3 May 2016 16:13:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0D28B2021F for ; Tue, 3 May 2016 16:13:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933555AbcECQM7 (ORCPT ); Tue, 3 May 2016 12:12:59 -0400 Received: from mx2.suse.de ([195.135.220.15]:46416 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933433AbcECQM5 (ORCPT ); Tue, 3 May 2016 12:12:57 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 67407AB9D for ; Tue, 3 May 2016 16:12:56 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id D30EBDAB64; Tue, 3 May 2016 18:12:40 +0200 (CEST) From: David Sterba To: linux-btrfs@vger.kernel.org Cc: David Sterba Subject: [PATCH 2/3] btrfs-progs: add getters for ioctl search_header Date: Tue, 3 May 2016 18:12:40 +0200 Message-Id: <99993863d5906bb4987502ea08411fab56b64f35.1462291729.git.dsterba@suse.com> X-Mailer: git-send-email 2.7.1 In-Reply-To: References: Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 */