From patchwork Tue Jun 2 11:53:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filip Bozuta X-Patchwork-Id: 1302414 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=syrmia.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=syrmia.com header.i=@syrmia.com header.a=rsa-sha256 header.s=selector1 header.b=H/mf+Z43; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49bsqD1w7Hz9sSd for ; Tue, 2 Jun 2020 23:10:47 +1000 (AEST) Received: from localhost ([::1]:49490 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jg6gl-0002zk-LZ for incoming@patchwork.ozlabs.org; Tue, 02 Jun 2020 09:10:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40856) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jg5UN-0000Sf-1a for qemu-devel@nongnu.org; Tue, 02 Jun 2020 07:53:51 -0400 Received: from mail-eopbgr140120.outbound.protection.outlook.com ([40.107.14.120]:62970 helo=EUR01-VE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jg5UM-0000gD-0m for qemu-devel@nongnu.org; Tue, 02 Jun 2020 07:53:50 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mTJD/ZDsBnhLzzbmo9tUZVRliP7N4EdepoKY7gXvnlCz0xDF9pOnKHvkUkDIQoccqDMt5lSckxpBN2k5kSAARA8mPa2KuN1yAhZXsiPGTriXC6LqYBLu2yEKe/wB8M1hWRqab0uYuTeeh/2LBEmml/SdDQvwScV26XWbHYLoIbtQRXY6Q3g7Lhzfc/w+m5wPASgkqyhU+EY4HcAkdf3Jb3O70HYf9h0zhsrFt1cadEoGEFL/dD9R0IYTEhjFWsIvcTGknEFVEItQCu+oGf5DNRrBVJFBDqUtLKQsiI5nLU245I1VepgreE0AQO5Je9l4y4zYg2S/ScT7t+8ODecAtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8HoGfHx833cseo7lcT98rumaR6KLzRSpmoMgOe0Z+IY=; b=VqZeUlZcwalsWP89+n9uzus3zAMt11hibRu2l+3ZodZltOVxGsscjbKyQDwFfS/575QUAhSwdXA7G3VAntxcoy7UraLlebdGRPfs2Wf5FB+ZZ6oGrnp6IcTjtqvlLHWf8bjqoV1fX7H+kWE/GuDphtrdfGaCGc0AHwesQu2Il1VdqrxzNno16K3aqUHr+hZU3yaeaPiLsdwTVGMSOuIzoQMlg1W1Fw/mgvWdpz6vhHR0wL8SqXIoqTJ45AYOAcaVR1IS4+gggVWAS+8bp5fEopHUJGJlawC59lfhgfa0+QHeJ/dZO10M9VkzgyCbomqF0Vd6Lvl5+gO8ZibqNyjoKw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=syrmia.com; dmarc=pass action=none header.from=syrmia.com; dkim=pass header.d=syrmia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=syrmia.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8HoGfHx833cseo7lcT98rumaR6KLzRSpmoMgOe0Z+IY=; b=H/mf+Z43l6B5CyWQ7g5z5z1AtWdzYv6MEVNomLrVbgJ4pshhSN4aAykauoqr75O18GFj5khYYhaco/e0G23c0+AQ2AQ8PuvZMBLBDJyBEBa0xLbigQThMVIqb2jkyLBC/PakgYImwmfLnj/hRM2RBO9+w/dPJ1ThoxxHK3KweV0= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=syrmia.com; Received: from AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) by AM6PR03MB4022.eurprd03.prod.outlook.com (2603:10a6:20b:22::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3045.22; Tue, 2 Jun 2020 11:53:44 +0000 Received: from AM6PR03MB5233.eurprd03.prod.outlook.com ([fe80::7935:50dd:e879:bca8]) by AM6PR03MB5233.eurprd03.prod.outlook.com ([fe80::7935:50dd:e879:bca8%7]) with mapi id 15.20.3045.024; Tue, 2 Jun 2020 11:53:44 +0000 From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH 1/5] linux-user: Add strace support for a group of syscalls Date: Tue, 2 Jun 2020 13:53:27 +0200 Message-Id: <20200602115331.1659-2-filip.bozuta@syrmia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200602115331.1659-1-filip.bozuta@syrmia.com> References: <20200602115331.1659-1-filip.bozuta@syrmia.com> X-ClientProxiedBy: LO2P265CA0116.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:c::32) To AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from bozuta-ubuntu-18.syrmia.com (46.240.135.226) by LO2P265CA0116.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:c::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3045.19 via Frontend Transport; Tue, 2 Jun 2020 11:53:44 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [46.240.135.226] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4225fe53-9582-4831-79a2-08d806eb99eb X-MS-TrafficTypeDiagnostic: AM6PR03MB4022: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:813; X-Forefront-PRVS: 0422860ED4 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6FYMLr8oTGDucE61zPep75PdZnUQQenu9h8NufMTNU7/+Ol0Q1Aa1++lhaPkLeX8eoCqn/N81GKnWhBKYwezhwDlTYtPkxeBU3IJvKcn8siKufD13N4GP2tdFBPV3qEGaQ2ejb2tZOQ7GbIAzWYtVfIMUEagFckpS9h6ALPWednoE9zN1t6Uqn7F3aMKR8mTMIYpjiCWbsluO0BrfFU1ZW7wDWbmpInHiDN9UIT6cNpN93OXrsBBo++qJFt4lEXUP5Y69wX81+iSwD3tKq8aVzDnYgSh7OGce2u9DPQAMCHeL9LantCJOpZ/+wby5bPLoIhKVzoVTYEkQhSMNNmXNvfo8CNLGUnkhvtG1CT/Y/tyYZcofyRbc3AmBCqi8xxTjsqWhGLWoBmDRsqMPydApQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR03MB5233.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(366004)(376002)(346002)(39830400003)(136003)(396003)(966005)(44832011)(956004)(2906002)(4326008)(36756003)(2616005)(86362001)(508600001)(66556008)(66476007)(7696005)(66946007)(26005)(8676002)(52116002)(6666004)(6916009)(8936002)(316002)(1076003)(5660300002)(16526019)(83380400001)(186003)(6486002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: pmFXPGhwT93EHWnOWIAfIHZYmhEV9IduWcixVzGhgJ196q7VstmNzZYhIa2+B3yMPn0OYM15b5WyoDIR/41ayM9r9/9LcBmbKvqDuVqE7bUMglLFIv7wjUapGwd73yHjetzpuSsRbOZEg/aehUMxgNPSxlDwHtFM92wzQrtVHXmMtqsy1fLODZZdAQBi71xEEUoMu5jW6NQuk7VYW8pZ+GODLTEynIR43Affc+STGqXIx2EvT0OkdjjyultF+afI8SchielyghfAaMaEJbhd8eOyArIcc5qbmRd9O89IjPTChdKi9MIKehESm8dqeEk14VEUQ/skX1ZWvzreVEU3wob248NH8NFvFihV7E7B0xS4DG4b7y4mWOH6B92gadp40ebDm/ndY/Yoq8J6CJ1NPzW06MXCltqhZtMp216mdyfXDXklYgRBuMRC4JzMzX6PGNwwbZyRGqmJyPXY6xHuRYpRbICHiTebn1Kd2IRBb9M= X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4225fe53-9582-4831-79a2-08d806eb99eb X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2020 11:53:44.4211 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 19214a73-c1ab-4e19-8f59-14bdcb09a66e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: +VhlRV/l3ATcwINTYCWlAOUGTQSH/ULPnnqenWg6wIzRg0fWheW0XApVGDwVdjYJ7I+UW48O2mufM05uvupg6Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR03MB4022 Received-SPF: pass client-ip=40.107.14.120; envelope-from=Filip.Bozuta@syrmia.com; helo=EUR01-VE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/02 07:53:48 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-Mailman-Approved-At: Tue, 02 Jun 2020 09:04:50 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch implements strace argument printing functionality for following syscalls: *acct - switch process accounting on or off int acct(const char *filename) man page: https://www.man7.org/linux/man-pages/man2/acct.2.html *fsync, fdatasync - synchronize a file's in-core state with storage device int fsync(int fd) int fdatasync(int fd) man page: https://www.man7.org/linux/man-pages/man2/fsync.2.html *listen - listen for connections on a socket int listen(int sockfd, int backlog) man page: https://www.man7.org/linux/man-pages/man2/listen.2.html Implementation notes: Syscall acct() takes string as its only argument and thus a separate print function "print_acct" is stated in file "strace.list". This function is defined and implemented in "strace.c" by using an existing function used to print string arguments: "print_string()". All the other syscalls have only primitive argument types, so the rest of the implementation was handled by stating an appropriate printing format in file "strace.list". Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier --- linux-user/strace.c | 13 ++++++++++++- linux-user/strace.list | 8 ++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index 0d9095c674..c578876d22 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1353,6 +1353,18 @@ print_access(const struct syscallname *name, } #endif +#ifdef TARGET_NR_acct +static void +print_acct(const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + print_syscall_prologue(name); + print_string(arg0, 1); + print_syscall_epilogue(name); +} +#endif + #ifdef TARGET_NR_brk static void print_brk(const struct syscallname *name, @@ -1617,7 +1629,6 @@ print_fcntl(const struct syscallname *name, #define print_fcntl64 print_fcntl #endif - #ifdef TARGET_NR_futimesat static void print_futimesat(const struct syscallname *name, diff --git a/linux-user/strace.list b/linux-user/strace.list index d49a1e92a8..fb9799e7e6 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -13,7 +13,7 @@ { TARGET_NR_access, "access" , NULL, print_access, NULL }, #endif #ifdef TARGET_NR_acct -{ TARGET_NR_acct, "acct" , NULL, NULL, NULL }, +{ TARGET_NR_acct, "acct" , NULL, print_acct, NULL }, #endif #ifdef TARGET_NR_add_key { TARGET_NR_add_key, "add_key" , NULL, NULL, NULL }, @@ -215,7 +215,7 @@ { TARGET_NR_fcntl64, "fcntl64" , NULL, print_fcntl64, NULL }, #endif #ifdef TARGET_NR_fdatasync -{ TARGET_NR_fdatasync, "fdatasync" , NULL, NULL, NULL }, +{ TARGET_NR_fdatasync, "fdatasync" , "%s(%d)", NULL, NULL }, #endif #ifdef TARGET_NR_fgetxattr { TARGET_NR_fgetxattr, "fgetxattr" , NULL, NULL, NULL }, @@ -251,7 +251,7 @@ { TARGET_NR_fstatfs64, "fstatfs64" , "%s(%d,%p)", NULL, NULL }, #endif #ifdef TARGET_NR_fsync -{ TARGET_NR_fsync, "fsync" , NULL, NULL, NULL }, +{ TARGET_NR_fsync, "fsync" , "%s(%d)", NULL, NULL }, #endif #ifdef TARGET_NR_ftime { TARGET_NR_ftime, "ftime" , NULL, NULL, NULL }, @@ -492,7 +492,7 @@ { TARGET_NR_Linux, "Linux" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_listen -{ TARGET_NR_listen, "listen" , NULL, NULL, NULL }, +{ TARGET_NR_listen, "listen" , "%s(%d,%d)", NULL, NULL }, #endif #ifdef TARGET_NR_listxattr { TARGET_NR_listxattr, "listxattr" , NULL, NULL, NULL }, From patchwork Tue Jun 2 11:53:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filip Bozuta X-Patchwork-Id: 1302396 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=syrmia.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=syrmia.com header.i=@syrmia.com header.a=rsa-sha256 header.s=selector1 header.b=kFRunn+R; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49bsj26Kxnz9sSd for ; Tue, 2 Jun 2020 23:05:25 +1000 (AEST) Received: from localhost ([::1]:33176 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jg6bZ-0004fo-Pi for incoming@patchwork.ozlabs.org; Tue, 02 Jun 2020 09:05:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40850) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jg5UM-0000Rb-23 for qemu-devel@nongnu.org; Tue, 02 Jun 2020 07:53:50 -0400 Received: from mail-db8eur05on2098.outbound.protection.outlook.com ([40.107.20.98]:20705 helo=EUR05-DB8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jg5UL-0000f1-3b for qemu-devel@nongnu.org; Tue, 02 Jun 2020 07:53:49 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RJMNwCgB4tDewg5LHrL9hPdwZAF0Cs0mLcco3tv7I9y17HPtZpxcv45O2UjpY2ryHsDRpS5KHthNRgZlII3ni0RDdOKazFCfS5p45zMKnvWsifPKJ4eepeLr4fdBZVE6DACTIQTJe+9UuCRNReaxWOea6SwOcaW/GsDbc4g14TAoUOxSRuIG9VoPhqfIcZ21I4cwIBoy3xlkWUl+cGO8wj6trEg2eVI5KEzfoZVLypcZeRQbYSQ3zcbzkz6IqcaVGZOrUYmkkutcz2IwDo8YzSfMT9RCpYz75QoDr7LQcAuLj4U99GnR/sOoBj7/WSGdMOPDOpcazJZpEXKtTX6cJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WSh4AVNR/OyJekO23RnLVMczpf/C7kIgC6iEaQcUuTk=; b=alBCfNAGdye7YGdcG/6q1XNg1w/tbmLi4An4e8nkyrp1mbiZq6GMZhTxUZ+kDgo9KfULscAS32grvEgynTittJ5f2uCcvQbLyPrOP4kvAwGMhh0NB0YLVifHZDAtnI3CQ5GKnntM5ka5x3shZobV5SzU3ByuttJ0i1965FsOcXMUq1vjF3K7XweMKYwSmFcLW30D4NBbEBKwhCHmhhJEAZ4RlnbXP/Z010/pItP6mvgSx4LQgeL5FTsOil19QWUz6cgPPYAwcLNrubTTCEqbH5ATSaleGTNmO4oWJZaYmY505X39xjz32eLf7e8LTsfr3RlLcY0pES3MPc4vG/r6MA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=syrmia.com; dmarc=pass action=none header.from=syrmia.com; dkim=pass header.d=syrmia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=syrmia.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WSh4AVNR/OyJekO23RnLVMczpf/C7kIgC6iEaQcUuTk=; b=kFRunn+RaPNJilwesrIeQMH9RiKnogIRiAgOe76z8Den2VaY6e+vqsnfTN6+ba16ikhnt/7+DRGz4RPgXQ4CgakwFECQ5t/q0NtgIwd3Z80evpW8UePGggUDNaOeQFulbz5jI8wBAE0EWY5xeItzw1vrNVMwI8UBL5B1nPyZbCU= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=syrmia.com; Received: from AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) by AM6PR03MB4022.eurprd03.prod.outlook.com (2603:10a6:20b:22::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3045.22; Tue, 2 Jun 2020 11:53:45 +0000 Received: from AM6PR03MB5233.eurprd03.prod.outlook.com ([fe80::7935:50dd:e879:bca8]) by AM6PR03MB5233.eurprd03.prod.outlook.com ([fe80::7935:50dd:e879:bca8%7]) with mapi id 15.20.3045.024; Tue, 2 Jun 2020 11:53:45 +0000 From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH 2/5] linux-user: Add strace support for printing argument of syscalls used for extend attributes Date: Tue, 2 Jun 2020 13:53:28 +0200 Message-Id: <20200602115331.1659-3-filip.bozuta@syrmia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200602115331.1659-1-filip.bozuta@syrmia.com> References: <20200602115331.1659-1-filip.bozuta@syrmia.com> X-ClientProxiedBy: LO2P265CA0116.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:c::32) To AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from bozuta-ubuntu-18.syrmia.com (46.240.135.226) by LO2P265CA0116.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:c::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3045.19 via Frontend Transport; Tue, 2 Jun 2020 11:53:44 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [46.240.135.226] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 10dcf27c-2980-4c7d-c1f2-08d806eb9a45 X-MS-TrafficTypeDiagnostic: AM6PR03MB4022: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:530; X-Forefront-PRVS: 0422860ED4 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qBg+p6mIUKT4J12ypRbOx8uQOVbWwj9hRI0T2JKZA9ZqmE5oWPb+2LIujdITMRY1wdXqOb/4UTyuXr4Gfd0WJWo3ReLQwHIQGVQ//JW84Z+UT01GZlidh7X0w9IkzwuXMtJ4Av7ggyGL0fSu05kyTUjshH7/JU+jQZNiheceMxuSjn7B0l/hY/43E4l+AUlO1XP/OI7j8lJWKGZ2QDrShsuJJDJcSwhT1pEvzBgxkfU1XdPfELulPeBTs2H1zmavEC7w6zWRKDMKaGhLmhYeSCzgAnRxO49OyviEWXi+6/QHj+LjIJmJAKYxxPcI9VFbjUhzjYwR0nY6f6PZraDVyU83mll/unCDa3TyPY8tfnXUc8+NXfiVOZSIKsj7XZ+jbt3JlSD+2lkyFzxgLerTMO72WASmsSlGMTMWgSzqviNbauALLb26HCX6EfKKK77thJmtzimKbxVQX2eKXx4Eow== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR03MB5233.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(366004)(376002)(346002)(39830400003)(136003)(396003)(966005)(44832011)(956004)(2906002)(4326008)(36756003)(2616005)(86362001)(508600001)(66556008)(66476007)(7696005)(66946007)(26005)(8676002)(52116002)(6666004)(6916009)(8936002)(316002)(1076003)(5660300002)(16526019)(83380400001)(186003)(6486002)(334744003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: An7pwbQwe8BrnVwzDg7NJ+FdhDvZ/l4w4/kd2iFMyvl4KMXMqj39wl+F07Cm5ROLdEkN4rE2NFEHNUko9XG8Yg3CFVdCD6NY1pI74HahUC40FR8eytedvySaZZt9q1dUPn15vtgjz1ASGb16faTxE2IAAPsggyObuYRj/6XIZYFlEOBoiUvpHPAlgQzbwi6bGDJAfLDC3ieQTrxkv9/c0USdKQd3u4fI2F/SV0k2KUTFVrKGL1DvFxldAFUf1ctrDK8hTZ1o9TyBg9aP4N+HHlxIfVx0ZjaMbMPpHgzwHKF0s/v0j/4pMtxsxfOcoCfwSMaqkSIkN9L3orST7p9eLT/y6JctlQQjQqyRAYxuUmm6lSIOMiQ2vuHeiDR6CbvhePJW5cx6aw/EDpTdr+9kllukuTjRC2v0lCqlYzzSYRzPw+TVtLLRku5oj9+jdK5NVivKYXHlwqFKtrmLzDkdlc11AY39uaK4Aaq6KUloE8Y= X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 10dcf27c-2980-4c7d-c1f2-08d806eb9a45 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2020 11:53:45.0058 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 19214a73-c1ab-4e19-8f59-14bdcb09a66e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: dxvnMbHh6YZqmip+K5Y5KdQumrVKKznNcFdGjyXgotgvRk55M1Z8/JQ1zOJMFCHe3bARdQ0u4Y7YcNlJTSCJYw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR03MB4022 Received-SPF: pass client-ip=40.107.20.98; envelope-from=Filip.Bozuta@syrmia.com; helo=EUR05-DB8-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/02 07:53:45 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-Mailman-Approved-At: Tue, 02 Jun 2020 09:04:50 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch implements strace argument printing functionality for following syscalls: *getxattr, lgetxattr, fgetxattr - retrieve an extended attribute value ssize_t getxattr(const char *path, const char *name, void *value, size_t size) ssize_t lgetxattr(const char *path, const char *name, void *value, size_t size) ssize_t fgetxattr(int fd, const char *name, void *value, size_t size) man page: https://www.man7.org/linux/man-pages/man2/getxattr.2.html *listxattr, llistxattr, flistxattr - list extended attribute names ssize_t listxattr(const char *path, char *list, size_t size) ssize_t llistxattr(const char *path, char *list, size_t size) ssize_t flistxattr(int fd, char *list, size_t size) man page: https://www.man7.org/linux/man-pages/man2/listxattr.2.html Implementation notes: All of the syscalls have strings as argument types and thus a separate printing function was stated in file "strace.list" for every one of them. All of these printing functions were defined in "strace.c" using existing printing functions for appropriate argument types: "print_strig()" - for (const char*) type "print_pointer()" - for (char*) and (void *) type "print_raw_param()" for (int) and (size_t) type Syscalls "getxattr()" and "lgetxattr()" have the same number and type of arguments and thus their print functions ("print_getxattr", "print_lgetxattr") share a same definition. The same statement applies to syscalls "listxattr()" and "llistxattr()". Signed-off-by: Filip Bozuta --- linux-user/strace.c | 60 ++++++++++++++++++++++++++++++++++++++++++ linux-user/strace.list | 12 ++++----- 2 files changed, 66 insertions(+), 6 deletions(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index c578876d22..5cf419989c 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1629,6 +1629,66 @@ print_fcntl(const struct syscallname *name, #define print_fcntl64 print_fcntl #endif +#ifdef TARGET_NR_fgetxattr +static void +print_fgetxattr(const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + print_syscall_prologue(name); + print_raw_param("%d", arg0, 0); + print_string(arg1, 0); + print_pointer(arg2, 0); + print_raw_param("%u", arg3, 1); + print_syscall_epilogue(name); +} +#endif + +#ifdef TARGET_NR_flistxattr +static void +print_flistxattr(const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + print_syscall_prologue(name); + print_raw_param("%d", arg0, 0); + print_pointer(arg1, 0); + print_raw_param("%u", arg2, 1); + print_syscall_epilogue(name); +} +#endif + +#if defined(TARGET_NR_getxattr) || defined(TARGET_NR_lgetxattr) +static void +print_getxattr(const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + print_syscall_prologue(name); + print_string(arg0, 0); + print_string(arg1, 0); + print_pointer(arg2, 0); + print_raw_param("%u", arg3, 1); + print_syscall_epilogue(name); +} +#define print_lgetxattr print_getxattr +#endif + +#if defined(TARGET_NR_listxattr) || defined(TARGET_NR_llistxattr) +static void +print_listxattr(const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + print_syscall_prologue(name); + print_string(arg0, 0); + print_pointer(arg1, 0); + print_raw_param("%u", arg2, 1); + print_syscall_epilogue(name); +} +#define print_llistxattr print_listxattr +#endif + #ifdef TARGET_NR_futimesat static void print_futimesat(const struct syscallname *name, diff --git a/linux-user/strace.list b/linux-user/strace.list index fb9799e7e6..8d51c54bca 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -218,13 +218,13 @@ { TARGET_NR_fdatasync, "fdatasync" , "%s(%d)", NULL, NULL }, #endif #ifdef TARGET_NR_fgetxattr -{ TARGET_NR_fgetxattr, "fgetxattr" , NULL, NULL, NULL }, +{ TARGET_NR_fgetxattr, "fgetxattr" , NULL, print_fgetxattr, NULL }, #endif #ifdef TARGET_NR_finit_module { TARGET_NR_finit_module, "finit_module" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_flistxattr -{ TARGET_NR_flistxattr, "flistxattr" , NULL, NULL, NULL }, +{ TARGET_NR_flistxattr, "flistxattr" , NULL, print_flistxattr, NULL }, #endif #ifdef TARGET_NR_flock { TARGET_NR_flock, "flock" , NULL, NULL, NULL }, @@ -396,7 +396,7 @@ { TARGET_NR_getuid32, "getuid32" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_getxattr -{ TARGET_NR_getxattr, "getxattr" , NULL, NULL, NULL }, +{ TARGET_NR_getxattr, "getxattr" , NULL, print_getxattr, NULL }, #endif #ifdef TARGET_NR_getxgid { TARGET_NR_getxgid, "getxgid" , NULL, NULL, NULL }, @@ -480,7 +480,7 @@ { TARGET_NR_lchown32, "lchown32" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_lgetxattr -{ TARGET_NR_lgetxattr, "lgetxattr" , NULL, NULL, NULL }, +{ TARGET_NR_lgetxattr, "lgetxattr" , NULL, print_lgetxattr, NULL }, #endif #ifdef TARGET_NR_link { TARGET_NR_link, "link" , NULL, print_link, NULL }, @@ -495,10 +495,10 @@ { TARGET_NR_listen, "listen" , "%s(%d,%d)", NULL, NULL }, #endif #ifdef TARGET_NR_listxattr -{ TARGET_NR_listxattr, "listxattr" , NULL, NULL, NULL }, +{ TARGET_NR_listxattr, "listxattr" , NULL, print_listxattr, NULL }, #endif #ifdef TARGET_NR_llistxattr -{ TARGET_NR_llistxattr, "llistxattr" , NULL, NULL, NULL }, +{ TARGET_NR_llistxattr, "llistxattr" , NULL, print_llistxattr, NULL }, #endif #ifdef TARGET_NR__llseek { TARGET_NR__llseek, "_llseek" , NULL, print__llseek, NULL }, From patchwork Tue Jun 2 11:53:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filip Bozuta X-Patchwork-Id: 1302402 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=syrmia.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=syrmia.com header.i=@syrmia.com header.a=rsa-sha256 header.s=selector1 header.b=a1HBFNgc; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49bskk63KPz9sTD for ; Tue, 2 Jun 2020 23:06:54 +1000 (AEST) Received: from localhost ([::1]:39884 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jg6d2-0007Tx-0I for incoming@patchwork.ozlabs.org; Tue, 02 Jun 2020 09:06:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40860) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jg5UN-0000Ta-Vq for qemu-devel@nongnu.org; Tue, 02 Jun 2020 07:53:51 -0400 Received: from mail-db8eur05on2098.outbound.protection.outlook.com ([40.107.20.98]:20705 helo=EUR05-DB8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jg5UM-0000f1-8p for qemu-devel@nongnu.org; Tue, 02 Jun 2020 07:53:51 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g43R9V5ivuHZVMWxB1V58cG2i5daayqAiSsreByhMpBRiuUTJaFPHOxscssA75QrkVAB0y4Olk8LrLZRGf9O/hMtVjOFmmaHXizBnNbb5sZCJXRkXZloI1TCHiTpR70SYFp/y0ySWnxpBw2lhVDi4RF8KoyrRkTjmLku9R17czlBHixAdjp8rZ+E4U/0XVa0Qzt+Gk/tvvIpHf9coxwJQt1fWMKR1Uz8rjCDILaR1ItdwH1EeYFEPbv6ZVFLHQfVs447V+5pTRdQtM6sGaC0jYfvAfmgmdhYHnIuPdG/9TY0l3PEte4Copyfa/HKBnv3YLlVu/2/8AaG+7KkFoepKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TY44iFpp45jA4aUldAT2cU45SX6PumUBvKPAEPX4oBE=; b=S2k+Ao59VEhLVLe0YVOd398pLMAQzKpYCCDNjZ0WAWqHEEmYmgh6ouhzPt1DgpY8VjMNnfdB11vAAiZr6let/VdLtt8tBKTsYMGmw+wIj73dxTdzozPpdqvXhXdJLeJA2MuqdBSOQEZs9bGlEIBeJrFCjhuQ72j13A7ZG2/SjesNm4S0XqLFMz5D/m9fqqV32PD6rVaq3MBpbziy+5VCshanH0MoJwXTGZSBqOLzpW05Uigff2C8HKofeOARyqxHmUI+lXyem9SFxIw9B9YUfiI9RzbKyZDqj94EVtAd3XbCeRStyMRuBaO08jiagtdMEWdUavGuTt2FR8UTQqEYeA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=syrmia.com; dmarc=pass action=none header.from=syrmia.com; dkim=pass header.d=syrmia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=syrmia.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TY44iFpp45jA4aUldAT2cU45SX6PumUBvKPAEPX4oBE=; b=a1HBFNgc2ZOSYinITR0a0H/PdfiaAPHCAVlSUiBNMWIHLcqdRZ7/4+Bx03z/N88dm1pR4USTftg3YXByZy+ql3I51KIUzSRra58gF16oF5kHkCtNytInEyZUqjOn+1yhc+2U43K2pngiqccNgTdSOPBx2jt2l41ovRKFWMYdej4= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=syrmia.com; Received: from AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) by AM6PR03MB4022.eurprd03.prod.outlook.com (2603:10a6:20b:22::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3045.22; Tue, 2 Jun 2020 11:53:45 +0000 Received: from AM6PR03MB5233.eurprd03.prod.outlook.com ([fe80::7935:50dd:e879:bca8]) by AM6PR03MB5233.eurprd03.prod.outlook.com ([fe80::7935:50dd:e879:bca8%7]) with mapi id 15.20.3045.024; Tue, 2 Jun 2020 11:53:45 +0000 From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH 3/5] linux-user: Add strace support for printing arguments of lseek() Date: Tue, 2 Jun 2020 13:53:29 +0200 Message-Id: <20200602115331.1659-4-filip.bozuta@syrmia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200602115331.1659-1-filip.bozuta@syrmia.com> References: <20200602115331.1659-1-filip.bozuta@syrmia.com> X-ClientProxiedBy: LO2P265CA0116.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:c::32) To AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from bozuta-ubuntu-18.syrmia.com (46.240.135.226) by LO2P265CA0116.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:c::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3045.19 via Frontend Transport; Tue, 2 Jun 2020 11:53:45 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [46.240.135.226] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8ff77803-ffb1-48d1-c095-08d806eb9a9d X-MS-TrafficTypeDiagnostic: AM6PR03MB4022: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-Forefront-PRVS: 0422860ED4 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mqBxfN3cH2/KL2b3sbGbDDM9TTgJ6YEWc9iDPMo4I+whjvVTwSSaFtAGLDHrpUEh9IU6iTnJus6ejhk2A/vBpxtuX/TgdPUM0p75ztU75WDZB3rhT4andeLEwe8quoJNzgfYPaatpKzPeiY/NibwyutxgLNoNToYU+QZIWZV+TpzXvU72ZG4HZJlCDsZyJp4yFHtkPMEpJYor4wP+glDRD8FW65Ws2uaYZ3NmFoykAE/mL4k4QHy4dyNOWJQ18Gj1jxTU6DQ7Wyd2Uhgrg+6D2p7eZGWV9I4MlVHvGuhOzFkxvw9jS2k8uqI/Qevh0PTfyj4LFVOR3gFmI7zTpW6mG8IgL9jrpAzVhxc8K/m19W2cq6UvNT95tEmRLReTdGyrsIczTxHn7+lGu6CFsDvWQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR03MB5233.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(366004)(376002)(346002)(39830400003)(136003)(396003)(966005)(44832011)(956004)(2906002)(4326008)(36756003)(2616005)(86362001)(508600001)(66556008)(66476007)(7696005)(66946007)(26005)(8676002)(52116002)(6666004)(6916009)(8936002)(316002)(1076003)(5660300002)(16526019)(83380400001)(186003)(6486002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: MVdfOyOCc8H+oDkAELDIVokZcsgcQGWKMqQYG1mCfMjDEyafCHRAepTF3eGsQKUCNFrpMU1GcofznuUwL6TOez6Gv9lyLn9P6m1lqpRX633DdfZyqG4X3P1PdQS3dsXDbYYa98zolfBN5JclDyUENBcxVI4MI2L1H3PJ4IOHF6Zty74GgecKMudQ4UoKu6wuok4VGE/WhAEn+nxVp1wpq5E+f6TeUjeqZX4Rq5fJ00tjG54Dy13HaPaYwPOxkVD5k2Ig6EMb7oIGQ1jKcP0m4R1wBKyDNq7zhp6kdo1k2wLsYsp2/cDhX6SsMjhElLIW9TpPXXQOlsjv7E0JCrqes3i2TcC8B+LAHhuRQeNGppzEu+A7EexXEulIh4R4/GqzLdnqAzvxPNygwSnVjKJ/ddn9hV6PFiiobj4roSNfcLdy7BCGyRr0WLFX6SO3LqrSiweWMXMaaZX+cr/6ORawWn0nyRI2eMkC+knU+bF56Ko= X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8ff77803-ffb1-48d1-c095-08d806eb9a9d X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2020 11:53:45.6264 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 19214a73-c1ab-4e19-8f59-14bdcb09a66e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: oLTDXS0C7jrVwGlt7zS+Hqp75Gk5m4Q4TP+TTFe/r17PFeDML1ZhNVb9aA5e5hwDy7LgRYUB+faZOLZYkIhN+A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR03MB4022 Received-SPF: pass client-ip=40.107.20.98; envelope-from=Filip.Bozuta@syrmia.com; helo=EUR05-DB8-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/02 07:53:45 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-Mailman-Approved-At: Tue, 02 Jun 2020 09:04:50 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch implements strace argument printing functionality for syscall: *lseek - reposition read/write file offset off_t lseek(int fd, off_t offset, int whence) man page: https://www.man7.org/linux/man-pages/man2/lseek.2.html Implementation notes: The syscall's third argument "whence" has predefined values: "SEEK_SET","SEEK_CUR","SEEK_END","SEEK_DATA","SEEK_HOLE" and thus a separate printing function "print_lseek" was stated in file "strace.list". This function is defined in "strace.c" by using an existing function "print_raw_param()" to print the first and second argument and a switch(case) statement for the predefined values of the third argument. Values "SEEK_DATA" and "SEEK_HOLE" are defined in kernel version 3.1. That is the reason why case statements for these values are enwrapped in #ifdef directive. Signed-off-by: Filip Bozuta --- linux-user/strace.c | 32 ++++++++++++++++++++++++++++++++ linux-user/strace.list | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index 5cf419989c..b7f012f1b5 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1768,6 +1768,38 @@ print__llseek(const struct syscallname *name, } #endif +#ifdef TARGET_NR_lseek +static void +print_lseek(const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + print_syscall_prologue(name); + print_raw_param("%d", arg0, 0); + print_raw_param("%ld", arg1, 0); + switch (arg2) { + case SEEK_SET: + qemu_log("SEEK_SET"); break; + case SEEK_CUR: + qemu_log("SEEK_CUR"); break; + case SEEK_END: + qemu_log("SEEK_END"); break; +#ifdef SEEK_DATA + case SEEK_DATA: + qemu_log("SEEK_DATA"); break; +#endif +#ifdef SEEK_HOLE + case SEEK_HOLE: + qemu_log("SEEK_HOLE"); break; +#endif + default: + print_raw_param("%#x", arg2, 1); + qemu_log(" /* SEEK_??? */"); + } + print_syscall_epilogue(name); +} +#endif + #if defined(TARGET_NR_socket) static void print_socket(const struct syscallname *name, diff --git a/linux-user/strace.list b/linux-user/strace.list index 8d51c54bca..5a56212532 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -513,7 +513,7 @@ { TARGET_NR_lremovexattr, "lremovexattr" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_lseek -{ TARGET_NR_lseek, "lseek" , NULL, NULL, NULL }, +{ TARGET_NR_lseek, "lseek" , NULL, print_lseek, NULL }, #endif #ifdef TARGET_NR_lsetxattr { TARGET_NR_lsetxattr, "lsetxattr" , NULL, NULL, NULL }, From patchwork Tue Jun 2 11:53:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filip Bozuta X-Patchwork-Id: 1302416 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=syrmia.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=syrmia.com header.i=@syrmia.com header.a=rsa-sha256 header.s=selector1 header.b=mCVIMDJ6; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49bsrW0Cqrz9sSc for ; Tue, 2 Jun 2020 23:11:55 +1000 (AEST) Received: from localhost ([::1]:51658 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jg6hs-000409-Oq for incoming@patchwork.ozlabs.org; Tue, 02 Jun 2020 09:11:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40862) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jg5UO-0000Tl-3f for qemu-devel@nongnu.org; Tue, 02 Jun 2020 07:53:52 -0400 Received: from mail-eopbgr140120.outbound.protection.outlook.com ([40.107.14.120]:62970 helo=EUR01-VE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jg5UN-0000gD-Aa for qemu-devel@nongnu.org; Tue, 02 Jun 2020 07:53:51 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VtQ/9pNJb/iba7i01lFD9djz1WIj9lWy5w6V0lHQU1qQ0WaNof+via5PZFGUb0BV+9a7Q7ZNvcKhHIhgIxAgA58pa9fmtCP0b8C9D5teg9jBNCVKVP0G1F2dqrTnoetzj5CtrjJhVeK6qDkaDlS3GuejtKSoa+UjWPk5KkmeopuP20tE5io1t8KMuj+hksnBedO48yrlCn/Jx7QBNP5xaTjqnS4SFqBDvbloakSSYrPAv8FlIdKE1QhKCVsdUa3b6jCD5pg+ffJ4dqlEABdVBC0o7chuWeU88XOR5kD4UOU300ZRLkhJstOQLSIjeIRtE3DRAswbLBzSAKb6N+6ZKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hAl752kyM1B1Z/Fmsw6lGIhRmCjuXq8U+QzWIJvLX3g=; b=Dc19adaO+3Jyb4V1Rt3IOyGif1J3iM7uOT6psYe16T92c4ifGWxLG49WFjIHcmnYym4KJozcxwLnmHkUIOW+YvPpHbpryZBCAWtSL3pxB8o14svGwdAFUAOo9nE53g5xWOWxyzQHuECE3+heWP4n1+rYzwRcjbSiLshXEyE5fHUGW0PqMZYG5znDijPXiZgARZhaMdwhmmynh/XlI42CGn2LdeltWPR/HPKaizBTcNp93gG3pWbXFCcxG+pS50zr8SZed8iPReyJ5rIgcGU0sv5vLyO9p013faeMDu8x3YTMmJEjM2/mGtt93wxJ4XA8WHSeg3HRu4WZfdYUk/cLmQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=syrmia.com; dmarc=pass action=none header.from=syrmia.com; dkim=pass header.d=syrmia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=syrmia.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hAl752kyM1B1Z/Fmsw6lGIhRmCjuXq8U+QzWIJvLX3g=; b=mCVIMDJ6b4NuJBclp3miL0Y5EzhmqDp9Mb58biW9TGLBKseBGU8huGx9kZBIL8WYc8XrDMcvlJA3zVJYi5sTwcOoK5OinFDXaKjOt1ekdOyBthb3ALDeHCps/LdxF0FSfXj+h527C79bGWLQuEwtAp//Mz1uztaaNG2errIcwNQ= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=syrmia.com; Received: from AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) by AM6PR03MB4022.eurprd03.prod.outlook.com (2603:10a6:20b:22::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3045.22; Tue, 2 Jun 2020 11:53:46 +0000 Received: from AM6PR03MB5233.eurprd03.prod.outlook.com ([fe80::7935:50dd:e879:bca8]) by AM6PR03MB5233.eurprd03.prod.outlook.com ([fe80::7935:50dd:e879:bca8%7]) with mapi id 15.20.3045.024; Tue, 2 Jun 2020 11:53:46 +0000 From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH 4/5] linux-user: Add strace support for printing arguments of chown()/lchown() Date: Tue, 2 Jun 2020 13:53:30 +0200 Message-Id: <20200602115331.1659-5-filip.bozuta@syrmia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200602115331.1659-1-filip.bozuta@syrmia.com> References: <20200602115331.1659-1-filip.bozuta@syrmia.com> X-ClientProxiedBy: LO2P265CA0116.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:c::32) To AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from bozuta-ubuntu-18.syrmia.com (46.240.135.226) by LO2P265CA0116.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:c::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3045.19 via Frontend Transport; Tue, 2 Jun 2020 11:53:45 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [46.240.135.226] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 63a1652b-3abc-40d8-c32e-08d806eb9afc X-MS-TrafficTypeDiagnostic: AM6PR03MB4022: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5516; X-Forefront-PRVS: 0422860ED4 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IP3QHs9clb8uDxc8+w2pJf46Vl5aNIcr4ZFMI1H/JhLLKTsYVRY7QZyOYLrZbfL1aS6WcrYTLONa2n52owgn1FTrWDrV2GTLPegrIwOkVGnc8ekqbXcNyHhJRFEHX6up0nyCY5/qE3COIcflKSGJZqnUdNr6rMndBeLG5s7Svq/EbTxKvKPzo188tLF4veKHHw2Mw5M72Riuz2X8G9yu7ov/6ItLwU3o1FIs+qnWNKEtIvQ78ZMvG86z2KyZ9BMHlK2W6t53s63LNKWN799zaOq4dE3RbPJO2QZ9xp7j0EaMrsxr6mW0MgCgyOGH0FHKVx7eOsGNry+jdOykJaraGvr0eTpJnwf1iV2u0AjY0Ovu5qfdNwb2ZbMCjhXBIQ+zkxEZBKNJ/2BZh/JgLvdt+Q== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR03MB5233.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(366004)(376002)(346002)(39830400003)(136003)(396003)(966005)(44832011)(956004)(2906002)(4326008)(36756003)(2616005)(86362001)(508600001)(66556008)(66476007)(7696005)(66946007)(26005)(8676002)(52116002)(6666004)(6916009)(8936002)(316002)(1076003)(5660300002)(16526019)(83380400001)(186003)(6486002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: CPqvehuHs+R0HK+3lmn2bB1jjxyYKvK8vQ/K8qRlRDauogjp9Q+nhbC7fbx11u6NAMK4Vngc1PCNdDIatK7IfcJ3hdXCsgFcQSBHOyH1MvC5IPQzy3SNcr+vuRe1PDtlFEN7otU6/kIqVK/t51JiZFjB19puCzZNkdfZ1R8zCQxuAEwfJDtZn0vlvLe4VC4UysTVMxoQWxq6TZx3zDAQCvRPo7802YtBW4lMY/DPVuzzKRlYZFT7tnKVXHyVCX291w3Qzji6xBQh3+uSxQleSGJZW1H6LcTIlT9xH2+xvacvUkNB5EPOsOcyroSvqsAssCEZlOjb5q4+/XaiX/fmoBtoejhKqy6oi+crskA/S3cHG6u+NIgVVxLUAewxjwYY2Lnoh/gRKVLskcUIaEO0iEt/RfA9QiykztQsbtM+VAuRL2A2ApoY8NehyXxCQ4n5EU6cEWWr9Txy0UKLgBnyOsKney8Y1OzaZypPdy0iPZ0= X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 63a1652b-3abc-40d8-c32e-08d806eb9afc X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2020 11:53:46.2251 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 19214a73-c1ab-4e19-8f59-14bdcb09a66e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: PyBa/KrDdw9NrIdFd8ItRbIAY9E124HBVLeowhhZ/HBDZ24SjRJUWTQXSE0hOKIOh+zOgTzTl+lEKmnMHyxiFA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR03MB4022 Received-SPF: pass client-ip=40.107.14.120; envelope-from=Filip.Bozuta@syrmia.com; helo=EUR01-VE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/02 07:53:48 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-Mailman-Approved-At: Tue, 02 Jun 2020 09:04:50 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch implements strace argument printing functionality for syscalls: *chown, lchown - change ownership of a file int chown(const char *pathname, uid_t owner, gid_t group) int lchown(const char *pathname, uid_t owner, gid_t group) man page: https://www.man7.org/linux/man-pages/man2/lchown.2.html Implementation notes: Both syscalls use strings as arguments and thus a separate printing function was stated in "strace.list" for them. Both syscalls share the same number and types of arguments and thus share a same definition in file "syscall.c". This defintion uses existing functions "print_string()" to print the string argument and "print_raw_param()" to print other two arguments that are of basic types. Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier --- linux-user/strace.c | 15 +++++++++++++++ linux-user/strace.list | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index b7f012f1b5..542bfdeb91 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1414,6 +1414,21 @@ print_chmod(const struct syscallname *name, } #endif +#if defined(TARGET_NR_chown) || defined(TARGET_NR_lchown) +static void +print_chown(const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + print_syscall_prologue(name); + print_string(arg0, 0); + print_raw_param("%d", arg1, 0); + print_raw_param("%d", arg2, 1); + print_syscall_epilogue(name); +} +#define print_lchown print_chown +#endif + #ifdef TARGET_NR_clock_adjtime static void print_clock_adjtime(const struct syscallname *name, diff --git a/linux-user/strace.list b/linux-user/strace.list index 5a56212532..b72f757d3f 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -71,7 +71,7 @@ { TARGET_NR_chmod, "chmod" , NULL, print_chmod, NULL }, #endif #ifdef TARGET_NR_chown -{ TARGET_NR_chown, "chown" , NULL, NULL, NULL }, +{ TARGET_NR_chown, "chown" , NULL, print_chown, NULL }, #endif #ifdef TARGET_NR_chown32 { TARGET_NR_chown32, "chown32" , NULL, NULL, NULL }, @@ -474,7 +474,7 @@ { TARGET_NR_kill, "kill", NULL, print_kill, NULL }, #endif #ifdef TARGET_NR_lchown -{ TARGET_NR_lchown, "lchown" , NULL, NULL, NULL }, +{ TARGET_NR_lchown, "lchown" , NULL, print_lchown, NULL }, #endif #ifdef TARGET_NR_lchown32 { TARGET_NR_lchown32, "lchown32" , NULL, NULL, NULL }, From patchwork Tue Jun 2 11:53:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filip Bozuta X-Patchwork-Id: 1302397 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=syrmia.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=syrmia.com header.i=@syrmia.com header.a=rsa-sha256 header.s=selector1 header.b=aCEtzqZY; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49bsj52VdCz9sSn for ; Tue, 2 Jun 2020 23:05:29 +1000 (AEST) Received: from localhost ([::1]:33406 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jg6bc-0004nB-Pg for incoming@patchwork.ozlabs.org; Tue, 02 Jun 2020 09:05:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40870) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jg5UP-0000Ux-4W for qemu-devel@nongnu.org; Tue, 02 Jun 2020 07:53:53 -0400 Received: from mail-db8eur05on2098.outbound.protection.outlook.com ([40.107.20.98]:20705 helo=EUR05-DB8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jg5UO-0000f1-68 for qemu-devel@nongnu.org; Tue, 02 Jun 2020 07:53:52 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JkyhJ/yHNtY6twerRAx2RK14DAJ8kLDlCS2R0V3gXB5212lUsVCFkWrthII5hQfWqTP22xVZQBYWqmPURgypgAULb7qCCoysO5CQmsB3IwHOQ+KQWkGXIDSBcY/CtWsQ3V3ChklSpkBrAqy1CcqdhSb4rsKxvWIkPze5viGn+LZOry7M4D9qy6R22aKbT87zFOfKmEVu3eWgYBwIgZYvnp+2KYkS71cw3Ujjg3fdpNSQWZPGL5GjpAolmLA/vFJGxuApZ9Y/IkDnwcyBW9Ux0n115lhWn0AwLngxuRXIcvoUMLaZ/3nLLjL8hkqHk3aYvMLBxqeoRNFATC74LcUWQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Acd1e1xFA/AYPEDvIYK7p2CNjbLwUHIdO8rjhtxLmMY=; b=d/okAP2JZwjHU8WE+BGTC4pyPKA/V2w/90g0x5UUOJuGe1EceSIEy+tmpuReUqiETh0a+2v4ksWY7soIpg4Xu33D4K5ZdQb/WyAt1LRoNJjoTXnDH7eToJDIyWYOleQEOQ1aEPY1OuvfAYt4PTXXkuTQ4KSv+ggqY7VefF1/siz9hJR7OzxMr3Q38VVBPcZHmux885ZDlBvvPFpMH08Nycw+nxZ2FhhetdhHjbTnhS18nrn+lsj+KLLnfmEFI082WIqJlrMnGKE04vHOYK0LZFGUGcA7oiaYf1ZKCJQGpytMg19TiHSoW1qElgad9sb4B111oWMZppLj1vY4hXaVOw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=syrmia.com; dmarc=pass action=none header.from=syrmia.com; dkim=pass header.d=syrmia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=syrmia.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Acd1e1xFA/AYPEDvIYK7p2CNjbLwUHIdO8rjhtxLmMY=; b=aCEtzqZYp8QDB9AySKfg1B3zR0M8U1h0+SxM1vL6LYrCyUdBl4MOfVetD4cYUY2x7VPaD/W8+b+zhh7SgIpiPs6ZK5ZLNOeN3GU2S11qyyOgWaH0llsykhfcDQyrg5KEt3i78ICbgouTiWAB61F0UtP21Jpq/2yEBcbVJFfZ/Pg= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=syrmia.com; Received: from AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) by AM6PR03MB4022.eurprd03.prod.outlook.com (2603:10a6:20b:22::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3045.22; Tue, 2 Jun 2020 11:53:46 +0000 Received: from AM6PR03MB5233.eurprd03.prod.outlook.com ([fe80::7935:50dd:e879:bca8]) by AM6PR03MB5233.eurprd03.prod.outlook.com ([fe80::7935:50dd:e879:bca8%7]) with mapi id 15.20.3045.024; Tue, 2 Jun 2020 11:53:46 +0000 From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH 5/5] linux-user: Add strace support for printing arguments of fallocate() Date: Tue, 2 Jun 2020 13:53:31 +0200 Message-Id: <20200602115331.1659-6-filip.bozuta@syrmia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200602115331.1659-1-filip.bozuta@syrmia.com> References: <20200602115331.1659-1-filip.bozuta@syrmia.com> X-ClientProxiedBy: LO2P265CA0116.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:c::32) To AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from bozuta-ubuntu-18.syrmia.com (46.240.135.226) by LO2P265CA0116.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:c::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3045.19 via Frontend Transport; Tue, 2 Jun 2020 11:53:46 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [46.240.135.226] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0e08af5a-896c-4fb9-3282-08d806eb9b57 X-MS-TrafficTypeDiagnostic: AM6PR03MB4022: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-Forefront-PRVS: 0422860ED4 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BCAfmFisHOVr6HDfTBbkSx/WyanI7XEY89iSEltfknSIS7dDlN/btFh8YDUU7b0dLc4UwUoW1RTIsiLUfxF39lRBiz4ec5FBII9GGBDnPC2JZ2I5GnjJh+HhgB1jcnRidrY1b7dz6GT8aAHLaIoRv4RUeu7l4NwRrgmfJ55jxGN4UJsU4wR+vCXMNPkW/vIV487K3k8Dv0drQj4RL9ITTesbudXHn4Pp7ShfMtAQFXj5ojhebVTKGebOyRv19mHkeY65b1VvPIN/atQbU5RMQoYiBM0JBwD9WXalo+pfiOo5blTPchcghVfl4h9qbTrWiLDcsXE+CzqSpbRW9PTlH0WU6FxxvNYqn4BC/Y/zwnNwAkTA/9s+MfG8oFN7J9TMahkfmaBeVuY6gn1bJ2FeQP+tlsIU1KKTUqmo2x/O1CuH4vkV8W9QlznO7ldUCOum1/YuAanxhh4ZAZFmXDTn+g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR03MB5233.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(366004)(376002)(346002)(39830400003)(136003)(396003)(966005)(44832011)(956004)(2906002)(4326008)(36756003)(2616005)(86362001)(508600001)(66556008)(66476007)(7696005)(66946007)(26005)(8676002)(52116002)(6666004)(6916009)(8936002)(316002)(1076003)(5660300002)(16526019)(83380400001)(186003)(6486002)(21314003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: vC0jEyN856QGyCgi7QjPNGsCeRd9LMFGAnIbpuKH6bhFcApuQ6kn31YWyQE9SkPsLZrUP+vVCYnk35gfepWUchVTNqgoZ5BMTRoMcYbNQI2mF0tKgoqnpZt9FQ+8+rrJq3qkgHxSjG66Ogj7tuhgqOrHe/uRcAQc+lJ2MRl4rd1c+ax/fdwr9qW+/TN/EfAqMDxjkMv/yibXKIgNQF2A3+/ooiQH/+urfVQb5HtOZcyXoidHzzBErTXlhUYMKhC/po42GdiKY8Tp1zLbLf74bKG1dTbx23Z5FwiM93yn+zm2iVo8/y3jEE+gr5UNd8Ak9lT8HQElEaGrB/AAcTV1L7fZwrpZJSrivgdcwgzczF2yN+ev8sXLObGesSyxfkMUME5W7fCEGHxWcmJhdqioZIa4xNcIF07/kjt4nMSX8dC30kqGrLsIXgowmVMToh813dMT27SDIg0zWQ6+Wddy4NjItATlWTGLCe0b/vizyk0= X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0e08af5a-896c-4fb9-3282-08d806eb9b57 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2020 11:53:46.8208 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 19214a73-c1ab-4e19-8f59-14bdcb09a66e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Pzhu4ODBQUDFT00dERWvRwd/p+UQfeTnzR2p4QDG1gGzTkUe2qNFdb2FAiSbrzhbArZ5q1Iw3RHtZ3flgJ6k6A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR03MB4022 Received-SPF: pass client-ip=40.107.20.98; envelope-from=Filip.Bozuta@syrmia.com; helo=EUR05-DB8-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/02 07:53:45 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-Mailman-Approved-At: Tue, 02 Jun 2020 09:04:50 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch implements strace argument printing functionality for following syscall: *fallocate - manipulate file space int fallocate(int fd, int mode, off_t offset, off_t len) man page: https://www.man7.org/linux/man-pages/man2/fallocate.2.html Implementation notes: This syscall's second argument "mode" is composed of predefined values which represent flags that determine the type of operation that is to be performed on the file space. For that reason, a printing function "print_fallocate" was stated in file "strace.list". This printing function uses an already existing function "print_flags()" to print flags of the "mode" argument. These flags are stated inside an array "falloc_flags" that contains values of type "struct flags". These values are instantiated using an existing macro "FLAG_GENERIC()". Most of these flags are defined after kernel version 3.0 which is why they are enwrapped in an #ifdef directive. The syscall's third ant fourth argument are of type "off_t" which can cause variations between 32/64-bit architectures. To handle this variation, function "target_offset64()" was copied from file "strace.c" and used in "print_fallocate" to print "off_t" arguments for 32-bit architectures. Signed-off-by: Filip Bozuta --- linux-user/strace.c | 56 ++++++++++++++++++++++++++++++++++++++++++ linux-user/strace.list | 2 +- 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index 542bfdeb91..3998a00bb4 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -34,6 +34,22 @@ struct syscallname { #define UNUSED #endif +#if TARGET_ABI_BITS == 32 +static inline uint64_t target_offset64(uint32_t word0, uint32_t word1) +{ +#ifdef TARGET_WORDS_BIGENDIAN + return ((uint64_t)word0 << 32) | word1; +#else + return ((uint64_t)word1 << 32) | word0; +#endif +} +#else /* TARGET_ABI_BITS == 32 */ +static inline uint64_t target_offset64(uint64_t word0, uint64_t word1) +{ + return word0; +} +#endif /* TARGET_ABI_BITS != 32 */ + /* * Structure used to translate flag values into strings. This is * similar that is in the actual strace tool. @@ -1097,6 +1113,26 @@ UNUSED static struct flags statx_mask[] = { FLAG_END, }; +UNUSED static struct flags falloc_flags[] = { + FLAG_GENERIC(FALLOC_FL_KEEP_SIZE), + FLAG_GENERIC(FALLOC_FL_PUNCH_HOLE), +#ifdef FALLOC_FL_NO_HIDE_STALE + FLAG_GENERIC(FALLOC_FL_NO_HIDE_STALE), +#endif +#ifdef FALLOC_FL_COLLAPSE_RANGE + FLAG_GENERIC(FALLOC_FL_COLLAPSE_RANGE), +#endif +#ifdef FALLOC_FL_ZERO_RANGE + FLAG_GENERIC(FALLOC_FL_ZERO_RANGE), +#endif +#ifdef FALLOC_FL_INSERT_RANGE + FLAG_GENERIC(FALLOC_FL_INSERT_RANGE), +#endif +#ifdef FALLOC_FL_UNSHARE_RANGE + FLAG_GENERIC(FALLOC_FL_UNSHARE_RANGE), +#endif +}; + /* * print_xxx utility functions. These are used to print syscall * parameters in certain format. All of these have parameter @@ -1514,6 +1550,26 @@ print_faccessat(const struct syscallname *name, } #endif +#ifdef TARGET_NR_fallocate +static void +print_fallocate(const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + print_syscall_prologue(name); + print_raw_param("%d", arg0, 0); + print_flags(falloc_flags, arg1, 0); +#if TARGET_ABI_BITS == 32 + print_raw_param("%ld", target_offset64(arg2, arg3), 0); + print_raw_param("%ld", target_offset64(arg4, arg5), 1); +#else + print_raw_param("%ld", arg2, 0); + print_raw_param("%ld", arg3, 1); +#endif + print_syscall_epilogue(name); +} +#endif + #ifdef TARGET_NR_fchmodat static void print_fchmodat(const struct syscallname *name, diff --git a/linux-user/strace.list b/linux-user/strace.list index b72f757d3f..d7458ce884 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -182,7 +182,7 @@ { TARGET_NR_fadvise64_64, "fadvise64_64" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_fallocate -{ TARGET_NR_fallocate, "fallocate" , NULL, NULL, NULL }, +{ TARGET_NR_fallocate, "fallocate" , NULL, print_fallocate, NULL }, #endif #ifdef TARGET_NR_fanotify_init { TARGET_NR_fanotify_init, "fanotify_init" , NULL, NULL, NULL },