From patchwork Tue Jul 5 15:36:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 9214703 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 50B9C6048F for ; Tue, 5 Jul 2016 16:08:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 428BA26D14 for ; Tue, 5 Jul 2016 16:08:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 36FE726E1A; Tue, 5 Jul 2016 16:08:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8266F26D14 for ; Tue, 5 Jul 2016 16:08:41 +0000 (UTC) Received: from localhost ([::1]:56058 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKSts-0001F3-JP for patchwork-qemu-devel@patchwork.kernel.org; Tue, 05 Jul 2016 12:08:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37531) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKSOv-0003za-Gd for qemu-devel@nongnu.org; Tue, 05 Jul 2016 11:36:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bKSOu-0003CU-DZ for qemu-devel@nongnu.org; Tue, 05 Jul 2016 11:36:41 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:58107) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKSOu-0003BF-4j for qemu-devel@nongnu.org; Tue, 05 Jul 2016 11:36:40 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.84_2) (envelope-from ) id 1bKSOk-0003Og-D0; Tue, 05 Jul 2016 16:36:30 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Tue, 5 Jul 2016 16:36:29 +0100 Message-Id: <1467732989-12028-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.9.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PATCH] linux-user: Correct type for LOOP_GET_STATUS{, 64} ioctls X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Chanho Park , Riku Voipio , Chanho Park , Laurent Vivier , patches@linaro.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The LOOP_GET_STATUS and LOOP_GET_STATUS64 ioctls were incorrectly defined as IOC_W rather than IOC_R, which meant we weren't correctly copying the information back from the kernel to the guest. The loop_info64 structure definition was also missing a member and using the wrong type for several 32-bit fields. In particular, this meant that "kpartx -d image.img" didn't work and "losetup -a" behaved strangely. Correct the ioctl type definitions. Reported-by: Chanho Park Signed-off-by: Peter Maydell Reviewed-by: Laurent Vivier Tested-by: Chanho Park --- This is intended to be applied on top of the other ioctl patches I've sent out recently. linux-user/ioctls.h | 4 ++-- linux-user/syscall_types.h | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 8978eb3..4b36baa 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -351,9 +351,9 @@ IOCTL(LOOP_SET_FD, 0, TYPE_INT) IOCTL(LOOP_CLR_FD, 0, TYPE_INT) IOCTL(LOOP_SET_STATUS, IOC_W, MK_PTR(MK_STRUCT(STRUCT_loop_info))) - IOCTL(LOOP_GET_STATUS, IOC_W, MK_PTR(MK_STRUCT(STRUCT_loop_info))) + IOCTL(LOOP_GET_STATUS, IOC_R, MK_PTR(MK_STRUCT(STRUCT_loop_info))) IOCTL(LOOP_SET_STATUS64, IOC_W, MK_PTR(MK_STRUCT(STRUCT_loop_info64))) - IOCTL(LOOP_GET_STATUS64, IOC_W, MK_PTR(MK_STRUCT(STRUCT_loop_info64))) + IOCTL(LOOP_GET_STATUS64, IOC_R, MK_PTR(MK_STRUCT(STRUCT_loop_info64))) IOCTL(LOOP_CHANGE_FD, 0, TYPE_INT) IOCTL(LOOP_CTL_ADD, 0, TYPE_INT) diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index 1fd4ee0..af79fbf 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -103,10 +103,11 @@ STRUCT(loop_info64, TYPE_ULONGLONG, /* lo_inode */ TYPE_ULONGLONG, /* lo_rdevice */ TYPE_ULONGLONG, /* lo_offset */ - TYPE_ULONG, /* lo_number */ - TYPE_ULONG, /* lo_encrypt_type */ - TYPE_ULONG, /* lo_encrypt_key_size */ - TYPE_ULONG, /* lo_flags */ + TYPE_ULONGLONG, /* lo_sizelimit */ + TYPE_INT, /* lo_number */ + TYPE_INT, /* lo_encrypt_type */ + TYPE_INT, /* lo_encrypt_key_size */ + TYPE_INT, /* lo_flags */ MK_ARRAY(TYPE_CHAR, 64), /* lo_name */ MK_ARRAY(TYPE_CHAR, 64), /* lo_crypt_name */ MK_ARRAY(TYPE_CHAR, 32), /* lo_encrypt_key */