From patchwork Tue Jan 29 06:06:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Brandenburger X-Patchwork-Id: 2059391 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 01955DF23E for ; Tue, 29 Jan 2013 06:06:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753849Ab3A2GGu (ORCPT ); Tue, 29 Jan 2013 01:06:50 -0500 Received: from mail-oa0-f73.google.com ([209.85.219.73]:42343 "EHLO mail-oa0-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753774Ab3A2GGt (ORCPT ); Tue, 29 Jan 2013 01:06:49 -0500 Received: by mail-oa0-f73.google.com with SMTP id n12so15826oag.0 for ; Mon, 28 Jan 2013 22:06:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=izdQ8SC8VidIMs3vQGLcVYQJpLQl8I7SzrMIIK/rRMA=; b=fL+/Q6rwdYc6QWYyRAZX08f79UAfuX+7TSPk4GNPVM39NMJ39R8pE5zd5weLBE5F6+ RwrxH6KhM8h0jFAmZk8xDUEnQ/aHmIBkABBVKK62WjkQScqzuw+oZigymclw+2Gksz7F kL1DR7vr67NcSlST9J2ofLR7bH+oKRIUP3iRkZ/v2eViUsrF6wkN6LndVeZaA9pSM9U1 zCJV1tPl8g4Y8LOOyP35s8oa/iSbFCO4eNlQ5u59KrVb3fx6I2De2OGyee020t0s9m+F LD544gMuHL/zs9V8MqBii0I/cDEKw1kJrWtbpGFSalPVqcZ8HULBdKvyVRAA+38FXULA zPtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=izdQ8SC8VidIMs3vQGLcVYQJpLQl8I7SzrMIIK/rRMA=; b=Q9xLd7xESVN6F2/l8Q543XdallUHJkL0pmKW4Je/FZquDEcCszL7P8ua31/Gvsu4xc nYX8Ai04BZoc39I63fb0ZUpk1Pjfay6sp/VT2XB9jPBmCk+G4hQLgbfsETuS7tjxvZIO EvqcQuB3S0ygUBL144WkaWgmuJFsnLJhJRljrywC8KSQT2kz6c0ibnOkC/+Onby4jV1r XT69/oCAKOV/mE4ZLF79IrH7ORyzH7XSqj+n6St749eJBclMfI+emuf097xh7bm1g1ue O/NTLeGl+AjeI+qAl0WhXBGp0mSxH13oWi1RYnPM8EsqgRc7dl8EiCHTmzTD8W+6hIwp OQEg== X-Received: by 10.50.237.73 with SMTP id va9mr178129igc.4.1359439608282; Mon, 28 Jan 2013 22:06:48 -0800 (PST) Received: from corp2gmr1-1.hot.corp.google.com (corp2gmr1-1.hot.corp.google.com [172.24.189.92]) by gmr-mx.google.com with ESMTPS id x4si126234igm.0.2013.01.28.22.06.48 (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Mon, 28 Jan 2013 22:06:48 -0800 (PST) Received: from obelix.sbo.corp.google.com (obelix.sbo.corp.google.com [172.31.172.210]) by corp2gmr1-1.hot.corp.google.com (Postfix) with ESMTP id 8CFBD31C00F; Mon, 28 Jan 2013 22:06:47 -0800 (PST) Received: by obelix.sbo.corp.google.com (Postfix, from userid 180819) id 17D922016A6; Mon, 28 Jan 2013 22:06:47 -0800 (PST) From: Filipe Brandenburger To: linux-btrfs@vger.kernel.org Cc: Filipe Brandenburger Subject: [PATCH 2/3] Add support for Btrfs ioctls: infrastructure to decode ioctl structs Date: Mon, 28 Jan 2013 22:06:37 -0800 Message-Id: <1359439598-4141-3-git-send-email-filbranden@google.com> X-Mailer: git-send-email 1.8.1 In-Reply-To: <1359439598-4141-1-git-send-email-filbranden@google.com> References: <1359439598-4141-1-git-send-email-filbranden@google.com> X-Gm-Message-State: ALoCoQkOArpUugxUbLeAIGtopUyr1luph2N5NxcyFKdP7raVrX1Zlu/WxcR6Yl8BiTjC5rUEkD8XA6PcgWDKTed7r1J6ksg60tddJ4p4x3M5VaQ7NbHDIpeFgVDiWwJmwWPBo80vgguBJGpl8Aepz3/l7ZOncP7wGussLjwXCrQ6N9Zk2s5snFpGi9Kc5ykqYUKozTolKLIGey8aoPd5HA+LE6nJYPrruA== Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org This adds a new btrfs_ioctl() function that can be used to decode Btrfs structs from Btrfs-specific ioctls. It adds a new case to ioctl_decode() to handle Btrfs ioctls. This adds autoconf detection of header file linux/btrfs.h so that the code can be disabled when the header is not present. Signed-off-by: Filipe Brandenburger --- Makefile.am | 2 +- btrfs.c | 39 +++++++++++++++++++++++++++++++++++++++ configure.ac | 1 + defs.h | 1 + ioctl.c | 2 ++ 5 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 btrfs.c diff --git a/Makefile.am b/Makefile.am index aa1a5f4..fe809b8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -18,7 +18,7 @@ strace_SOURCES = strace.c syscall.c count.c util.c desc.c file.c ipc.c \ io.c ioctl.c mem.c net.c process.c bjm.c quota.c \ resource.c signal.c sock.c system.c term.c time.c \ scsi.c stream.c block.c pathtrace.c mtd.c vsprintf.c \ - loop.c + loop.c btrfs.c noinst_HEADERS = defs.h EXTRA_DIST = $(man_MANS) errnoent.sh signalent.sh syscallent.sh ioctlsort.c \ diff --git a/btrfs.c b/btrfs.c new file mode 100644 index 0000000..a4895e4 --- /dev/null +++ b/btrfs.c @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2013 Filipe Brandenburger + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "defs.h" +#include + +#ifdef HAVE_LINUX_BTRFS_H +#include +#endif /* HAVE_LINUX_BTRFS_H */ + +int +btrfs_ioctl(struct tcb *tcp, long code, long arg) +{ + return 0; +} diff --git a/configure.ac b/configure.ac index f44eaf1..9021fe1 100644 --- a/configure.ac +++ b/configure.ac @@ -222,6 +222,7 @@ AC_CHECK_HEADERS([asm/sigcontext.h], [], [], [#include ]) AC_CHECK_TYPES([struct sigcontext_struct, struct sigcontext],,, [#include ]) AC_CHECK_HEADERS([netinet/tcp.h netinet/udp.h],,, [#include ]) +AC_CHECK_HEADERS([linux/btrfs.h]) AC_CHECK_MEMBERS([struct msghdr.msg_control],,, [#include ]) diff --git a/defs.h b/defs.h index 0e05c6e..9270786 100644 --- a/defs.h +++ b/defs.h @@ -631,6 +631,7 @@ extern int scsi_ioctl(struct tcb *, long, long); extern int block_ioctl(struct tcb *, long, long); extern int mtd_ioctl(struct tcb *, long, long); extern int loop_ioctl(struct tcb *, long, long); +extern int btrfs_ioctl(struct tcb *, long, long); extern int tv_nz(struct timeval *); extern int tv_cmp(struct timeval *, struct timeval *); diff --git a/ioctl.c b/ioctl.c index 323946d..6c39fc0 100644 --- a/ioctl.c +++ b/ioctl.c @@ -92,6 +92,8 @@ ioctl_decode(struct tcb *tcp, long code, long arg) return loop_ioctl(tcp, code, arg); case 'M': return mtd_ioctl(tcp, code, arg); + case 0x94: + return btrfs_ioctl(tcp, code, arg); default: break; }