From patchwork Fri Nov 11 04:22:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13039635 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 5C3C2C4332F for ; Fri, 11 Nov 2022 04:24:57 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otLZc-0000Y2-Mf; Thu, 10 Nov 2022 23:23:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otLZY-0000V4-1V for qemu-devel@nongnu.org; Thu, 10 Nov 2022 23:23:20 -0500 Received: from mx0b-0064b401.pphosted.com ([205.220.178.238]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otLZV-0001ZL-9x for qemu-devel@nongnu.org; Thu, 10 Nov 2022 23:23:19 -0500 Received: from pps.filterd (m0250811.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AB4N0iJ024928; Fri, 11 Nov 2022 04:23:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=3J2NROZnClrvuX5c5BEezlgW8s+8HRmDzv9cpo+LHXE=; b=n7/GQu9ei74NAisd7t7hkWwupoGMSSUMdyit7zCfuja2gmCc7kmakGHW5w8jV00jFeFD Mb6g4vBn8r4Qlxfq5xOXOyNBbIwXkM8L3sV+iQ4/ctZc3kRAEliJb8yrLe4/RbcS8TVt glKtS+HnCGzC+HVSO7vZaL2nBWhg0klJWQt2EvCz8Fsdoz+OA4qWNEofkXbVB27ta7j4 G1teiDwZhKkX9Nu3T+DL+7N3bwQIaQlXMou1rJoXUcFrzDq3XCOczzRkvNw8sjCpH1yp fo3dNa2g8wAoGHyPGCxDvtyCC9ve2p/auL9cDh78TwfyENNHB8TQ0/UhZW+YtkVGdOBQ pg== Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2103.outbound.protection.outlook.com [104.47.70.103]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3knd21ndvc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 11 Nov 2022 04:23:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DU4kFg9PaUYbLNRZYXMhUxPxjxHJt/TcpPSPHvj7l6Yiewm8VtVoUGOkbS9ghwzqWMs4lwCYRxThZ3OaYcujB31aUr+yb/S4CqX/P4gIGsEfSDTl2L160F+2MlhgjreEpr2eC38rHsBti8pWemQzDaEuzvHgVUFlV33berwxz+xcX4nDf25b7lpu99Wr18WhyKJFpb4/EYVNglzfob9+nAcEjQ2r965fQowETLqokS374uEnZAepesYqN4Nvd6WBtmqhD6WMXAdPX83OW460MSzHs3kDkaUxo+j3q4Lg634CI9mUjx9S7K/qXv/PEWJKaDJpW7lm0Nr9ily07XwThQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3J2NROZnClrvuX5c5BEezlgW8s+8HRmDzv9cpo+LHXE=; b=hW21Hm0d/aI+jdEFLE5VPxI4IwEeNSxq6K+aXdfpHq0mCvU5voF3SFTh1kMW5KiG9n6N6kE+jagzihRyqHa32DvICjW6nh1pbXeXS+JafJ86fKN8hcGz602/+iiYCOZT13r2c2TzeQ2kjP3P/N/nZhcOootqDCog+UD4bKodxguins/Jf+sIjbVW00rhRLOmp4lRsDDb60Zod+I6/sGUcSal59d494U1vkbT5sMpSLp/0HTU9Zcl288I9vYJfh/HgBHPkRcaxaI/XiIa+npe7JKLgsQj+FdyaGWh3Tf78TWUjC6iwdVidlgFtY/XVrZ26YCWhQjED83SQxMumEzeNg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by SJ0PR11MB5102.namprd11.prod.outlook.com (2603:10b6:a03:2ac::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27; Fri, 11 Nov 2022 04:22:49 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::8e5e:71da:1e29:bc15]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::8e5e:71da:1e29:bc15%5]) with mapi id 15.20.5813.013; Fri, 11 Nov 2022 04:22:49 +0000 From: Bin Meng To: qemu-devel@nongnu.org Cc: Christian Schoenebeck , Greg Kurz , Keno Fischer , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v2 01/19] qemu/xattr.h: Exclude for Windows Date: Fri, 11 Nov 2022 12:22:07 +0800 Message-Id: <20221111042225.1115931-2-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221111042225.1115931-1-bin.meng@windriver.com> References: <20221111042225.1115931-1-bin.meng@windriver.com> X-ClientProxiedBy: SL2P216CA0138.KORP216.PROD.OUTLOOK.COM (2603:1096:101:1::17) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|SJ0PR11MB5102:EE_ X-MS-Office365-Filtering-Correlation-Id: 89c12892-0948-4a36-fd51-08dac39c6405 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: c4KZM8CdJVsskPYh/oVm84k8Eug5M9yPn7Tbgnxzedd1QbBFEEM2m51tx2Zmkkf8D2hrlcM58htp7ddPD4Cv6X4Da4U5SyTFKnxzlb8NvrZokF/qY5hrW5LdQ6ysPy137knGvvYLvwu8j3l92kg5sUixT0fm/CoBUssy+DpGgCyFR/nYEmvHh1RLdVLwIJH4eO3chjviJ//wGD/gGOueHFJ5JqXIa+dUl28Re4bInnzILO2h3D7b250Vecr0haSjJdgygv5lB5yq4vOUvTJOexLEL6ueyUwpOKHrEW/JAHyfSK6yn+tqYVDcOlNuxvggSSxvhZZAlehhN+dQRI2qb3CkjTuLlZ+yJNo0NkoraW5ArkiyeriIU355JLb3hSOFGq5mvEhh43NgxI4FWr1lpq51Oz9x/gNbDY1UfzdlrOq2y03xDMWDXjnaVITZ4C/e3u3KswJgFw7Fn6ZTJEbOwiGfMIxgzGSrXRnYG6BqPM0CBtJgDXuIM+MVw0zWOnMLbaR1crSf2W6NY2EyKYsgadRHzUycQnIcoGVviu4Akn25Shr8GT7UZRZ8P1fphvO3hNw5IRvRRmkgNIOVUNRM9qGRkCHlcge9kg96hb6+2bCcDO4tuh6ns8P56T5y1YrFybywlCNhIEdpZgJtZilElwOlsxJ4mViYGPn6Bqbw4jMWgGvQAS06/Vh8brTop0D3LBDh8ATmnDruVg+2SRff6iNFQO+cAuJXBVML4dOGQO1fIiqDddRUOlq+E3enXYbX+gACv5T2VO2ySLfY9SWOQw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5358.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(396003)(346002)(376002)(39850400004)(366004)(136003)(451199015)(66556008)(316002)(86362001)(8676002)(66476007)(66946007)(4326008)(38350700002)(38100700002)(36756003)(44832011)(83380400001)(52116002)(6512007)(2616005)(1076003)(26005)(6506007)(478600001)(6666004)(186003)(6486002)(4744005)(8936002)(41300700001)(6916009)(2906002)(54906003)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SHS+5MbVpgOQyDmajYNoAkzb2YhL4zZHUvhIl6NZbvhjR/pGpzzJgSgBKIqazN8e10fScnN97yJDP6UdA/cUUb6a9jIl/z2lglWfOlaKpSXyD3Gxr4uxJbY9b5drlUVsHE8z02RILLhoBPnxGuDkrMCyNhvB0CBEKrNyE8VNCcRPvo/s1lbVcab0Q0wvaMko2zKvJdllyvr0+JJIJ42XpfjmqenE147bzaUVMBo0twolSrJJLywWZr/fSOnfH/HWB+12TbD0waN6Gy/Hhn8gECtaHErgXvtUruSjmxntrItNytsxnkhjI5ntLi3t2jCc99jXOUYFTj8TKp8wLxwLzeV0DJE+KliFN2V829rgilTo+OOhhnQgkNdfkHvOFcBxrCmiWoVzVK7sAzHXMgSkKhOM5LhgBMmll8JB0jyemF4QUXW6ggN/A4d9sL/K65n4ZOOteLusKuhiHNAzQFpBNMYwngCymRdr00e1yCIABUhupDGEkRuPAhcBYneDr4Y3uxbx2FYk2Ev2sCYK4w45mOi9XswYFpcWWKPjdUjBj7MBgAK2GI19NTVg8/NxQ8xD7nOzgr3u2tRc4nq5NuiA1nF8JxnP4cvthaZFcz1w4ED2KsWipES9tuNJ9sDVBecnRrgmq5RAnr66XEM/pOz1Qcv8s7lAZzfeNDuf2f3WjyWUDOREI+5BeujC+uuhlZhbjdw1q/kyuIayLictVjnfvwmLfsFBo0NMYXVGoMEl9JMfZlM9A3IQuqvZ6khQnxWCtlE/2JrxShIlSBWPDe4PBDfEfKe7NG2tDXDy3dF6dgf4neKtP8r/UYYQyGu2dSn5KVJeyLAVuNtlnkVuhI3b4J0Bt3vhe/7KaVAALTXeTx83SNRBPL9RXeEo2fLHIpv/qfZqsdpoTJcigjJ8D40FL1s6BokQW/v7IOMm0A48NW0qCZ1MznIV5nQ7L+yIfNGih58Cy6k+5YTtXVPVMSRJpZL3UXLaqwpJ8/4zYsGykXd06iyWLOWPxdyxMKm9nXCr5NE2NJrNnWC2DQr4ChHC2KHPdbNZ0lH+LVOFRsLXTFH83BinVGFV8JJMnWgGSPJV9NT7DDCaheBxqdRLVb1/IESi7ZWdsYdDDKDz3hqPWYBd2WkuTpL73k8hm3ElwZvfe/68yrFshFoQiM4zu1BNJY8HLl+62m3YkGIjnf2l8CElOYG1J3+30UBEA3RFnrLX9qsYJ08NQ7A1oRXD6vejZhiXN3Fy9Q6aMQEN63/oglH3CwCI04r+l2M6RfceZCNdwWoa+ILWAeFV9oe0zXrQYR2w6VlWfaqyXw7/NAvOP4hdb9r0SudKYHG5+O7UeJaTF9ZeBloo+CwA/fd0LLBmOVhfZtTmy+EZL68X3KUxIwLlB4mv8XkJ60qMkci99exD2uUVDoK0NwOxPji62/fvu/Bt2fW3GPKosDlln9zWJtYC2xE2ngcUYJMNV/l3KMDD+kOi2zLTZSdVRob4NhIwU3sAtbGqvb81W5g3fetwLtUuQlfQTKy93utyWCEfn5QV4y8Akl8NQm8ULHxymTGdbUJ2a+P0U/cDTtLcNrwdLnAov+LZbbi28q40H9ZkDWkNJ0y9/OsIrXt11fQKqoLe5A== X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 89c12892-0948-4a36-fd51-08dac39c6405 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Nov 2022 04:22:48.9600 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: dI7xpfSlQBoH+dBfjRNvVPYh/IRYCDL1qDgPVoz0oczjDl9ccm7/LyN0gg4JE+RQOI+koByU8gxW5SXTa8AiPw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB5102 X-Proofpoint-GUID: ggP3nISzijyCas2SHjfWXlGPD5vVUcJ1 X-Proofpoint-ORIG-GUID: ggP3nISzijyCas2SHjfWXlGPD5vVUcJ1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-11_01,2022-11-09_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1011 suspectscore=0 lowpriorityscore=0 mlxscore=0 malwarescore=0 adultscore=0 bulkscore=0 phishscore=0 impostorscore=0 priorityscore=1501 mlxlogscore=549 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211110027 Received-SPF: pass client-ip=205.220.178.238; envelope-from=prvs=83144312e2=bin.meng@windriver.com; helo=mx0b-0064b401.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Windows does not have . Signed-off-by: Bin Meng --- (no changes since v1) include/qemu/xattr.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/qemu/xattr.h b/include/qemu/xattr.h index f1d0f7be74..b08a934acc 100644 --- a/include/qemu/xattr.h +++ b/include/qemu/xattr.h @@ -25,7 +25,9 @@ # if !defined(ENOATTR) # define ENOATTR ENODATA # endif -# include +# ifndef CONFIG_WIN32 +# include +# endif #endif #endif From patchwork Fri Nov 11 04:22:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13039626 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 4426FC4332F for ; Fri, 11 Nov 2022 04:24:05 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otLZY-0000VC-B5; Thu, 10 Nov 2022 23:23:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otLZX-0000Ud-1e for qemu-devel@nongnu.org; Thu, 10 Nov 2022 23:23:19 -0500 Received: from mx0b-0064b401.pphosted.com ([205.220.178.238]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otLZV-0001ZH-Gj for qemu-devel@nongnu.org; Thu, 10 Nov 2022 23:23:18 -0500 Received: from pps.filterd (m0250811.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AB4N0iK024928; Fri, 11 Nov 2022 04:23:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=/uG133JgMTeEcLUb0aMTqUIK7dCdL9iQpNTDfZLiPAo=; b=fu0+dycVvny0iADlypkLwnkTrzgiz7vR4US/T23oaacpa9tFBeAukc7TWVBK8HNonIY/ sjvUcuW/jeCDdB5YihQ8/aehwKHFM4sC+GdY547y8Zv0W1/ETROZ+RpTQLSU7I4ZP9Aa LaADBlrrNOR/XqP9oJKEr6JCFPnBsSb56VIVxoy55z5yBaSy4Hm5xJIoG5rG5kmsv/zl 9msxYxU3IAyJR6ArnFwF2rjszM8vvEvSfN5WgZmiWx1CPUJRbMFlhQ8qTSS75dKtuLoR 5Maej/v2OzCzxUDCXhvZ3PoSNBrN1EaoGtYB+GPEWSAJRN+z7lTsbY8U94Q/83039cm+ TQ== Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2103.outbound.protection.outlook.com [104.47.70.103]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3knd21ndvc-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 11 Nov 2022 04:23:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FuB/kqteNb1ih+5wrBi9VDFlDK0HQk3nerpR5fs+jKa9S2m5vNlXPU4XNTYnmGvQLhO67hiAGJTozJRcZAElipnk6h9iDE2EvO72YkSinuIoXH9tRm4KBn4r2nh+xFm44fQEpoOiWmjoVnYDm/KEgDaf7LeXh7694t6tSzBTyUbY2ezveO8A4tfc7DeWmhSJNkj+Nb9Hr7nglxozc32kYrDRU/r0f3JgawMPx0RU3NJPhLNLhpgVsriSxDDiFFCfNov+c3OAeteuF6QsCkv3JxVxzzw6ydidfZyZVI6xhCtb3eClvfa6xb4s1v5NfIaT6RecqED8FYzVBillD2VDTw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/uG133JgMTeEcLUb0aMTqUIK7dCdL9iQpNTDfZLiPAo=; b=IZtdnmiertHxVHqt2oLdgmgfwvZ19icmz+3z6MIGca9UdoVAkJ81VUuBiAMPNan6ARfTlOSDyqQp1pZpIzAfgNlGffP9ccfI452y/ePBMedy4OAQQjLOXXvIOcp7YiPakF9dRHDbvPsjtWT+8PYcZAA1zDdRUDKa29YeGDmWZjC1Aa67nZfCQA8+rm5b303Mxx6nbfvLV/1/Cgjymd0KclXe1z8fpLL9ZznAHg9bswPpBMVPEwCxiyWCl4xFtoEO/MXVDUfR5koz/UjAN5PL1OJkNhJqyGxSinBvQRJpsckoDqamp2KQ9Z8QwUSD4G5WW1VPcIIuuK7IGedLUsBG3Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by SJ0PR11MB5102.namprd11.prod.outlook.com (2603:10b6:a03:2ac::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27; Fri, 11 Nov 2022 04:22:50 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::8e5e:71da:1e29:bc15]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::8e5e:71da:1e29:bc15%5]) with mapi id 15.20.5813.013; Fri, 11 Nov 2022 04:22:50 +0000 From: Bin Meng To: qemu-devel@nongnu.org Cc: Christian Schoenebeck , Greg Kurz Subject: [PATCH v2 02/19] hw/9pfs: Drop unnecessary *xattr wrapper API declarations Date: Fri, 11 Nov 2022 12:22:08 +0800 Message-Id: <20221111042225.1115931-3-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221111042225.1115931-1-bin.meng@windriver.com> References: <20221111042225.1115931-1-bin.meng@windriver.com> X-ClientProxiedBy: SL2P216CA0138.KORP216.PROD.OUTLOOK.COM (2603:1096:101:1::17) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|SJ0PR11MB5102:EE_ X-MS-Office365-Filtering-Correlation-Id: dbb24cf6-d6d5-4685-daa8-08dac39c6521 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NjjrpruNY4ysBjlrQXzLp86AZaaSWCSOM9ph/Yz5A4T7SGmTVWfd7UFFsLz8hYXx4AZCrpOcKfM/AnYMIp3CLXj3KgQxDE3ocHedoo+AusodAiXPGZWNM92Dvx8jmhhdYYOLGvNvIu6MiExNYUQ1DB19OI4E4NG6b5OT2HxGQzDORfMNQK8GMlCcjwjvZ9RSqsHVwIqyoxq8ph8qjSJRTn3uRWOfbV2z08fKI1m+w5UFMj+ve8a6lO3SLgjmxLgMP56aExSMX3/eq7CMrbAD9kE+YqjhOHKIS0zwukGpWOirwYRKjVN9KNAGo63Nd/vAlwHIaiGxT4tctbwfu/1ZfdTyN9ZfXbjpQC+ZseOHa7u0OPhL1N5fdZGi6xtlGYXiC+QVZcsoESlI4/F9p4xJeSXvdtaaxujj9f/iZmR9h2BxmEJDzVoLIlPhnJNhnrwGn1o88ahJqZvJYt5VZTRCwu7Gok941R0w5Ov86pca1coSZ1nZ5BEqOsaG5X4+5f4L4Zyzg4nta7jy1NGt8lowT1hh45p7XCtcIDjTzzLwFeNvO32uMhwB4KZE+0+4Lw8rGzYcKTsXFlPv5jtUrS2WYT4ugWG+7JTPhOGfAE4qUBorLH7jgjd+kghzwXVgipsGSyh+oWr8UgU2dasGdpqCrAJBRTeUrafoWcaKCDf7YpEXzobcrCI43KeNWofzVxTGu5mlKBHGesGRJSUZMOZ++lLbMRtL/lzAs/MIkLaRYrOM7AyoA+P/DDy56T9rOclq X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5358.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(396003)(346002)(376002)(39850400004)(366004)(136003)(451199015)(66556008)(316002)(86362001)(8676002)(66476007)(66946007)(4326008)(38350700002)(38100700002)(36756003)(44832011)(83380400001)(52116002)(6512007)(2616005)(1076003)(26005)(6506007)(478600001)(6666004)(186003)(6486002)(8936002)(41300700001)(6916009)(2906002)(54906003)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 19LgT4ywt8rMhkiZonbHIMsqpLODriz/Ze6hxRzCwv1y5M1QT3HuCAUsVN6S/o59i6SVjl1wK52th2t2jqY5En4p7Lz4AwHje+hPLKM6fYFkbG792TnysxuuZS+SuytOKA/1xzB+K33doXz0ugdfAfTfqxNNbd6DLchmXfP16B6C7BTRX+/4Q3wluWwU4jUhXfzjfbXnahSDRtD24BpuNqR6E82fK9Apa6QQ2kfFZmHq9Btxbi5DqVbkIWYHQZQsaNCxvB46Mpfx4cWjnt9RPZWYR8GVrgxpRI2+++McgXPjCL6pn+8rkdaOxKCeL5nyfWVCrFz/mlhqjy8xlaHRVLxMrCvZ8bdfkvxr2xAS2Bj3v+aV3l3u6ebsWKa/4bqut1A+t7VmkshtsMLfFVf3Wzmim91VCXINkIoPREDqkT8IuuvzP+ScjiEse/lSTpJJZj1a9vl+1akZ//9dS1n4QLi4H0IydAlzmh8H0HjLe84GOLoCium/J9tGuBZnOcrEO+F7/w5edb7nvyJ4GfrbYlaPqofHAGexpWh0F5uOkxej4q2tE1NAFCHHYoOwnILoDwOdoKFu+XuG2t5GoBZtoIG0cCZ2rqq8sckDZxbMwBkf0lBRFFeE6HaQcEh3i8zFBG2WBiZxEa+8Zq9GCCHB8/j2WODvzgCyAl/DPn9BhTGCLhjL8X1RsXhctEcILFdl+b6XAzr1nQD379pySv0C4IuaJ5SM+jfgNfauuB2FKvK7JJVEwZ/X7WA2Zk2rvpoQjkR6Z4G9LJxmx9BYtvZSFvATow6LLMMO7mOKNF8Qsot2I9oe7f9QGE87OvQcHUWm01tDTvPvDY1I3BaLmT+J9AeiDbLlrQinKcTFlf1kg9z58QMg1qAUrvltW76insRTc27rbTWIUC3NvF0yS6NY5m3wed1OQYtCQVPM73zVNgponJ1DI5E1jAfBsYxGRaY9JKbE/6GMMiHOs3kyrdT5jk2k2N85zOTEJTl5I8gGE9RLQsY9ZdrCJgVmHtC3ppds6bYTo3BWY9eGplXCAAZQLcnXvDJLxxoDaFgqvm+4kMqCC05UZXKy8IorhGxduWgmwtcmK+iUuupe+hWXRs0qmrf1uEh1l/5CRotYTbqX7Pl+5TVKnR8pu7w5WX5/ihzWG8/RpbtsRKe7T0FYC8oUBu00xjOqpPqcEr2q0X8qyoHf/k2g2BZSb+Sle2tPPi/AkQ1CtETBgsD+xqhBaqVTOrOkzoUInBwg7kVFE0KhUPPeHeFVsOSM2MUmzhLx/79zemQRJTVrqSJ7Ba88evH2M+TSJeTLYt3bOKeRRVok6GfaxC6jy7VugrX3iZGT20f405GGopyxcKVV3cHicaMWPgzbUVFEuR/NOX1Y9A8qvfzK0r27E82gobKlspOA+NiQ5JlxgNpmArlgZGe76XDCHHaERNCrTMi5t20Rh/kQbeNn2c/ncjAgAW1RM60X9wF7SipH/sn9aZKXq5ZZmp9YCm0w8CnVnp6+9tPe67FaC+3FNEQL/bn3BHb8U6OdaR5u9ZV/cLQjmVsmgmkQbOcAwixZTJTic/9wkddD1QwnYvUHt9ZqZdZeMb9uonO3J4su X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: dbb24cf6-d6d5-4685-daa8-08dac39c6521 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Nov 2022 04:22:50.8033 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: avef87tCw3zD5alIVoKYnSbWwyNKOyzPLUOQpfAhHgn4C2pMTP5NJ/TK6xbscFIyPdHdghzaVpnggk+WjDifPQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB5102 X-Proofpoint-GUID: zVqecsJl7wN0ilygiCparkhzCC9JS2u6 X-Proofpoint-ORIG-GUID: zVqecsJl7wN0ilygiCparkhzCC9JS2u6 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-11_01,2022-11-09_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 suspectscore=0 lowpriorityscore=0 mlxscore=0 malwarescore=0 adultscore=0 bulkscore=0 phishscore=0 impostorscore=0 priorityscore=1501 mlxlogscore=707 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211110027 Received-SPF: pass client-ip=205.220.178.238; envelope-from=prvs=83144312e2=bin.meng@windriver.com; helo=mx0b-0064b401.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org These are not used anywhere in the source tree. Drop them. Signed-off-by: Bin Meng Reviewed-by: Greg Kurz --- (no changes since v1) hw/9pfs/9p-util.h | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index c3526144c9..ccfc8b1cb3 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -90,19 +90,8 @@ static inline int errno_to_dotl(int err) { #ifdef CONFIG_DARWIN #define qemu_fgetxattr(...) fgetxattr(__VA_ARGS__, 0, 0) -#define qemu_lgetxattr(...) getxattr(__VA_ARGS__, 0, XATTR_NOFOLLOW) -#define qemu_llistxattr(...) listxattr(__VA_ARGS__, XATTR_NOFOLLOW) -#define qemu_lremovexattr(...) removexattr(__VA_ARGS__, XATTR_NOFOLLOW) -static inline int qemu_lsetxattr(const char *path, const char *name, - const void *value, size_t size, int flags) { - return setxattr(path, name, value, size, 0, flags | XATTR_NOFOLLOW); -} #else #define qemu_fgetxattr fgetxattr -#define qemu_lgetxattr lgetxattr -#define qemu_llistxattr llistxattr -#define qemu_lremovexattr lremovexattr -#define qemu_lsetxattr lsetxattr #endif static inline void close_preserve_errno(int fd) From patchwork Fri Nov 11 04:22:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13039630 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id E77E3C4332F for ; Fri, 11 Nov 2022 04:24:35 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otLZX-0000Uo-EI; Thu, 10 Nov 2022 23:23:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otLZV-0000UV-P1 for qemu-devel@nongnu.org; Thu, 10 Nov 2022 23:23:17 -0500 Received: from mx0b-0064b401.pphosted.com ([205.220.178.238]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otLZT-0001Yz-Uf for qemu-devel@nongnu.org; Thu, 10 Nov 2022 23:23:17 -0500 Received: from pps.filterd (m0250811.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AB4N0iL024928; Fri, 11 Nov 2022 04:23:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=p4PqmM8VRzaiQongGzltUo2mhDuqdEHEEZ/RVds/fAE=; b=LW/rfcNqI5apCbFV23d3PzaQCoDxNr1L362HvVPVvDExe8xFleodKBCSYw2gsQmXTDGe YEcnoPZVttcIjtpvwqTC5RDJoLnp53/GAYsLEn8clY9flLwsIP+3aNnGBMuQZfakbWqL B07NcZzUagY0VUXo+lQMDeh0ikUA+zbSb+ca63nAj3vcWkQMdTiKN7wC1nwuAeYX7xcH yMSps40R4Nssr1f83klo6UNvkfXIIZCAzHjwWhwuOv1voa3qqlb7rHxUXITY4dNgVVFK EsdlABKANhSOiPL/W7lujK7xjSHgcRV/z4wR0ODKH65HFwwGlbVGOxXDST3HOidsfIME jw== Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2103.outbound.protection.outlook.com [104.47.70.103]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3knd21ndvc-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 11 Nov 2022 04:23:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Jal5Om/27kLfIa3MvDiQ6QeGymaM/2ZtT7se2AtSqts925kACgB7C3dRGFlr+krhXi/7vqqWDix/WyQ8DJoRAkaAZPZgc+/SHGpYjkFS3g54MZXrjvZ6boSYPKvCQVpJR71rgqCvV72S5lhZ8+WMfR60zxpvVjsBz5K/pe1tZdBvMN63VERjRcmYVw93kTBRSo+GHFbMV81bJ5KIHR1ZOjnhfGCproSIXRIC/xIJlIjzjp4bC5YCLDig88ti/zjIgPWLUo9T33V0zm56kRRS3kZnasxUJDrF/7TCcATLfxVdkKnWTnkXUZPz9CKeF/dKhjviZmg14Zm99phvf+lQtw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=p4PqmM8VRzaiQongGzltUo2mhDuqdEHEEZ/RVds/fAE=; b=BkWqKzM/lPZFKeIQcFm7GyYK0olCS8tcM9XN9n0WoLU8itZ+Q7iC9ct1TGVCFPpWG2FvlS/fv/VtGXlfq5KKSavHKIt/9pt17nA28fwdt52bRVwdgg9LH93HChnyl/tBvcJp01N9ZBvpuIVcVkAyq5c8bDaG2fhUHaW9jddX1ulIkqNqPIGHKgv8ceyajZ7+LqHSyxeA5B4/rsb/ZMGYW0xPRQ6lKoN6iWXXcK1dL01I6J8K11RtKJiB7EoBnwPGsf4+dhJr3Dwtlxg3jongFm4Pvbgnril7siRVQVf/n/HyNqk/o8W3gczP6+e7wZwy7dLpXJQTnu0pQXmOsExbqA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by SJ0PR11MB5102.namprd11.prod.outlook.com (2603:10b6:a03:2ac::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27; Fri, 11 Nov 2022 04:22:52 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::8e5e:71da:1e29:bc15]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::8e5e:71da:1e29:bc15%5]) with mapi id 15.20.5813.013; Fri, 11 Nov 2022 04:22:52 +0000 From: Bin Meng To: qemu-devel@nongnu.org Cc: Christian Schoenebeck , Greg Kurz Subject: [PATCH v2 03/19] hw/9pfs: Replace the direct call to xxxat() APIs with a wrapper Date: Fri, 11 Nov 2022 12:22:09 +0800 Message-Id: <20221111042225.1115931-4-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221111042225.1115931-1-bin.meng@windriver.com> References: <20221111042225.1115931-1-bin.meng@windriver.com> X-ClientProxiedBy: SL2P216CA0138.KORP216.PROD.OUTLOOK.COM (2603:1096:101:1::17) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|SJ0PR11MB5102:EE_ X-MS-Office365-Filtering-Correlation-Id: 7505de7b-ae2e-4555-30ec-08dac39c663b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Tx2oCDlRlHEd/G8yP/6pWHFAw0P3P+sQNrXZoaQARQkQqaVT0BeXh01wgBMDtU8rwOOlvSmOs/NkA0DFpRU/SM3qDJEfrKIA0j7MFgpNueFUvoeHliN2kJrl8GLVY8nB+mbD0gIaMJ/1Gl8tVXpyZwOw8kXdAfMBbkMfhrtsJdQSqVfSXI6n+kfMCmZe9DGs3MutEfzuuqTR4oSMNBzhHKnyj0XrQUCuTmtLqz0dY/9KIz6vAj4wR/nH404L7XbnuqaT3qlTXnQycPSm3vg8crYZBNNZiUP7eGPEAsYsNZFmpUVjZPMTi0AhMIajzoaPbV2JeVcOcF/OFtHm8/ytt7mPi9BE6noDmH2HVMWxGhDIIcfoo5qAnNRINcq/cCVV3mTCSyFmrh1Fs7XCZRe+41PFAKgCz+GSr9hE6gSTrgwgO4E8D4qQpAXJ+YeQPqhBOVlxOrMtD/qCM12uCDcl3HJevdKdIBTKm0HiNXljIuY1YdriCPHpFPx8wHiVtmMjHvnOyHkaFTKf/37W2LOYHHHxQH9AM31prW/V544cQVhXuj5lZ97rKjoro4yKhBUeVKamrBdg2uuO3Ucm0sTG+2f6AS4v6ljIKw6CF9thd8FhPoM6eWzMNFkcp/XY0TiNy/Zp9RsZfSYhqOgnolriA60KUBnMESOX2d0Y07iEcSZMko2qVruyUg6HycMf3BFoibg9VumaptOrDWOVFhtWkwPO2aTY0MTRPi+mq2IOEzPvnsPUHl7FkYQJC0Y+tfnjV5VbD5b47cle4ZpLJ2e6Bg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5358.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(396003)(346002)(376002)(39850400004)(366004)(136003)(451199015)(66556008)(316002)(86362001)(8676002)(66476007)(66946007)(4326008)(38350700002)(38100700002)(36756003)(44832011)(83380400001)(52116002)(6512007)(2616005)(1076003)(26005)(6506007)(478600001)(6666004)(186003)(6486002)(8936002)(41300700001)(6916009)(2906002)(54906003)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: HiJRUJVyacNdD77PPrPC4Qew0orkTeV5K9s6jVRRJFKkVLlPJ2Ryaqj32qtTua5D1amsf1qzGU4jyHS1fQHdLlmKWlslyd3j3m/crMXA9iY2aUHqhWmBqDBMA8MbodVCiq9DvcmNB+uU86f/JNYEMOImPve0aU/8wqWp4zNUyEbEzhOD8/L48JOc7X/9B7/lMEQb1uW8R+KAIiUR5bSPznzYvH18WQS3cTSu7DkjVJnAWkGvj2PBEDnmoqBm17cbx6rbRztcv0W0bx+wfWU22nyDp0JnWWsnDw+kH+QRr0+WNhyj8/4vSvQ0jZOmiNba/QHeNjfakfixCOs2yle3WjWEBAX8Cs2mIPfrXgXThUY935bDJ1wQn8g6f23usSjWJkBq1mv+Rpn+XczRLdxaVxMeI8VkbtJoyXGYLpMfI0ju8djAcLrNt4WDef42m2i5xIIl41FVoHrTY6BHBVAkBKoAIMDvAZMJYEpOZK2Py4uoSKocyzB1MNOpLpHIWC4Yvyfi4ihI1E1u4ElhWF510sGMQkJtH2nCub349b7oFQlnGlfnjbxnp65waFBK9bfgDGJ++KgAjKQJN5LEosS+AWmBQCB0kmNQ1AbfDXpnuQsG6JYx9QBDCuTFxSylPAw/zLWBSIzV2AefLdPqYcFBC9qi4wWjQbE29ROPz5p3so2MPj2HGCYWcLAuyhX8ZHvRpmSy15ZEjULmcHDni1KsEjoLCS3sC4/m12kTUqMBiz5Y2vJOnmOCN+mXwg8uffbh5W70LwIT7cAwO2VKIqHe9gDiUaJIyHPSY2ZPTjXbqTJ4VgkvSOchXu6oGIhNkUh0cTHWnxORjug8E4ygz8nqITlZrwNc4FxGqBwrtc/9prBrrAe3JKu0aaDwrVhal48V0CZVu6Cz0ELk2NswlTXQIeahs3mV6kv/okIzL6mF/d+Ay4JQQFaXlxBCR6BhAW74gROZZ4nPjWWxp0rhYQZDt0TmiPwNiuh2E0asSXLDtqK4FNbJm8ibYX0HBe89yUXvClvoqOj040PsMmUJVhs6wk3+VH2eCuUjLLWeLcjgvH7CQgZ2jBZpl4WC66DVZC2qwyS2G04Ghcc1cUR+VAjA1RGkIM873/Ta1Eotw3OsrCO8Kdh0IFAC+XeE4QCGfgUJZoZgEO0s/Sly0dbKpOkwVEtc9plJZ+Os20mfbLaO5dePgSa4kpYnHEBmSrDvjqM/Uaq5T9tSxGFSoRvZsU0wR6eZ8CsustthU2qrz9SrU5ZTlPpJfvuWxZSGau2AvkofeqAGGX9/DTINZkXPZ0XN7XzOhQRRV1MYRTwr8u0Hcar4j10Hs3Oqn4HU7jzncntQgHIrCMNNOG78cXnNOl2zR2x07OLYfuuRLFmhEfSIx4dKpuTj1RNh6KpTZkJHVQRRwPW8ILfOkpLoWyWwEzFgn/qjW7CK9V1pwq6u1+alYKEZzH74T+BU57WiFmceEmchcizVMsy9Q3zPR2pgopLoGOLuGkGdpHVDfMkdG1AMB7z8KbsTWUfQEjav9Q/UJUS7StgqsWJGYMeplOAkoAgDppTq6FMWepQ+oCaBv7SJeGCWwI+j+g26bQ6kJ/aKKzwl X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7505de7b-ae2e-4555-30ec-08dac39c663b X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Nov 2022 04:22:52.5222 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: TrDyz4yNX5gdGA4a5sBUI4r/X5tZLBJM78j4pMxsZpNINbvqbWoBNg4Qde+i//G13Kxkj4KaKQ2sSFuoFKSO6Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB5102 X-Proofpoint-GUID: JFuDdXqJE621Gq4L7R4YB5YxNSb7LIH3 X-Proofpoint-ORIG-GUID: JFuDdXqJE621Gq4L7R4YB5YxNSb7LIH3 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-11_01,2022-11-09_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 suspectscore=0 lowpriorityscore=0 mlxscore=0 malwarescore=0 adultscore=0 bulkscore=0 phishscore=0 impostorscore=0 priorityscore=1501 mlxlogscore=595 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211110027 Received-SPF: pass client-ip=205.220.178.238; envelope-from=prvs=83144312e2=bin.meng@windriver.com; helo=mx0b-0064b401.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org xxxat() APIs are only available on POSIX platforms. For future extension to Windows, let's replace the direct call to xxxat() APIs with a wrapper. Signed-off-by: Bin Meng --- (no changes since v1) hw/9pfs/9p-util.h | 15 +++++++++++---- hw/9pfs/9p-local.c | 32 ++++++++++++++++---------------- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index ccfc8b1cb3..c314cf381d 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -94,6 +94,13 @@ static inline int errno_to_dotl(int err) { #define qemu_fgetxattr fgetxattr #endif +#define qemu_openat openat +#define qemu_fstatat fstatat +#define qemu_mkdirat mkdirat +#define qemu_renameat renameat +#define qemu_utimensat utimensat +#define qemu_unlinkat unlinkat + static inline void close_preserve_errno(int fd) { int serrno = errno; @@ -103,8 +110,8 @@ static inline void close_preserve_errno(int fd) static inline int openat_dir(int dirfd, const char *name) { - return openat(dirfd, name, - O_DIRECTORY | O_RDONLY | O_NOFOLLOW | O_PATH_9P_UTIL); + return qemu_openat(dirfd, name, + O_DIRECTORY | O_RDONLY | O_NOFOLLOW | O_PATH_9P_UTIL); } static inline int openat_file(int dirfd, const char *name, int flags, @@ -115,8 +122,8 @@ static inline int openat_file(int dirfd, const char *name, int flags, #ifndef CONFIG_DARWIN again: #endif - fd = openat(dirfd, name, flags | O_NOFOLLOW | O_NOCTTY | O_NONBLOCK, - mode); + fd = qemu_openat(dirfd, name, flags | O_NOFOLLOW | O_NOCTTY | O_NONBLOCK, + mode); if (fd == -1) { #ifndef CONFIG_DARWIN if (errno == EPERM && (flags & O_NOATIME)) { diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index d42ce6d8b8..d2246a3d7e 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -103,14 +103,14 @@ static void renameat_preserve_errno(int odirfd, const char *opath, int ndirfd, const char *npath) { int serrno = errno; - renameat(odirfd, opath, ndirfd, npath); + qemu_renameat(odirfd, opath, ndirfd, npath); errno = serrno; } static void unlinkat_preserve_errno(int dirfd, const char *path, int flags) { int serrno = errno; - unlinkat(dirfd, path, flags); + qemu_unlinkat(dirfd, path, flags); errno = serrno; } @@ -194,7 +194,7 @@ static int local_lstat(FsContext *fs_ctx, V9fsPath *fs_path, struct stat *stbuf) goto out; } - err = fstatat(dirfd, name, stbuf, AT_SYMLINK_NOFOLLOW); + err = qemu_fstatat(dirfd, name, stbuf, AT_SYMLINK_NOFOLLOW); if (err) { goto err_out; } @@ -253,7 +253,7 @@ static int local_set_mapped_file_attrat(int dirfd, const char *name, } } } else { - ret = mkdirat(dirfd, VIRTFS_META_DIR, 0700); + ret = qemu_mkdirat(dirfd, VIRTFS_META_DIR, 0700); if (ret < 0 && errno != EEXIST) { return -1; } @@ -349,7 +349,7 @@ static int fchmodat_nofollow(int dirfd, const char *name, mode_t mode) */ /* First, we clear non-racing symlinks out of the way. */ - if (fstatat(dirfd, name, &stbuf, AT_SYMLINK_NOFOLLOW)) { + if (qemu_fstatat(dirfd, name, &stbuf, AT_SYMLINK_NOFOLLOW)) { return -1; } if (S_ISLNK(stbuf.st_mode)) { @@ -734,7 +734,7 @@ static int local_mkdir(FsContext *fs_ctx, V9fsPath *dir_path, if (fs_ctx->export_flags & V9FS_SM_MAPPED || fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) { - err = mkdirat(dirfd, name, fs_ctx->dmode); + err = qemu_mkdirat(dirfd, name, fs_ctx->dmode); if (err == -1) { goto out; } @@ -750,7 +750,7 @@ static int local_mkdir(FsContext *fs_ctx, V9fsPath *dir_path, } } else if (fs_ctx->export_flags & V9FS_SM_PASSTHROUGH || fs_ctx->export_flags & V9FS_SM_NONE) { - err = mkdirat(dirfd, name, credp->fc_mode); + err = qemu_mkdirat(dirfd, name, credp->fc_mode); if (err == -1) { goto out; } @@ -990,7 +990,7 @@ static int local_link(FsContext *ctx, V9fsPath *oldpath, if (ctx->export_flags & V9FS_SM_MAPPED_FILE) { int omap_dirfd, nmap_dirfd; - ret = mkdirat(ndirfd, VIRTFS_META_DIR, 0700); + ret = qemu_mkdirat(ndirfd, VIRTFS_META_DIR, 0700); if (ret < 0 && errno != EEXIST) { goto err_undo_link; } @@ -1085,7 +1085,7 @@ static int local_utimensat(FsContext *s, V9fsPath *fs_path, goto out; } - ret = utimensat(dirfd, name, buf, AT_SYMLINK_NOFOLLOW); + ret = qemu_utimensat(dirfd, name, buf, AT_SYMLINK_NOFOLLOW); close_preserve_errno(dirfd); out: g_free(dirpath); @@ -1116,7 +1116,7 @@ static int local_unlinkat_common(FsContext *ctx, int dirfd, const char *name, if (fd == -1) { return -1; } - ret = unlinkat(fd, VIRTFS_META_DIR, AT_REMOVEDIR); + ret = qemu_unlinkat(fd, VIRTFS_META_DIR, AT_REMOVEDIR); close_preserve_errno(fd); if (ret < 0 && errno != ENOENT) { return -1; @@ -1124,7 +1124,7 @@ static int local_unlinkat_common(FsContext *ctx, int dirfd, const char *name, } map_dirfd = openat_dir(dirfd, VIRTFS_META_DIR); if (map_dirfd != -1) { - ret = unlinkat(map_dirfd, name, 0); + ret = qemu_unlinkat(map_dirfd, name, 0); close_preserve_errno(map_dirfd); if (ret < 0 && errno != ENOENT) { return -1; @@ -1134,7 +1134,7 @@ static int local_unlinkat_common(FsContext *ctx, int dirfd, const char *name, } } - return unlinkat(dirfd, name, flags); + return qemu_unlinkat(dirfd, name, flags); } static int local_remove(FsContext *ctx, const char *path) @@ -1151,7 +1151,7 @@ static int local_remove(FsContext *ctx, const char *path) goto out; } - if (fstatat(dirfd, name, &stbuf, AT_SYMLINK_NOFOLLOW) < 0) { + if (qemu_fstatat(dirfd, name, &stbuf, AT_SYMLINK_NOFOLLOW) < 0) { goto err_out; } @@ -1296,7 +1296,7 @@ static int local_renameat(FsContext *ctx, V9fsPath *olddir, return -1; } - ret = renameat(odirfd, old_name, ndirfd, new_name); + ret = qemu_renameat(odirfd, old_name, ndirfd, new_name); if (ret < 0) { goto out; } @@ -1304,7 +1304,7 @@ static int local_renameat(FsContext *ctx, V9fsPath *olddir, if (ctx->export_flags & V9FS_SM_MAPPED_FILE) { int omap_dirfd, nmap_dirfd; - ret = mkdirat(ndirfd, VIRTFS_META_DIR, 0700); + ret = qemu_mkdirat(ndirfd, VIRTFS_META_DIR, 0700); if (ret < 0 && errno != EEXIST) { goto err_undo_rename; } @@ -1321,7 +1321,7 @@ static int local_renameat(FsContext *ctx, V9fsPath *olddir, } /* rename the .virtfs_metadata files */ - ret = renameat(omap_dirfd, old_name, nmap_dirfd, new_name); + ret = qemu_renameat(omap_dirfd, old_name, nmap_dirfd, new_name); close_preserve_errno(nmap_dirfd); close_preserve_errno(omap_dirfd); if (ret < 0 && errno != ENOENT) { From patchwork Fri Nov 11 04:22:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13039634 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id A6621C4332F for ; Fri, 11 Nov 2022 04:24:54 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otLZP-0000Tr-Pd; Thu, 10 Nov 2022 23:23:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otLZO-0000TX-AH for qemu-devel@nongnu.org; Thu, 10 Nov 2022 23:23:10 -0500 Received: from mx0b-0064b401.pphosted.com ([205.220.178.238]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otLZL-0001Y6-OK for qemu-devel@nongnu.org; Thu, 10 Nov 2022 23:23:10 -0500 Received: from pps.filterd (m0250811.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AB4N0iM024928; Fri, 11 Nov 2022 04:23:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=UtEzJOqW8iIbBBj7/HaMvsgPYrEDv8luASoWw86jxRo=; b=kUMRfjAxf9k8T12NVGoK/tjYDpdItDCmho5n3SlFc+XzLPuGR8Ioa7pcOVbp2UOeznt/ FDjOZy6rNuCcCBuXStNSfZKwMiHN7nxU6JrASLcl79j4Jy3i9Em2gpJsairNlakh7sBK BQDBX2NZD5kFFBxmEuTk3aVCb1I8K7mFRuL4fIPa10VNjd+loevbt3wBZqtytZz9/vDz NabWtwX9ybIpMHgfNNGd3h7nymGdTG79ZhlLoVGAV2tqFQP2TDrA0+EcOzv/IZtfhRmz aITepp/GalSbeeLqRUsJagLHEf3Y+ZKGqa2Yb2kZdsP2ING0q7yWW47xg8oXFuFUJMvI Kg== Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2103.outbound.protection.outlook.com [104.47.70.103]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3knd21ndvc-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 11 Nov 2022 04:23:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PbAGdkZm9JWO9zJe05Iki2BouLxB3JmdqK883SjhDBgVHdjR5AGaFF3AqAy6ZZZChFdPhUwRorCVM6j/Jcr/CGS1acWlDh/hwq5TbPvKvLY17ry6uhknAnjcnM/anEaFbluq8XvYvuXAD4tW/1u9K124WHb5IHSfMnTr73FXLSJ9+tNwUiGi0cvbSWj2bfbJBhZ6N7oYRIf0Jh7c/K3+3/zLYGye4B8jjB3etSrhKF7to1cWTi8F/3H9fo2u7dlfgirWefcE10skY0fR0HnpVrfO0AWe73sZ4/G4Ss2oh9TD45nJQx3BFJbJL/Hyg1s+IIPNXAqh5dP4OqRGviekRA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=UtEzJOqW8iIbBBj7/HaMvsgPYrEDv8luASoWw86jxRo=; b=MKFs76CVyHmrPxGyIUuuHePXpC62eK/vU2ABgBUiL7AEnuXiF3v8hqYKg4Ri/SKOFnuVkOIKSi6SOV0O0DPzYt9uXU9Cf7nCAf5ZOtkj1jyi0bChrlHcXuE9kk5i7d9cEmhWESradGiHZnJxd8rKiuoVHrkP1u/FSyytW+5iKZHF2J3sewigDUDJTwJ9nYWh6MXi0W3blFR3wQ8OqUcRxCHCRULTZZuiEUagTP69o8qAWPDlCGt77W+uOSJ/cOdvU9lmnLOmP8GnuWk/HVsIQoRTc7XDXwXchu0D51SKuUNsQQqBU6h7Ely5HFK70kuDkPMlUbRw9bdO3jBfk5Xb1Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by SJ0PR11MB5102.namprd11.prod.outlook.com (2603:10b6:a03:2ac::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27; Fri, 11 Nov 2022 04:22:55 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::8e5e:71da:1e29:bc15]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::8e5e:71da:1e29:bc15%5]) with mapi id 15.20.5813.013; Fri, 11 Nov 2022 04:22:55 +0000 From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?M?= =?utf-8?q?arc-Andr=C3=A9_Lureau?= , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Richard Henderson Subject: [PATCH v2 04/19] osdep.h: Introduce a QEMU file descriptor type Date: Fri, 11 Nov 2022 12:22:10 +0800 Message-Id: <20221111042225.1115931-5-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221111042225.1115931-1-bin.meng@windriver.com> References: <20221111042225.1115931-1-bin.meng@windriver.com> X-ClientProxiedBy: SL2P216CA0138.KORP216.PROD.OUTLOOK.COM (2603:1096:101:1::17) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|SJ0PR11MB5102:EE_ X-MS-Office365-Filtering-Correlation-Id: 051449a4-04b1-4b2b-429c-08dac39c67af X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OQq27Wj01RYivX9GrDc1Y+REsaXGJVSxIeigNCBTaefWQPsDye1kYo2i1K3u8LXJdeDQS33Jo4omSNgu9phwvFUt8bCieGSbqUu3TUjPoq3v53QGs6p6dVwVCdRcEPDMYwrGV+zx67yzcTA0rH5GQpulP3hMuhOtrC+X5j75v5ETBsh3VsayjCMEyNCcozhR0Mz8uZFLQFQgUr1EtizyM61d5Mbrqzctiz37S79ZKITrPyQvn3pBhQBXYPDkr7mHwU837c5i2zHY0VFbteV7Pq0tgTd3GVZyI7lX5D4Vc7KRjAnSuTRHaVGTFRyTD3FFX7bAUVV242uQfoYR5eAsKK/Fi7aegOJ2dRPHRzIVVe3zB9d1o71MEIPs1R4ySaeRacrjImY1wBUwD4iN5/7s3XHrT/2/RqqHXhWqqzxNGY6LLiljPJXVXOyB12a6rL1aV4bU0p4mWkcjc4j9LaFq5ibNxIPhpB0+8Mv2tKd6B1WoN2RUU3A8bw0clU9TQm74Hw0ftb+zy96qeCJi9qB0Z85qsnIHKXAi4sSKZo0FczXcm48/cWem+tbMUVgqwabcKfX+wZro443hdL/WCvBkdZV8xrZt0v6tHYSvGM02flqM3MqlDzXuP6VvOg8hltRgTbX+3X9VroXjuluDZ0XEYHXhaBApgKjcokaoHYMov9Zf4xhyMGKyhGpyU1XHy0O/tVzL3//7gcWMtWEkOIWrq3YHMaRuFMv8i9ltzUWV4u1dzC/BsPShFzz+ttR5lqkIGA2QNiwba2rX4p3gnlUPcg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5358.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(396003)(346002)(376002)(39850400004)(366004)(136003)(451199015)(66556008)(316002)(86362001)(8676002)(66476007)(66946007)(4326008)(38350700002)(38100700002)(36756003)(44832011)(52116002)(6512007)(2616005)(1076003)(26005)(6506007)(478600001)(6666004)(186003)(6486002)(8936002)(41300700001)(6916009)(2906002)(54906003)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uoAQWzgap6fZZO4c3zqlCAyv99/01cvyuiJIUASIFAKJxVU4jODPkVZxENixoXJfvd/w0BO9XYXn6H3ELjsxmrijm8BDWNy2XfvBwNmUkRRji0KU/SYdhGqHEPW6/upu5AkVCwB77eCWLUuGOey2VKIEUfjg4s+hXYNcWvbp/IOfVo/dxcOehyJW0bd/IRpSmrhU/4urKGy6p67ynsxEQnom/BiTgNkAppI1/XkV0bFB8oDmqNG1WG4lDU0VJz5ysQHb1Z8mWhvBrtQv0zI0JRnL0+OghCkcOGaErEc1dxd/PcRS5p7NZy156f1z5VBj34e0a/Puv4z+WMvMf+XNiJezLv68rNogjuk5aLzC4wA3rvIxRq9QENCAVza+wWynJU0t3RhX6GXyiYK5e45tIsxcbNQ7mlsvBM7EXZuAaoqhktQojDLya/4GHFI8BPo2zAB39L4q8fMSPaNz8yDqWFbErRUnaMy43pUBaxN4IiS4Tq+2/pwsRl4PKqpW1jZ9T/Nv1Y6YcMfBzcaWue7ZNxRLrbQdqILjUh8XEOgpaGVUZKze83CY1CA12iBOjtnFpzLtgAIfvpn2yM66VsCmsI6jF/NocPun1e17tQvHfzuFqKMhB/+iDF6IGLSSNIhPDF8A8ynxO0jZoLFR0OiqGe5akA7bGgtYLK7F5DMPz55UXQzYvzTPhQaJgxpWw1kfSxg7nCNlUEkwGoMxQvA7SJfraTFNQX6Ti57+E9Rz4bPr45alFGhogNHPG6wfC+t04RNZbsScwkjA243B+nw0LOVl/YXiaMUt7QazhPq0VyCUftQ1/0jJ2QWsF34g17M1VTSGK7PZHDppGhrKw16zovhHVX9QnddyY25Th3aIe9sAe1zQ1QObdp+6h4derw+wuEpkRgzzHAiyZ+2T1GTcTIEMfzsuA7+EMV6Qs0JEKHjtu0dUPNDp038OYLrePJKBDGMv0195yPzMValVLdym9VEqT/Y2N7rg4uOL0zx2kVQnIG1mvVTtRy5wX7+fbQ21i4jKvLKIRiD1AKGIUdg5LGp3Cox0qrSfV/mEb8q2oNP2EChulA6LShdV2m5Gibr2KdC0lIlVOwrIn58jBXNXEBrahFyTYsdaG9YSXuY1FyiSw/i+b26gaKtdTf7bJ0upbkzW/wnVXz//XGOShIdbV++KeX7dKHOZDiGyWSzlgeGsB0inwGMDgHEmIyhabGFoMLss5k7BMDibAbnhXqtgUkzuiviWWap0tSVBwpA5SfacPYJ0xVc6d8i8esAjX71kseVfJYkB1RdLDXwA10Mb7j0x+nx7+3S9Fg3eCYM5Ofj4Jmh3ZE49ubxp5IrHGjLH48kpZWErtLv0vEiT0h9pm0Q28gJtZ6+yIdUx5UFP+SlJlwSaDpcxdVZZjhM/INvGXFbPeVg5Vmfux5OkvkGYLu2ubksUNRx2QEtyM76QcwoXsB9fKC1k2vcEIGVsIkOqQT3tK2NvP/rHOubMlAbU5uXQwuoJEfpUjvzCKlS9RieEdF7TQMgBHIEfhaM9/N77z8WKe+PmaFCMPcgBOj/YfMkU0yfLA8PlxsVw1hGnTF2JpgV+OSoJiFVfzxe3iKMP X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 051449a4-04b1-4b2b-429c-08dac39c67af X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Nov 2022 04:22:55.0867 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: UNftmdphQ/hBFHWkPa40Mdu5kJwzTGvdFE5WhXgXWujQY19MD8eTN9Qub/xSM9/GKWr+wdluDQqb6mLLfebqBg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB5102 X-Proofpoint-GUID: Yygb_MXUg9n_o-ntCPxkVErSDuFufo07 X-Proofpoint-ORIG-GUID: Yygb_MXUg9n_o-ntCPxkVErSDuFufo07 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-11_01,2022-11-09_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1011 suspectscore=0 lowpriorityscore=0 mlxscore=0 malwarescore=0 adultscore=0 bulkscore=0 phishscore=0 impostorscore=0 priorityscore=1501 mlxlogscore=562 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211110027 Received-SPF: pass client-ip=205.220.178.238; envelope-from=prvs=83144312e2=bin.meng@windriver.com; helo=mx0b-0064b401.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Introduce a new QemuFd_t type to represent a file descriptor for different platforms. On POSIX platforms, this is a file descriptor On Windows, this is a file handle. Signed-off-by: Bin Meng --- Changes in v2: - Change to introduce QemuFd_t in osdep.h include/qemu/osdep.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index b9c4307779..45fc8bb5d9 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -705,6 +705,32 @@ static inline int platform_does_not_support_system(const char *command) } #endif /* !HAVE_SYSTEM_FUNCTION */ +/* + * QEMU file descriptor type + * + * On POSIX platforms, this is a file descriptor (int). + * On Windows, this is a file handle (HANDLE). + */ +#ifndef _WIN32 +typedef int QemuFd_t; +#define QEMU_FD_INVALID -1 +#else +typedef HANDLE QemuFd_t; +#define QEMU_FD_INVALID INVALID_HANDLE_VALUE +#endif + +/** + * qemu_fd_invalid - determine if a given QEMU file descriptor is invalid + * + * @fd: the value of a QEMU file descriptor + * + * Returns true if a given QEMU file descriptor is invalid, otherwise false. + */ +static inline bool qemu_fd_invalid(QemuFd_t fd) +{ + return (fd == QEMU_FD_INVALID); +} + #ifdef __cplusplus } #endif From patchwork Fri Nov 11 04:22:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13039639 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id BB086C433FE for ; Fri, 11 Nov 2022 04:26:00 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otLZZ-0000Vb-3A; Thu, 10 Nov 2022 23:23:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otLZX-0000Um-AS for qemu-devel@nongnu.org; Thu, 10 Nov 2022 23:23:19 -0500 Received: from mx0b-0064b401.pphosted.com ([205.220.178.238]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otLZU-0001Z2-Ac for qemu-devel@nongnu.org; Thu, 10 Nov 2022 23:23:19 -0500 Received: from pps.filterd (m0250811.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AB4N0iN024928; Fri, 11 Nov 2022 04:23:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=eO+j4U8lYVJulhU9rfL8NCdALTNM9uSn/kJ7Mrgg3KQ=; b=flesH5sTX58rUuKsfNGljbVCDNsU+jGvC0tyh2DLO+r00OVUjVpyyNCY6Mp+jNdJ456n n9oC6ijTQu1OqGlEDCzhJKMf4aIhnMZykOjg3k+ZPkZ8Nzc+behRAzbelMrF7yltlfgD S/Lxs0tDB1410QruSJHha5EY83uMg+y8ITsLKyPPUrR/5UoH7VAffuctxJYxrudEAPHj ISy9j7LtyrPFMs45vdM6azRmVOr1h1JFbZAPfCdqLQ0b7RC+WwZ3sygEE37e7GZ/IjJ+ uE7bmWvLQkAscbCTVFY2Ucj6z7vMTRlGBcvczk9GQzSUnKll0Cv9ZO0mz5SWBxMkRFsV KA== Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2103.outbound.protection.outlook.com [104.47.70.103]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3knd21ndvc-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 11 Nov 2022 04:23:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EQlA7GoDLnBlCTac4aqc0JH6PsqmIos1JHnFFojiQ9dQnmtXPlSKxnYUzomp1F5G/sf+yh54dpSGiHDt8yTFSPuoNlXWIxz4tZ4rYEmHyITS5lBR9lNfd2fP6i5aaMXw451H2EPpl33X+DG0MqF88GMywa+QfqJfp3mt/D8J0fbyb1LSQUqaduXFWPvHb2dxosADxkFlfRIMuvarrowec7j5r6+UVC+0RE+7VtRs02Rqt1YHAPyNiV9pwETFP22a/o+9+0KlOvnOMjjWIHVP3kTLfS9NYGosU0P5j9iZA/NdZELcqBPnhTN4EDDFgqGhAnmrpuuUjpK38UuqDADCAA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=eO+j4U8lYVJulhU9rfL8NCdALTNM9uSn/kJ7Mrgg3KQ=; b=EP6g99lKbHAKORBtokD/leCXnaKMTxienybZHleUOovv5w80PFEtAepDUtQJziZLGg48PXaq1LGpPe1weFuEcZdu+SJCYJuxG/v8Eb818j9LdGMV2OvBC+5MX5cHkDJbNybpB2c8IYUuZc0g0Xv1C/AUe1Cjp7DEbS80f6k5vvIJsuTTlAL5uXfn+lCmIftq98xrFtPotARcYAbXDKFHL9eIRaHXV5PSATgRYnOGksuw5fZMA7qUg0c/Cgd/ih0xsXXDOL6Qtq2Q86MT6fxSzxAq3xJ5QWchmhqlPr6Bt5B72qOfqFwSBQeSuEE9hyjxHv6tnnTapPIbaH7amu+C3w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by SJ0PR11MB5102.namprd11.prod.outlook.com (2603:10b6:a03:2ac::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27; Fri, 11 Nov 2022 04:22:57 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::8e5e:71da:1e29:bc15]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::8e5e:71da:1e29:bc15%5]) with mapi id 15.20.5813.013; Fri, 11 Nov 2022 04:22:56 +0000 From: Bin Meng To: qemu-devel@nongnu.org Cc: Christian Schoenebeck , Greg Kurz Subject: [PATCH v2 05/19] hw/9pfs: Update 9pfs to use the new QemuFd_t type Date: Fri, 11 Nov 2022 12:22:11 +0800 Message-Id: <20221111042225.1115931-6-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221111042225.1115931-1-bin.meng@windriver.com> References: <20221111042225.1115931-1-bin.meng@windriver.com> X-ClientProxiedBy: SL2P216CA0138.KORP216.PROD.OUTLOOK.COM (2603:1096:101:1::17) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|SJ0PR11MB5102:EE_ X-MS-Office365-Filtering-Correlation-Id: 54f4ee7d-b7c5-43e3-effd-08dac39c68ca X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6wueHGXveE5YEJ9zq73UvU4lY8Lt2i/miYBMZTls4F96Hr9l8ANajSwqi6F3RsursILssVo/tQKaipdWzYXPZI3irjegTQ6RwKu0f/hHLPjF8KxbxlomEkXt9FQJf/jRlfb1e8SbjvnX8VLLBZ0v91rmLONsPxPHN7zU2lcNR8Zym7H9SdiRJ6CGyCNOGI9WOPPXW3FOhusYEIRaO8bU23YdqGNMDGP+JcNiMMHZjUT7Lzq0OqNrQD/C8s0a6XBbL6qV1O4FrgeMTRRetmmuW4ZGUXSpvpGS9ZTF1h5Gk0zIRT4klRAq9pe9492f54kXq4gxxhecwc2y6sAJozSQ542mCK/TgVC6ACfu3vZLVVxcx01OmOD8DXqh158TGezFbq2wiS0YZBiJzI7mTq+B/M0/3i3zAdsPErcztNK9icZM5UbiLDNZG/F0JV+FvTxrISmrN3w8Z8R6fE6Sy1SOkeOfFejYamsTgymc7PrsWMMyQxrhgf+WmcTZA6xyGoxJxyCfCwlPPc5u1yToemrAYYmIjg+cLkHjTlHELMQpRl7sUAtzCzfZaRbsDjkgVsyGmM0wTadkLTepSq1mENO2C6rCVvQrQibUFMQ2wbYQdkg/PqwhBkxfmUI4q0bdBFZwQHe/y7hHEI4CC0oNAIcRxB1I6I5w4BPkVbpdoBt8Sn8JtCCxdeXWg3g/IJ7ZPuyUs4FpSNWKPEPnOA2tvYXIbCuSmer3P9fuPPRpPsyNzrqMXASFcQPMxN5yIRqqeco0pmHFnj3G7d+ngo1ua2cd7Q== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5358.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(396003)(346002)(376002)(39850400004)(366004)(136003)(451199015)(66556008)(316002)(86362001)(8676002)(66476007)(66946007)(4326008)(38350700002)(38100700002)(36756003)(44832011)(83380400001)(52116002)(6512007)(2616005)(1076003)(26005)(6506007)(478600001)(6666004)(186003)(6486002)(8936002)(30864003)(41300700001)(15650500001)(6916009)(2906002)(54906003)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dladdF7Et8Q2SgHAAwBXrAuv61LTA0r3ZeMO4Tk8nURWTSXVaTrG458KRFtuM1fswtJSrjc15iwxgsLiyc7XEnNjk0JV8RILIae1mP9Duos2xPzqaivQXct7oyO9I1nX6LreXz1mtSPFyiY63ocXkQ7iU74lfQx8fWGM2zDkRo3DjCcwLUsl5ZhfiClvzAR0nXXchVIUd1YRzWj6VVAFTXNjZmM+YqR8isMrUxLgK5Je48dbW+7dF2b7S9c/o3m3Vl5pfp4nrQJa1WsTJNzQeRGNdjT2bCugpRWf8uiAXftRhPGJqKR7rZn/DpMWEwHItNaEU5I6oSq8VsysI+l2sExdTRZthXCk3G8IPEVB6fpdaZL2p9sbvdZwEQIQGhDvPae9fsqklJ8MVXfRCSyX0u6lXYpP+kpXj0GlAwNtHw+INj42PNfFm+XFFIVsJKoXoK/dGHb5xe5MWkJYdxLCOC/2NGZuzb/0j37dbnFJrA07s1LtOrtsUkxaIONCMwaQ5IDecivqbqSt/6dawbW3PZTLX04Ds22wxfzHaSXbFZSnNLUhnH8cfeDC6b4XyjAkjK5jeXYdB5FDan9i+iBKn1IkcpMk44Q5iHVEOJ5yVGQazDnr25ZsWr6QcKdICWIBNz3xaNNKQrJLbg5OlgOq5vgAL2hxoIkj18h3DZJlyjAOYK0dt3j/gGk3PFg6h4tYm3tMSv07GZ0DFVUJ6NkqFPnJQfXwKJ9C3YgkcKhg3enLiGqoCX6E74Se4OIM8sBUyxUfG5bJq2XnPQUjufJKV6/zK7NL2qisKmuvfFn6zkA7Oey9uo7im359Y53k/8QW9ZXuYiX0U62AytnCpUMo0RU7QkGhiNtuUeDFBWPg/t33sug0EE8my8aF7UY2J4Ty0Xs+XnRZH0wl3L2DmDyPH7QXT7k4MMlYGB91dqmCOUbdZFccLA7hGt6hK9TU1pzB/WAf1KMMp/5/ox0aWXOkJiy5C2bWitCdtw/UKr06cpH+MwRFVb+4UJBiZCYEaCYwiRwbxhsBtr8rrP7Uey15rt7Cys5Kw6luym+GbaYUkTcnk6k0K6HJAwAofQKnufvXoRXR/POEScVn4ARoGuPVPTV6o7uH61qQUysq+Xjwi2SCQ18mXZPeHoxt0ibuIK7pEJ+ThSnO6678NIof/ELMxxGqAsxhfAj6VPLDhLjq4laxD8urdSsLxdzCQpAsDfGdf/5BJMJzJzFH7up4eIFUO1dEuij2M+RAzpftfbqN12BGJuyRkVpAvazD01xnEdlyCds7hn/IZGn9LU9rlVRAJa1BljlbHhl0BH5rVnaRmAUNT3uBQfkU2UZV60T567rE7SSnbjeykD5Yr6uHQUAwAQ2XKWYSRMqdV/Ec/ruKZ5e//3Hf4PwhWbCzDyCUJLk7pJcBtjggNccMp1Z6Qudfibe/et2AKqvXvqXtNhYV8MxTPtkghIq1QF4lreGn5VRRpqWoRIUf9Zazce9aKbs/uOoei9n7cW7k8O7sy8A4uloDm1P8g/pC5X2z7zwQOASD6gtsg3vDEP7XkPrTy1KlQtcmOYOaFW8sQRmiY7vLmjpsndfqG92f2iVQ8AU9MakW X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 54f4ee7d-b7c5-43e3-effd-08dac39c68ca X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Nov 2022 04:22:56.9459 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: RpQ3Qs9rW5qlRG5a3QWWvDD+OYNuZwYE66GaqPLSv8x2m7+qaJ0EKFXILOi/NwDjxyeQZNaRCHzFB8vibeMlWA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB5102 X-Proofpoint-GUID: BhplmFcIvXXolupRXi0PUh5MOPGeaR6k X-Proofpoint-ORIG-GUID: BhplmFcIvXXolupRXi0PUh5MOPGeaR6k X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-11_01,2022-11-09_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 suspectscore=0 lowpriorityscore=0 mlxscore=0 malwarescore=0 adultscore=0 bulkscore=0 phishscore=0 impostorscore=0 priorityscore=1501 mlxlogscore=916 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211110027 Received-SPF: pass client-ip=205.220.178.238; envelope-from=prvs=83144312e2=bin.meng@windriver.com; helo=mx0b-0064b401.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org With this new QemuFd_t type, it significantly reduces the number of deviated code paths when adding Windows support. Signed-off-by: Bin Meng --- Changes in v2: - Use the new QemuFd_t type hw/9pfs/9p-local.h | 6 +- hw/9pfs/9p-util.h | 26 +++--- hw/9pfs/9p-local.c | 174 ++++++++++++++++++++------------------- hw/9pfs/9p-util-darwin.c | 14 ++-- hw/9pfs/9p-util-linux.c | 14 ++-- hw/9pfs/9p-xattr.c | 16 ++-- 6 files changed, 129 insertions(+), 121 deletions(-) diff --git a/hw/9pfs/9p-local.h b/hw/9pfs/9p-local.h index 32c72749d9..66a21316a0 100644 --- a/hw/9pfs/9p-local.h +++ b/hw/9pfs/9p-local.h @@ -13,8 +13,8 @@ #ifndef QEMU_9P_LOCAL_H #define QEMU_9P_LOCAL_H -int local_open_nofollow(FsContext *fs_ctx, const char *path, int flags, - mode_t mode); -int local_opendir_nofollow(FsContext *fs_ctx, const char *path); +QemuFd_t local_open_nofollow(FsContext *fs_ctx, const char *path, int flags, + mode_t mode); +QemuFd_t local_opendir_nofollow(FsContext *fs_ctx, const char *path); #endif diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index c314cf381d..3d6bd1a51e 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -101,30 +101,31 @@ static inline int errno_to_dotl(int err) { #define qemu_utimensat utimensat #define qemu_unlinkat unlinkat -static inline void close_preserve_errno(int fd) +static inline void close_preserve_errno(QemuFd_t fd) { int serrno = errno; close(fd); errno = serrno; } -static inline int openat_dir(int dirfd, const char *name) +static inline QemuFd_t openat_dir(QemuFd_t dirfd, const char *name) { return qemu_openat(dirfd, name, O_DIRECTORY | O_RDONLY | O_NOFOLLOW | O_PATH_9P_UTIL); } -static inline int openat_file(int dirfd, const char *name, int flags, - mode_t mode) +static inline QemuFd_t openat_file(QemuFd_t dirfd, const char *name, + int flags, mode_t mode) { - int fd, serrno, ret; + int serrno, ret; + QemuFd_t fd; #ifndef CONFIG_DARWIN again: #endif fd = qemu_openat(dirfd, name, flags | O_NOFOLLOW | O_NOCTTY | O_NONBLOCK, mode); - if (fd == -1) { + if (qemu_fd_invalid(fd)) { #ifndef CONFIG_DARWIN if (errno == EPERM && (flags & O_NOATIME)) { /* @@ -155,13 +156,13 @@ again: return fd; } -ssize_t fgetxattrat_nofollow(int dirfd, const char *path, const char *name, - void *value, size_t size); -int fsetxattrat_nofollow(int dirfd, const char *path, const char *name, +ssize_t fgetxattrat_nofollow(QemuFd_t dirfd, const char *path, + const char *name, void *value, size_t size); +int fsetxattrat_nofollow(QemuFd_t dirfd, const char *path, const char *name, void *value, size_t size, int flags); -ssize_t flistxattrat_nofollow(int dirfd, const char *filename, +ssize_t flistxattrat_nofollow(QemuFd_t dirfd, const char *filename, char *list, size_t size); -ssize_t fremovexattrat_nofollow(int dirfd, const char *filename, +ssize_t fremovexattrat_nofollow(QemuFd_t dirfd, const char *filename, const char *name); /* @@ -219,6 +220,7 @@ static inline struct dirent *qemu_dirent_dup(struct dirent *dent) #if defined CONFIG_DARWIN && defined CONFIG_PTHREAD_FCHDIR_NP int pthread_fchdir_np(int fd) __attribute__((weak_import)); #endif -int qemu_mknodat(int dirfd, const char *filename, mode_t mode, dev_t dev); +int qemu_mknodat(QemuFd_t dirfd, const char *filename, mode_t mode, + dev_t dev); #endif diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index d2246a3d7e..22377a3105 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -54,18 +54,18 @@ #endif typedef struct { - int mountfd; + QemuFd_t mountfd; } LocalData; -int local_open_nofollow(FsContext *fs_ctx, const char *path, int flags, - mode_t mode) +QemuFd_t local_open_nofollow(FsContext *fs_ctx, const char *path, int flags, + mode_t mode) { LocalData *data = fs_ctx->private; - int fd = data->mountfd; + QemuFd_t fd = data->mountfd; - while (*path && fd != -1) { + while (*path && !qemu_fd_invalid(fd)) { const char *c; - int next_fd; + QemuFd_t next_fd; char *head; /* Only relative paths without consecutive slashes */ @@ -94,20 +94,21 @@ int local_open_nofollow(FsContext *fs_ctx, const char *path, int flags, return fd; } -int local_opendir_nofollow(FsContext *fs_ctx, const char *path) +QemuFd_t local_opendir_nofollow(FsContext *fs_ctx, const char *path) { return local_open_nofollow(fs_ctx, path, O_DIRECTORY | O_RDONLY, 0); } -static void renameat_preserve_errno(int odirfd, const char *opath, int ndirfd, - const char *npath) +static void renameat_preserve_errno(QemuFd_t odirfd, const char *opath, + QemuFd_t ndirfd, const char *npath) { int serrno = errno; qemu_renameat(odirfd, opath, ndirfd, npath); errno = serrno; } -static void unlinkat_preserve_errno(int dirfd, const char *path, int flags) +static void unlinkat_preserve_errno(QemuFd_t dirfd, const char *path, + int flags) { int serrno = errno; qemu_unlinkat(dirfd, path, flags); @@ -117,9 +118,10 @@ static void unlinkat_preserve_errno(int dirfd, const char *path, int flags) #define VIRTFS_META_DIR ".virtfs_metadata" #define VIRTFS_META_ROOT_FILE VIRTFS_META_DIR "_root" -static FILE *local_fopenat(int dirfd, const char *name, const char *mode) +static FILE *local_fopenat(QemuFd_t dirfd, const char *name, const char *mode) { - int fd, o_mode = 0; + QemuFd_t fd; + int o_mode = 0; FILE *fp; int flags; /* @@ -134,7 +136,7 @@ static FILE *local_fopenat(int dirfd, const char *name, const char *mode) return NULL; } fd = openat_file(dirfd, name, flags, o_mode); - if (fd == -1) { + if (qemu_fd_invalid(fd)) { return NULL; } fp = fdopen(fd, mode); @@ -145,16 +147,16 @@ static FILE *local_fopenat(int dirfd, const char *name, const char *mode) } #define ATTR_MAX 100 -static void local_mapped_file_attr(int dirfd, const char *name, +static void local_mapped_file_attr(QemuFd_t dirfd, const char *name, struct stat *stbuf) { FILE *fp; char buf[ATTR_MAX]; - int map_dirfd; + QemuFd_t map_dirfd; if (strcmp(name, ".")) { map_dirfd = openat_dir(dirfd, VIRTFS_META_DIR); - if (map_dirfd == -1) { + if (qemu_fd_invalid(map_dirfd)) { return; } @@ -187,10 +189,10 @@ static int local_lstat(FsContext *fs_ctx, V9fsPath *fs_path, struct stat *stbuf) int err = -1; char *dirpath = g_path_get_dirname(fs_path->data); char *name = g_path_get_basename(fs_path->data); - int dirfd; + QemuFd_t dirfd; dirfd = local_opendir_nofollow(fs_ctx, dirpath); - if (dirfd == -1) { + if (qemu_fd_invalid(dirfd)) { goto out; } @@ -233,14 +235,14 @@ out: return err; } -static int local_set_mapped_file_attrat(int dirfd, const char *name, +static int local_set_mapped_file_attrat(QemuFd_t dirfd, const char *name, FsCred *credp) { FILE *fp; int ret; char buf[ATTR_MAX]; int uid = -1, gid = -1, mode = -1, rdev = -1; - int map_dirfd = -1, map_fd; + QemuFd_t map_dirfd = QEMU_FD_INVALID, map_fd; bool is_root = !strcmp(name, "."); if (is_root) { @@ -259,7 +261,7 @@ static int local_set_mapped_file_attrat(int dirfd, const char *name, } map_dirfd = openat_dir(dirfd, VIRTFS_META_DIR); - if (map_dirfd == -1) { + if (qemu_fd_invalid(map_dirfd)) { return -1; } @@ -296,7 +298,7 @@ update_map_file: /* We can't go this far with map_dirfd not being a valid file descriptor * but some versions of gcc aren't smart enough to see it. */ - if (map_dirfd != -1) { + if (!qemu_fd_invalid(map_dirfd)) { close_preserve_errno(map_dirfd); } } @@ -305,7 +307,7 @@ update_map_file: } map_fd = fileno(fp); - assert(map_fd != -1); + assert(!qemu_fd_invalid(map_fd)); ret = fchmod(map_fd, 0600); assert(ret == 0); @@ -339,10 +341,11 @@ update_map_file: return 0; } -static int fchmodat_nofollow(int dirfd, const char *name, mode_t mode) +static int fchmodat_nofollow(QemuFd_t dirfd, const char *name, mode_t mode) { struct stat stbuf; - int fd, ret; + QemuFd_t fd; + int ret; /* FIXME: this should be handled with fchmodat(AT_SYMLINK_NOFOLLOW). * Unfortunately, the linux kernel doesn't implement it yet. @@ -362,16 +365,16 @@ static int fchmodat_nofollow(int dirfd, const char *name, mode_t mode) /* Fallback for systems that don't support O_PATH: we depend on the file * being readable or writable. */ - if (fd == -1) { + if (qemu_fd_invalid(fd)) { /* In case the file is writable-only and isn't a directory. */ if (errno == EACCES) { fd = openat_file(dirfd, name, O_WRONLY, 0); } - if (fd == -1 && errno == EISDIR) { + if (qemu_fd_invalid(fd) && errno == EISDIR) { errno = EACCES; } } - if (fd == -1) { + if (qemu_fd_invalid(fd)) { return -1; } ret = fchmod(fd, mode); @@ -380,7 +383,7 @@ static int fchmodat_nofollow(int dirfd, const char *name, mode_t mode) * link, O_PATH | O_NOFOLLOW causes openat(2) to return a file descriptor * referring to the symbolic link. */ - if (fd == -1) { + if (qemu_fd_invalid(fd)) { return -1; } @@ -401,7 +404,7 @@ static int fchmodat_nofollow(int dirfd, const char *name, mode_t mode) return ret; } -static int local_set_xattrat(int dirfd, const char *path, FsCred *credp) +static int local_set_xattrat(QemuFd_t dirfd, const char *path, FsCred *credp) { int err; @@ -440,7 +443,7 @@ static int local_set_xattrat(int dirfd, const char *path, FsCred *credp) return 0; } -static int local_set_cred_passthrough(FsContext *fs_ctx, int dirfd, +static int local_set_cred_passthrough(FsContext *fs_ctx, QemuFd_t dirfd, const char *name, FsCred *credp) { if (fchownat(dirfd, name, credp->fc_uid, credp->fc_gid, @@ -464,10 +467,10 @@ static ssize_t local_readlink(FsContext *fs_ctx, V9fsPath *fs_path, if ((fs_ctx->export_flags & V9FS_SM_MAPPED) || (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE)) { - int fd; + QemuFd_t fd; fd = local_open_nofollow(fs_ctx, fs_path->data, O_RDONLY, 0); - if (fd == -1) { + if (qemu_fd_invalid(fd)) { return -1; } do { @@ -478,10 +481,10 @@ static ssize_t local_readlink(FsContext *fs_ctx, V9fsPath *fs_path, (fs_ctx->export_flags & V9FS_SM_NONE)) { char *dirpath = g_path_get_dirname(fs_path->data); char *name = g_path_get_basename(fs_path->data); - int dirfd; + QemuFd_t dirfd; dirfd = local_opendir_nofollow(fs_ctx, dirpath); - if (dirfd == -1) { + if (qemu_fd_invalid(dirfd)) { goto out; } @@ -507,10 +510,10 @@ static int local_closedir(FsContext *ctx, V9fsFidOpenState *fs) static int local_open(FsContext *ctx, V9fsPath *fs_path, int flags, V9fsFidOpenState *fs) { - int fd; + QemuFd_t fd; fd = local_open_nofollow(ctx, fs_path->data, flags, 0); - if (fd == -1) { + if (qemu_fd_invalid(fd)) { return -1; } fs->fd = fd; @@ -520,11 +523,11 @@ static int local_open(FsContext *ctx, V9fsPath *fs_path, static int local_opendir(FsContext *ctx, V9fsPath *fs_path, V9fsFidOpenState *fs) { - int dirfd; + QemuFd_t dirfd; DIR *stream; dirfd = local_opendir_nofollow(ctx, fs_path->data); - if (dirfd == -1) { + if (qemu_fd_invalid(dirfd)) { return -1; } @@ -640,10 +643,10 @@ static int local_chmod(FsContext *fs_ctx, V9fsPath *fs_path, FsCred *credp) char *dirpath = g_path_get_dirname(fs_path->data); char *name = g_path_get_basename(fs_path->data); int ret = -1; - int dirfd; + QemuFd_t dirfd; dirfd = local_opendir_nofollow(fs_ctx, dirpath); - if (dirfd == -1) { + if (qemu_fd_invalid(dirfd)) { goto out; } @@ -667,7 +670,7 @@ static int local_mknod(FsContext *fs_ctx, V9fsPath *dir_path, const char *name, FsCred *credp) { int err = -1; - int dirfd; + QemuFd_t dirfd; if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE && local_is_mapped_file_metadata(fs_ctx, name)) { @@ -676,7 +679,7 @@ static int local_mknod(FsContext *fs_ctx, V9fsPath *dir_path, } dirfd = local_opendir_nofollow(fs_ctx, dir_path->data); - if (dirfd == -1) { + if (qemu_fd_invalid(dirfd)) { return -1; } @@ -719,7 +722,7 @@ static int local_mkdir(FsContext *fs_ctx, V9fsPath *dir_path, const char *name, FsCred *credp) { int err = -1; - int dirfd; + QemuFd_t dirfd; if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE && local_is_mapped_file_metadata(fs_ctx, name)) { @@ -728,7 +731,7 @@ static int local_mkdir(FsContext *fs_ctx, V9fsPath *dir_path, } dirfd = local_opendir_nofollow(fs_ctx, dir_path->data); - if (dirfd == -1) { + if (qemu_fd_invalid(dirfd)) { return -1; } @@ -816,9 +819,9 @@ static int local_fstat(FsContext *fs_ctx, int fid_type, static int local_open2(FsContext *fs_ctx, V9fsPath *dir_path, const char *name, int flags, FsCred *credp, V9fsFidOpenState *fs) { - int fd = -1; + QemuFd_t fd = QEMU_FD_INVALID; int err = -1; - int dirfd; + QemuFd_t dirfd; if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE && local_is_mapped_file_metadata(fs_ctx, name)) { @@ -832,7 +835,7 @@ static int local_open2(FsContext *fs_ctx, V9fsPath *dir_path, const char *name, flags |= O_NOFOLLOW; dirfd = local_opendir_nofollow(fs_ctx, dir_path->data); - if (dirfd == -1) { + if (qemu_fd_invalid(dirfd)) { return -1; } @@ -840,7 +843,7 @@ static int local_open2(FsContext *fs_ctx, V9fsPath *dir_path, const char *name, if (fs_ctx->export_flags & V9FS_SM_MAPPED || fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) { fd = openat_file(dirfd, name, flags, fs_ctx->fmode); - if (fd == -1) { + if (qemu_fd_invalid(fd)) { goto out; } credp->fc_mode = credp->fc_mode | S_IFREG; @@ -856,7 +859,7 @@ static int local_open2(FsContext *fs_ctx, V9fsPath *dir_path, const char *name, } else if ((fs_ctx->export_flags & V9FS_SM_PASSTHROUGH) || (fs_ctx->export_flags & V9FS_SM_NONE)) { fd = openat_file(dirfd, name, flags, credp->fc_mode); - if (fd == -1) { + if (qemu_fd_invalid(fd)) { goto out; } err = local_set_cred_passthrough(fs_ctx, dirfd, name, credp); @@ -882,7 +885,7 @@ static int local_symlink(FsContext *fs_ctx, const char *oldpath, V9fsPath *dir_path, const char *name, FsCred *credp) { int err = -1; - int dirfd; + QemuFd_t dirfd; if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE && local_is_mapped_file_metadata(fs_ctx, name)) { @@ -891,19 +894,19 @@ static int local_symlink(FsContext *fs_ctx, const char *oldpath, } dirfd = local_opendir_nofollow(fs_ctx, dir_path->data); - if (dirfd == -1) { + if (qemu_fd_invalid(dirfd)) { return -1; } /* Determine the security model */ if (fs_ctx->export_flags & V9FS_SM_MAPPED || fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) { - int fd; + QemuFd_t fd; ssize_t oldpath_size, write_size; fd = openat_file(dirfd, name, O_CREAT | O_EXCL | O_RDWR, fs_ctx->fmode); - if (fd == -1) { + if (qemu_fd_invalid(fd)) { goto out; } /* Write the oldpath (target) to the file. */ @@ -962,7 +965,7 @@ static int local_link(FsContext *ctx, V9fsPath *oldpath, char *odirpath = g_path_get_dirname(oldpath->data); char *oname = g_path_get_basename(oldpath->data); int ret = -1; - int odirfd, ndirfd; + QemuFd_t odirfd, ndirfd; if (ctx->export_flags & V9FS_SM_MAPPED_FILE && local_is_mapped_file_metadata(ctx, name)) { @@ -971,12 +974,12 @@ static int local_link(FsContext *ctx, V9fsPath *oldpath, } odirfd = local_opendir_nofollow(ctx, odirpath); - if (odirfd == -1) { + if (qemu_fd_invalid(odirfd)) { goto out; } ndirfd = local_opendir_nofollow(ctx, dirpath->data); - if (ndirfd == -1) { + if (qemu_fd_invalid(ndirfd)) { close_preserve_errno(odirfd); goto out; } @@ -996,12 +999,12 @@ static int local_link(FsContext *ctx, V9fsPath *oldpath, } omap_dirfd = openat_dir(odirfd, VIRTFS_META_DIR); - if (omap_dirfd == -1) { + if (qemu_fd_invalid(omap_dirfd)) { goto err; } nmap_dirfd = openat_dir(ndirfd, VIRTFS_META_DIR); - if (nmap_dirfd == -1) { + if (qemu_fd_invalid(nmap_dirfd)) { close_preserve_errno(omap_dirfd); goto err; } @@ -1032,10 +1035,11 @@ out: static int local_truncate(FsContext *ctx, V9fsPath *fs_path, off_t size) { - int fd, ret; + QemuFd_t fd; + int ret; fd = local_open_nofollow(ctx, fs_path->data, O_WRONLY, 0); - if (fd == -1) { + if (qemu_fd_invalid(fd)) { return -1; } ret = ftruncate(fd, size); @@ -1048,10 +1052,10 @@ static int local_chown(FsContext *fs_ctx, V9fsPath *fs_path, FsCred *credp) char *dirpath = g_path_get_dirname(fs_path->data); char *name = g_path_get_basename(fs_path->data); int ret = -1; - int dirfd; + QemuFd_t dirfd; dirfd = local_opendir_nofollow(fs_ctx, dirpath); - if (dirfd == -1) { + if (qemu_fd_invalid(dirfd)) { goto out; } @@ -1078,10 +1082,11 @@ static int local_utimensat(FsContext *s, V9fsPath *fs_path, { char *dirpath = g_path_get_dirname(fs_path->data); char *name = g_path_get_basename(fs_path->data); - int dirfd, ret = -1; + QemuFd_t dirfd; + int ret = -1; dirfd = local_opendir_nofollow(s, dirpath); - if (dirfd == -1) { + if (qemu_fd_invalid(dirfd)) { goto out; } @@ -1093,13 +1098,13 @@ out: return ret; } -static int local_unlinkat_common(FsContext *ctx, int dirfd, const char *name, - int flags) +static int local_unlinkat_common(FsContext *ctx, QemuFd_t dirfd, + const char *name, int flags) { int ret; if (ctx->export_flags & V9FS_SM_MAPPED_FILE) { - int map_dirfd; + QemuFd_t map_dirfd; /* We need to remove the metadata as well: * - the metadata directory if we're removing a directory @@ -1110,10 +1115,10 @@ static int local_unlinkat_common(FsContext *ctx, int dirfd, const char *name, * mode. We just ignore the error. */ if (flags == AT_REMOVEDIR) { - int fd; + QemuFd_t fd; fd = openat_dir(dirfd, name); - if (fd == -1) { + if (qemu_fd_invalid(fd)) { return -1; } ret = qemu_unlinkat(fd, VIRTFS_META_DIR, AT_REMOVEDIR); @@ -1123,7 +1128,7 @@ static int local_unlinkat_common(FsContext *ctx, int dirfd, const char *name, } } map_dirfd = openat_dir(dirfd, VIRTFS_META_DIR); - if (map_dirfd != -1) { + if (!qemu_fd_invalid(map_dirfd)) { ret = qemu_unlinkat(map_dirfd, name, 0); close_preserve_errno(map_dirfd); if (ret < 0 && errno != ENOENT) { @@ -1143,11 +1148,11 @@ static int local_remove(FsContext *ctx, const char *path) char *dirpath = g_path_get_dirname(path); char *name = g_path_get_basename(path); int flags = 0; - int dirfd; + QemuFd_t dirfd; int err = -1; dirfd = local_opendir_nofollow(ctx, dirpath); - if (dirfd == -1) { + if (qemu_fd_invalid(dirfd)) { goto out; } @@ -1188,10 +1193,11 @@ static int local_fsync(FsContext *ctx, int fid_type, static int local_statfs(FsContext *s, V9fsPath *fs_path, struct statfs *stbuf) { - int fd, ret; + QemuFd_t fd; + int ret; fd = local_open_nofollow(s, fs_path->data, O_RDONLY, 0); - if (fd == -1) { + if (qemu_fd_invalid(fd)) { return -1; } ret = fstatfs(fd, stbuf); @@ -1276,7 +1282,7 @@ static int local_renameat(FsContext *ctx, V9fsPath *olddir, const char *new_name) { int ret; - int odirfd, ndirfd; + QemuFd_t odirfd, ndirfd; if (ctx->export_flags & V9FS_SM_MAPPED_FILE && (local_is_mapped_file_metadata(ctx, old_name) || @@ -1286,12 +1292,12 @@ static int local_renameat(FsContext *ctx, V9fsPath *olddir, } odirfd = local_opendir_nofollow(ctx, olddir->data); - if (odirfd == -1) { + if (qemu_fd_invalid(odirfd)) { return -1; } ndirfd = local_opendir_nofollow(ctx, newdir->data); - if (ndirfd == -1) { + if (qemu_fd_invalid(ndirfd)) { close_preserve_errno(odirfd); return -1; } @@ -1302,7 +1308,7 @@ static int local_renameat(FsContext *ctx, V9fsPath *olddir, } if (ctx->export_flags & V9FS_SM_MAPPED_FILE) { - int omap_dirfd, nmap_dirfd; + QemuFd_t omap_dirfd, nmap_dirfd; ret = qemu_mkdirat(ndirfd, VIRTFS_META_DIR, 0700); if (ret < 0 && errno != EEXIST) { @@ -1310,12 +1316,12 @@ static int local_renameat(FsContext *ctx, V9fsPath *olddir, } omap_dirfd = openat_dir(odirfd, VIRTFS_META_DIR); - if (omap_dirfd == -1) { + if (qemu_fd_invalid(omap_dirfd)) { goto err; } nmap_dirfd = openat_dir(ndirfd, VIRTFS_META_DIR); - if (nmap_dirfd == -1) { + if (qemu_fd_invalid(nmap_dirfd)) { close_preserve_errno(omap_dirfd); goto err; } @@ -1373,7 +1379,7 @@ static int local_unlinkat(FsContext *ctx, V9fsPath *dir, const char *name, int flags) { int ret; - int dirfd; + QemuFd_t dirfd; if (ctx->export_flags & V9FS_SM_MAPPED_FILE && local_is_mapped_file_metadata(ctx, name)) { @@ -1382,7 +1388,7 @@ static int local_unlinkat(FsContext *ctx, V9fsPath *dir, } dirfd = local_opendir_nofollow(ctx, dir->data); - if (dirfd == -1) { + if (qemu_fd_invalid(dirfd)) { return -1; } @@ -1446,7 +1452,7 @@ static int local_init(FsContext *ctx, Error **errp) LocalData *data = g_malloc(sizeof(*data)); data->mountfd = open(ctx->fs_root, O_DIRECTORY | O_RDONLY); - if (data->mountfd == -1) { + if (qemu_fd_invalid(data->mountfd)) { error_setg_errno(errp, errno, "failed to open '%s'", ctx->fs_root); goto err; } diff --git a/hw/9pfs/9p-util-darwin.c b/hw/9pfs/9p-util-darwin.c index 95146e7354..f85cfd26bb 100644 --- a/hw/9pfs/9p-util-darwin.c +++ b/hw/9pfs/9p-util-darwin.c @@ -11,8 +11,8 @@ #include "qemu/error-report.h" #include "9p-util.h" -ssize_t fgetxattrat_nofollow(int dirfd, const char *filename, const char *name, - void *value, size_t size) +ssize_t fgetxattrat_nofollow(QemuFd_t dirfd, const char *filename, + const char *name, void *value, size_t size) { int ret; int fd = openat_file(dirfd, filename, @@ -25,7 +25,7 @@ ssize_t fgetxattrat_nofollow(int dirfd, const char *filename, const char *name, return ret; } -ssize_t flistxattrat_nofollow(int dirfd, const char *filename, +ssize_t flistxattrat_nofollow(QemuFd_t dirfd, const char *filename, char *list, size_t size) { int ret; @@ -39,7 +39,7 @@ ssize_t flistxattrat_nofollow(int dirfd, const char *filename, return ret; } -ssize_t fremovexattrat_nofollow(int dirfd, const char *filename, +ssize_t fremovexattrat_nofollow(QemuFd_t dirfd, const char *filename, const char *name) { int ret; @@ -52,8 +52,8 @@ ssize_t fremovexattrat_nofollow(int dirfd, const char *filename, return ret; } -int fsetxattrat_nofollow(int dirfd, const char *filename, const char *name, - void *value, size_t size, int flags) +int fsetxattrat_nofollow(QemuFd_t dirfd, const char *filename, + const char *name, void *value, size_t size, int flags) { int ret; int fd = openat_file(dirfd, filename, O_PATH_9P_UTIL | O_NOFOLLOW, 0); @@ -110,7 +110,7 @@ out: return err; } -int qemu_mknodat(int dirfd, const char *filename, mode_t mode, dev_t dev) +int qemu_mknodat(QemuFd_t dirfd, const char *filename, mode_t mode, dev_t dev) { int preserved_errno, err; diff --git a/hw/9pfs/9p-util-linux.c b/hw/9pfs/9p-util-linux.c index db451b0784..8dd9da10b6 100644 --- a/hw/9pfs/9p-util-linux.c +++ b/hw/9pfs/9p-util-linux.c @@ -19,8 +19,8 @@ #include "qemu/xattr.h" #include "9p-util.h" -ssize_t fgetxattrat_nofollow(int dirfd, const char *filename, const char *name, - void *value, size_t size) +ssize_t fgetxattrat_nofollow(QemuFd_t dirfd, const char *filename, + const char *name, void *value, size_t size) { char *proc_path = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename); int ret; @@ -30,7 +30,7 @@ ssize_t fgetxattrat_nofollow(int dirfd, const char *filename, const char *name, return ret; } -ssize_t flistxattrat_nofollow(int dirfd, const char *filename, +ssize_t flistxattrat_nofollow(QemuFd_t dirfd, const char *filename, char *list, size_t size) { char *proc_path = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename); @@ -41,7 +41,7 @@ ssize_t flistxattrat_nofollow(int dirfd, const char *filename, return ret; } -ssize_t fremovexattrat_nofollow(int dirfd, const char *filename, +ssize_t fremovexattrat_nofollow(QemuFd_t dirfd, const char *filename, const char *name) { char *proc_path = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename); @@ -52,8 +52,8 @@ ssize_t fremovexattrat_nofollow(int dirfd, const char *filename, return ret; } -int fsetxattrat_nofollow(int dirfd, const char *filename, const char *name, - void *value, size_t size, int flags) +int fsetxattrat_nofollow(QemuFd_t dirfd, const char *filename, + const char *name, void *value, size_t size, int flags) { char *proc_path = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename); int ret; @@ -64,7 +64,7 @@ int fsetxattrat_nofollow(int dirfd, const char *filename, const char *name, } -int qemu_mknodat(int dirfd, const char *filename, mode_t mode, dev_t dev) +int qemu_mknodat(QemuFd_t dirfd, const char *filename, mode_t mode, dev_t dev) { return mknodat(dirfd, filename, mode, dev); } diff --git a/hw/9pfs/9p-xattr.c b/hw/9pfs/9p-xattr.c index 9ae69dd8db..062bf2d1f0 100644 --- a/hw/9pfs/9p-xattr.c +++ b/hw/9pfs/9p-xattr.c @@ -78,13 +78,13 @@ ssize_t v9fs_list_xattr(FsContext *ctx, const char *path, char *orig_value, *orig_value_start; ssize_t xattr_len, parsed_len = 0, attr_len; char *dirpath, *name; - int dirfd; + QemuFd_t dirfd; /* Get the actual len */ dirpath = g_path_get_dirname(path); dirfd = local_opendir_nofollow(ctx, dirpath); g_free(dirpath); - if (dirfd == -1) { + if (qemu_fd_invalid(dirfd)) { return -1; } @@ -168,11 +168,11 @@ ssize_t local_getxattr_nofollow(FsContext *ctx, const char *path, { char *dirpath = g_path_get_dirname(path); char *filename = g_path_get_basename(path); - int dirfd; + QemuFd_t dirfd; ssize_t ret = -1; dirfd = local_opendir_nofollow(ctx, dirpath); - if (dirfd == -1) { + if (qemu_fd_invalid(dirfd)) { goto out; } @@ -196,11 +196,11 @@ ssize_t local_setxattr_nofollow(FsContext *ctx, const char *path, { char *dirpath = g_path_get_dirname(path); char *filename = g_path_get_basename(path); - int dirfd; + QemuFd_t dirfd; ssize_t ret = -1; dirfd = local_opendir_nofollow(ctx, dirpath); - if (dirfd == -1) { + if (qemu_fd_invalid(dirfd)) { goto out; } @@ -223,11 +223,11 @@ ssize_t local_removexattr_nofollow(FsContext *ctx, const char *path, { char *dirpath = g_path_get_dirname(path); char *filename = g_path_get_basename(path); - int dirfd; + QemuFd_t dirfd; ssize_t ret = -1; dirfd = local_opendir_nofollow(ctx, dirpath); - if (dirfd == -1) { + if (qemu_fd_invalid(dirfd)) { goto out; } From patchwork Fri Nov 11 04:22:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13039632 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 1D877C433FE for ; Fri, 11 Nov 2022 04:24:43 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otLZZ-0000Vo-6J; Thu, 10 Nov 2022 23:23:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otLZX-0000Ul-9W for qemu-devel@nongnu.org; Thu, 10 Nov 2022 23:23:19 -0500 Received: from mx0b-0064b401.pphosted.com ([205.220.178.238]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otLZU-0001ZD-S1 for qemu-devel@nongnu.org; Thu, 10 Nov 2022 23:23:19 -0500 Received: from pps.filterd (m0250811.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AB4N0iO024928; Fri, 11 Nov 2022 04:23:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=gNc9mXTr/EyEiKJ6AiSyzYNMP3zaIbsnD4BKi7tOfKg=; b=OA4f54ZJNXVphr9gAkN5CFtbCc0kd34MBKipyc4lPFYd4Ey1Aq5fz6ZB9TAHLatoMRnp YjrgCx5UkM0Pu061JyvNI5A/KMq2VY0zbh2zZFhZg7dmN0SVkQx3VcLbsej3T2n1KIor xw80BHmLQR5/bpO0ilIWyta+082Rv9pnCpSXnBL22JSMMobNEvfTdso0zmtYGNKYZZL7 mbiYIVXmjZybRN29kNhJJhzYLcQWVkiR2MGvSAADq3NakDSifp78Uj55NQYLuBbwtgB7 3nigQYCVGsaYP3+8yxTFxVgjjpfG0ctUW/uNsoQlIjPVEWLyIdBFFsrzlraZr6BlEWOP jA== Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2103.outbound.protection.outlook.com [104.47.70.103]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3knd21ndvc-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 11 Nov 2022 04:23:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ha7PXRpeAla0Z1aYm58TKqGZjuLT2fWHrMDCDjYQWx/M6cZ9iAChauy+ROXMjUiBCZqe4J/LyfOLwwsFv6qs45zQVitzn2OAPKPT1HqaETPdJ37R435zBcSHW7GNhu9vbuHQ/TMsuEwclzIqFtWcg5lqqzHqK7swTgpL09pcIJ3JTJvsA8qUYreYhbyrlz34WLnaLOX+ibE+b7FOnGru1pxy0QmKv1huuHVd75wDFB333vDmY/8JFMIyYOWcp0xzfrn6Ai9RBLdaX/EsbvXFXDPOeVqIv728Yx5rNFAENVyZTQ+qTgB/LvRnTvBqc9J0CGqJn21JGKL3+Gmz+IMaCg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=gNc9mXTr/EyEiKJ6AiSyzYNMP3zaIbsnD4BKi7tOfKg=; b=JepxFwEjeXkvwxqBqxbXMWXXe3EMmlCLVD7C9OZO0bO37+OoFA23+M/X/7XnmhYO00poHbehXGbEb+X1zKhlXg18Kfl3zSyzntSC9Iv0c9H2+CWiF1q8r/mODd1nZDztPvyz90iG1BuBXTTLvLjY4iWOFWdHIscCL82i3ELnhOgOVDBU5TLHaS15W8uJSWqXiiKmzCZNS7eI61+Fx96yyOPuOF1z+DwQPuaUuqhxTdtAEzEbZyoLJVOanWg+d/6MjQ52WZgy03YdD//bij4E6E6VVJcbIzgx4shKQT/FXq6ZqxcGorBh9wipCLMkRuXYz0vQHTv8DtE9+tyQzY52VQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by SJ0PR11MB5102.namprd11.prod.outlook.com (2603:10b6:a03:2ac::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27; Fri, 11 Nov 2022 04:22:59 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::8e5e:71da:1e29:bc15]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::8e5e:71da:1e29:bc15%5]) with mapi id 15.20.5813.013; Fri, 11 Nov 2022 04:22:58 +0000 From: Bin Meng To: qemu-devel@nongnu.org Cc: Guohuai Shi , Christian Schoenebeck , Greg Kurz Subject: [PATCH v2 06/19] hw/9pfs: Add missing definitions for Windows Date: Fri, 11 Nov 2022 12:22:12 +0800 Message-Id: <20221111042225.1115931-7-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221111042225.1115931-1-bin.meng@windriver.com> References: <20221111042225.1115931-1-bin.meng@windriver.com> X-ClientProxiedBy: SL2P216CA0138.KORP216.PROD.OUTLOOK.COM (2603:1096:101:1::17) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|SJ0PR11MB5102:EE_ X-MS-Office365-Filtering-Correlation-Id: 5398c00b-8bfa-4718-c69c-08dac39c6a0a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ufM0HiCE4ndWHvwNR9DrnZmBewCVRGwQvZAxKM0Vs/P66EbGwQhPC83ruxPZ6gz3h+frAFVLSEZ5buIbrMyXsWs72OYIfOk1UzukNGlUXB0BnHXQC6LnY71rSD8cslQDgtGbSNb8SAdFjopOFPX3fD4Qcpm3KgPJfaJJl4TW5w6DC8ipFkmvkq+K984PtWg0NqbmDIYsGKSRPWdK24VLIzHgeljtoTreQGPIkILFdjwjLtlM1VD9N9PVCoXFywRsIBZbsMELSUC4rFHu3+NsQzZYIUeUBSSW2S13JzWYhF8y4p/aA4q1u5xaiBRLDYgcwSJ5lDXgSfiHVzhYVx81sfGBzp4apNxhWUOYdf8iE39NgWNFfHqr13sFNeJnXHzNWRedKJ7JkTPgJ1dFY1UTF52PN8eO4tsPLsbQenf0eZ6MgBLuYrzTqt5bHSn+1uhrzbUjqCp2al9d+ZNLT4AKE2nR2vEW1EcNN7nFL4XxNhASYPTFhKPNb3ZmqM01IjxBQNDJ8fx/ThThHrm5yncBaleQ1KHmET6ALm0sMFHT6fEs5AtTGQF1yLjFMic7LIBWd5r7iAhAoOykOBQnl35ystsuel8uhNirkCoMsT9Y5YGJSEhZdK3WDiz2dzvyAo26GdsZFXkaAKCX5Kne8BTcncH/aLj0UkXYB2925l8AaMsSEBDmDyXvmwczB9MtGhQfteXFcLHsdg6TqnTolqpK3XsPPYSLvNArcsEqRs0OOmdFcOqZ8VNHfbYhjJBTbeiJYNHGeEUYVcabJFZxSg2IH7sn7LcRtHO6FT3Ek1B9/SM= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5358.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(396003)(346002)(376002)(39850400004)(366004)(136003)(451199015)(66556008)(316002)(86362001)(8676002)(66476007)(66946007)(4326008)(38350700002)(38100700002)(36756003)(44832011)(83380400001)(966005)(52116002)(6512007)(2616005)(1076003)(26005)(6506007)(478600001)(6666004)(186003)(6486002)(8936002)(41300700001)(6916009)(2906002)(54906003)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZFiYL+H/o1Zv8Ywfl/Jz7HT2tUP/1Wp+/35BFTVg/ISwYKYbrWgF6Dh9Eue4T+/YbVm9DjSBT0d/2DVHXFkpba+MLipXCD4fYKJeN7zh1CwWxLWmpFqftoXCrzxT2DtGhGSNyGSEyUVNfiodpwpJitcMEmKequJJpPkjKP+LbejtL3zFLrHkWbGpIgT3qTgYpm7Cfad45SIlmvZ4qsVVWATCWZV2sLLmjXigXrVhWo/aXCcV+EXfwS+BnBFzhJmr3WhZ/0m3SuQN3JJj9gXLfC4pNUAfOAhfJMFMho7Qa1WOVjLy4H6exOwuC+XdxPDDJSq2P86/m9kTvQtwtGAI3HxIku6Hqk/goJcg3yh8U7czxoQ9Bs/DQnGNroL6PhrFV1esfdtJcTeBqHu5SyFwQohs8UgsB2cOm8uFFEd3PVIzJMQWJtPksNTWy9RdKaltVJIwkR+kSlK6LiPjaKxrEWZ4KfXvTg8nbzHyZzB/Whhy0U81oqhKt1+28X4jlB0Sgsd2bPCT/gZT0K54nT+howBef9DZPJcqwz4muxCvjaGNFHwfoBI1VFfYGJ6JkI4G/MSLhav6Yf12dMuslXnDBwPRa7b+Xg6lOyjEDZCssaasxRvM1qnhC45APy1hXT3ppsZwY8idYw0oOue5QSsJLyQUx6f6IYWPogIO+fITojT+mOen0IHGaFzeB3RdiCj4PCIL8NiIlLzhOY279vYXtU95CjvcRcBYzZ1uAtDwnf52OaXTnOnhLncfZdOdGOTmWnSxtHT45Jd1TJvs7xaFHBY0K2T0dqCtQLqnX4DlUAc/cwdF+27C/qhraBuJ48ghVA4QOLvI7acVqKFtS+oOnmZyWgJ9i/6adEIqHgYOnJswcgXBxiVz/qbOEuRaUM7hSBaR8Wo8VtQL50Lf+6WJn16EbqtXaWutII4bcXbwbjMzI4+sGhdQ+80xs4Sry3l1ufYDc8wtr9kT260N6lurMwsITZrUp3bvJ2QhX+9VEyJicLaD1wptiDi3I5Uev7C6wypAastFo0qExrbb32y/TvnEL8UV9inOklpMx9OriEGGJaAlbvznaXDTyi7CPg/J6skezAGXKg8p/1p3FhbKeybuOWXW5uTawosf5JebES7OeOX3Ec1mK1wv+6ZO85IY+WSgzYRVLyi4xHtEyO7na7eTfEXvLvBXkmYV/qED9jw/y6Vhalxq6dN9iaTcUJxy/3V18PYeXuNLbFN18WIdeRvsx1ltjk1Vef+xwjWMb5qZIs+wSPBoeH7ET9IPlZlyPNF6EdY1HWigtdGPXq/ndDwOQEjg/ftCG1vcza9SmjBayX2NooaL0xCJI+YciPWPOzSZ1wsOV1eALdXVwlWx2myNdHqm6n8ohGdEvmQ9IqYsN4AiSc6gWMZq1XTx98ITV/WgXZZjqBMjZBxxi/VCjzWr+kmUwG91gSy0m8hRzf2mOE8go4TCLchkDSqfqpPmLZcjV3pDYMb8CN39fLCAoTwwsz27dA6awsYOG9p5Q3/uPLtt9cq3S7I08/aEth9KVoXnzPtDdA1KTADrU8cO2t7h+TD4TvvZwXkWcneVcE7KkkQJ5jKb5Wod/N3GvVn+ X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5398c00b-8bfa-4718-c69c-08dac39c6a0a X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Nov 2022 04:22:58.9326 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: BLMgCJIpkYeQE8NeaMysK/apU514htT4EqErg7xBXrP0WGDhZwbV4cZf366iz98jSDqm73iZaaWnZ3qCq+RjGA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB5102 X-Proofpoint-GUID: sPQ9gfdlgHQZeFIyNjBjpEVu6rdXzt0L X-Proofpoint-ORIG-GUID: sPQ9gfdlgHQZeFIyNjBjpEVu6rdXzt0L X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-11_01,2022-11-09_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 suspectscore=0 lowpriorityscore=0 mlxscore=0 malwarescore=0 adultscore=0 bulkscore=0 phishscore=0 impostorscore=0 priorityscore=1501 mlxlogscore=535 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211110027 Received-SPF: pass client-ip=205.220.178.238; envelope-from=prvs=83144312e2=bin.meng@windriver.com; helo=mx0b-0064b401.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Guohuai Shi Some definitions currently used by the 9pfs codes are only available on POSIX platforms. Let's add our own ones in preparation to adding 9pfs support for Windows. Signed-off-by: Guohuai Shi Signed-off-by: Bin Meng --- Changes in v2: - Add S_IFLNK related macros to support symbolic link fsdev/file-op-9p.h | 33 +++++++++++++++++++++++++++++++++ hw/9pfs/9p.h | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/fsdev/file-op-9p.h b/fsdev/file-op-9p.h index 4997677460..7d9a736b66 100644 --- a/fsdev/file-op-9p.h +++ b/fsdev/file-op-9p.h @@ -27,6 +27,39 @@ # include #endif +#ifdef CONFIG_WIN32 + +/* POSIX structure not defined in Windows */ + +typedef uint32_t uid_t; +typedef uint32_t gid_t; + +/* from http://man7.org/linux/man-pages/man2/statfs.2.html */ +typedef uint32_t __fsword_t; +typedef uint32_t fsblkcnt_t; +typedef uint32_t fsfilcnt_t; + +/* from linux/include/uapi/asm-generic/posix_types.h */ +typedef struct { + long __val[2]; +} fsid_t; + +struct statfs { + __fsword_t f_type; + __fsword_t f_bsize; + fsblkcnt_t f_blocks; + fsblkcnt_t f_bfree; + fsblkcnt_t f_bavail; + fsfilcnt_t f_files; + fsfilcnt_t f_ffree; + fsid_t f_fsid; + __fsword_t f_namelen; + __fsword_t f_frsize; + __fsword_t f_flags; +}; + +#endif /* CONFIG_WIN32 */ + #define SM_LOCAL_MODE_BITS 0600 #define SM_LOCAL_DIR_MODE_BITS 0700 diff --git a/hw/9pfs/9p.h b/hw/9pfs/9p.h index 2fce4140d1..957a7e4ccc 100644 --- a/hw/9pfs/9p.h +++ b/hw/9pfs/9p.h @@ -3,13 +3,46 @@ #include #include +#ifndef CONFIG_WIN32 #include +#endif #include "fsdev/file-op-9p.h" #include "fsdev/9p-iov-marshal.h" #include "qemu/thread.h" #include "qemu/coroutine.h" #include "qemu/qht.h" +#ifdef CONFIG_WIN32 + +#define NAME_MAX MAX_PATH + +/* macros required for build, values do not matter */ +#define AT_SYMLINK_NOFOLLOW 0x100 /* Do not follow symbolic links */ +#define AT_REMOVEDIR 0x200 /* Remove directory instead of file */ +#define O_DIRECTORY 02000000 + +#define makedev(major, minor) \ + ((dev_t)((((major) & 0xfff) << 8) | ((minor) & 0xff))) +#define major(dev) ((unsigned int)(((dev) >> 8) & 0xfff)) +#define minor(dev) ((unsigned int)(((dev) & 0xff))) + +#ifndef S_IFLNK +/* + * Currenlty Windows/MinGW does not provide the following flag macros, + * so define them here for 9p codes. + * + * Once Windows/MinGW provides them, remove the defines to prevent conflicts. + */ +#define S_IFLNK 0xA000 +#define S_ISUID 0x0800 +#define S_ISGID 0x0400 +#define S_ISVTX 0x0200 + +#define S_ISLNK(mode) ((mode & S_IFMT) == S_IFLNK) +#endif /* S_IFLNK */ + +#endif /* CONFIG_WIN32 */ + enum { P9_TLERROR = 6, P9_RLERROR, From patchwork Fri Nov 11 04:22:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13039637 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id CFC2CC433FE for ; Fri, 11 Nov 2022 04:25:29 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otLZc-0000Xs-Bv; Thu, 10 Nov 2022 23:23:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otLZa-0000WU-Gc for qemu-devel@nongnu.org; Thu, 10 Nov 2022 23:23:22 -0500 Received: from mx0b-0064b401.pphosted.com ([205.220.178.238]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otLZX-0001ZT-2n for qemu-devel@nongnu.org; Thu, 10 Nov 2022 23:23:22 -0500 Received: from pps.filterd (m0250811.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AB4N0iP024928; Fri, 11 Nov 2022 04:23:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=g4+5Nk34AbaSJWhXTaDd8OGNDH5bMbDEK3ah/RPsGKg=; b=KQu2ZhfrxRDhOsrVcgZpazIUPFRdp//AH4BIbaTDJlJdL3Maui941LqvQTJk8yR63GLG bYQtpscoGv5MAJxT2Qssa8n870T7TPhNFqrVWHhKXMPtYn4w4m9VqJyXO12ikdfzqfgs iRP8DCX199ZlAsFQ8S+xdaA3EAo8EajFQwIlvHiqV2PTC4+AfhhTBIVRtyy1Brw0wr3p Q21VQiidigx0veZZ4PkSzQJ+CQmogK+akPRovZZ9GyPDPsWmhdeKTnWJoJIOhzUaDHje ubEWrR/TelXeui5yZyZAbqDq81uS3DPKxdmLOOUFGBVgx+BV2x1nuST/JKZ2v/Y8oK56 0w== Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2103.outbound.protection.outlook.com [104.47.70.103]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3knd21ndvc-7 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 11 Nov 2022 04:23:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lxMeMmP6Qav9gC/eaNb06UV9VvjUrI5CAd8U0k9ybH1s77Gek6Vs1vyWRknsjZXHrzW7vjAyZtT4E27QIq7K9o3PrWZLOeN8M2X/pBwPEP9Tnpek3oACCRgTKoNbX2K8uEso4ElWMWDzjDyyrMbE67Ib4fziMEaNnWSgVzwKk8R6+/ByWWkediDp3siP5eNWFr3Kf9wmz3WyrHlgCCrojcIQ6a+zG2MnpaojNkrnQZSuZg9qtd+RAQrm4qnPxlM180RVFKtWPijLejcV9E8M0vZ3dnFWMgRpUrwbP5w7d9ntOaKLJq//rO5kHW+TZxtC7YqQOpARx+kj8cH/sPEkZg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=g4+5Nk34AbaSJWhXTaDd8OGNDH5bMbDEK3ah/RPsGKg=; b=g6etALYu/GfiJD90eUeNAqU8kBUetVa31SRLYXnIrTh6f6Ip9Kbju3MSvH1CVlW38JYkMa1jR+YNcomrh4+PMh5qxoQoZcbQZ2U4Tu1hFCLrp6Z3kPw0elDVkCOcII56K7aEcoiQUK55vDQWGb/gRtGN2BIFg79DYrKyT3rHgmhyeDmZdG2NGorhT/PDgqgEeAO2QYz99OMUafYayVIeawjMh5bF55hhlfowjTwJMkcGK8XnZ27zMbpoKBcEO6EZvS2PbA46WbFdMhI9ACu8kYuzekVIY4/Om0C53OCCJcIIN57DtYZVG9IgF9UXP5WeotLIZhFSn741lMspqs1iZg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by SJ0PR11MB5102.namprd11.prod.outlook.com (2603:10b6:a03:2ac::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27; Fri, 11 Nov 2022 04:23:01 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::8e5e:71da:1e29:bc15]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::8e5e:71da:1e29:bc15%5]) with mapi id 15.20.5813.013; Fri, 11 Nov 2022 04:23:01 +0000 From: Bin Meng To: qemu-devel@nongnu.org Cc: Guohuai Shi , Christian Schoenebeck , Greg Kurz Subject: [PATCH v2 07/19] hw/9pfs: Implement Windows specific utilities functions for 9pfs Date: Fri, 11 Nov 2022 12:22:13 +0800 Message-Id: <20221111042225.1115931-8-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221111042225.1115931-1-bin.meng@windriver.com> References: <20221111042225.1115931-1-bin.meng@windriver.com> X-ClientProxiedBy: SL2P216CA0138.KORP216.PROD.OUTLOOK.COM (2603:1096:101:1::17) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|SJ0PR11MB5102:EE_ X-MS-Office365-Filtering-Correlation-Id: 99f85fc1-90f9-4681-b30f-08dac39c6b39 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5x7h3wdCerShEvUu80pr1rtRuvpqsh0LUWtqrj8rXrdJzuqkoMuzTtndBWXxa3i4A3+8VJaBqq7GhwcXf6zbmS4X3wHacn1KFjeOU1/A3aO1ULO9YXazmXcukw6iOrKCRCZ9SumDNpg1zPP9XZ7lm6T9+Vmg8FiJpPua6nw0UYFwZdF4Ep/px787HyXP+CmbQg5EjkclK4WLByFOqJVvmu+Z4pcJlvhxTfZnMOxrk5ik5Luhzwcw3RM64nk+qrdM0xV2l8ih0S1dQQ2QpEeqmEt1Art7XmoXuCRXB6rKf8UzvbCrO3SPv1DUVemfA0xX5bSg7YKpuWpsvS0EZX/v7csafF2X98+w/8DUsvc/hdzC1Pcfpd3YGVougTh3uo2vrPmENu0YtWNCQQshjeZjozpQIC+ZBAB6sh8xKyyABGuizwpQ5VRxI7Cm9PAThhbEK+FyvaJZsMMQ4mQpeaOwFetnSu/JWXkbfq9tpFh1sOjPfD/Y9tsBqrcdFJlc6n5Y07NqJFpBRMIbwmpNWur6fN42dNqiFzspIQ6cjyfp+Hxy2RVHHxOVh8OX/FEjPEiYYDNlF2U2KuIIPSBxzNm83owzMCY45a32Xr9ElJiPG90itciktlDw3Bs6Dllwm29bqIs4sZfdqBsc0uTEqmz3Ocdr+W4miJjtRMKqOtrIdEaWWRgiy9gg43zIgu9j5LKP5LwPEmG9kKEw6W4WF6QZTSUFfBj8Iq8xXuM4cmExCXw366gXkKbBNetp5bSIuU2EVWouZfRihRQaE14D8LgpPIrJ7k3Z+tyMqpaUIu2De5g= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5358.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(396003)(346002)(376002)(39850400004)(366004)(136003)(451199015)(66556008)(316002)(86362001)(8676002)(66476007)(66946007)(4326008)(38350700002)(38100700002)(36756003)(44832011)(83380400001)(52116002)(6512007)(2616005)(1076003)(26005)(6506007)(478600001)(6666004)(186003)(6486002)(8936002)(30864003)(41300700001)(6916009)(2906002)(54906003)(5660300002)(21314003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: nn0jAHhJJYVj59WYRnfYuLqVtNOAEeLSg/bfbc5S6VoGmu9KPhCLkFGV2f9UmkGW2iYDo4TBnNVn7DWafNL1xVGSrb4j3TN9VpTsgt65tmb6uenyrj+CMINXcXE7gvMBHAIygbDYzlRX3JF9/714y2uy/QotMQUn71+PtsW9Ab28Efdwc6hXgVN7ObgSH7bSALcM+zNMbiEyzZxwJQpQG8aW7UnhV7aNTrqpoal99HzuVKIGwa2w6NYWn7GjB4tlGuPv/hgAoVTewoNbYJ3Uqi2YDrEP6WttFFEihKDY2tkgsi8rXal3gZDfCPb1XBy7mXEdAF4xuoCvDGMbtu9/D4uOH0dVn7/2u67POUCj/eQzaC9nPp9mvdm4PngQArWF36eFKEi4jebGYM2SZvjz9Cz5xOKr2U0qSFgOe5wtBq0yfXkoLavFh0V78RLVm5Ru9ND9m6iU003lyxLC7XPVDch8M4dxpPhbht/hLKwsG4E++/Db0+dbBr7dSU+eVfBiFepGH1Wab+GaUmm3exBQzDFtpaGFa/dQUae7n3GhjkXw2V3rcKsidtpcFYhz4oG+Kgn0WeKWvH1OIT2lBLSri5NkQCo4fPgysokPkAySXUleUvkWslJ0qeN+3iwKWLjjtUMS4anTPhehbJ0YlrfvlUnu5EKcITJFQwgDcSX4Wnvi3GAeDsZby+cBtTcgdH03Lt436rAN4adRW5mhoxvZ348aof5q612N9d/pxBjJX0ahusLWN9fIEP5LFIHxalD1QhwP9U3Hm+85oR41SMOxiqmUcsRObLf1GVbgwAIQ3w96DQJt1y7WITOERSz+yAof0eqKzRgCetYqel9az/Y7osuNyXmw26NV/M0oQjR5WrZQq44X8SKa1dwLO94Vy01kLishhbhKQKKlhlP9nCiSYHisNNECRdWq0uZnCT4bu8vjIcp6wCJxq8HrfxgG2D762nlIbRHb1rmFlfrJbama4TtViLNgfdkotU+8OGBYtrWWQuFKNw96kBLQv/2oOrJJZ7oBmobz/yz8b6gNNGe+DbiiYxVbhPpxrRpF5ludx6x5iaUQzhowzcmXadb29CGM9LdfGDqT5bLt8mi80HGKsscc7EYWoM0p8aVRdZrHW1p8G1ZqLutrG6QEP6dbLcYAMhhkWd5NBzzuFcL+UZmUP08D56qNqi/FvIdMojiP+ZDxUkl4nXNX95/X7ngwX+ZjgxPBcuKX4YCkiTH7qQLK9YeRll/rQSQ7YA1OflprViEJa02Z6JG87F8wnuBCcnoVp1Ks04TIi4ELEFR72l4PT7zeBnLFff1nU5v5pejhrp7tnmM3Wc7HNPGQst5x/N2q4frtL2aSWtLO/BECj+USBbqkyeRLoO5qJuE12adh6lOiZTDkJhxBmOYirvYtonW2S2mCtXXQE4nJsb3p/WGCT8cQWY8FHpZrfJQmHQmgQr4oeDEtqhxsnuTx51hLlyRfWhGKaltyUlvKALkL1uoSpLTwsLP4Mcl0crgcWdqP91AcsPSkYtFFygFcURnFky2mYniDl+D/FYhr1OYMsz23AM4jbnEGlCmRVf7YaMlK9kP04LnvM0T62RTMWwWxHueH X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 99f85fc1-90f9-4681-b30f-08dac39c6b39 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Nov 2022 04:23:01.0585 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 8ECBGhClZSMkhJbKbbwMPF4U3dt9pxd5YbknUuvrFovxoswUJMIicCdgGcF2iKiLMPhPsp2j/vgLFa2Ua3SZqA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB5102 X-Proofpoint-GUID: e_QCzm5h0h2ylJCjFj54oshcvnkrXuOM X-Proofpoint-ORIG-GUID: e_QCzm5h0h2ylJCjFj54oshcvnkrXuOM X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-11_01,2022-11-09_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 suspectscore=0 lowpriorityscore=0 mlxscore=0 malwarescore=0 adultscore=0 bulkscore=0 phishscore=0 impostorscore=0 priorityscore=1501 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211110027 Received-SPF: pass client-ip=205.220.178.238; envelope-from=prvs=83144312e2=bin.meng@windriver.com; helo=mx0b-0064b401.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Guohuai Shi Windows POSIX API and MinGW library do not provide the NO_FOLLOW flag, and do not allow opening a directory by POSIX open(). This causes all xxx_at() functions cannot work directly. However, we can provide Windows handle based functions to emulate xxx_at() functions (e.g.: openat_win32, utimensat_win32, etc.). NTFS ADS (Alternate Data Streams) is used to emulate 9pfs extended attributes on Windows. Symbolic link is only supported when security model is "mapped-xattr" or "mapped-file". Signed-off-by: Guohuai Shi Signed-off-by: Bin Meng --- Changes in v2: - Support symbolic link when security model is "mapped-xattr" or "mapped-file" hw/9pfs/9p-local.h | 7 + hw/9pfs/9p-util.h | 38 +- hw/9pfs/9p-local.c | 4 - hw/9pfs/9p-util-win32.c | 934 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 978 insertions(+), 5 deletions(-) create mode 100644 hw/9pfs/9p-util-win32.c diff --git a/hw/9pfs/9p-local.h b/hw/9pfs/9p-local.h index 66a21316a0..eb4f39ddc2 100644 --- a/hw/9pfs/9p-local.h +++ b/hw/9pfs/9p-local.h @@ -13,6 +13,13 @@ #ifndef QEMU_9P_LOCAL_H #define QEMU_9P_LOCAL_H +typedef struct { + QemuFd_t mountfd; +#ifdef CONFIG_WIN32 + char *root_path; +#endif +} LocalData; + QemuFd_t local_open_nofollow(FsContext *fs_ctx, const char *path, int flags, mode_t mode); QemuFd_t local_opendir_nofollow(FsContext *fs_ctx, const char *path); diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index 3d6bd1a51e..5fb854bf61 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -88,26 +88,61 @@ static inline int errno_to_dotl(int err) { return err; } -#ifdef CONFIG_DARWIN +#if defined(CONFIG_DARWIN) #define qemu_fgetxattr(...) fgetxattr(__VA_ARGS__, 0, 0) +#elif defined(CONFIG_WIN32) +#define qemu_fgetxattr fgetxattr_win32 #else #define qemu_fgetxattr fgetxattr #endif +#ifdef CONFIG_WIN32 +#define qemu_openat openat_win32 +#define qemu_fstatat fstatat_win32 +#define qemu_mkdirat mkdirat_win32 +#define qemu_renameat renameat_win32 +#define qemu_utimensat utimensat_win32 +#define qemu_unlinkat unlinkat_win32 +#else #define qemu_openat openat #define qemu_fstatat fstatat #define qemu_mkdirat mkdirat #define qemu_renameat renameat #define qemu_utimensat utimensat #define qemu_unlinkat unlinkat +#endif + +#ifdef CONFIG_WIN32 +char *get_full_path_win32(QemuFd_t fd, const char *name); +ssize_t fgetxattr_win32(int fd, const char *name, void *value, size_t size); +QemuFd_t openat_win32(QemuFd_t dirfd, const char *pathname, int flags, + mode_t mode); +int fstatat_win32(QemuFd_t dirfd, const char *pathname, + struct stat *statbuf, int flags); +int mkdirat_win32(QemuFd_t dirfd, const char *pathname, mode_t mode); +int renameat_win32(QemuFd_t olddirfd, const char *oldpath, + QemuFd_t newdirfd, const char *newpath); +int utimensat_win32(QemuFd_t dirfd, const char *pathname, + const struct timespec times[2], int flags); +int unlinkat_win32(QemuFd_t dirfd, const char *pathname, int flags); +int statfs_win32(const char *root_path, struct statfs *stbuf); +QemuFd_t openat_dir(QemuFd_t dirfd, const char *name); +QemuFd_t openat_file(QemuFd_t dirfd, const char *name, int flags, + mode_t mode); +#endif static inline void close_preserve_errno(QemuFd_t fd) { int serrno = errno; +#ifndef CONFIG_WIN32 close(fd); +#else + CloseHandle(fd); +#endif errno = serrno; } +#ifndef CONFIG_WIN32 static inline QemuFd_t openat_dir(QemuFd_t dirfd, const char *name) { return qemu_openat(dirfd, name, @@ -155,6 +190,7 @@ again: errno = serrno; return fd; } +#endif ssize_t fgetxattrat_nofollow(QemuFd_t dirfd, const char *path, const char *name, void *value, size_t size); diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index 22377a3105..24e21141d5 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -53,10 +53,6 @@ #define BTRFS_SUPER_MAGIC 0x9123683E #endif -typedef struct { - QemuFd_t mountfd; -} LocalData; - QemuFd_t local_open_nofollow(FsContext *fs_ctx, const char *path, int flags, mode_t mode) { diff --git a/hw/9pfs/9p-util-win32.c b/hw/9pfs/9p-util-win32.c new file mode 100644 index 0000000000..ed3d519937 --- /dev/null +++ b/hw/9pfs/9p-util-win32.c @@ -0,0 +1,934 @@ +/* + * 9p utilities (Windows Implementation) + * + * Copyright (c) 2022 Wind River Systems, Inc. + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +/* + * This file contains Windows only functions for 9pfs. + * + * For 9pfs Windows host, the following features are different from Linux host: + * + * 1. Windows POSIX API does not provide the NO_FOLLOW flag, that means MinGW + * cannot detect if a path is a symbolic link or not. Also Windows do not + * provide POSIX compatible readlink(). Supporting symbolic link in 9pfs on + * Windows may cause security issues, so symbolic link support is disabled + * completely for security model "none" or "passthrough". + * + * 2. Windows file system does not support extended attributes directly. 9pfs + * for Windows uses NTFS ADS (Alternate Data Streams) to emulate extended + * attributes. + * + * 3. statfs() is not available on Windows. qemu_statfs() is used to emulate it. + * + * 4. On Windows trying to open a directory with the open() API will fail. + * This is because Windows does not allow opening directory in normal usage. + * + * As a result of this, all xxx_at() functions won't work directly on + * Windows, e.g.: openat(), unlinkat(), etc. + * + * As xxx_at() can prevent parent directory to be modified on Linux host, + * to support this and prevent security issue, all xxx_at() APIs are replaced + * by xxx_at_win32() and Windows handle is used to replace the directory fd. + * + * Windows file system does not allow replacing a file or directory if it is + * referenced by a handle. Keep the handle open will lock and protect the + * parent directory and make the access to files atomically. + * + * If we don't protect (lock) the parent directory, the parent directory may + * be replaced by others (e.g.: a symbolic link) and cause security issues. + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qemu/error-report.h" +#include "9p.h" +#include "9p-util.h" +#include "9p-local.h" + +#include +#include + +#define V9FS_MAGIC 0x53465039 /* string "9PFS" */ + +/* + * build_ads_name - construct Windows ADS name + * + * This function constructs Windows NTFS ADS (Alternate Data Streams) name + * to . + */ +static int build_ads_name(char *namebuf, size_t namebuf_len, + const char *filename, const char *ads_name) +{ + size_t total_size; + + total_size = strlen(filename) + strlen(ads_name) + 2; + if (total_size > namebuf_len) { + return -1; + } + + /* + * NTFS ADS (Alternate Data Streams) name format: filename:ads_name + * e.g.: D:\1.txt:my_ads_name + */ + + strcpy(namebuf, filename); + strcat(namebuf, ":"); + strcat(namebuf, ads_name); + + return 0; +} + +/* + * copy_ads_name - copy ADS name from buffer returned by FindNextStreamW() + * + * This function removes string "$DATA" in ADS name string returned by + * FindNextStreamW(), and copies the real ADS name to . + */ +static ssize_t copy_ads_name(char *namebuf, size_t namebuf_len, + char *full_ads_name) +{ + char *p1, *p2; + + /* + * NTFS ADS (Alternate Data Streams) name from enumerate data format: + * :ads_name:$DATA, e.g.: :my_ads_name:$DATA + * + * ADS name from FindNextStreamW() always has ":$DATA" string at the end. + * + * This function copies ADS name to namebuf. + */ + + p1 = strchr(full_ads_name, ':'); + if (p1 == NULL) { + return -1; + } + + p2 = strchr(p1 + 1, ':'); + if (p2 == NULL) { + return -1; + } + + /* skip empty ads name */ + if (p2 - p1 == 1) { + return 0; + } + + if (p2 - p1 + 1 > namebuf_len) { + return -1; + } + + memcpy(namebuf, p1 + 1, p2 - p1 - 1); + namebuf[p2 - p1 - 1] = '\0'; + + return p2 - p1; +} + +/* + * get_full_path_win32 - get full file name base on a handle + * + * This function gets full file name based on a handle specified by to + * a file or directory. + * + * Caller function needs to free the file name string after use. + */ +char *get_full_path_win32(QemuFd_t fd, const char *name) +{ + g_autofree char *full_file_name = NULL; + DWORD total_size; + DWORD name_size; + + full_file_name = g_malloc0(NAME_MAX); + + /* get parent directory full file name */ + name_size = GetFinalPathNameByHandle(fd, full_file_name, + NAME_MAX - 1, FILE_NAME_NORMALIZED); + if (name_size == 0 || name_size > NAME_MAX - 1) { + return NULL; + } + + /* full path returned is the "\\?\" syntax, remove the lead string */ + memmove(full_file_name, full_file_name + 4, NAME_MAX - 4); + + if (name != NULL) { + total_size = strlen(full_file_name) + strlen(name) + 2; + + if (total_size > NAME_MAX) { + return NULL; + } + + /* build sub-directory file name */ + strcat(full_file_name, "\\"); + strcat(full_file_name, name); + } + + return g_steal_pointer(&full_file_name); +} + +/* + * fgetxattr_win32 - get extended attribute by fd + * + * This function gets extened attribute by . will be translated to + * Windows handle. + * + * This function emulates extended attribute by NTFS ADS. + */ +ssize_t fgetxattr_win32(int fd, const char *name, void *value, size_t size) +{ + g_autofree char *full_file_name = NULL; + char ads_file_name[NAME_MAX + 1] = {0}; + DWORD dwBytesRead; + HANDLE hStream; + HANDLE hFile; + + hFile = (HANDLE)_get_osfhandle(fd); + + full_file_name = get_full_path_win32(hFile, NULL); + if (full_file_name == NULL) { + errno = EIO; + return -1; + } + + if (build_ads_name(ads_file_name, NAME_MAX, full_file_name, name) < 0) { + errno = EIO; + return -1; + } + + hStream = CreateFile(ads_file_name, GENERIC_READ, FILE_SHARE_READ, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (hStream == INVALID_HANDLE_VALUE && + GetLastError() == ERROR_FILE_NOT_FOUND) { + errno = ENODATA; + return -1; + } + + if (ReadFile(hStream, value, size, &dwBytesRead, NULL) == FALSE) { + errno = EIO; + CloseHandle(hStream); + return -1; + } + + CloseHandle(hStream); + + return dwBytesRead; +} + +/* + * openat_win32 - emulate openat() + * + * This function emulates openat(). + * + * Windows POSIX API does not support opening a directory by open(). Only + * handle of directory can be opened by CreateFile(). + * + * So openat_win32() has to use a directory handle instead of a directory fd. + * + * For symbolic access: + * 1. Parent directory handle should not be a symbolic link because + * it is opened by openat_dir() which can prevent from opening a link to + * a dirctory. + * 2. Link flag in is not set because Windows does not have this flag. + * Create a new symbolic link will be denied. + * 3. This function checks file symbolic link attribute after open. + * + * So symbolic link will not be accessed by 9p client. + */ +QemuFd_t openat_win32(QemuFd_t dirfd, const char *pathname, int flags, + mode_t mode) +{ + g_autofree char *full_file_name1 = NULL; + g_autofree char *full_file_name2 = NULL; + HANDLE hFile = INVALID_HANDLE_VALUE; + int fd; + + full_file_name1 = get_full_path_win32(dirfd, pathname); + if (full_file_name1 == NULL) { + return hFile; + } + + fd = open(full_file_name1, flags, mode); + if (fd > 0) { + DWORD attribute; + hFile = (HANDLE)_get_osfhandle(fd); + + full_file_name2 = get_full_path_win32(hFile, NULL); + attribute = GetFileAttributes(full_file_name2); + + /* check if it is a symbolic link */ + if ((attribute == INVALID_FILE_ATTRIBUTES) + || (attribute & FILE_ATTRIBUTE_REPARSE_POINT) != 0) { + errno = EACCES; + hFile = INVALID_HANDLE_VALUE; + close(fd); + } + } + + return hFile; +} + +/* + * fstatat_win32 - emulate fstatat() + * + * This function emulates fstatat(). + * + * Windows POSIX API does not support opening a directory by open(). Only + * handle of directory can be opened by CreateFile(). + * + * So fstatat_win32() has to use a directory handle instead of a directory fd. + * + * Access to a symbolic link will be denied to prevent security issues. + */ +int fstatat_win32(QemuFd_t dirfd, const char *pathname, + struct stat *statbuf, int flags) +{ + g_autofree char *full_file_name = NULL; + HANDLE hFile = INVALID_HANDLE_VALUE; + BY_HANDLE_FILE_INFORMATION file_info; + DWORD attribute; + int err = 0; + int ret = -1; + ino_t st_ino; + + full_file_name = get_full_path_win32(dirfd, pathname); + if (full_file_name == NULL) { + return ret; + } + + /* open file to lock it */ + hFile = CreateFile(full_file_name, GENERIC_READ, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, + NULL, + OPEN_EXISTING, + FILE_FLAG_BACKUP_SEMANTICS + | FILE_FLAG_OPEN_REPARSE_POINT, + NULL); + + if (hFile == INVALID_HANDLE_VALUE) { + err = EACCES; + goto out; + } + + attribute = GetFileAttributes(full_file_name); + + /* check if it is a symbolic link */ + if ((attribute == INVALID_FILE_ATTRIBUTES) + || (attribute & FILE_ATTRIBUTE_REPARSE_POINT) != 0) { + errno = EACCES; + goto out; + } + + ret = stat(full_file_name, statbuf); + + if (GetFileInformationByHandle(hFile, &file_info) == 0) { + errno = EACCES; + goto out; + } + + /* + * Windows (NTFS) file ID is a 64-bit ID: + * 16-bit sequence ID + 48 bit segment number + * + * But currently, ino_t defined in Windows header file is only 16-bit, + * and it is not patched by MinGW. So we build a pseudo inode number + * by the low 32-bit segment number when ino_t is only 16-bit. + */ + if (sizeof(st_ino) == sizeof(uint64_t)) { + st_ino = (ino_t)((uint64_t)file_info.nFileIndexLow + | (((uint64_t)file_info.nFileIndexHigh) << 32)); + } else if (sizeof(st_ino) == sizeof(uint16_t)) { + st_ino = (ino_t)(((uint16_t)file_info.nFileIndexLow) + ^ ((uint16_t)(file_info.nFileIndexLow >> 16))); + } else { + st_ino = (ino_t)file_info.nFileIndexLow; + } + + statbuf->st_ino = st_ino; + +out: + if (hFile != INVALID_HANDLE_VALUE) { + CloseHandle(hFile); + } + + if (err != 0) { + errno = err; + } + return ret; +} + +/* + * mkdirat_win32 - emulate mkdirat() + * + * This function emulates mkdirat(). + * + * Windows POSIX API does not support opening a directory by open(). Only + * handle of directory can be opened by CreateFile(). + * + * So mkdirat_win32() has to use a directory handle instead of a directory fd. + */ +int mkdirat_win32(QemuFd_t dirfd, const char *pathname, mode_t mode) +{ + g_autofree char *full_file_name = NULL; + int ret = -1; + + full_file_name = get_full_path_win32(dirfd, pathname); + if (full_file_name == NULL) { + return ret; + } + + ret = mkdir(full_file_name); + + return ret; +} + +/* + * renameat_win32 - emulate renameat() + * + * This function emulates renameat(). + * + * Windows POSIX API does not support openning a directory by open(). Only + * handle of directory can be opened by CreateFile(). + * + * So renameat_win32() has to use a directory handle instead of a directory fd. + * + * Access to a symbolic link will be denied to prevent security issues. + */ +int renameat_win32(HANDLE olddirfd, const char *oldpath, + HANDLE newdirfd, const char *newpath) +{ + g_autofree char *full_old_name = NULL; + g_autofree char *full_new_name = NULL; + HANDLE hFile; + DWORD attribute; + int err = 0; + int ret = -1; + + full_old_name = get_full_path_win32(olddirfd, oldpath); + full_new_name = get_full_path_win32(newdirfd, newpath); + if (full_old_name == NULL || full_new_name == NULL) { + return ret; + } + + /* open file to lock it */ + hFile = CreateFile(full_old_name, GENERIC_READ, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, + NULL, + OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); + + attribute = GetFileAttributes(full_old_name); + + /* check if it is a symbolic link */ + if ((attribute == INVALID_FILE_ATTRIBUTES) + || (attribute & FILE_ATTRIBUTE_REPARSE_POINT) != 0) { + err = EACCES; + goto out; + } + + CloseHandle(hFile); + + ret = rename(full_old_name, full_new_name); +out: + if (err != 0) { + errno = err; + } + return ret; +} + +/* + * utimensat_win32 - emulate utimensat() + * + * This function emulates utimensat(). + * + * Windows POSIX API does not support opening a directory by open(). Only + * handle of directory can be opened by CreateFile(). + * + * So utimensat_win32() has to use a directory handle instead of a directory fd. + * + * Access to a symbolic link will be denied to prevent security issues. + */ +int utimensat_win32(QemuFd_t dirfd, const char *pathname, + const struct timespec times[2], int flags) +{ + g_autofree char *full_file_name = NULL; + HANDLE hFile = INVALID_HANDLE_VALUE; + DWORD attribute; + struct utimbuf tm; + int err = 0; + int ret = -1; + + full_file_name = get_full_path_win32(dirfd, pathname); + if (full_file_name == NULL) { + return ret; + } + + /* open file to lock it */ + hFile = CreateFile(full_file_name, GENERIC_READ, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, + NULL, + OPEN_EXISTING, + FILE_FLAG_BACKUP_SEMANTICS + | FILE_FLAG_OPEN_REPARSE_POINT, + NULL); + + if (hFile == INVALID_HANDLE_VALUE) { + err = EACCES; + goto out; + } + + attribute = GetFileAttributes(full_file_name); + + /* check if it is a symbolic link */ + if ((attribute == INVALID_FILE_ATTRIBUTES) + || (attribute & FILE_ATTRIBUTE_REPARSE_POINT) != 0) { + errno = EACCES; + goto out; + } + + tm.actime = times[0].tv_sec; + tm.modtime = times[1].tv_sec; + + ret = utime(full_file_name, &tm); + +out: + if (hFile != INVALID_HANDLE_VALUE) { + CloseHandle(hFile); + } + + if (err != 0) { + errno = err; + } + return ret; +} + +/* + * unlinkat_win32 - emulate unlinkat() + * + * This function emulates unlinkat(). + * + * Windows POSIX API does not support opening a directory by open(). Only + * handle of directory can be opened by CreateFile(). + * + * So unlinkat_win32() has to use a directory handle instead of a directory fd. + * + * Access to a symbolic link will be denied to prevent security issues. + */ + +int unlinkat_win32(QemuFd_t dirfd, const char *pathname, int flags) +{ + g_autofree char *full_file_name = NULL; + HANDLE hFile; + DWORD attribute; + int err = 0; + int ret = -1; + + full_file_name = get_full_path_win32(dirfd, pathname); + if (full_file_name == NULL) { + return ret; + } + + /* open file to prevent other one modify it */ + hFile = CreateFile(full_file_name, GENERIC_READ, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, + NULL, + OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); + + attribute = GetFileAttributes(full_file_name); + + /* check if it is a symbolic link */ + if ((attribute == INVALID_FILE_ATTRIBUTES) + || (attribute & FILE_ATTRIBUTE_REPARSE_POINT) != 0) { + err = EACCES; + goto out; + } + + if (flags == AT_REMOVEDIR) { /* remove directory */ + if ((attribute & FILE_ATTRIBUTE_DIRECTORY) == 0) { + err = ENOTDIR; + goto out; + } + ret = rmdir(full_file_name); + } else { /* remove regular file */ + if ((attribute & FILE_ATTRIBUTE_DIRECTORY) != 0) { + err = EISDIR; + goto out; + } + ret = remove(full_file_name); + } + + /* after last handle closed, file will be removed */ + CloseHandle(hFile); + +out: + if (err != 0) { + errno = err; + } + return ret; +} + +/* + * statfs_win32 - statfs() on Windows + * + * This function emulates statfs() on Windows host. + */ +int statfs_win32(const char *path, struct statfs *stbuf) +{ + char RealPath[4] = { 0 }; + unsigned long SectorsPerCluster; + unsigned long BytesPerSector; + unsigned long NumberOfFreeClusters; + unsigned long TotalNumberOfClusters; + + /* only need first 3 bytes, e.g. "C:\ABC", only need "C:\" */ + memcpy(RealPath, path, 3); + + if (GetDiskFreeSpace(RealPath, &SectorsPerCluster, &BytesPerSector, + &NumberOfFreeClusters, &TotalNumberOfClusters) == 0) { + errno = EIO; + return -1; + } + + stbuf->f_type = V9FS_MAGIC; + stbuf->f_bsize = + (__fsword_t)SectorsPerCluster * (__fsword_t)BytesPerSector; + stbuf->f_blocks = (fsblkcnt_t)TotalNumberOfClusters; + stbuf->f_bfree = (fsblkcnt_t)NumberOfFreeClusters; + stbuf->f_bavail = (fsblkcnt_t)NumberOfFreeClusters; + stbuf->f_files = -1; + stbuf->f_ffree = -1; + stbuf->f_namelen = NAME_MAX; + stbuf->f_frsize = 0; + stbuf->f_flags = 0; + + return 0; +} + +/* + * openat_dir - emulate openat_dir() + * + * This function emulates openat_dir(). + * + * Windows POSIX API does not support opening a directory by open(). Only + * handle of directory can be opened by CreateFile(). + * + * So openat_dir() has to use a directory handle instead of a directory fd. + * + * Access to a symbolic link will be denied to prevent security issues. + */ +QemuFd_t openat_dir(QemuFd_t dirfd, const char *name) +{ + g_autofree char *full_file_name = NULL; + HANDLE hSubDir; + DWORD attribute; + + full_file_name = get_full_path_win32(dirfd, name); + if (full_file_name == NULL) { + return INVALID_HANDLE_VALUE; + } + + attribute = GetFileAttributes(full_file_name); + if (attribute == INVALID_FILE_ATTRIBUTES) { + return INVALID_HANDLE_VALUE; + } + + /* check if it is a directory */ + if ((attribute & FILE_ATTRIBUTE_DIRECTORY) == 0) { + return INVALID_HANDLE_VALUE; + } + + /* do not allow opening a symbolic link */ + if ((attribute & FILE_ATTRIBUTE_REPARSE_POINT) != 0) { + return INVALID_HANDLE_VALUE; + } + + /* open it */ + hSubDir = CreateFile(full_file_name, GENERIC_READ, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, + NULL, + OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); + return hSubDir; +} + +QemuFd_t openat_file(QemuFd_t dirfd, const char *name, int flags, + mode_t mode) +{ + return openat_win32(dirfd, name, flags | _O_BINARY, mode); +} + +/* + * fgetxattrat_nofollow - get extended attribute + * + * This function gets extended attribute from file in the directory + * specified by . The extended atrribute name is specified by + * and return value will be put in . + * + * This function emulates extended attribute by NTFS ADS. + */ +ssize_t fgetxattrat_nofollow(QemuFd_t dirfd, const char *path, + const char *name, void *value, size_t size) +{ + g_autofree char *full_file_name = NULL; + char ads_file_name[NAME_MAX + 1] = { 0 }; + DWORD dwBytesRead; + HANDLE hStream; + + full_file_name = get_full_path_win32(dirfd, path); + if (full_file_name == NULL) { + errno = EIO; + return -1; + } + + if (build_ads_name(ads_file_name, NAME_MAX, full_file_name, name) < 0) { + errno = EIO; + return -1; + } + + hStream = CreateFile(ads_file_name, GENERIC_READ, FILE_SHARE_READ, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (hStream == INVALID_HANDLE_VALUE && + GetLastError() == ERROR_FILE_NOT_FOUND) { + errno = ENODATA; + return -1; + } + + if (ReadFile(hStream, value, size, &dwBytesRead, NULL) == FALSE) { + errno = EIO; + CloseHandle(hStream); + return -1; + } + + CloseHandle(hStream); + + return dwBytesRead; +} + +/* + * fsetxattrat_nofollow - set extended attribute + * + * This function set extended attribute to file in the directory + * specified by . + * + * This function emulates extended attribute by NTFS ADS. + */ + +int fsetxattrat_nofollow(QemuFd_t dirfd, const char *path, const char *name, + void *value, size_t size, int flags) +{ + g_autofree char *full_file_name = NULL; + char ads_file_name[NAME_MAX + 1] = { 0 }; + DWORD dwBytesWrite; + HANDLE hStream; + + full_file_name = get_full_path_win32(dirfd, path); + if (full_file_name == NULL) { + errno = EIO; + return -1; + } + + if (build_ads_name(ads_file_name, NAME_MAX, full_file_name, name) < 0) { + errno = EIO; + return -1; + } + + hStream = CreateFile(ads_file_name, GENERIC_WRITE, FILE_SHARE_READ, NULL, + CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + if (hStream == INVALID_HANDLE_VALUE) { + errno = EIO; + return -1; + } + + if (WriteFile(hStream, value, size, &dwBytesWrite, NULL) == FALSE) { + errno = EIO; + CloseHandle(hStream); + return -1; + } + + CloseHandle(hStream); + + return 0; +} + +/* + * flistxattrat_nofollow - list extended attribute + * + * This function gets extended attribute lists from file in the + * directory specified by . Lists returned will be put in . + * + * This function emulates extended attribute by NTFS ADS. + */ +ssize_t flistxattrat_nofollow(QemuFd_t dirfd, const char *filename, + char *list, size_t size) +{ + g_autofree char *full_file_name = NULL; + WCHAR WideCharStr[NAME_MAX + 1] = { 0 }; + char full_ads_name[NAME_MAX + 1]; + WIN32_FIND_STREAM_DATA fsd; + BOOL bFindNext; + char *list_ptr = list; + size_t list_left_size = size; + HANDLE hFind; + int ret; + + full_file_name = get_full_path_win32(dirfd, filename); + if (full_file_name == NULL) { + errno = EIO; + return -1; + } + + /* + * ADS enumerate function only has WCHAR version, so we need to + * covert filename to utf-8 string. + */ + ret = MultiByteToWideChar(CP_UTF8, 0, full_file_name, + strlen(full_file_name), WideCharStr, NAME_MAX); + if (ret == 0) { + errno = EIO; + return -1; + } + + hFind = FindFirstStreamW(WideCharStr, FindStreamInfoStandard, &fsd, 0); + if (hFind == INVALID_HANDLE_VALUE) { + errno = ENODATA; + return -1; + } + + do { + memset(full_ads_name, 0, sizeof(full_ads_name)); + + /* + * ADS enumerate function only has WCHAR version, so we need to + * covert cStreamName to utf-8 string. + */ + ret = WideCharToMultiByte(CP_UTF8, 0, + fsd.cStreamName, wcslen(fsd.cStreamName) + 1, + full_ads_name, sizeof(full_ads_name) - 1, + NULL, NULL); + if (ret == 0) { + if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) { + errno = ERANGE; + } + CloseHandle(hFind); + return -1; + } + + ret = copy_ads_name(list_ptr, list_left_size, full_ads_name); + if (ret < 0) { + errno = ERANGE; + CloseHandle(hFind); + return -1; + } + + list_ptr = list_ptr + ret; + list_left_size = list_left_size - ret; + + bFindNext = FindNextStreamW(hFind, &fsd); + } while (bFindNext); + + CloseHandle(hFind); + + return size - list_left_size; +} + +/* + * fremovexattrat_nofollow - remove extended attribute + * + * This function removes an extended attribute from file in the + * directory specified by . + * + * This function emulates extended attribute by NTFS ADS. + */ +ssize_t fremovexattrat_nofollow(QemuFd_t dirfd, const char *filename, + const char *name) +{ + g_autofree char *full_file_name = NULL; + char ads_file_name[NAME_MAX + 1] = { 0 }; + + full_file_name = get_full_path_win32(dirfd, filename); + if (full_file_name == NULL) { + errno = EIO; + return -1; + } + + if (build_ads_name(ads_file_name, NAME_MAX, filename, name) < 0) { + errno = EIO; + return -1; + } + + if (DeleteFile(ads_file_name) != 0) { + if (GetLastError() == ERROR_FILE_NOT_FOUND) { + errno = ENODATA; + return -1; + } + } + + return 0; +} + +/* + * local_opendir_nofollow - open a Windows directory + * + * This function returns a Windows file handle of the directory specified by + * based on 9pfs mount point. + * + * Windows POSIX API does not support opening a directory by open(). Only + * handle of directory can be opened by CreateFile(). + * + * This function checks the resolved path of . If the resolved + * path is not in the scope of root directory (e.g. by symbolic link), then + * this function will fail to prevent any security issues. + */ +HANDLE local_opendir_nofollow(FsContext *fs_ctx, const char *dirpath) +{ + g_autofree char *full_file_name = NULL; + LocalData *data = fs_ctx->private; + HANDLE hDir; + + hDir = openat_dir(data->mountfd, dirpath); + if (hDir == INVALID_HANDLE_VALUE) { + return INVALID_HANDLE_VALUE; + } + + full_file_name = get_full_path_win32(hDir, NULL); + if (full_file_name == NULL) { + CloseHandle(hDir); + return INVALID_HANDLE_VALUE; + } + + /* + * Check if the resolved path is in the root directory scope: + * data->root_path and full_file_name are full path with symbolic + * link resolved, so fs_ctx->root_path must be in the head of + * full_file_name. If not, that means guest OS tries to open a file not + * in the scope of mount point. This operation should be denied. + */ + if (memcmp(full_file_name, data->root_path, + strlen(data->root_path)) != 0) { + CloseHandle(hDir); + hDir = INVALID_HANDLE_VALUE; + } + + return hDir; +} + +/* + * qemu_mknodat - mknodat emulate function + * + * This function emulates mknodat on Windows. It only works when security + * model is mapped or mapped-xattr. + */ +int qemu_mknodat(QemuFd_t dirfd, const char *filename, mode_t mode, dev_t dev) +{ + if (S_ISREG(mode) || !(mode & S_IFMT)) { + HANDLE hFile = openat_file(dirfd, filename, O_CREAT, mode); + if (hFile == INVALID_HANDLE_VALUE) { + return -1; + } + close_preserve_errno(hFile); + return 0; + } + + error_report_once("Unsupported operation for mknodat"); + errno = ENOTSUP; + return -1; +} From patchwork Fri Nov 11 04:22:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13039631 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 919D8C4332F for ; Fri, 11 Nov 2022 04:24:38 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otLZb-0000Wx-LT; Thu, 10 Nov 2022 23:23:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otLZa-0000W8-A1 for qemu-devel@nongnu.org; Thu, 10 Nov 2022 23:23:22 -0500 Received: from mx0a-0064b401.pphosted.com ([205.220.166.238]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otLZX-0001Zj-Bs for qemu-devel@nongnu.org; Thu, 10 Nov 2022 23:23:22 -0500 Received: from pps.filterd (m0250810.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AB4N5DM004957; Thu, 10 Nov 2022 20:23:06 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=s601e/7v4tldu0dGoFfcjj104NlHNzgzG04TEzou+Io=; b=cQq72DevbIdQ8LkyTaMS0vn8KT1FWj3vNwkUWRHkmEkfO8s76Rz0lJ9fBMWYFkDTdkGN u9sFv2BT1DpgjRUqVKNLQM2slnwx1oviFlWZL95xrzor+VnghzdmGoN599ildP+INOXY s21yOFS5avjBDMMRKUN1rukAZjdXP1UXKkOq0ms1of5IT2FrLXXK98sPSGMVllQ4HGs0 NZ+MsQIj+fdCurVf0xOzPdtw0fITLGufX+soz0AiMx175+IWttdwWomwKEKM+I4XyO7c p2QCTBvtaE9O0Iyhijc81RVvlQTzwpY6b8c2xdUA0XNpBtWNbYS8WqoHNik3pQJ5e2VD Qg== Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2169.outbound.protection.outlook.com [104.47.56.169]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3knk43d9m3-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Nov 2022 20:23:06 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jnqmCvDDhk4DR3BTAtuJRpeNMLiLiqrHqJvvAnTGhfNoBDf++9eEt1AUY10ra3Oh6Xe6cfFvqQogBNvKNLlVoJzAUgRrJ+A7o427aSb3jWdFDKocJDQnHZn54hbja3OgGQLHPpK0PqxXcF+4QjZRP1B8coUgZ2L/DE5dvX/xyD7yhDXYQArqZGEVf/gNDc2gxFbmz9c3KGXhBp61hWnkIpldUpIR3x8N9TEJ5k/IgeXF84PUjDtDisSVofpVy1ntPqpkiuTi9L2xCEXu5xMTAZTL5naeoTQiwUi6iwOgX9AaSZj3nzy2eAXoMgXXdnOSSOqCUHPziBtitA6UDemCdw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=s601e/7v4tldu0dGoFfcjj104NlHNzgzG04TEzou+Io=; b=gmhJ1MIdOq1/LYqmsD3PGDaOp755KzZL2X03n9s78hn39cqqkBIs2GriFVzFm3zsss3Xk64PXg8/ib4QLvV6b3rdVTy9AVhXOC6hVUFI74dIGnNFvK7dCAciXNf6L5BxwApyxGRhmXNH0ZRWJd+Ci/nbfJpZWdr3pYUGqet3mY7i56OzAr3lShXyvKJu/lfqhVqd7tdUkHrTeJDBJR1Q7uTeHjog/CTXAeUWBfocb3986N4AgyHQGVzBEzyOjCQ5EVJqbx4q5vlWYFAX1E8BAft+h3vTflALy/DB2WwKAiMahYk67NSP8UT+ygSaCUIn+IQj5MFaiEokGQfARFcVhQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by SJ0PR11MB5102.namprd11.prod.outlook.com (2603:10b6:a03:2ac::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27; Fri, 11 Nov 2022 04:23:03 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::8e5e:71da:1e29:bc15]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::8e5e:71da:1e29:bc15%5]) with mapi id 15.20.5813.013; Fri, 11 Nov 2022 04:23:03 +0000 From: Bin Meng To: qemu-devel@nongnu.org Cc: Guohuai Shi , Christian Schoenebeck , Greg Kurz Subject: [PATCH v2 08/19] hw/9pfs: Update the local fs driver to support Windows Date: Fri, 11 Nov 2022 12:22:14 +0800 Message-Id: <20221111042225.1115931-9-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221111042225.1115931-1-bin.meng@windriver.com> References: <20221111042225.1115931-1-bin.meng@windriver.com> X-ClientProxiedBy: SL2P216CA0138.KORP216.PROD.OUTLOOK.COM (2603:1096:101:1::17) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|SJ0PR11MB5102:EE_ X-MS-Office365-Filtering-Correlation-Id: e741222e-37a8-4b00-ac5c-08dac39c6c9f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RnMprc5k+4HRVnimlrcO8k1li2eQy7VyKQv5aaSIRY+Co/y9vn4uxpDDi1isgTk8/pIOc97wJtMA/ohR78UM/pFmboZxvtowYvYAClZYnhYEqeTsP8UTNO/gK3Wc6SpZ8ssIWQeCZBZcEO6dOcWQ6Zt2BGBnn/inOLNb9PVJ42UNL18dawSbyt4W+7L4HCXOvfM9YVPgTAuzhx4bQ6VlCjgZPntY8R6kr7XsyDrB045HH0VI9i04k2d97x6pooPGfa4e76ZbdziXuw01D+38jp1tBshQJcekBysYJ2ABdNJLL35HnHizRSac4JyK0KbMRRYoG+47AJ9C3n1I4ze+0Cm/0rvWidQ1LBs5GF4G/fnqUqTEnqJUyHw5bh/bCI6XQY/Ai7AGehZNIEc1r3S6xRZIhv3DOyklhPpfToRiuiu2Fu4HFQa88l8fQJM2WsIDUf2HDK6K70zGeAiKUuNv6Aro3DvCejL79FswB/vucQFrE1PC0Lsb3BCpvOt+pgE5SDhU66yD9m/jUNvyVt/UcPqyO00wxyTokzDwqI8pHdB5xp/cpaZKzrjaBoTeiHdVC0OicfG68SccXqOdLhcFTp1ATHfEJbf07o0x7MY/s1fJM1t+OIOeFStOWKi2VY5WzSn9A87qTT386xmWpHwY10/W7RHUJsZi6m+ZTL2h+B48iM8+48k2HgMSqE/oNRSUoWY0HRqQjC7X+m3u7q0a7/C2JI6Z4H9XiEtl+umQ8CF/T5LxOFVgXVqHZSeXvLSFYeU8V/tA++nd2+TSmXDvCQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5358.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(396003)(346002)(376002)(39850400004)(366004)(136003)(451199015)(66556008)(316002)(86362001)(8676002)(66476007)(66946007)(4326008)(38350700002)(38100700002)(36756003)(44832011)(83380400001)(52116002)(6512007)(2616005)(1076003)(26005)(6506007)(478600001)(6666004)(186003)(6486002)(8936002)(30864003)(41300700001)(15650500001)(6916009)(2906002)(54906003)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: iwmWvxGoqkQZDOUeaTgE+rfcUKiRwXiS2zJDbZjEw5O9IuHleUq2LhHyIZnojQv2N9nXc6XNXWgDFsnLcvm/oRmkIsJV7EFKg6hWUk6TzaCxhVHZMeZ4Rr4S1UByxXRvAuBqiwUwfT9/BRbEmDnnaUtQzvtMeX2XBI191UoMtFh54ZZzx8TFBlSGbm6tFDnKJuMkMtN7/J3zynOOL8Zt+kp4g3zFRvsPYTqD1tTY3PAM4FDd8J9Fi/NrTD6Y8YJg5ujpad7oQeeBl2HWD0YTmPfBhod0RDnf1ygpGKYeCotuHqFk7+twJc/ZWytFrPr+0CDPpmGmqJwvZfwKY97pFT9cohe9+2p30tS5TkNQlTi47bA2BLxjem9wfanXaEQ8E2nhyolUZTnD3wsrbJRqya4lWfTT/cmyyOJvCh4Qa/aSU5k8N+zKd5V2zkJRdOEsSD83Q2ajp/emPvFDt/sgr7tb1kajKtuRfRt+kD/9O3m3I/DSRb1ZZmGpxdt0bd2RzxwgfvKokX8O6x28sUbRuBN+C3lVV8+Lg7rsXjVvGd/HnJXSZoMpX4w/xTBrmYVdAib1KN7Pp43qynLzdrPm0HB0v/53XAZ1H+LVkWzo6eJKMjyWPvHC2FlZa1ei7AzvZsCZamFf1qQtsr/DydHlPSFP6Clzeb/rckf38aPVTn9E8AOif3vSXoNNwA3S46WmvjCTrn0KrlHk6KRZ5CpIN2WVtvv6NM7qFHUoKnKOO8QYBbvl382ImEl9ORGGFMrW/PExlE/13XhkNDYixvZ0v5QrrSLamxXctaIpKDO4UFQs61aCPZVQEL7xC1Tu3VoGX3S4xzM3NwloHg4EKOXM3YOM0K7yMZ5k7fvzKfmN+asWw1ocGDerK6vQ2o13fPyp3ghn9+MwMLifhxptJPDKAI3igPqZ0JIctRmozSMTJBDo7XdZcKj38kK46WsWELu0NwJhBOZ24YtM1gr1NcMGHKPt6b5MljNoX0z5WJtdpKl5g94p62en0FDhKsNblPrRs/VyC2rurIRBxDZezz4NpYVtFtKJb7iEGJ8LBzsD8Ppy5821d4yfiTDWZDkBvM/YJ5LSFfznUbup65Jsf5FoUd8+fowj+qdiwvSFQEmwOWVN4UPWN+XEVzFS5XHqbvNACrayk1kDIANiXCWHhM3QREF17GlMIq82spsg6pUIiX7YvE6FoBkpcbOwlQo2beDlQNDu/GJD57H/2l4EsLn89AucA2R/gU3nTeHYqc3HjtpHA7B0oQEM2UFf/0lcSd1hAEg7HP7IsT0YVRWR6KCoPxEnSs7CXT4NkW8jeAN4+91aO04VFKdB3oy2EYQxXoDkBAvv2R4NmVciRBGmJdtAppzoFcXqIRatgA2NNXfPS3/sQBeWClj3C6BBmMvmHo+kshkN6SaF6qy8vlUPAAdV7tZ8pmecbAMqhKMBL8Z20jk8xExOwBv5DZ6h6Ph7lGSkKUhDQHyy+7wUqnH12s+Rjn+U4jKj34HgiZTf4B1ouoVQZ647+LG20TZOS8vaPm5UQRyO2BfZ8HQy4INRRCnj7qmE6U0vxss8WPCHWTvothaHPbXCpje038pC+5vphl92 X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: e741222e-37a8-4b00-ac5c-08dac39c6c9f X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Nov 2022 04:23:03.2783 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: NFAPtHnaSpwvF+tOUyqIxvfKInr77qwEvpWqNG8btEIcSCEr48jf9I5hSM5lcrlo3Zm1ZVe7xuo21wsLympAxg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB5102 X-Proofpoint-ORIG-GUID: 2bODpACHrIISw1HeC9Y_GM8FKDv5pdjP X-Proofpoint-GUID: 2bODpACHrIISw1HeC9Y_GM8FKDv5pdjP X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-11_01,2022-11-09_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 mlxlogscore=942 lowpriorityscore=0 suspectscore=0 priorityscore=1501 phishscore=0 mlxscore=0 adultscore=0 impostorscore=0 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211110027 Received-SPF: pass client-ip=205.220.166.238; envelope-from=prvs=83144312e2=bin.meng@windriver.com; helo=mx0a-0064b401.pphosted.com X-Spam_score_int: 0 X-Spam_score: -0.1 X-Spam_bar: / X-Spam_report: (-0.1 / 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, PDS_OTHER_BAD_TLD=2, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Guohuai Shi Update the 9p 'local' file system driver to support Windows, including open, read, write, close, rename, remove, etc. All security models are supported. The mapped (mapped-xattr) security model is implemented using NTFS Alternate Data Stream (ADS) so the 9p export path shall be on an NTFS partition. Symbolic link and hard link are not supported when security model is "passthrough" or "none", because Windows NTFS does not fully support them with POSIX compatibility. Symbolic link is enabled when security model is "mapped-file" or "mapped-xattr". inode remap is always enabled because Windows file system does not provide a compatible inode number. mknod() is not supported because Windows does not support it. chown() and chmod() are not supported when 9pfs is configured with security mode to 'none' or 'passthrough' because Windows host does not support such type request. Signed-off-by: Guohuai Shi Signed-off-by: Bin Meng --- Changes in v2: - Update to support symbolic link when applicable - Warn user if a specific 9pfs operation is not supported hw/9pfs/9p-local.h | 1 + hw/9pfs/9p-local.c | 388 +++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 378 insertions(+), 11 deletions(-) diff --git a/hw/9pfs/9p-local.h b/hw/9pfs/9p-local.h index eb4f39ddc2..311067d9af 100644 --- a/hw/9pfs/9p-local.h +++ b/hw/9pfs/9p-local.h @@ -17,6 +17,7 @@ typedef struct { QemuFd_t mountfd; #ifdef CONFIG_WIN32 char *root_path; + DWORD block_size; #endif } LocalData; diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index 24e21141d5..20e3091cd7 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -1,5 +1,5 @@ /* - * 9p Posix callback + * 9p callback * * Copyright IBM, Corp. 2010 * @@ -21,11 +21,13 @@ #include "9p-xattr.h" #include "9p-util.h" #include "fsdev/qemu-fsdev.h" /* local_ops */ +#ifndef CONFIG_WIN32 #include #include #include #include #include +#endif #include "qemu/xattr.h" #include "qapi/error.h" #include "qemu/cutils.h" @@ -38,7 +40,9 @@ #include #endif #endif +#ifndef CONFIG_WIN32 #include +#endif #ifndef XFS_SUPER_MAGIC #define XFS_SUPER_MAGIC 0x58465342 @@ -90,10 +94,12 @@ QemuFd_t local_open_nofollow(FsContext *fs_ctx, const char *path, int flags, return fd; } +#ifndef CONFIG_WIN32 QemuFd_t local_opendir_nofollow(FsContext *fs_ctx, const char *path) { return local_open_nofollow(fs_ctx, path, O_DIRECTORY | O_RDONLY, 0); } +#endif static void renameat_preserve_errno(QemuFd_t odirfd, const char *opath, QemuFd_t ndirfd, const char *npath) @@ -135,10 +141,20 @@ static FILE *local_fopenat(QemuFd_t dirfd, const char *name, const char *mode) if (qemu_fd_invalid(fd)) { return NULL; } +#ifdef CONFIG_WIN32 + int _flags = mode[0] == 'r' ? O_RDONLY : 0; + int _fd = _open_osfhandle((intptr_t)fd, _flags); + assert(_fd != -1); + fp = fdopen(_fd, mode); + if (!fp) { + close(_fd); + } +#else fp = fdopen(fd, mode); if (!fp) { close(fd); } +#endif return fp; } @@ -238,7 +254,7 @@ static int local_set_mapped_file_attrat(QemuFd_t dirfd, const char *name, int ret; char buf[ATTR_MAX]; int uid = -1, gid = -1, mode = -1, rdev = -1; - QemuFd_t map_dirfd = QEMU_FD_INVALID, map_fd; + QemuFd_t map_dirfd = QEMU_FD_INVALID; bool is_root = !strcmp(name, "."); if (is_root) { @@ -302,10 +318,12 @@ update_map_file: return -1; } - map_fd = fileno(fp); +#ifndef CONFIG_WIN32 + QemuFd_t map_fd = fileno(fp); assert(!qemu_fd_invalid(map_fd)); ret = fchmod(map_fd, 0600); assert(ret == 0); +#endif if (credp->fc_uid != -1) { uid = credp->fc_uid; @@ -337,6 +355,7 @@ update_map_file: return 0; } +#ifndef CONFIG_WIN32 static int fchmodat_nofollow(QemuFd_t dirfd, const char *name, mode_t mode) { struct stat stbuf; @@ -399,6 +418,7 @@ static int fchmodat_nofollow(QemuFd_t dirfd, const char *name, mode_t mode) close_preserve_errno(fd); return ret; } +#endif static int local_set_xattrat(QemuFd_t dirfd, const char *path, FsCred *credp) { @@ -439,6 +459,7 @@ static int local_set_xattrat(QemuFd_t dirfd, const char *path, FsCred *credp) return 0; } +#ifndef CONFIG_WIN32 static int local_set_cred_passthrough(FsContext *fs_ctx, QemuFd_t dirfd, const char *name, FsCred *credp) { @@ -455,6 +476,7 @@ static int local_set_cred_passthrough(FsContext *fs_ctx, QemuFd_t dirfd, return fchmodat_nofollow(dirfd, name, credp->fc_mode & 07777); } +#endif static ssize_t local_readlink(FsContext *fs_ctx, V9fsPath *fs_path, char *buf, size_t bufsz) @@ -464,17 +486,33 @@ static ssize_t local_readlink(FsContext *fs_ctx, V9fsPath *fs_path, if ((fs_ctx->export_flags & V9FS_SM_MAPPED) || (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE)) { QemuFd_t fd; + int _fd; fd = local_open_nofollow(fs_ctx, fs_path->data, O_RDONLY, 0); if (qemu_fd_invalid(fd)) { return -1; } +#ifdef CONFIG_WIN32 + _fd = _open_osfhandle((intptr_t)fd, 0); +#else + _fd = fd; +#endif do { - tsize = read(fd, (void *)buf, bufsz); + tsize = read(_fd, (void *)buf, bufsz); } while (tsize == -1 && errno == EINTR); +#ifdef CONFIG_WIN32 + close(_fd); +#else close_preserve_errno(fd); +#endif } else if ((fs_ctx->export_flags & V9FS_SM_PASSTHROUGH) || (fs_ctx->export_flags & V9FS_SM_NONE)) { +#ifdef CONFIG_WIN32 + errno = ENOTSUP; + error_report_once("readlink is not available on Windows host when" + "security_model is \"none\" or \"passthrough\""); + tsize = -1; +#else char *dirpath = g_path_get_dirname(fs_path->data); char *name = g_path_get_basename(fs_path->data); QemuFd_t dirfd; @@ -489,6 +527,7 @@ static ssize_t local_readlink(FsContext *fs_ctx, V9fsPath *fs_path, out: g_free(name); g_free(dirpath); +#endif } return tsize; } @@ -512,7 +551,13 @@ static int local_open(FsContext *ctx, V9fsPath *fs_path, if (qemu_fd_invalid(fd)) { return -1; } +#ifdef CONFIG_WIN32 + int _fd = _open_osfhandle((intptr_t)fd, 0); + assert(_fd != -1); + fs->fd = _fd; +#else fs->fd = fd; +#endif return fs->fd; } @@ -527,9 +572,24 @@ static int local_opendir(FsContext *ctx, return -1; } +#ifdef CONFIG_WIN32 + char *full_file_name = get_full_path_win32(dirfd, NULL); + if (full_file_name == NULL) { + CloseHandle(dirfd); + return -1; + } + stream = opendir(full_file_name); + g_free(full_file_name); +#else stream = fdopendir(dirfd); +#endif + if (!stream) { +#ifdef CONFIG_WIN32 + CloseHandle(dirfd); +#else close(dirfd); +#endif return -1; } fs->dir.stream = stream; @@ -572,13 +632,17 @@ again: #endif if (ctx->export_flags & V9FS_SM_MAPPED) { +#ifndef CONFIG_WIN32 entry->d_type = DT_UNKNOWN; +#endif } else if (ctx->export_flags & V9FS_SM_MAPPED_FILE) { if (local_is_mapped_file_metadata(ctx, entry->d_name)) { /* skip the meta data */ goto again; } +#ifndef CONFIG_WIN32 entry->d_type = DT_UNKNOWN; +#endif } return entry; @@ -586,7 +650,94 @@ again: static void local_seekdir(FsContext *ctx, V9fsFidOpenState *fs, off_t off) { +#ifndef CONFIG_WIN32 + seekdir(fs->dir.stream, off); +#else + off_t count; + struct dirent *findentry; + struct dirent *entry; + size_t namelen[3] = { 0 }; + off_t direntoff[3] = { -1, -1, -1 }; + char *d_name[3]; + int i; + + /* + * MinGW's seekdir() requires directory is not modified. If guest OS is + * modifying the directory when calling seekdir(), e.g.: "rm -rf *", + * then MinGW's seekdir() will seek to a wrong offset. + * + * This function saves some old offset directory entry name, + * and looks up current entry again, and compares the offset. + * + * If the new offset is less than the old offset, that means someone is + * deleting files in the directory, thus we need to seek offset backward. + * + * If the new offset is larger than the old offset, that means someone is + * creating files in the directory, thus we need to seek offset forward. + */ + + direntoff[0] = telldir(fs->dir.stream); + + /* do nothing if current offset is 0 or EOF */ + if (direntoff[0] == 0 || direntoff[0] < 0) { + seekdir(fs->dir.stream, off); + return; + } + + d_name[0] = g_malloc0(sizeof(entry->d_name) * 3); + d_name[1] = d_name[0] + sizeof(entry->d_name); + d_name[2] = d_name[1] + sizeof(entry->d_name); + + /* save 3 nearest entries and offsets */ + for (i = 0; i < 3; i++) { + entry = &fs->dir.stream->dd_dir; + + memcpy(d_name[i], entry->d_name, entry->d_namlen); + namelen[i] = strlen(d_name[i]) + 1; + + direntoff[i] = telldir(fs->dir.stream); + + entry = readdir(fs->dir.stream); + if (entry == NULL) { + break; + } + } + + /* look up saved entries again */ + for (i = 0; i < 3 && direntoff[i] != -1; i++) { + rewinddir(fs->dir.stream); + count = 0; + while ((findentry = readdir(fs->dir.stream)) != NULL) { + count++; + + if (memcmp(findentry->d_name, d_name[i], namelen[i]) == 0) { + if (count + i == direntoff[i]) { + seekdir(fs->dir.stream, off); + goto out; + } else if (count + i < direntoff[i]) { + off = off - (direntoff[i] - count) - i; + if (off <= 0) { + off = 0; + } + seekdir(fs->dir.stream, off); + goto out; + } else { + off = off + (count - direntoff[i]) - i; + seekdir(fs->dir.stream, off); + goto out; + } + } + } + } + + /* cannot get anything, seek backward */ + off = off - 1; seekdir(fs->dir.stream, off); + +out: + g_free(d_name[0]); + return; +#endif } static ssize_t local_preadv(FsContext *ctx, V9fsFidOpenState *fs, @@ -652,7 +803,14 @@ static int local_chmod(FsContext *fs_ctx, V9fsPath *fs_path, FsCred *credp) ret = local_set_mapped_file_attrat(dirfd, name, credp); } else if (fs_ctx->export_flags & V9FS_SM_PASSTHROUGH || fs_ctx->export_flags & V9FS_SM_NONE) { +#ifdef CONFIG_WIN32 + errno = ENOTSUP; + error_report_once("chmod is not available on Windows host when" + "security_model is \"none\" or \"passthrough\""); + ret = -1; +#else ret = fchmodat_nofollow(dirfd, name, credp->fc_mode); +#endif } close_preserve_errno(dirfd); @@ -696,6 +854,12 @@ static int local_mknod(FsContext *fs_ctx, V9fsPath *dir_path, } } else if (fs_ctx->export_flags & V9FS_SM_PASSTHROUGH || fs_ctx->export_flags & V9FS_SM_NONE) { +#ifdef CONFIG_WIN32 + errno = ENOTSUP; + error_report_once("mknod is not available on Windows host when" + "security_model is \"none\" or \"passthrough\""); + goto out; +#else err = qemu_mknodat(dirfd, name, credp->fc_mode, credp->fc_rdev); if (err == -1) { goto out; @@ -704,6 +868,7 @@ static int local_mknod(FsContext *fs_ctx, V9fsPath *dir_path, if (err == -1) { goto err_end; } +#endif } goto out; @@ -753,10 +918,12 @@ static int local_mkdir(FsContext *fs_ctx, V9fsPath *dir_path, if (err == -1) { goto out; } +#ifndef CONFIG_WIN32 err = local_set_cred_passthrough(fs_ctx, dirfd, name, credp); if (err == -1) { goto err_end; } +#endif } goto out; @@ -773,7 +940,12 @@ static int local_fstat(FsContext *fs_ctx, int fid_type, int err, fd; if (fid_type == P9_FID_DIR) { +#ifdef CONFIG_WIN32 + errno = ENOTSUP; + return -1; /* Windows do not allow opening a directory by open() */ +#else fd = dirfd(fs->dir.stream); +#endif } else { fd = fs->fd; } @@ -825,10 +997,10 @@ static int local_open2(FsContext *fs_ctx, V9fsPath *dir_path, const char *name, return -1; } - /* - * Mark all the open to not follow symlinks - */ +#ifndef CONFIG_WIN32 + /* Mark all the open to not follow symlinks */ flags |= O_NOFOLLOW; +#endif dirfd = local_opendir_nofollow(fs_ctx, dir_path->data); if (qemu_fd_invalid(dirfd)) { @@ -858,13 +1030,22 @@ static int local_open2(FsContext *fs_ctx, V9fsPath *dir_path, const char *name, if (qemu_fd_invalid(fd)) { goto out; } +#ifndef CONFIG_WIN32 err = local_set_cred_passthrough(fs_ctx, dirfd, name, credp); if (err == -1) { goto err_end; } +#endif } +#ifdef CONFIG_WIN32 + int _fd = _open_osfhandle((intptr_t)fd, 0); + assert(_fd != -1); + err = _fd; + fs->fd = _fd; +#else err = fd; fs->fd = fd; +#endif goto out; err_end: @@ -898,6 +1079,7 @@ static int local_symlink(FsContext *fs_ctx, const char *oldpath, if (fs_ctx->export_flags & V9FS_SM_MAPPED || fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) { QemuFd_t fd; + int _fd; ssize_t oldpath_size, write_size; fd = openat_file(dirfd, name, O_CREAT | O_EXCL | O_RDWR, @@ -905,12 +1087,21 @@ static int local_symlink(FsContext *fs_ctx, const char *oldpath, if (qemu_fd_invalid(fd)) { goto out; } +#ifdef CONFIG_WIN32 + _fd = _open_osfhandle((intptr_t)fd, 0); +#else + _fd = fd; +#endif /* Write the oldpath (target) to the file. */ oldpath_size = strlen(oldpath); do { - write_size = write(fd, (void *)oldpath, oldpath_size); + write_size = write(_fd, (void *)oldpath, oldpath_size); } while (write_size == -1 && errno == EINTR); +#ifdef CONFIG_WIN32 + close(_fd); +#else close_preserve_errno(fd); +#endif if (write_size != oldpath_size) { goto err_end; @@ -928,6 +1119,21 @@ static int local_symlink(FsContext *fs_ctx, const char *oldpath, } } else if (fs_ctx->export_flags & V9FS_SM_PASSTHROUGH || fs_ctx->export_flags & V9FS_SM_NONE) { +#ifdef CONFIG_WIN32 + /* + * Windows symbolic link requires administrator privilage. + * And Windows does not provide any interface like readlink(). + * All symbolic links on Windows are always absolute paths. + * It's not 100% compatible with POSIX symbolic link. + * + * With above reasons, symbolic link with "passthrough" or "none" + * mode is disabled on Windows host. + */ + errno = ENOTSUP; + error_report_once("symlink is not available on Windows host when" + "security_model is \"none\" or \"passthrough\""); + goto out; +#else err = symlinkat(oldpath, dirfd, name); if (err) { goto out; @@ -945,6 +1151,7 @@ static int local_symlink(FsContext *fs_ctx, const char *oldpath, err = 0; } } +#endif } goto out; @@ -958,6 +1165,11 @@ out: static int local_link(FsContext *ctx, V9fsPath *oldpath, V9fsPath *dirpath, const char *name) { +#ifdef CONFIG_WIN32 + errno = ENOTSUP; + error_report_once("link is not available on Windows host"); + return -1; +#else char *odirpath = g_path_get_dirname(oldpath->data); char *oname = g_path_get_basename(oldpath->data); int ret = -1; @@ -1027,6 +1239,7 @@ out: g_free(oname); g_free(odirpath); return ret; +#endif } static int local_truncate(FsContext *ctx, V9fsPath *fs_path, off_t size) @@ -1038,7 +1251,13 @@ static int local_truncate(FsContext *ctx, V9fsPath *fs_path, off_t size) if (qemu_fd_invalid(fd)) { return -1; } +#ifdef CONFIG_WIN32 + int _fd = _open_osfhandle((intptr_t)fd, 0); + assert(_fd != -1); + ret = ftruncate(_fd, size); +#else ret = ftruncate(fd, size); +#endif close_preserve_errno(fd); return ret; } @@ -1058,8 +1277,15 @@ static int local_chown(FsContext *fs_ctx, V9fsPath *fs_path, FsCred *credp) if ((credp->fc_uid == -1 && credp->fc_gid == -1) || (fs_ctx->export_flags & V9FS_SM_PASSTHROUGH) || (fs_ctx->export_flags & V9FS_SM_NONE)) { +#ifdef CONFIG_WIN32 + errno = ENOTSUP; + error_report_once("chown is not available on Windows host when" + "security_model is \"none\" or \"passthrough\""); + ret = -1; +#else ret = fchownat(dirfd, name, credp->fc_uid, credp->fc_gid, AT_SYMLINK_NOFOLLOW); +#endif } else if (fs_ctx->export_flags & V9FS_SM_MAPPED) { ret = local_set_xattrat(dirfd, name, credp); } else if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) { @@ -1172,6 +1398,12 @@ out: static int local_fsync(FsContext *ctx, int fid_type, V9fsFidOpenState *fs, int datasync) { +#ifdef CONFIG_WIN32 + if (fid_type != P9_FID_DIR) { + return _commit(fs->fd); + } + return 0; +#else int fd; if (fid_type == P9_FID_DIR) { @@ -1185,12 +1417,14 @@ static int local_fsync(FsContext *ctx, int fid_type, } else { return fsync(fd); } +#endif } static int local_statfs(FsContext *s, V9fsPath *fs_path, struct statfs *stbuf) { - QemuFd_t fd; int ret; +#ifndef CONFIG_WIN32 + QemuFd_t fd; fd = local_open_nofollow(s, fs_path->data, O_RDONLY, 0); if (qemu_fd_invalid(fd)) { @@ -1198,39 +1432,65 @@ static int local_statfs(FsContext *s, V9fsPath *fs_path, struct statfs *stbuf) } ret = fstatfs(fd, stbuf); close_preserve_errno(fd); +#else + LocalData *data = (LocalData *)s->private; + + ret = statfs_win32(data->root_path, stbuf); + if (ret == 0) { + /* use context address as fsid */ + memcpy(&stbuf->f_fsid, s, sizeof(intptr_t)); + } +#endif + return ret; } static ssize_t local_lgetxattr(FsContext *ctx, V9fsPath *fs_path, const char *name, void *value, size_t size) { +#ifdef CONFIG_WIN32 + return -1; +#else char *path = fs_path->data; return v9fs_get_xattr(ctx, path, name, value, size); +#endif } static ssize_t local_llistxattr(FsContext *ctx, V9fsPath *fs_path, void *value, size_t size) { +#ifdef CONFIG_WIN32 + return -1; +#else char *path = fs_path->data; return v9fs_list_xattr(ctx, path, value, size); +#endif } static int local_lsetxattr(FsContext *ctx, V9fsPath *fs_path, const char *name, void *value, size_t size, int flags) { +#ifdef CONFIG_WIN32 + return -1; +#else char *path = fs_path->data; return v9fs_set_xattr(ctx, path, name, value, size, flags); +#endif } static int local_lremovexattr(FsContext *ctx, V9fsPath *fs_path, const char *name) { +#ifdef CONFIG_WIN32 + return -1; +#else char *path = fs_path->data; return v9fs_remove_xattr(ctx, path, name); +#endif } static int local_name_to_path(FsContext *ctx, V9fsPath *dir_path, @@ -1393,6 +1653,7 @@ static int local_unlinkat(FsContext *ctx, V9fsPath *dir, return ret; } +#ifndef CONFIG_WIN32 #ifdef FS_IOC_GETVERSION static int local_ioc_getversion(FsContext *ctx, V9fsPath *path, mode_t st_mode, uint64_t *st_gen) @@ -1442,11 +1703,88 @@ static int local_ioc_getversion_init(FsContext *ctx, LocalData *data, Error **er #endif return 0; } +#endif -static int local_init(FsContext *ctx, Error **errp) +#ifdef CONFIG_WIN32 +static int init_win32_root_directory(FsContext *ctx, LocalData *data, + Error **errp) { - LocalData *data = g_malloc(sizeof(*data)); + HANDLE mountfd; + char *root_path; + DWORD SectorsPerCluster; + DWORD BytesPerSector; + DWORD NumberOfFreeClusters; + DWORD TotalNumberOfClusters; + char disk_root[4] = { 0 }; + + mountfd = CreateFile(ctx->fs_root, GENERIC_READ, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, + NULL, + OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); + if (mountfd == INVALID_HANDLE_VALUE) { + error_setg_errno(errp, EINVAL, "cannot open %s", ctx->fs_root); + return -1; + } + + if ((ctx->export_flags & V9FS_SM_MAPPED) != 0) { + wchar_t fs_name[MAX_PATH + 1] = {0}; + wchar_t ntfs_name[5] = {'N', 'T', 'F', 'S'}; + /* Get file system type name */ + if (GetVolumeInformationByHandleW(mountfd, NULL, 0, NULL, NULL, NULL, + fs_name, MAX_PATH + 1) == 0) { + error_setg_errno(errp, EINVAL, + "cannot get file system information"); + CloseHandle(mountfd); + return -1; + } + + /* + * security_model=mapped(-xattr) requires a fileystem on Windows that + * supports Alternate Data Stream (ADS). NTFS is one of them, and is + * probably most popular on Windows. It is fair enough to assume + * Windows users to use NTFS for the mapped security model. + */ + if (wcscmp(fs_name, ntfs_name) != 0) { + CloseHandle(mountfd); + error_setg_errno(errp, EINVAL, "require NTFS file system"); + return -1; + } + } + + root_path = get_full_path_win32(mountfd, NULL); + if (root_path == NULL) { + CloseHandle(mountfd); + error_setg_errno(errp, EINVAL, "cannot get full root path"); + return -1; + } + + /* copy the first 3 characters for the root directory */ + memcpy(disk_root, root_path, 3); + + if (GetDiskFreeSpace(disk_root, &SectorsPerCluster, &BytesPerSector, + &NumberOfFreeClusters, &TotalNumberOfClusters) == 0) { + CloseHandle(mountfd); + error_setg_errno(errp, EINVAL, "cannot get file system block size"); + return -1; + } + + /* + * hold the root handle will prevent other one to delete or replace the + * root directory during runtime. + */ + data->mountfd = mountfd; + data->root_path = root_path; + data->block_size = SectorsPerCluster * BytesPerSector; + + return 0; +} +#endif + +static int local_init(FsContext *ctx, Error **errp) +{ + LocalData *data = g_malloc0(sizeof(*data)); +#ifndef CONFIG_WIN32 data->mountfd = open(ctx->fs_root, O_DIRECTORY | O_RDONLY); if (qemu_fd_invalid(data->mountfd)) { error_setg_errno(errp, errno, "failed to open '%s'", ctx->fs_root); @@ -1457,7 +1795,17 @@ static int local_init(FsContext *ctx, Error **errp) close(data->mountfd); goto err; } +#else + if (init_win32_root_directory(ctx, data, errp) != 0) { + goto err; + } + /* + * Always enable inode remap since Windows file system does not + * have inode number. + */ + ctx->export_flags |= V9FS_REMAP_INODES; +#endif if (ctx->export_flags & V9FS_SM_PASSTHROUGH) { ctx->xops = passthrough_xattr_ops; } else if (ctx->export_flags & V9FS_SM_MAPPED) { @@ -1477,6 +1825,15 @@ static int local_init(FsContext *ctx, Error **errp) return 0; err: +#ifdef CONFIG_WIN32 + if (data->root_path != NULL) { + g_free(data->root_path); + } + + if (data->mountfd != 0 && data->mountfd != INVALID_HANDLE_VALUE) { + CloseHandle(data->mountfd); + } +#endif g_free(data); return -1; } @@ -1488,8 +1845,17 @@ static void local_cleanup(FsContext *ctx) if (!data) { return; } +#ifdef CONFIG_WIN32 + if (data->root_path != NULL) { + g_free(data->root_path); + } + if (data->mountfd != 0 && data->mountfd != INVALID_HANDLE_VALUE) { + CloseHandle(data->mountfd); + } +#else close(data->mountfd); +#endif g_free(data); } From patchwork Fri Nov 11 04:22:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13039629 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 17F4FC433FE for ; Fri, 11 Nov 2022 04:24:32 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otLZe-0000Z9-LX; Thu, 10 Nov 2022 23:23:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otLZb-0000Wr-Gz for qemu-devel@nongnu.org; Thu, 10 Nov 2022 23:23:23 -0500 Received: from mx0a-0064b401.pphosted.com ([205.220.166.238]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otLZY-0001Zk-9b for qemu-devel@nongnu.org; Thu, 10 Nov 2022 23:23:23 -0500 Received: from pps.filterd (m0250810.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AB4N5DN004957; Thu, 10 Nov 2022 20:23:06 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=z3rAyMTrdhdHyeeGQtwrC7054GNebIFHAns0B5YVblA=; b=G+FlcXP8QJF3MmYyeA807LETcQpZgRV5+x5opYVeiKvohKos7ITGhHs/3+LH5UCy7Rvo utmX1yyKLp7Ys/IhFSIMjb2t3kG6ZE80a+DoFV2DtVG7AWXec+Hmr3EzBls6OWAYINQk 8BGKf4aBoS+9W7qaTh1QgubopWnMFBhdJd1MGXfYfGwZWsL0ftKfvcvWfWt8wNORdGgu X3NDgUL8DB6rPTUYz9225HcCT2uvx0pe7hQzD41G7qP91Cv5l6NvZ0xo1XzYs3/MU/hp fMS1Z8YC6iyvcIn3euLWSM6PMtH2kTt0qTfHN1tnoTH8HecZDC8x5LBrtsp1dkM8urXk Zw== Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2169.outbound.protection.outlook.com [104.47.56.169]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3knk43d9m3-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Nov 2022 20:23:06 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ckNkBPhuP4oLGLQ5r26pm91umSaocivAg5J9QetWyz9+Fa2WW3dnbN4JHuCdY2KpFdxXhashUqtm+Lcjok73hza38ZOE7d/F1EFjDO7KB5PzC94MrF/MIOrkFC9k5z6c6TXHneMDnLZR9b+FnYRwv7TqZirz2KcGv91q90EmwDo0/pM6GK/ceXrmY1J3W4CrnVQU4AHP82YAdVZ14YPcUudn9iKr1Y+4qy7I4tgFmt4a0qziuOndD0tLdiLW9pgMhqFI7PQUR/OC4aBNdRxxMygjLST1mvMPNohT6su3faLJTZUUYqZuPY2zb162fo5evZF/mr729NHvbOlna/xv1g== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=z3rAyMTrdhdHyeeGQtwrC7054GNebIFHAns0B5YVblA=; b=Ag6Rv4muWedItukdE1rwH9C510/sBbXMEPtQWSqj/DtUwsCUaD0Fd8CdMFBJaGRVVv1vPbgq4QcfxpXmeGTiJyR1pV27hI8J2Dqv1UwwH+n13CoTZAJQCOcycIRX1zLOVHGfMf/F2ce7uRcTV6fQUJcRGCzrOvvWCigFJI3Lzv2NswwEqLjklFhYT68RsnZYVcmlkvC9iFQRvLL9+E21gxPn+sEq0h71gLpPYMIurNH65V7uInCt8lCLh7Nd1A0c7sz8Fjq6tEb75QeM3WU9y/1lz6AGnPUgDGlPs3A6DhOz624m8qRIjAKKhG0SyCJknhuR4XLJlqcTzFkhecbCzg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by SJ0PR11MB5102.namprd11.prod.outlook.com (2603:10b6:a03:2ac::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27; Fri, 11 Nov 2022 04:23:05 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::8e5e:71da:1e29:bc15]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::8e5e:71da:1e29:bc15%5]) with mapi id 15.20.5813.013; Fri, 11 Nov 2022 04:23:05 +0000 From: Bin Meng To: qemu-devel@nongnu.org Cc: Guohuai Shi , Christian Schoenebeck , Greg Kurz Subject: [PATCH v2 09/19] hw/9pfs: Support getting current directory offset for Windows Date: Fri, 11 Nov 2022 12:22:15 +0800 Message-Id: <20221111042225.1115931-10-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221111042225.1115931-1-bin.meng@windriver.com> References: <20221111042225.1115931-1-bin.meng@windriver.com> X-ClientProxiedBy: SL2P216CA0138.KORP216.PROD.OUTLOOK.COM (2603:1096:101:1::17) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|SJ0PR11MB5102:EE_ X-MS-Office365-Filtering-Correlation-Id: d81e8cf0-4fd2-478d-0528-08dac39c6dd1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HbwEu2biGRf+B/fWSbtQ/ZAPQGNxa+sb/eQb5h3hIh6rAHlxJ346Hm/cMrVE3aBf7wPLvfQooUMhGtSkmE3346Nd1ztGZOtkXy/odh3csA2Arzx8i0M7MhvZNxjqI3rML966NfHv0yQgU0koRQPNqKq7oYljquzBzDSJ/tDvjAJmV6+hV9tHd4RqEEw3BbE9CE52H9jRUkJGy5IIPMhvkWdfZUBWTL6mpHz9Ap8vpb0sZ81uDSv/tDKZC9kVcwp5gBvQywZORH3Dk8lfUYLtoVJaX97lcU7gYUfmOkqw6No6hSqoWEzPorWuSd5GaM1+z0GkUnDiOvTopcg8QA+ZUlhSoTB0Z78HQljmySTBX3aMnHeHE9YLF2zooiaw+0fm/9ZamPtlTyzEROtQ24XanXEJw77B4K6phey4sM4NIm8y7qPdQ0T8yOBrhsKqYHJIe0t9/ZrEelsKNLQktLFaQyC97j1O/DDTChxpLinlERHCnZ9mEjDfu7/09QPpQrrSUg4q/Ss7znLTnWb6TzLA23dUZaHU6it40QpfJDkvmCrKdRIAtwIcPHl4Ah6HYoY033lVzX+GXv0KoxbwznMdfiPrIUv+RpN9EdI4Sqwic5EksDX6i0x36a/Z1rmlL5S0Hj35Jiyqs7InpukGZP37TPAcpFmiiQtMD3s4lrctC37WaVdK9oDJ4x+xf2w603YCwee9NwNfv3Yt/dvcZeE/e5QWOtxNF6fOy9q1nu+c3ozxQhU5x7gYhNR5ozp+xqsDciXss19eB1EKkMXTT+TOBw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5358.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(396003)(346002)(376002)(39850400004)(366004)(136003)(451199015)(66556008)(316002)(86362001)(8676002)(66476007)(66946007)(4326008)(38350700002)(38100700002)(36756003)(44832011)(83380400001)(52116002)(6512007)(2616005)(1076003)(26005)(6506007)(478600001)(6666004)(186003)(6486002)(8936002)(41300700001)(6916009)(2906002)(54906003)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NXaXoHG/AfTMfyTXqc7yRvvRl6mLfxxi/HY9DECg0DUh92TYYPGTFnIyFErIIoBkw+pkFG+zowhHn+EP/znB2rJgrezUliQf8zYGhvzGmqq0ivxGMwRIu4xAHTRz3fjTj7shDN9S62rU1aHEHJw1B4wcFUje5qq9k78SYBK0G+LPBHu+g5UThkdhqUonUA6mEGbOOrHnBnPBDikuE6e10ACX53NmSu1mcG/UqcJLaZoEjEOzFSkX2Z6l0qbPrb3wdBDxKnPBLY+mhLawndJ5QCjAjyhp+O6EpjwQ2VGkuVkfSJUJKXqcosEvB8365z+/lo3df6F35+AfJsDhdQZfEBrR88ac1Bzpc4KlAT3g4WtQR0VhkRz1ahMACOiJbg8tJ5hE5SLcF6gkCTqpiK1MxEhkQfToncxYdeNWMFaVQsfM1SFlMawgzgKWEvUzACUJIvNbMyOGtTdIMNUhB68Ua/mcJg/GZ32iR6dO9pA/uVjZARsJQDiFfQzSuI6Traq9C+Z1G7RWUWtgUrSUUI33SzotO21iQQoSM31L8imQP94Q2cqUioAnv5qzbiFxCcbJqMmSu/xzbV2JRax89YEt6uP1rY6SR0+wrPxkhFdo4qo+/RuTqEf2d0bWq6JH5QFWj7k68kpEm4eWn6Ehh4gCGVRFMewEb/916Mx95r0iXDvuZnqOuDDSMDl/hq0MD71UKClkZWCRcPVRTbko/tgGdMTYATmWZoCC9kUDXByDuc4hmTIFzI31nAtKm+MoB1G5bzyACTYHcpfMnCMBpz9WfYARDUb0TEAKZdHRq8S4b1Z4Tcz5KWB08tDYe1vaMh/4GflgIO717c1rBS+9JwHHShV5eFv4NsF743QQPBb+a3m9yv++kwgHJd9TNDIXGJLa4g224De0GgNoBoQipTlLYBkh7v0zk6bptJt/8g6zkx+mCKN2y6kMgavk7w41jmybgKh6nciNM4FaDsCBtn+y39RqIneTR/uHoQGGGKoO2gDmKYr9YTIeLV6XLToaf08CRfw7Ou2u7XgoNraO2y73XlKosU1K041wPK3HbSAeT46TEeOhaZSyvfj0Trg5MSwcq9ZlKVAw4S38MpjOn54ph81gczU2L0kiAdvi8OvSoeKl4+3txf+Vj9tfTTwhaGARcpCX9cjvhm1G16vbK9AZw2SPNSaxyAGqxTaebLtNfrkRnrc/OAZ/QiyC3570eKsXCRprdxTwLJ92DUtaGVdGsZjG+zG5ysMiT2kQPOjdagMPQRkYxmxU2PYfea5DhY7S5jng3OJ2twNMMatusWoKGGq7Q/Dciw6UXWKyHrcltirU4x4RpBTfq3GLWfFMlN9vWEOFluHxd6AVfKTb6KUEYWF8zZaUrXKMr+qdOfqQoRsG11kV4VWf++LiTqW0yye73KoV5WzJ5mOgjhSohjuoyPFbM5tsLtX1vLfBAJj3tAJ+C/Gf57paM8e+q0eqIMVujztnnVTbwRjljdTweSi6BmOQ8TQ6S2IeBVhb6LgkLVz4jwWOF+rtqoz24OdV+fDsVEfmH2qR8uncdK2OrPHAjlHWMRwtqbZReXDPCi0dBW1T2cm193lMcp9B77gx1G9+ X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: d81e8cf0-4fd2-478d-0528-08dac39c6dd1 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Nov 2022 04:23:05.2638 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ow5INxa3EGC10b7j/W9Pnyb09ZM07AyJG5/EWDXemDRAD/Tdb8sEXoJ4oGQxniuCI2MQ6l4BEqSVj4J+/oYhqw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB5102 X-Proofpoint-ORIG-GUID: cfmogL9k35A_b86nCjOWnuKetLx9D8lP X-Proofpoint-GUID: cfmogL9k35A_b86nCjOWnuKetLx9D8lP X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-11_01,2022-11-09_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 mlxlogscore=886 lowpriorityscore=0 suspectscore=0 priorityscore=1501 phishscore=0 mlxscore=0 adultscore=0 impostorscore=0 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211110027 Received-SPF: pass client-ip=205.220.166.238; envelope-from=prvs=83144312e2=bin.meng@windriver.com; helo=mx0a-0064b401.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Guohuai Shi On Windows 'struct dirent' does not have current directory offset. Update qemu_dirent_off() to support Windows. While we are here, add a build time check to error out if a new host does not implement this helper. Signed-off-by: Guohuai Shi Signed-off-by: Bin Meng --- Changes in v2: - Use qemu_dirent_off() directly instead of coroutine hw/9pfs/9p-util.h | 11 ++++++++--- hw/9pfs/9p-util-win32.c | 7 +++++++ hw/9pfs/9p.c | 4 ++-- hw/9pfs/codir.c | 2 +- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index 5fb854bf61..892465b392 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -129,6 +129,7 @@ int statfs_win32(const char *root_path, struct statfs *stbuf); QemuFd_t openat_dir(QemuFd_t dirfd, const char *name); QemuFd_t openat_file(QemuFd_t dirfd, const char *name, int flags, mode_t mode); +off_t qemu_dirent_off_win32(void *s, void *fs); #endif static inline void close_preserve_errno(QemuFd_t fd) @@ -207,12 +208,16 @@ ssize_t fremovexattrat_nofollow(QemuFd_t dirfd, const char *filename, * so ensure it is manually injected earlier and call here when * needed. */ -static inline off_t qemu_dirent_off(struct dirent *dent) +static inline off_t qemu_dirent_off(struct dirent *dent, void *s, void *fs) { -#ifdef CONFIG_DARWIN +#if defined(CONFIG_DARWIN) return dent->d_seekoff; -#else +#elif defined(CONFIG_LINUX) return dent->d_off; +#elif defined(CONFIG_WIN32) + return qemu_dirent_off_win32(s, fs); +#else +#error Missing qemu_dirent_off() implementation for this host system #endif } diff --git a/hw/9pfs/9p-util-win32.c b/hw/9pfs/9p-util-win32.c index ed3d519937..a8b8b8c832 100644 --- a/hw/9pfs/9p-util-win32.c +++ b/hw/9pfs/9p-util-win32.c @@ -932,3 +932,10 @@ int qemu_mknodat(QemuFd_t dirfd, const char *filename, mode_t mode, dev_t dev) errno = ENOTSUP; return -1; } + +off_t qemu_dirent_off_win32(void *s, void *fs) +{ + V9fsState *v9fs = s; + + return v9fs->ops->telldir(&v9fs->ctx, (V9fsFidOpenState *)fs); +} diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 072cf67956..be247eeb30 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -2336,7 +2336,7 @@ static int coroutine_fn v9fs_do_readdir_with_stat(V9fsPDU *pdu, count += len; v9fs_stat_free(&v9stat); v9fs_path_free(&path); - saved_dir_pos = qemu_dirent_off(dent); + saved_dir_pos = qemu_dirent_off(dent, pdu->s, &fidp->fs); } v9fs_readdir_unlock(&fidp->fs.dir); @@ -2537,7 +2537,7 @@ static int coroutine_fn v9fs_do_readdir(V9fsPDU *pdu, V9fsFidState *fidp, qid.version = 0; } - off = qemu_dirent_off(dent); + off = qemu_dirent_off(dent, pdu->s, &fidp->fs); v9fs_string_init(&name); v9fs_string_sprintf(&name, "%s", dent->d_name); diff --git a/hw/9pfs/codir.c b/hw/9pfs/codir.c index 93ba44fb75..d40515a607 100644 --- a/hw/9pfs/codir.c +++ b/hw/9pfs/codir.c @@ -168,7 +168,7 @@ static int do_readdir_many(V9fsPDU *pdu, V9fsFidState *fidp, } size += len; - saved_dir_pos = qemu_dirent_off(dent); + saved_dir_pos = qemu_dirent_off(dent, s, &fidp->fs); } /* restore (last) saved position */ From patchwork Fri Nov 11 04:22:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13039641 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 7D3E3C4332F for ; Fri, 11 Nov 2022 04:26:15 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otLZc-0000Y3-PO; Thu, 10 Nov 2022 23:23:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otLZb-0000X3-Mi for qemu-devel@nongnu.org; Thu, 10 Nov 2022 23:23:23 -0500 Received: from mx0a-0064b401.pphosted.com ([205.220.166.238]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otLZZ-0001aT-4E for qemu-devel@nongnu.org; Thu, 10 Nov 2022 23:23:23 -0500 Received: from pps.filterd (m0250810.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AB4N9pt004974; Thu, 10 Nov 2022 20:23:09 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=HZO+0yGtG3Rr66MSooBmPWDGjGuHB1C3qKMoQtSVztA=; b=CAmiwHPi3kWMMvkxtyQT0j3YmtYsCb3/DVyCdSFobkPEmn5MdrJyAHDy6XsRpxQMc9eI LeLBWsf7nYzGZpcJPzwDXGLE3BepaUjG1HH1zZF4ERVL5J2dSxUkvVU9Ulj6uEu6ZakW wCbCCMgPtu1VwxDDDDk9hzCQOC4lxp8jO3DnGHR/mhBj3U8P5s7ezF6SVdGF+zPxQFrj Y51gnrQn40Z8fKnQuYvZVH/fXaGxCEBlt55pY7Urah/Tk7JWpw1Kdww2pu2vBsXLoCnv r8pUXtDT1eFsEEUyDO+alyPkAzeLs4aeocOOGgAtvKLh0ZY8f6oQRpbOtwJWeqn69gx2 Og== Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2176.outbound.protection.outlook.com [104.47.56.176]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3knk43d9m7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Nov 2022 20:23:08 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C0bJUI1zmPF0mCpgGWRSKhNjixIJAW7qYeOfUT5s+fCvqt3oDF7dbOt3Yg5eAyvGv39gk2vXCZempUINKEuY2oKJIvaYihfwsaNvjdhoKQjibuMDfvZKLY1obpsBXqEaNnvn6kyc6RwwrhW/92f87RGPnus4x/moxJ19fT5p5wPGlQg9tRqxYY3bdBcvhT3z4SKScTxaKF4DTKrqtjCEUMQ4vJdjAzTLDqJk0xraU5SHk3Wabhicxxs2OwGl8qqo4+C3mmmMsRmQRjO7R9I+FtJk5vPWg/QX2XeQ98Pf5tki8Os7IWXeDqS/YqAZFMQ2k/2Bc/BE+NNieGw30X6adA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=HZO+0yGtG3Rr66MSooBmPWDGjGuHB1C3qKMoQtSVztA=; b=J+YSTlWdf1Jw9IERNk39Jptg4pJfxuwEERrgLAZfwHUFrwgDsoaBi8gcNizMDL8EHEX8zIQ7qMd9AAmuW5VQEhIv8Slx+XOp3wMA/mg8rTtrHHaQghDA1BNtJLeohrmCoblyPqXeiV7GPxdaqJw0m/Pcf9eX/bhGXC9Tk8tEIoOVZ/PY3UOOODdx3egO2Zara/dC2p3cotu8MIhFM8anwLBafGqh7MFXlkrWa4qkp/JnBSrelWb0UVY9ETp5MdPFM0xf15de8GwSaKwxwcjheptv3czDOTtY+4qyU35VVsK/8W2QtT36lWZSuRdr4looqR5/b1e8u+b4SKcG7LK/cA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by SJ0PR11MB5102.namprd11.prod.outlook.com (2603:10b6:a03:2ac::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27; Fri, 11 Nov 2022 04:23:07 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::8e5e:71da:1e29:bc15]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::8e5e:71da:1e29:bc15%5]) with mapi id 15.20.5813.013; Fri, 11 Nov 2022 04:23:07 +0000 From: Bin Meng To: qemu-devel@nongnu.org Cc: Guohuai Shi , Christian Schoenebeck , Greg Kurz Subject: [PATCH v2 10/19] hw/9pfs: Add a helper qemu_stat_rdev() Date: Fri, 11 Nov 2022 12:22:16 +0800 Message-Id: <20221111042225.1115931-11-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221111042225.1115931-1-bin.meng@windriver.com> References: <20221111042225.1115931-1-bin.meng@windriver.com> X-ClientProxiedBy: SL2P216CA0138.KORP216.PROD.OUTLOOK.COM (2603:1096:101:1::17) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|SJ0PR11MB5102:EE_ X-MS-Office365-Filtering-Correlation-Id: cd8291a2-b08e-404c-cc4e-08dac39c6eff X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: weqdMuaU4rLTWxxIcFnxNV8I7749zyYQTOidXiq6jiZV08ydJikYMhJJ0AEC7XDGWA7BHMJ3bCRcxHRz/V9Wz8w8MeKSlC0HfN3MALK6ro3wuTQ6Sx7JIief+9rAAGU9NOen5wemEitoojuWFt4gMt9WS5okijLKZi+aWyux5FMEpAlxF0aQthcGB5xgX1yccBmY6yNyMsHMsk1ivkaXYVOq+jYAl2j3iAUGPmfvlbVIBM3tKK6/aLX8Z+t6gGhgH7uRcpHqCIhfVLb+jt2/+AD+V/3JS9vfGedZ8AIDfHDg+IXeRihGhoWSZ/1vZISB4X/OOfbKfmwSPORJ5KTEAy5O0ejnhCEsCdH6zI3NpKP4iUm9wq+uLfGOg82BrKvErhl17Fg1+tYUmTIP7aGPe/gxigRA9JRmsXH5COKxBh6SpaPK7sXvDI7d/x/Fk4Mhc37PGrGE4uZMNE8K35o+LyYBV3IxKIfIi1hX4bhl5KaKcM183zVSoQqqfnYzfidLQFqwK5hKbjH8DbHKqtsfs6LgJh8VL3UnTasvqeAyM0wEv8CoUHWoZoPgBdEi3iSnVbyWNMqpK+G5kESd0Pxmz4Iqt+iAreodJhkq4VIHQiaO2/EyOu4wW7qKdOoSiiWiaGyOMdw7yWsoFqc0vQTId+zSUWYoqiNN9xxg9TYuErrF5nbhfLg7DsgoKvZhJ9p4ZcFiMMlhBP14tNBgiZGkEf7h2OM/68PIJt0bTZj1tosdB4sSQ3h5TQX6aAB+MT4kGBr7XNm+Hlezrilcevh+0Q== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5358.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(396003)(346002)(376002)(39850400004)(366004)(136003)(451199015)(66556008)(316002)(86362001)(8676002)(66476007)(66946007)(4326008)(38350700002)(38100700002)(36756003)(44832011)(83380400001)(52116002)(6512007)(2616005)(1076003)(26005)(6506007)(478600001)(6666004)(186003)(6486002)(8936002)(41300700001)(6916009)(2906002)(54906003)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RJcoGYHiHzlqo3r+IZyGZ1GPCZOMf9KtwxMYltFAkJZC1nBLLxG7T0m5ktiUAZJQ3OXcNMNS/cBqtyoO7BUvzzzelJ9Hrp/s00OgqUH0V3dwTPoxrpBCIBK89MucGZyCL+VSji2Xm/Tr/hCeoR2lhcTeQA9Kbl52L6p8oHKK7EeUnhPb2cNbPJTqGneNtwm0iw1HZ5hUmkmjRRYNnmdtBhMT4ikv14DlMBv5WanhpX6DxejPJNXiMO+z2pKcUexYyLcDU2vpwdE8s5s0i5G9qON2sAxVrI+s+jZWYHXk+NALGH7WiJopP2nJtD+EzqZwmL8eHAuVbO4hz2/a56z/S28sYg6sOgpPbwQRhpvG3bXZKJOxfyLhTK4ADKEL0f6I/hcQD3nn9LW6nt56wYB4SdbJDikGPclLIAXWKktS5WVuNLvU8A1kN5X9qEH9hpuId4ryuoOP7nQetXFJXW9kSpraONdodYn3ayMnKWwj0HLIjR1vbQAzS3hbW4laUb1SdnJMzq0jZCTWWjBDPlcH6Ms9g13UH0U7peh7FYg1vSFTwc9wUIIRDnHk0xQUMvFCBNdhbGXpOqycvE5FmnYJuIuy45eXnQqWiJOkidx6exOhHnpF7Z6z6G3umACqMcIGfsKP5wtbzMyi0U5U368dBWQZjMUSVnmz1uRs8HeceWqjoY8uQnjh5Hg60L91invK9ANxzq/ZKgdAf5mIfV/P7EHZniuRaa+PvNNGkMrK9sOmOvhcO46uZewd3Q6AC5zIi5ptzHsd34/bMcy9SCKKpOpoN7oIgt34iZJmBbqWO+gF154PMmFblXMKtTCpT+UW7MYi7tVCM//IQoP/TQz1857PaUX4YzXENHYh5D4AYP/PzMicDQbvospuqLXvikw/wTTRH3YEZlP6lcJPO93sSnPmeOtYMC03GL13gkOT+OMLz0Ik1IcsPTTtGd197B8p1BIL+Ze8ifjdhjAg0gVo7eCSvD18kWR85j+LPDXHY91KBWkUHVo8HLrgP3d9QRLXzHDbEQnczS7F5uN8bawjv9OywHtSGtwOFl6yIhweH50AmwR3kE5f5NKKJOCJ2ndaVME6LpR1N28QFIgoWB4ntY4Nvj2+SEhWyDc3dQa5G8HzS4+EubGbfixHwcf/vbe4GFTDvIb+tBfupD7SbVpBi5JV/piwCMYsabNoqsqZJ1p4wSp+fR2iv7NGIwkisgXJd98T2wrOx9ZZ1wCuBsMQaOzzKbvybQDErXmF8D5NRcPJkEX1URAXe72AbEA6nlVLafjrWyF9U8uBIDotDN9l854dQ/HjgVE6EhAV2AhnM+cQ11aGecQ9kbygCglkWiMsvnqmLAKvdYWR2OrYOXetE1rsuoqSTM3xjsvfsAXh3dCEEviNFJTRa/zsdtjb39IokG0jF1Z92ZHDjkuEYi6oxkr9VxkmRh+05THEviJckunX06yAaQ3ui0lI+qDnijjvJ4NNLB+i8E+9QSREs6ErBpuF/8h6AuC6veLeHZU90v9CI2KKICfTs2KPyOO3j2ileZ1MFyuGYbR9YiXD35YI6cT5k08JgLDuWH0XubkEZP8awJXTXaPfppvjlvp+YxKS X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: cd8291a2-b08e-404c-cc4e-08dac39c6eff X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Nov 2022 04:23:07.2168 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: jvcUva0u6wMEHw2Splb8awU/3U5CTbFfjfTTXJSKAR2ldkvAgmAD8jOiTiS56QHDAJa+10yyJ0pIHD7fst2gJQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB5102 X-Proofpoint-ORIG-GUID: OBCfC4okHcOWlTDB0vyzypLkD0IaGLpC X-Proofpoint-GUID: OBCfC4okHcOWlTDB0vyzypLkD0IaGLpC X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-11_01,2022-11-09_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 mlxlogscore=765 lowpriorityscore=0 suspectscore=0 priorityscore=1501 phishscore=0 mlxscore=0 adultscore=0 impostorscore=0 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211110027 Received-SPF: pass client-ip=205.220.166.238; envelope-from=prvs=83144312e2=bin.meng@windriver.com; helo=mx0a-0064b401.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org As Windows host does not have stat->st_rdev field, we use the first 3 characters of the root path to build a device id. Add a helper qemu_stat_rdev() to use it to avoid direct access to stat->st_rdev. Co-developed-by: Guohuai Shi Signed-off-by: Bin Meng --- Changes in v2: - new patch: "hw/9pfs: Add a helper qemu_stat_rdev()" hw/9pfs/9p-util.h | 20 +++++++++++++++++--- hw/9pfs/9p-util-win32.c | 15 +++++++++++++++ hw/9pfs/9p.c | 7 +++++-- 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index 892465b392..c424cb00ca 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -19,7 +19,7 @@ #define O_PATH_9P_UTIL 0 #endif -#if !defined(CONFIG_LINUX) +#ifdef CONFIG_DARWIN /* * Generates a Linux device number (a.k.a. dev_t) for given device major @@ -51,10 +51,12 @@ static inline uint64_t makedev_dotl(uint32_t dev_major, uint32_t dev_minor) */ static inline uint64_t host_dev_to_dotl_dev(dev_t dev) { -#ifdef CONFIG_LINUX +#if defined(CONFIG_LINUX) || defined(CONFIG_WIN32) return dev; -#else +#elif defined(CONFIG_DARWIN) return makedev_dotl(major(dev), minor(dev)); +#else +#error Missing host_dev_to_dotl_dev() implementation for this host system #endif } @@ -130,6 +132,7 @@ QemuFd_t openat_dir(QemuFd_t dirfd, const char *name); QemuFd_t openat_file(QemuFd_t dirfd, const char *name, int flags, mode_t mode); off_t qemu_dirent_off_win32(void *s, void *fs); +uint64_t qemu_stat_rdev_win32(void *fs_ctx); #endif static inline void close_preserve_errno(QemuFd_t fd) @@ -251,6 +254,17 @@ static inline struct dirent *qemu_dirent_dup(struct dirent *dent) return g_memdup(dent, sz); } +static inline uint64_t qemu_stat_rdev(const struct stat *stbuf, void *fs_ctx) +{ +#if defined(CONFIG_LINUX) || defined(CONFIG_DARWIN) + return stbuf->st_rdev; +#elif defined(CONFIG_WIN32) + return qemu_stat_rdev_win32(fs_ctx); +#else +#error Missing qemu_stat_rdev() implementation for this host system +#endif +} + /* * As long as mknodat is not available on macOS, this workaround * using pthread_fchdir_np is needed. qemu_mknodat is defined in diff --git a/hw/9pfs/9p-util-win32.c b/hw/9pfs/9p-util-win32.c index a8b8b8c832..44c10370ae 100644 --- a/hw/9pfs/9p-util-win32.c +++ b/hw/9pfs/9p-util-win32.c @@ -939,3 +939,18 @@ off_t qemu_dirent_off_win32(void *s, void *fs) return v9fs->ops->telldir(&v9fs->ctx, (V9fsFidOpenState *)fs); } + +uint64_t qemu_stat_rdev_win32(void *fs_ctx) +{ + uint64_t rdev = 0; + LocalData *data = ((FsContext *)fs_ctx)->private; + + /* + * As Windows host does not have stat->st_rdev field, we use the first + * 3 characters of the root path to build a device id. + * + * (Windows root path always starts from a driver letter like "C:\") + */ + memcpy(&rdev, data->root_path, 3); + return rdev; +} diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index be247eeb30..7080503b97 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -1266,7 +1266,8 @@ static int coroutine_fn stat_to_v9stat(V9fsPDU *pdu, V9fsPath *path, } else if (v9stat->mode & P9_STAT_MODE_DEVICE) { v9fs_string_sprintf(&v9stat->extension, "%c %u %u", S_ISCHR(stbuf->st_mode) ? 'c' : 'b', - major(stbuf->st_rdev), minor(stbuf->st_rdev)); + major(qemu_stat_rdev(stbuf, &pdu->s->ctx)), + minor(qemu_stat_rdev(stbuf, &pdu->s->ctx))); } else if (S_ISDIR(stbuf->st_mode) || S_ISREG(stbuf->st_mode)) { v9fs_string_sprintf(&v9stat->extension, "%s %lu", "HARDLINKCOUNT", (unsigned long)stbuf->st_nlink); @@ -1340,13 +1341,15 @@ static int32_t stat_to_iounit(const V9fsPDU *pdu, const struct stat *stbuf) static int stat_to_v9stat_dotl(V9fsPDU *pdu, const struct stat *stbuf, V9fsStatDotl *v9lstat) { + dev_t rdev = qemu_stat_rdev(stbuf, &pdu->s->ctx); + memset(v9lstat, 0, sizeof(*v9lstat)); v9lstat->st_mode = stbuf->st_mode; v9lstat->st_nlink = stbuf->st_nlink; v9lstat->st_uid = stbuf->st_uid; v9lstat->st_gid = stbuf->st_gid; - v9lstat->st_rdev = host_dev_to_dotl_dev(stbuf->st_rdev); + v9lstat->st_rdev = host_dev_to_dotl_dev(rdev); v9lstat->st_size = stbuf->st_size; v9lstat->st_blksize = stat_to_iounit(pdu, stbuf); v9lstat->st_blocks = stbuf->st_blocks; From patchwork Fri Nov 11 04:22:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13039647 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 0F62CC4332F for ; Fri, 11 Nov 2022 04:27:06 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otLZe-0000Z8-JI; Thu, 10 Nov 2022 23:23:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otLZc-0000Y4-UX for qemu-devel@nongnu.org; Thu, 10 Nov 2022 23:23:24 -0500 Received: from mx0a-0064b401.pphosted.com ([205.220.166.238]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otLZb-0001au-3F for qemu-devel@nongnu.org; Thu, 10 Nov 2022 23:23:24 -0500 Received: from pps.filterd (m0250809.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AB4CtKE030334; Thu, 10 Nov 2022 20:23:11 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=vsiZrQUtUBTAU4WuT6dlDDfQS+EyxZPRhMhDYhmH78c=; b=Lc4uOYIRgDL3c7nZQl0EGTj4JfCvBIVp/qvLY9cPuXMISPfY0v4ojvNg0TREL+XhxIAh rDRZ3O/6EWVm9kxhNL5aFgOJUGj+yqhIuamw1gMcticcp4bvtxnTF63mF+6LxALeLn8I ts9d+WBjg90cGVPq0pxDKKx4ZU1hL4cexNdTVrj3yBzHKFxoI2Jg6G8O3tg/3oDQvzIL AnWq64DzArFN4nIYVM92ZdRrKoLayQ24sOZtC3Ebl+AIv5knGybQHQsnPEDsMpN/KqOZ JLKITzvJVLPv1ZpKK14IG0aL27TQ6ee3neBx0v/mkfXoalyGe3q6oOU9PwzzRO/lt6Ko 8w== Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2172.outbound.protection.outlook.com [104.47.56.172]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3knqbkn4dt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Nov 2022 20:23:10 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bW3UdsDtgMzEhGPtezXJEnl6X9dxSwbVKHK8OuIKD0Euy+AV57kL8D/rvqy5Y9+sb1ByZNPsRYC1rJVOJcpPFOsI9qkyBE9eqG3qkCQhMZrvtFeWVRrCrH+iZv24mrqpVpWGF2HjpQR5WgFwd0EBJGkMQGWfLlgSxFI7GEB0MHs1TzaC3YsT9Ir9qquH3zputonGSdXBNlajIqUcZ6E32hAwmWENNqDdpvxGutRZx8kmRW9+BS9j+x+whp9FLePLwjahjmujB5lgi3QzDAaeFbTQN42p9IBWr4Qeq9CTzDQhf4nxCknNfB2EPtrTMuJby0PlR+1X1UnEQjWbefZyUw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=vsiZrQUtUBTAU4WuT6dlDDfQS+EyxZPRhMhDYhmH78c=; b=WJJaeIkcb5MngxTuqJefQ77KhoDrt1kFSbFTtKXbzeq89gz4mrPuIBBL6aBoZSTkWMXp1ODZJX/3XNA1Bn56eUR/vmjeoW2i95S0FCLMUrfqJUuCJhBJAJEGBO61rQFpQVNUaNASNGxgfV4kBEz/KPS+Dv5iZZgU6Ug1baJgjbZ6QdNCojMqk6r/+8cVyIU4xPGfseYxliedUrj03aU/02wGEk5mQ3fOswczz2oghTMJOW8Lvwy3f3agp+bRAMH/qRd8E5EVOAmddP4uS7b1jBmYyiKhm+Iy3PaMr8Zia/sq+x6H6RTFl91uG/JNsg0MqtqArZjjrL80YZE4iauukA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by SJ0PR11MB5102.namprd11.prod.outlook.com (2603:10b6:a03:2ac::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27; Fri, 11 Nov 2022 04:23:09 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::8e5e:71da:1e29:bc15]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::8e5e:71da:1e29:bc15%5]) with mapi id 15.20.5813.013; Fri, 11 Nov 2022 04:23:09 +0000 From: Bin Meng To: qemu-devel@nongnu.org Cc: Guohuai Shi , Christian Schoenebeck , Greg Kurz Subject: [PATCH v2 11/19] hw/9pfs: Add a helper qemu_stat_blksize() Date: Fri, 11 Nov 2022 12:22:17 +0800 Message-Id: <20221111042225.1115931-12-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221111042225.1115931-1-bin.meng@windriver.com> References: <20221111042225.1115931-1-bin.meng@windriver.com> X-ClientProxiedBy: SL2P216CA0138.KORP216.PROD.OUTLOOK.COM (2603:1096:101:1::17) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|SJ0PR11MB5102:EE_ X-MS-Office365-Filtering-Correlation-Id: bb173cf3-1aa3-40ab-ce4a-08dac39c7027 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: k8Zc3lYhpQAFegh6UE1rOaNb7PsuE+XmPJDvhMKtfmEQ4DHKPE3FsrhTK3OzvfN8Qs1jWI9KKUjp/hN+sSzNRp9AIIxkK1FBZAq27gc6HtZwoJ3AlRS1GjGl7MBXaGgYugec2giqgwZwT60swGbdnBP7x3rZ3ceiM19KMcHAMbFK1frLXC934EqfgbscYG15E0uSVfJqvAkdLHiNxtn/Scj0FuIkgsGvR4FtaiiygYnUi3PSPUixXRg1S8huUm0Wi1SEuv6nAmpb0toY/+WrQ81+4h6AVsTH1uh73c1Nn6qTfXSh/TUDx3i5ZoBgAXxJNZEk5/dd0ZQI1NJtWcWC9Q6eSinq1qoQehjIztvQNmsVIEfo8Z5GMcr7+mkeoLBIopdEG2HzJaDx29LBXUY1rxtUlF4dLMVnNT2A7aoJnH90EpveSTAygdCiLwX2SyouOuf80xLxSMpyAj13bNxNcW5FXdPb6qB5PUFrjVunuc1Xk/3HRGPdPCd5/tfWbl131uNpaVYYg7z687z8iAoCgeAyC9LupKtnSH5TgEC12jfL67MSyrFT+xWWJEiXrXLY9l5aUItraOXhcfHxMVt51YSd0nDDQreOWj0liOJ3sKHffgvRPeorZFpeW5O3IBAC7vqbJZ17XpTFHsb2MBXqaDpvne7ayXlryRNItCob+4t0QambCyGqHAzCMb7pFZKodBbJKe99wBVehY/GmI8soWmlt4AcBSkNkZQu6IFpJe5nOFBog8DqLqua0h0bjPryPpuyq6XBXuPLIOUKq3kHeQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5358.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(396003)(346002)(376002)(39850400004)(366004)(136003)(451199015)(66556008)(316002)(86362001)(8676002)(66476007)(66946007)(4326008)(38350700002)(38100700002)(36756003)(44832011)(83380400001)(52116002)(6512007)(2616005)(1076003)(26005)(6506007)(478600001)(6666004)(186003)(6486002)(8936002)(41300700001)(6916009)(2906002)(54906003)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Em+47rLHY+klanWxWV2j4FgoEqjTSvNfmGfz9xLi7AXIx4i0+RrWdUyXLhQSsSBOxcTO36oT3snkkxRKsJtsqtr6yTu/vjSF4ZMaAx0nRGM3adr+zgUww5ERyqIJf7cLbo/kQ9M7zfcVGJp+lu5DRyIFRjy6DmMDF2oDJQm9yy2J3Fl98oJfDyLOyspreHxoV717zuOAtO5KgZts/+nLOgYTxWR9cwnGptRpBHHcUHUeK5pOE7MZOrR4kU5GHPQUR+vGkWb1Mk+EEy5X1y3ZviTI4VfbF++0kHNjGOEUr8aHerNYrg9AE9DvQFu+OlrfdoICAjRKs5pWlpOvuRPext7c8yMd+RShxI2CtiwQNujUjpRoQsH96C1yBdacESLHQKFtvmsgt9jfTP0hHhkuF5k1n6dSJSDJE2Ozhr7+d55Km46BWhGuc9wBH3rO0l3zgUsKaxqLGslEHmiYg6Evda3cuzvfCnsD6LxwGwUmALMoATr9qWBnh4Ozmz0MaZrsW6pJKkiFI1HZWIPznp4Cjd5jWB75raMxwwCbyI4NFeclPhXL/HUMEKIpH8QAiog7velt1BQpWwPoGdohbe2Wwt/TTz9+iuWA29nPdChKQpfPxqy2x0hEe63ANHfJKmzVwjJYjqO/1UVKVR1H+O2TG9tQ5JkK5rxn5sivfCYg/uVw6P1i0pRNfMP1ug1b66db/3AB+pOB8jX8larviM4CVq65zhsw1hywd4ERznhyg05ltbX1cKnWVBDyoDUhZlcsmHmL8i76BzM+bL6MYQYW00np2cgSrD9vcC0gIs5DpbVqTumFULpjKA3ozbIyPduML5nBQWEJAY1Z59PmNagvjxdmQdhfAgRUSK4X9BhcvHMnOkr89IfLPo1LCnAkA9CNmvF3x79wQ/8BsLbFJ7XEFObTXRbXNl7zV1taQ/LWZlOnlhDQ86smyPTmQkPR11w6obL8fPVw4qJ1albRtBnY08eRV/f9i+MGSZT6G0tFKsA1rDDhqLOpVuN2qn7VNXz5k7ixBWdynZZVJ3otslwSi7vXEIOt0EM9aHQqBbZGstu8V792NksMEMA+0TEaXyf6j0wvasqOvhpXjPgEpGJUYYIC7qKoVDIBnbmXJuHwe+Np+4uXg11rmWSJKVUF7FgfWCJKjZ5VWpXQzZQJ3TXH/B/M8ZxNN3KIjU/GhoalOSPjjd2+BIFeHgEwg3x4nx3IlMjPiAvPeentM5Tgw/eCR9p83vLo0IS17DEvNV5lZmXYd0KHvbYqGs6o9rgPbXL45Sja6SgC13GTJd9WCYNiAfmuy62j+7Z0xhJr6w2IhQQbvax4HVflOzlVPbyxyyGpAYVwSj0yMKP/AjFxOqFFAGmwLcrUmmgc37zz/fSFTvxNwvI6MDcu6M9XJd1I/IMRPg+iKdimJLDtqGUfoFmTjvFZHNhqzQU6tVVyonrDL5LUAOQo8AuX/tOZXmcnB8ce4c6cWSUkH0oll5b3mwES8RRhHIcMOjokdtt7BnZpPPs3QSbxIlfsoh6gzP0XwrXbHOIpuo+oVjRKUH3/BcBhDzuqOL3cn1VgvDgXWErttLktTWzBZ4XvYCraqH7lJJxe X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: bb173cf3-1aa3-40ab-ce4a-08dac39c7027 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Nov 2022 04:23:09.1567 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: nTcHv4qHEjEK7WPoiUkZKXMI9WOW4SQEYxCF6aRGEX+NERxAuZpisRHmCyEzPi2cdKDHBTuWAi68MxDRbwCW4A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB5102 X-Proofpoint-GUID: lQBsYuNd7BF1-sP5PLSKGq4tbH-jxYqf X-Proofpoint-ORIG-GUID: lQBsYuNd7BF1-sP5PLSKGq4tbH-jxYqf X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-11_02,2022-11-09_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 mlxlogscore=784 bulkscore=0 suspectscore=0 spamscore=0 impostorscore=0 phishscore=0 malwarescore=0 priorityscore=1501 clxscore=1015 adultscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211110027 Received-SPF: pass client-ip=205.220.166.238; envelope-from=prvs=83144312e2=bin.meng@windriver.com; helo=mx0a-0064b401.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org As Windows host does not have stat->st_blksize field, we use the one we calculated in init_win32_root_directory(). Add a helper qemu_stat_blksize() and use it to avoid direct access to stat->st_blksize. Co-developed-by: Guohuai Shi Signed-off-by: Bin Meng --- Changes in v2: - new patch: "hw/9pfs: Add a helper qemu_stat_blksize()" hw/9pfs/9p-util.h | 12 ++++++++++++ hw/9pfs/9p-util-win32.c | 7 +++++++ hw/9pfs/9p.c | 7 ++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index c424cb00ca..df84374b78 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -133,6 +133,7 @@ QemuFd_t openat_file(QemuFd_t dirfd, const char *name, int flags, mode_t mode); off_t qemu_dirent_off_win32(void *s, void *fs); uint64_t qemu_stat_rdev_win32(void *fs_ctx); +uint64_t qemu_stat_blksize_win32(void *fs_ctx); #endif static inline void close_preserve_errno(QemuFd_t fd) @@ -265,6 +266,17 @@ static inline uint64_t qemu_stat_rdev(const struct stat *stbuf, void *fs_ctx) #endif } +static inline uint64_t qemu_stat_blksize(const struct stat *stbuf, void *fs_ctx) +{ +#if defined(CONFIG_LINUX) || defined(CONFIG_DARWIN) + return stbuf->st_blksize; +#elif defined(CONFIG_WIN32) + return qemu_stat_blksize_win32(fs_ctx); +#else +#error Missing qemu_stat_blksize() implementation for this host system +#endif +} + /* * As long as mknodat is not available on macOS, this workaround * using pthread_fchdir_np is needed. qemu_mknodat is defined in diff --git a/hw/9pfs/9p-util-win32.c b/hw/9pfs/9p-util-win32.c index 44c10370ae..064f878e5e 100644 --- a/hw/9pfs/9p-util-win32.c +++ b/hw/9pfs/9p-util-win32.c @@ -954,3 +954,10 @@ uint64_t qemu_stat_rdev_win32(void *fs_ctx) memcpy(&rdev, data->root_path, 3); return rdev; } + +uint64_t qemu_stat_blksize_win32(void *fs_ctx) +{ + LocalData *data = ((FsContext *)fs_ctx)->private; + + return (uint64_t)data->block_size; +} diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 7080503b97..169578cc1d 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -1335,7 +1335,7 @@ static int32_t blksize_to_iounit(const V9fsPDU *pdu, int32_t blksize) static int32_t stat_to_iounit(const V9fsPDU *pdu, const struct stat *stbuf) { - return blksize_to_iounit(pdu, stbuf->st_blksize); + return blksize_to_iounit(pdu, qemu_stat_blksize(stbuf, &pdu->s->ctx)); } static int stat_to_v9stat_dotl(V9fsPDU *pdu, const struct stat *stbuf, @@ -1352,7 +1352,12 @@ static int stat_to_v9stat_dotl(V9fsPDU *pdu, const struct stat *stbuf, v9lstat->st_rdev = host_dev_to_dotl_dev(rdev); v9lstat->st_size = stbuf->st_size; v9lstat->st_blksize = stat_to_iounit(pdu, stbuf); +#if defined(CONFIG_LINUX) || defined(CONFIG_DARWIN) v9lstat->st_blocks = stbuf->st_blocks; +#elif defined(CONFIG_WIN32) + v9lstat->st_blocks = ROUND_UP(v9lstat->st_size / v9lstat->st_blksize, + v9lstat->st_blksize); +#endif v9lstat->st_atime_sec = stbuf->st_atime; v9lstat->st_mtime_sec = stbuf->st_mtime; v9lstat->st_ctime_sec = stbuf->st_ctime; From patchwork Fri Nov 11 04:22:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13039640 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 91445C43219 for ; Fri, 11 Nov 2022 04:26:02 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otLZh-0000aJ-9c; Thu, 10 Nov 2022 23:23:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otLZg-0000Zo-0r for qemu-devel@nongnu.org; Thu, 10 Nov 2022 23:23:28 -0500 Received: from mx0a-0064b401.pphosted.com ([205.220.166.238]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otLZe-0001bv-3F for qemu-devel@nongnu.org; Thu, 10 Nov 2022 23:23:27 -0500 Received: from pps.filterd (m0250809.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AB4JruM011527; Thu, 10 Nov 2022 20:23:13 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=oE/jEJRyYyIld6FO/F1csjXJv6UzdqPxqp8YPSsk74E=; b=eLXmRgI896+b0/KPVUJXwitowAAZiUwNTe83RFlkhQ5SjNJkkPa3Op3pVo703UJnO2W4 3JFFhUvyvEp3cNUCeggeRyayBeZ26R9H4IcWWN+wve8MoYs1XFq5pmZwN1Who/RFqJjq zgu81w+7wwIemh8sMb4dZZhfWU9vRdhJbccIuonFvX+ld2Nw+vypAHpxqbKu4lpfD0Jr y8Fr5RUm+W6IIXrne7sJ8CTtvawj3+oYyW/ipaFCg8x11nmOa3vFyFeSheFBC7hoWJES hly+Hh46l0+JtqVuEmU6NJD3PYCb77/dBcY+96LL6v7BMCEGGSFbWVU+9G1b32NsHIvr 3A== Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2176.outbound.protection.outlook.com [104.47.56.176]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3knqbkn4dv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Nov 2022 20:23:12 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m/mfWejRqzd++UIG35zcW+h6WTwHHVlPVSHZwOUJfOKEymPN7dN9tpGMTY+wmohI6k/k4H1CHUdnwkX0ynAENf+aNVYF4HZCr1oJEsgg+/0wzpn+fFXkej3TixUBsRhnUk0pTspGAufW74YkmRDpEQgsUOSp8v8GU0dzLzlUksZXvNNhKcVCJHN6QdPM78RfRD3zRWa3gx13f+e8S4eDtJChuYQfOCEUvpQCyGoyJ3DpSB+PYOM0Tfinx+aErT/cpBr1V4W5E0LEjP9vcnd0jtPF2LKLdgKni4EBEsV458i06Mn8sBxX87FAVBL6IiOiMOgHnMe24pE5Fm1G5NEFOA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=oE/jEJRyYyIld6FO/F1csjXJv6UzdqPxqp8YPSsk74E=; b=MlsNORP0uw7T3vso9FPBFDDJVCeDkdCSUnd7QCqGjqOkoGw9ZFDk5EoefBCsQ1U5vf98reuc2vWsXogXG50cAMhpLpFbMLot2Ltu/RD4B8VU1O7eBPNdykX2v5xEByWwzF5XjWc3KWQAAObAjiRKZCwBOU+YjCtY3neI91nnGKqXkMz4EQXysnItR1O7cudry94CRyICxpQN5j4d95jGaDAzc87elxxaBcm47bpm6GMyd9wKVclgeKn3zorf477DoAVPd9FSIFSad4bvxy+CryoFhYf7oDCo9uEc2M8/6UWoFiJeRq2hv/ePalAIlMjZUMOa1JSjhy7RPo04EvP3uQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by SJ0PR11MB5102.namprd11.prod.outlook.com (2603:10b6:a03:2ac::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27; Fri, 11 Nov 2022 04:23:11 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::8e5e:71da:1e29:bc15]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::8e5e:71da:1e29:bc15%5]) with mapi id 15.20.5813.013; Fri, 11 Nov 2022 04:23:11 +0000 From: Bin Meng To: qemu-devel@nongnu.org Cc: Guohuai Shi , Christian Schoenebeck , Greg Kurz Subject: [PATCH v2 12/19] hw/9pfs: Disable unsupported flags and features for Windows Date: Fri, 11 Nov 2022 12:22:18 +0800 Message-Id: <20221111042225.1115931-13-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221111042225.1115931-1-bin.meng@windriver.com> References: <20221111042225.1115931-1-bin.meng@windriver.com> X-ClientProxiedBy: SL2P216CA0138.KORP216.PROD.OUTLOOK.COM (2603:1096:101:1::17) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|SJ0PR11MB5102:EE_ X-MS-Office365-Filtering-Correlation-Id: d10076c4-96c6-4ef7-700a-08dac39c7154 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2ZBmpo/5U+KdvqTCW8CrgwhIRzyoYBAXC1dWN/wxepAZMGUdkCbLYi8UcYvDlH23Pdp/rF6RCEWihG6xkGG18+rJLDVoneZCQ7L6KemYhLXTFMfT1gPbT9Jk5hEL03HNUO9/y3N2aQZmITKASo+/8jqLaKEn3JjMl9MJc6nuR1brcaMKSaw54ucuAlxD3T/RKyRupYEoiDRyd/ZC6vcE9O0G/eJT6LBxmbf94vEofI3+R/q8iJWrOfbgR8q8CYJ8Jz7yRa6iyqwdeI0Kb0t4jDS+FLidZRN9yOhFBwAKvhxUCt6ZTz+1SyWtx8mKyEO2f7ZYCuEHvrQGP5YkT82O9TkCCzow/v/KnXtEvSmr9FYLJkPalrV6rST5g82RRVsbAPs15dPAhNrFXuJoFUgDK8DH2Ao1A5/7cu0YKUnb+DpcZZw6nmnqfZppw2GQHolJ8OYEB6pS2qeD+TCnKhrZZhzAO2moe41lT8lJlO2KY6YEJQz6JVxpnwCx8K+a8UmW3yh4WKzZhN9le6tBeAwC6dB98dmWo3faaSwdwVYKpKKCoG0pVWNB6gzSWcEDYbPu0NogYI0Gk3spbOEdQfQ6dCCpT5TKh5XqAyBME52wVVY3sYm0U8+YF/kV0fKQoii3PExt+bSLEE9KnnsvkURPdGcRx9Bo2fgKNSb+MnkKh7BMDbo8P2ONaniozxTCHYBbmjbFNasR2SFWb4S0JuUle2yMUXn8fHaXMKLV1ViBZLQXCyPjqE4McKHWWoMNZpy/98Turq6/9Q58spBfWO5D+A== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5358.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(396003)(346002)(376002)(39850400004)(366004)(136003)(451199015)(66556008)(316002)(86362001)(8676002)(66476007)(66946007)(4326008)(38350700002)(38100700002)(36756003)(44832011)(83380400001)(52116002)(6512007)(2616005)(1076003)(26005)(6506007)(478600001)(186003)(6486002)(8936002)(41300700001)(6916009)(2906002)(54906003)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CdKCpGRk89wJzrsEIZptTk45bGZ89Ft/TWeSTSPNlEEZfU0QmMleWD5gby6FBHISc52EszoT0yIFJF02IKe1vS1sAxkPmkNNT8GH7es40UVUh3EjUs6gp8mmwPUeX2w/d4SpJWbtGQRqjJAmMtub8FXogCojataV0rxh9TihhjNwngF92C0c+PHgWwu0oU9ZtoaFJQUjczrmTD3Ja9Zvel58bCluOG0sYMADxGi7GuR0D4RS0Qd/hK8loTssumMnV3WBLQo2zaq83VhXKGexkOtpKFP54LeKnCoOUS01+IKTm4Q/j5b8fSwmmVCKYAHqdsqVAstlxWzqtZBUg9ZmEeZJRswOX+nPXyjaIF0U3m+EWPR32moJniTLqLXG2CWEFMNusEJr5xYAPhwsKo5SQEz5XmTeh58RVMmdlupKE+qTgTJI/eqQaihniJwN9N65tSaLbl2cb1X17JiE2uU3zHycfeCDKRNpr/VZLwyrYTfGdATnQQyju/nW3bQ17ssq2Av2o2tqQK2RAx5C2YbGpIjDvpZgLAQG1t0bgEwC0awPTiKr9317E4KLmjtoi3mNA44Kd79Wdw3rGx8h7chNi2tnd/4MQUimeeknoO9hRGvKsHQO0khPUaV0IFaB2uMgw/tLQ6mLekGP/JdR+CM9bFaq+DwyDMWG/ARfXitnca/6sGtnT9nEUcPCCY8Dofjz/r8UoEEzIgz2EQK0nWwp4ITu7k0x9Vb7Doj+Kz9TvmXwih4zzaeKu9BGdhZOnc69Ko0eMUQjy8RvAa4xk63feIfNlzGPJPi6Mmkh81YVd5sDGFKkIIqCzPqLLcs/59KxwylR9a051xvz7QA4CiBMxL5rm2vADKUHdPZ9mpi3jFcjjY3E/HkW5E0bPZgKLohtAiYhYKSUWWj0tMcxQfhOnmJ7eoZxLBZrcSeuqr+xnD0Qs1UjvwuA6ZaUAN1J5muYFOx0l+J+dwWGhdryGwjJvUrMo3SQfSIeSn2C0pg2ttnZz9BtuPSIas9hx7B7H6VO+q8S6OfhMHacvbN5Oh6hSvyogkmxHeNd/1OL8ffjzwBced89tgpFEqPg0VeKu044H8dcm2dxx45lONOj4r4Yy98PfzJCi09LKYwfXy5siBGGnY03Gk1SjDLTIt1fcrnV0nid6VQqiTXufBesLpABliliP7AjJ/tIoW7YmwKXfOgsLvojjbXs07CbZzZjKqug3heguGrIVP2aGyVYUPsBuaOonZwI2tXsjXSxL8tFP/ufjZS0UyzC79RsZNx+gsLWVhxhVNfga3FzSflmjHhteqG26Fef3dDu6BR5Ru3f1DAxvUw3GWM8/Y3MwFje/8duMqWsvS1C7H4L5fr2iBI8IrGcGcJBGhydkeff+isaY7rgSiKb8Mj8/FrdeyBXnMVcJph3llktT1fITUn29Gwi09Z567fCIjMuMKm3uLFETOA54oopnEaYoWbZf3zSSzhNOCbTVORZYYUK+AybXQ2L3znnDJhkOTNoFc+d5FJ5C7tvG7kKFi6b9ICQhaNSTJlOuqsmtokaLAssyzhE+txm6T/4OW+GM5jFKOLX+ilaq4ntMI5deazTW9aHo4vQJR3i X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: d10076c4-96c6-4ef7-700a-08dac39c7154 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Nov 2022 04:23:11.1582 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: tQLU3xyb2nuBSe9ocvm4d6KWy4TLnV343SgghzSvpDhNinpGdjyYx11bqh1lM/Rw6cXmppbjHSNJffbjij1fnw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB5102 X-Proofpoint-GUID: ny6i8Zf_BYpRhP6uLe2RlNX78OATMrgf X-Proofpoint-ORIG-GUID: ny6i8Zf_BYpRhP6uLe2RlNX78OATMrgf X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-11_02,2022-11-09_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 mlxlogscore=999 bulkscore=0 suspectscore=0 spamscore=0 impostorscore=0 phishscore=0 malwarescore=0 priorityscore=1501 clxscore=1015 adultscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211110027 Received-SPF: pass client-ip=205.220.166.238; envelope-from=prvs=83144312e2=bin.meng@windriver.com; helo=mx0a-0064b401.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Guohuai Shi Some flags and features are not supported on Windows, like mknod, readlink, file mode, etc. Update the codes for Windows. Signed-off-by: Guohuai Shi Signed-off-by: Bin Meng --- Changes in v2: - Use precise platform check in ifdefs to avoid automatically opting-out other future platforms unintentionally hw/9pfs/9p.c | 45 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 169578cc1d..0b5e1fa8d2 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -39,6 +39,11 @@ #include "qemu/xxhash.h" #include +#ifdef CONFIG_WIN32 +#define UTIME_NOW ((1l << 30) - 1l) +#define UTIME_OMIT ((1l << 30) - 2l) +#endif + int open_fd_hw; int total_open_fd; static int open_fd_rc; @@ -132,13 +137,17 @@ static int dotl_to_open_flags(int flags) DotlOpenflagMap dotl_oflag_map[] = { { P9_DOTL_CREATE, O_CREAT }, { P9_DOTL_EXCL, O_EXCL }, +#ifndef CONFIG_WIN32 { P9_DOTL_NOCTTY , O_NOCTTY }, +#endif { P9_DOTL_TRUNC, O_TRUNC }, { P9_DOTL_APPEND, O_APPEND }, +#ifndef CONFIG_WIN32 { P9_DOTL_NONBLOCK, O_NONBLOCK } , { P9_DOTL_DSYNC, O_DSYNC }, { P9_DOTL_FASYNC, FASYNC }, -#ifndef CONFIG_DARWIN +#endif +#if !defined(CONFIG_DARWIN) && !defined(CONFIG_WIN32) { P9_DOTL_NOATIME, O_NOATIME }, /* * On Darwin, we could map to F_NOCACHE, which is @@ -151,8 +160,10 @@ static int dotl_to_open_flags(int flags) #endif { P9_DOTL_LARGEFILE, O_LARGEFILE }, { P9_DOTL_DIRECTORY, O_DIRECTORY }, +#ifndef CONFIG_WIN32 { P9_DOTL_NOFOLLOW, O_NOFOLLOW }, { P9_DOTL_SYNC, O_SYNC }, +#endif }; for (i = 0; i < ARRAY_SIZE(dotl_oflag_map); i++) { @@ -179,8 +190,11 @@ static int get_dotl_openflags(V9fsState *s, int oflags) * Filter the client open flags */ flags = dotl_to_open_flags(oflags); - flags &= ~(O_NOCTTY | O_ASYNC | O_CREAT); -#ifndef CONFIG_DARWIN + flags &= ~(O_CREAT); +#ifndef CONFIG_WIN32 + flags &= ~(O_NOCTTY | O_ASYNC); +#endif +#if !defined(CONFIG_DARWIN) && !defined(CONFIG_WIN32) /* * Ignore direct disk access hint until the server supports it. */ @@ -1117,12 +1131,14 @@ static mode_t v9mode_to_mode(uint32_t mode, V9fsString *extension) if (mode & P9_STAT_MODE_SYMLINK) { ret |= S_IFLNK; } +#ifndef CONFIG_WIN32 if (mode & P9_STAT_MODE_SOCKET) { ret |= S_IFSOCK; } if (mode & P9_STAT_MODE_NAMED_PIPE) { ret |= S_IFIFO; } +#endif if (mode & P9_STAT_MODE_DEVICE) { if (extension->size && extension->data[0] == 'c') { ret |= S_IFCHR; @@ -1203,6 +1219,7 @@ static uint32_t stat_to_v9mode(const struct stat *stbuf) mode |= P9_STAT_MODE_SYMLINK; } +#ifndef CONFIG_WIN32 if (S_ISSOCK(stbuf->st_mode)) { mode |= P9_STAT_MODE_SOCKET; } @@ -1210,6 +1227,7 @@ static uint32_t stat_to_v9mode(const struct stat *stbuf) if (S_ISFIFO(stbuf->st_mode)) { mode |= P9_STAT_MODE_NAMED_PIPE; } +#endif if (S_ISBLK(stbuf->st_mode) || S_ISCHR(stbuf->st_mode)) { mode |= P9_STAT_MODE_DEVICE; @@ -1365,7 +1383,8 @@ static int stat_to_v9stat_dotl(V9fsPDU *pdu, const struct stat *stbuf, v9lstat->st_atime_nsec = stbuf->st_atimespec.tv_nsec; v9lstat->st_mtime_nsec = stbuf->st_mtimespec.tv_nsec; v9lstat->st_ctime_nsec = stbuf->st_ctimespec.tv_nsec; -#else +#endif +#ifdef CONFIG_LINUX v9lstat->st_atime_nsec = stbuf->st_atim.tv_nsec; v9lstat->st_mtime_nsec = stbuf->st_mtim.tv_nsec; v9lstat->st_ctime_nsec = stbuf->st_ctim.tv_nsec; @@ -2488,6 +2507,7 @@ static int coroutine_fn v9fs_do_readdir(V9fsPDU *pdu, V9fsFidState *fidp, struct dirent *dent; struct stat *st; struct V9fsDirEnt *entries = NULL; + unsigned char d_type = 0; /* * inode remapping requires the device id, which in turn might be @@ -2549,10 +2569,13 @@ static int coroutine_fn v9fs_do_readdir(V9fsPDU *pdu, V9fsFidState *fidp, v9fs_string_init(&name); v9fs_string_sprintf(&name, "%s", dent->d_name); +#ifndef CONFIG_WIN32 + d_type = dent->d_type; +#endif /* 11 = 7 + 4 (7 = start offset, 4 = space for storing count) */ len = pdu_marshal(pdu, 11 + count, "Qqbs", &qid, off, - dent->d_type, &name); + d_type, &name); v9fs_string_free(&name); @@ -2908,8 +2931,12 @@ static void coroutine_fn v9fs_create(void *opaque) v9fs_path_copy(&fidp->path, &path); v9fs_path_unlock(s); } else if (perm & P9_STAT_MODE_SOCKET) { +#ifndef CONFIG_WIN32 err = v9fs_co_mknod(pdu, fidp, &name, fidp->uid, -1, 0, S_IFSOCK | (perm & 0777), &stbuf); +#else + err = -ENOTSUP; +#endif if (err < 0) { goto out; } @@ -3979,7 +4006,7 @@ out_nofid: #if defined(CONFIG_LINUX) /* Currently, only Linux has XATTR_SIZE_MAX */ #define P9_XATTR_SIZE_MAX XATTR_SIZE_MAX -#elif defined(CONFIG_DARWIN) +#elif defined(CONFIG_DARWIN) || defined(CONFIG_WIN32) /* * Darwin doesn't seem to define a maximum xattr size in its user * space header, so manually configure it across platforms as 64k. @@ -3996,6 +4023,8 @@ out_nofid: static void coroutine_fn v9fs_xattrcreate(void *opaque) { + V9fsPDU *pdu = opaque; +#ifndef CONFIG_WIN32 int flags, rflags = 0; int32_t fid; uint64_t size; @@ -4004,7 +4033,6 @@ static void coroutine_fn v9fs_xattrcreate(void *opaque) size_t offset = 7; V9fsFidState *file_fidp; V9fsFidState *xattr_fidp; - V9fsPDU *pdu = opaque; v9fs_string_init(&name); err = pdu_unmarshal(pdu, offset, "dsqd", &fid, &name, &size, &flags); @@ -4057,6 +4085,9 @@ out_put_fid: out_nofid: pdu_complete(pdu, err); v9fs_string_free(&name); +#else + pdu_complete(pdu, -1); +#endif } static void coroutine_fn v9fs_readlink(void *opaque) From patchwork Fri Nov 11 04:22:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13039649 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id E3E9AC433FE for ; Fri, 11 Nov 2022 04:28:12 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otLZh-0000aI-9R; Thu, 10 Nov 2022 23:23:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otLZf-0000Zh-QH for qemu-devel@nongnu.org; Thu, 10 Nov 2022 23:23:27 -0500 Received: from mx0a-0064b401.pphosted.com ([205.220.166.238]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otLZe-0001bx-85 for qemu-devel@nongnu.org; Thu, 10 Nov 2022 23:23:27 -0500 Received: from pps.filterd (m0250810.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AB43I17028685; Thu, 10 Nov 2022 20:23:14 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=NAClB/vYcrJi/d56y20Tl8wxwlevWX+TEdbP015zj3M=; b=KH0GRbRTKbZu04i6b0Jjpp1Imrr97UwehAGumU9lBhuf6sA77reSDf1ho3zGSsLLPy39 ge3zDs1YPqIYnDtQyb1zgUa/TXFZo643YGjcukstAA8/bw4HvCnEh8CJP2Uuwhj3gKY7 NrTdvT/AE1vvIyZqIsdcAVSL8c6l/dTFl4tHjVgLME2yhw1XvNeiyylw4lRctB/1rNeK ZxE5LpyYFCFplqFuPxFyWL4uCAIu/fqz8O1LzDbOvExrSoPBNmhBzMaVJS5IhMmPaG4L CcScXshIIzYP3aqaYsGW/+Gp5nFZuzv3GYpym+qa82y7nSsWaqV7HugWqcpkloGN/fPE bg== Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2169.outbound.protection.outlook.com [104.47.56.169]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3knk43d9ma-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Nov 2022 20:23:14 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oLEiS2WIZlVPQl/ZZVSnJBJeouiCWeQslkdJZVLjndBRUbttzbq2jqp16Pehq7Vv40tegc9zHNv6k3mgY37Mxcsolgq1TVKHjcMhnImA2aLUKSxMyp3Y5wuj5Odc3EfEK1JBInwbwsChHA/VohYcwCQZrBxzB8ev4N09tCKkkJkj2HF/N9ZBge5JicWVpJU7Qp0WwEgYQpWNqqOV4GThRm1kzgPWnOqpUiCZUaiGapUrschs08j/Qyrpq+evJOqeik8b+tRM3DMZtBdWEHhEThHuiH90I4qeVm7xPYUX8xAR6A7wjcELA5QKQJKcb9lNhwBuT9Y/IuKoFQ6knfjdsg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=NAClB/vYcrJi/d56y20Tl8wxwlevWX+TEdbP015zj3M=; b=Tasbzz/fMZb0jfbftk9nwB/E6HMM7BA73hm490Bv4jbLLljJCPptanBTfkymj+f08/VRRJDUhRfdKaPLrvlw/tjSQlZ66hWppeRtUWRhdjQgSJe80yHG7RUwI8t57BDUWwOucqp6mP24Bv8Q0N4UTpCiPNetQPq+p6NOIo3NojO06bBtpMyu5hKFjdBgKKoESmekhwBw69Cp0SLPzUWY3ZzoizDIy6OOsoxuoqg5zaMv6j0FgG1LPi+O/sKNoWmcEGqU/WdbK/MFaItkWTOZxVvvR0gsOeLu9ByBA50Ux56mtq27c+APPCar+IJRH4sVa9YxYYyUTK/qlnwAmYr1tg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by SJ0PR11MB5102.namprd11.prod.outlook.com (2603:10b6:a03:2ac::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27; Fri, 11 Nov 2022 04:23:13 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::8e5e:71da:1e29:bc15]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::8e5e:71da:1e29:bc15%5]) with mapi id 15.20.5813.013; Fri, 11 Nov 2022 04:23:13 +0000 From: Bin Meng To: qemu-devel@nongnu.org Cc: Guohuai Shi , Christian Schoenebeck , Greg Kurz Subject: [PATCH v2 13/19] hw/9pfs: Update v9fs_set_fd_limit() for Windows Date: Fri, 11 Nov 2022 12:22:19 +0800 Message-Id: <20221111042225.1115931-14-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221111042225.1115931-1-bin.meng@windriver.com> References: <20221111042225.1115931-1-bin.meng@windriver.com> X-ClientProxiedBy: SL2P216CA0138.KORP216.PROD.OUTLOOK.COM (2603:1096:101:1::17) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|SJ0PR11MB5102:EE_ X-MS-Office365-Filtering-Correlation-Id: 2dd90164-6956-481e-3a1b-08dac39c7283 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 95m43/3/O1Yg4f3V+LLlFRoyxeSB7B9AeU6SJb1qAw4b4ag/cO3DyVVX1bxBOdlI7s3dhDpQnCrlNaE343m5t6/hcm6/zK9TYu5XWN6lR8QlY1axT3/H/VN/fYTPLQ6TNmhpPH5+iKHxNJy6eM8tQZJB85u4k53W8I3l4gmdGUuVxCfOfav1FjxVxAbz+FwOEWDFEkAO7VVCSHSSFuWunxa56d9JAQ6f5LXR7AFPBDUAok9zSfuhK1maZR8y929m1QImcn3w2wOxwNzZ1XmxpsAUPVDPgbebVD1N8A/YmHjELBxORaYVIEYhIqOZBoD8U0PXqokfY3vI4KQtIXI31WDjh+/xorclzZMqxV2/SNO1N0IcMikDHXnsqcDGlNo21/i6liMy8o5mWtCF4gde3VAp/RR8FLxFbd882vhAH6oESdXTIP0WiGujSmd/yXc/iCC3ayQ5GxrptdJDcyTXZtF2zIMJeZio7NUFID2qdmbS8R46RA9ys9zSmucK0SwUHF7eeFcJfK35treJLMcgpI74KKp4Es0nveHRfpuCl36odFh6pVBmss1+98+s7hTk7nnjUsSyWO1onVDX0CGX1b6HaDaytIkEOIqoZISsTbVIEC6xekdD4aurFFhqnr90Mttnx+0tvS4uwJTVnViB0lazvG4xxY0pAxbgQxrEqIqlSaQXhDpkWYcZTOEulfCKgnuNhklEgMczAXrp+m1eXNCruIGZsejF14hGF8JB0RMyXg3aDJJGI/KRJZ34C47dCY+CvrmMnj+Ja2cEZZqyDg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5358.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(396003)(346002)(376002)(39850400004)(366004)(136003)(451199015)(66556008)(316002)(86362001)(8676002)(66476007)(66946007)(4326008)(38350700002)(38100700002)(36756003)(44832011)(83380400001)(52116002)(6512007)(2616005)(1076003)(26005)(6506007)(478600001)(186003)(6486002)(8936002)(41300700001)(15650500001)(6916009)(2906002)(54906003)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bxvHiOak1vtDr3RsLrBaTVO1iZcgEv3vkG/gzkW+OL7pZKKlUISnqfi6rjJZn4JbZqvWs5UaXFq9vNyRDO339DHATNNO07rnZQU3KfSIxp2GRde5+i+GfRsaEWeDDqLXwkugvJC5IsB+g9YfXIwKONcClNy3/T0eCrD64HkRZqJ0l1yhqw8/MrNLu275RE6uU6UnX9h+/quG5UxyRD2Sv6YZDd0KCDWwZReMtx1LiQhtHn4dHx6M1+Kb2KZLxB4Bjh9hANY3XEpUsrj/4p9do11byINvplQ/8okUnY43yJRkx8pKbN5esjq4mOBjr77IF08EgpBTkRjwLN0/TYVejxH7pKqGgVm7a94fc9HgnYx0T4ZwIIay9cTW7BHeCZOj5O9pKIx7srDL768FG+ZbnvJjuqfBM4THNzeTychNZkEa4CaLYVED7AMiQv9eXWpLPwbtQrqD4Gkr5sekhqYLxjDd0qR8Ds3EMq6bV97arEJ9EjOD0C3kpZJdAL8zddzTial9Oi0Po96O5aNiTp8JQuj0W13asPhKd3edR4fyYBfX1NWccGOmEd93eIjuO5c9JdatFN56uOyTZ0pybDuxT0rHi4qJ60CuYiwmm7XHNV0hNeuhYicJpB1HZxfYcuN+pCRZDTk1hFrAdxuabGMtqbof56IKRP6F7onCljNohoCzgDLMBcIWUep0hla9ZxiiUaETuttKk1WIh1GpdJMwiXHZBgzDGtcY0qsW9J/kx3r5+/fpV20sFs3o9GGYBWH4LS+2gW14IrPvGjKXandsBxaxjLVJiof2rR1p3AHbv4HrpYbkOdXozScW+d5tx9tMQuUymvtTi0go8dzWP4N6wNgUNZ+yWSZmn4T1M5W7eZ6rpw+7TKKYk0cH9reAPXk9QWbVsAELBjSyYaJl4DOEavTf0KbMDQP51LRMTt/rezJUhh4+cbFUT31FY/DBdwX8sWuTeHzwnIQyAmZy5dWA585jMS1VXszdc6J414hqFNCjmy0lI3OmnJ2FCWYBWvjajlVxyAVRBAlGSOVa5xIXdLOywW2Ajr+BnsoquyDKsDOZO1W5Qs8uG8kOZQdGJq5V57dIO+RHAFv1lwJGZJlpFgXDxeEsCliyB4qBtP0I3G34BfinBgq+oASYmnT1bUn3rVoPACwSdRNLuywDtBwV6rJjcwFnDFj/Pqy+TUGxFRZs13GcOSxY1ALtNco+hO6B0mwN7lZ1ClbDa54SME1vqALyz0I5v3Pc5an+Y79/HOftIO2/omUOEsdA+TB34dgx4+GIngAa/+/WgRemrPQQ+SjQneCwDccXJ7yRbSXm23wpDIy4QBSUr5SolK+qrbHA8+ZFRyUCfHwflZPdP6l1Z3hCJlTgp6BU9rst10KKpl2hFzdv+zJZEX1lvyHU+RAUe3dRY/LEyjHTUMcjCBlVZtp/gmC4d9Tl+yykBxfzaXJHXSYK1Fg3V4Haz4pFLnmX8dh8c5FyTiUc0dOaBsXOSnplyKOWEjjPU3JAdREBupj6hbyQ7aV0ocHK7HkLH7Iv9EivUfDN/+fwv90BE5u9ZsB23Lw3iCmaLeP6exYuPorTpmW+aVOfTeF6VSoWNM+N X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2dd90164-6956-481e-3a1b-08dac39c7283 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Nov 2022 04:23:13.1582 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: eUHI0C1RUqay7Y4wMcKNNX2qjSMixIl6nfKCzrh+IbX//ogOmyGjNpbST0jFaIYRPcin6fWdwBZTBsSslRWeSQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB5102 X-Proofpoint-ORIG-GUID: KUYjvmfBn9TTETq5gSkvyt_ZSiipY-La X-Proofpoint-GUID: KUYjvmfBn9TTETq5gSkvyt_ZSiipY-La X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-11_01,2022-11-09_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 mlxlogscore=801 lowpriorityscore=0 suspectscore=0 priorityscore=1501 phishscore=0 mlxscore=0 adultscore=0 impostorscore=0 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211110027 Received-SPF: pass client-ip=205.220.166.238; envelope-from=prvs=83144312e2=bin.meng@windriver.com; helo=mx0a-0064b401.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Guohuai Shi Use _getmaxstdio() to set the fd limit on Windows. Signed-off-by: Guohuai Shi Signed-off-by: Bin Meng --- Changes in v2: - new patch: "hw/9pfs: Update v9fs_set_fd_limit() for Windows" hw/9pfs/9p.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 0b5e1fa8d2..be1d2a4f04 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -4392,11 +4392,28 @@ void v9fs_reset(V9fsState *s) static void __attribute__((__constructor__)) v9fs_set_fd_limit(void) { + int rlim_cur; + int ret; + +#ifndef CONFIG_WIN32 struct rlimit rlim; - if (getrlimit(RLIMIT_NOFILE, &rlim) < 0) { + ret = getrlimit(RLIMIT_NOFILE, &rlim); + rlim_cur = rlim.rlim_cur; +#else + /* + * On Windows host, _getmaxstdio() actually returns the number of max + * open files at the stdio level. It *may* be smaller than the number + * of open files by open() or CreateFile(). + */ + ret = _getmaxstdio(); + rlim_cur = ret; +#endif + + if (ret < 0) { error_report("Failed to get the resource limit"); exit(1); } - open_fd_hw = rlim.rlim_cur - MIN(400, rlim.rlim_cur / 3); - open_fd_rc = rlim.rlim_cur / 2; + + open_fd_hw = rlim_cur - MIN(400, rlim_cur / 3); + open_fd_rc = rlim_cur / 2; } From patchwork Fri Nov 11 04:22:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13039627 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 0F889C4332F for ; Fri, 11 Nov 2022 04:24:10 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otLZm-0000bX-UZ; Thu, 10 Nov 2022 23:23:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otLZk-0000bH-QG for qemu-devel@nongnu.org; Thu, 10 Nov 2022 23:23:32 -0500 Received: from mx0a-0064b401.pphosted.com ([205.220.166.238]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otLZi-0001ci-IB for qemu-devel@nongnu.org; Thu, 10 Nov 2022 23:23:32 -0500 Received: from pps.filterd (m0250810.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AB40lZJ022509; Thu, 10 Nov 2022 20:23:18 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=GuVPlV4qQp+8jvTEQk8lbZWAq5jCINDQDlXwOFBdkqc=; b=rfpM5nkh+1e8nlxpohlIboFzN+4Jrqqwqy0gmk/AoLpgtpDHATi1FIsNW78my8qiHo6C obe5aak75riy02Bzh36lsYmPblK2f8rPabd86Q96MTpCO+ySaxgld/XzPuwkZa4SXqNd pQEDnxSZEpwng3S0+ZQpiGkFWkMwTQmx7yxLPinMeJIn9OS6qYPr0jsLWj+erzTUBEnO KST1PiGwzQbY2eB5JSo6f7UPLNEZmoPGQCsJe8zuWc4V3b4xqNhpirU041M8mNO8IHrm zJLPnfYlUnZmumYMGjSXZTraZr3MmMewMdc3VGar4mBBwr9XpjPTg35MAi3COGvUSG/D vA== Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2108.outbound.protection.outlook.com [104.47.70.108]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3knk43d9mb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Nov 2022 20:23:17 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RVEmjdcqXv2v2CfkmDPaT5Wymn6a7ZoUo9Htz5+e6CGwTUV34Jd1GEpLviDupwiqBr3axkfkSlCTTW5fCi3mJc3h130yBJTISEXOb0/dG73nW2qFCOU8DQYILZ/zkqRCQHXWzPFYgHwHex2spregKufRhB2JABREPsDf7+VXz7z1IUglZfMh28Fy/6Q3O5Wq1W63VAwUklAvTfe2I8FYlrAKsmqu1gEwRoRL5vMLoez23rV81guD/vJenTsYqA4sBAXWp1I6OPnkZ/AwzhOoIiy5bA2gQbRDW6ev7YBFiqu8uNNstVfuc7aiOhWPDLHxdpTqPzI81DkHx7tsJLFllw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=GuVPlV4qQp+8jvTEQk8lbZWAq5jCINDQDlXwOFBdkqc=; b=c3+GcsSkQigYUqGZEvAH/+Q6TqrW7pFBnmFeRw6GTy/EeyspRzj9OZhauI+RVw9MD/JIL1s8pHbvh1mPiWmCvyZ8pc2TV4GKkcwtGkLAPXidmMXbAH9UA1fuLsFKDhUJvouX3ZiGdlRFiSPO1mMBi8jpc/iIADBqOamUKqptvdUVlUe8qXQ+CwMs2Q6oqRQV+xtuhwrl3ph0JOdoOMP/52x6GUs63UCtKauERrthJ7J49c7Ob5lcN2pUqhgnWCZ1wsHrxH5U6WK946XEKVTs34MeLycXVin3HRKw9IbXfENiX5gNY5dZ+fqveUFFV+PKE5kRMNh53e1nllZq3iU8RA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by SJ0PR11MB5102.namprd11.prod.outlook.com (2603:10b6:a03:2ac::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27; Fri, 11 Nov 2022 04:23:15 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::8e5e:71da:1e29:bc15]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::8e5e:71da:1e29:bc15%5]) with mapi id 15.20.5813.013; Fri, 11 Nov 2022 04:23:15 +0000 From: Bin Meng To: qemu-devel@nongnu.org Cc: Guohuai Shi , Christian Schoenebeck , Greg Kurz Subject: [PATCH v2 14/19] hw/9pfs: Add Linux error number definition Date: Fri, 11 Nov 2022 12:22:20 +0800 Message-Id: <20221111042225.1115931-15-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221111042225.1115931-1-bin.meng@windriver.com> References: <20221111042225.1115931-1-bin.meng@windriver.com> X-ClientProxiedBy: SL2P216CA0138.KORP216.PROD.OUTLOOK.COM (2603:1096:101:1::17) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|SJ0PR11MB5102:EE_ X-MS-Office365-Filtering-Correlation-Id: 82371a24-e348-4d64-89a2-08dac39c73b4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vCAriHjDXD3CZPLbVJa9qa+dBkJqjZGk4JXOAyYhImCzyICw064oBvoi7ZRgNMuKwtCxlokhgis8wYDAdFi2xPeRDt8gVfg8/LRHmCcVMIr73StPDCcdXN5Mr76SoEaR0KDqLprlSDFt3XQ67hs/FT/zgsnK+p/duC5jpFRJo3zDWlaZpltLO17Ectxn8/JAPNwrsQJkXBvL1sVZYY8NWOoLKAOHV+juwwiwLsQ20j8htupaBv1eEYHbmqJzg/5To6KZHZI6XN8pGh6JJq7H0yFU34YRpPvjSulnfRNIy4Fpq5lxP9hiXT9llLjsh7DiIz3zTVsz5oweOyc7+fwnlCE9uEeWZCVJKbTN7Ufo8d2NCAFpXdYjznWQJxuSau6db9zuVPV4Z3L6KXe0VyVyGMIjmcYObOAIEmY9wHHD/99lYvi0CXNFm/9EBFnckMqoduP00IvDSdZt0nFmq3s8AsKjMHJv9VCyNoxvAULsdY++kgROUBcgDUWiZgkt3mg9ghp0ZDJCuVeuSkYEj09JQ40NQ5y1dlGlt2WGIq9pWVmA3+hr5rYFjf0I6qTdm1K+0ftlcummFH/sE1exqtPFj7fopP8Jha3ZlKF6aJevcg547wjbUbL20N0GjbjtqrERi/oc7zCxPqLEp7k29q6A9Ca8vNRjJMh+KHhekR+wxxP9G7W5g0MaNvuH95kbw/onUcLXpytWcWxoNeJytmI03s27yqyvk9M9gr4J1LDT0O6ufAGM/jcMMDpFbMQBQPhc X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5358.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(396003)(346002)(376002)(39850400004)(366004)(136003)(451199015)(66556008)(316002)(86362001)(8676002)(66476007)(66946007)(4326008)(38350700002)(38100700002)(36756003)(44832011)(83380400001)(52116002)(6512007)(2616005)(1076003)(26005)(6506007)(478600001)(6666004)(186003)(6486002)(8936002)(41300700001)(6916009)(2906002)(54906003)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: aprwv2FNftUmHdNy+Zhm+tLguFwCW+RmhmL8tzUjS8einWO7MLYCnVjp7HAiTpAXnjh0xSucZY9lvVQT5MNjCW2yyUA/hM0F/XoCXUfz32y5yZBRMswY16mUSe9M5Hwls3PJteJ74b4SzU6baA5k5p/gp6GpxisQ2hk/RIqLpVNVpzbx2h9hDSjfMiT36bWGjjlgArHEufPfRg3Okjl9b9DvfAxN2aFPbNp4InLQQlD0YwRHhw6w5QQPB7NHE8N2b3Ri9d8bZWcxXJUFBQ59vsGy2QDnbPtcYIswBOgj8+lxzcW4b5p1IFWJrokctDYPK6vnHRRMD1FzY4wkCwjTragySjIH1uhBE2iFujiJ5hlEhzWgsQMhLd4xPXzeUBdfV90C3QEqAhqVIt9MzXHZ1XVBxeJ6aGJXpok5aC1jtTa51/iTyj9LUh+kRScIJ/jxe21eqaemsUGOSfVWiF6XbIzx6QT2rKbH8niBJ0OepvKgDy3bD45pamF0IhY+9gaEvsuIQAB1MrmdGFSV7xK3Jr4sT1hrYP1tuggcHe1Yl/Oj6sBKkaECQ7r84eNDWEHIj7V1hPc23RP1x2hNgMms3hMQ9jaK5jKMdcXAqPYEpnS5XhPjjN46nv5iXxTAdB6ur/mLvl0wF5L9SQk3azsY3Y8qB2HTW2UQBw6rJK2yQKhl8vSDslRvKV1WqqIdZLSSyXJXaBWYHFypDAa2RtWZnmVofxD0MIxFzf0A+Zzz6a9EF0Ob7iWKfB46xkThMJq4fou7leYHPc/S42/Sat3a2aozAHdTjlDBJMW4DVJh9ZJCHobwwtr+L9FxXbaoOgcBA3ZcecsoWKHB5ekkuEL1kJEBWQpCPFDR9S8FtQN1zCOILGs1x7tdezLjsa/JdSSuqhOs27SDbMNzX7hOMxpkjeO8l45O8GkPiltlJPoh+BwE0Cx+SPJVZLgJ395VvM4WV58p31ulLcXKjQWVIPxF4c3ghAe+ySkSeEQdIbWiGCFWudrZdFRP5/lf5P0QBstE40SMO4bHwfHQN3s4gsGInsNp/C+3NThsShzqzuOrIP0BT9grred+RegAcm8bCDoKCgb1nIB4asHad6HiMQuIvyaWOn2hrlq42gcF/T8s5aAEh4OHe3F/mupLx6tCFX8P0lrE/m5ouNbFUh09zTrgciM6w3m241WHg0z29mLPHI7jw+hAFjEusQROXBwWoYt9kWhop3dYieEWWKhFjv/6LPyj0tLN6kTJCGeb7Md+dq/Xt/l4wXIqFc0vT60cMr3LGPFNfILksmQIkQkF5XE8GcWVbZkHcw/7NZONs6TRvmEsR8bTAf/uIti+TLz5SlMt1WqVt36KvUt5FpB1TKDSMkgifxECMdLxmJ843lbsIWQskjpPrrQbUD9eq0eLy8HL7H4HPCjO20KrW42jTJRuN2hDNcSWw6ZxOmHQXIAm7wZfxys+z2pNcoihFbPUYGCE8MdQQIFAgVPJbed4hf7xHADglubr2ShuJVq+98+I+DmXPqRYXxHN3BX/uLwt4fS1bTtJrJqRyOuVrGB7Ekv1L5ledRvcJSz8iYCVhcymoWowyvHkNKm5YRnMvcUjvl4n X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 82371a24-e348-4d64-89a2-08dac39c73b4 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Nov 2022 04:23:15.2527 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: yo28KSRODjD3U2l0pGoqCuhDBD6DVGHp4bwXlbj/PUokS9GF5V33FiB8f3JSzdvL2pSkskG9HHbtc4dgf5CcxQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB5102 X-Proofpoint-ORIG-GUID: -m0Muav9F0FxKIRsVUMIvn6pZM-S8WOd X-Proofpoint-GUID: -m0Muav9F0FxKIRsVUMIvn6pZM-S8WOd X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-11_01,2022-11-09_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 mlxlogscore=822 lowpriorityscore=0 suspectscore=0 priorityscore=1501 phishscore=0 mlxscore=0 adultscore=0 impostorscore=0 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211110027 Received-SPF: pass client-ip=205.220.166.238; envelope-from=prvs=83144312e2=bin.meng@windriver.com; helo=mx0a-0064b401.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Guohuai Shi When using 9p2000.L protocol, the errno should use the Linux errno. Currently magic numbers with comments are used. Replace these with macros for future expansion. Signed-off-by: Guohuai Shi Signed-off-by: Bin Meng --- Changes in v2: - Use a more compact solution in the switch..case.. block hw/9pfs/9p-linux-errno.h | 151 +++++++++++++++++++++++++++++++++++++++ hw/9pfs/9p-util.h | 25 ++++--- 2 files changed, 163 insertions(+), 13 deletions(-) create mode 100644 hw/9pfs/9p-linux-errno.h diff --git a/hw/9pfs/9p-linux-errno.h b/hw/9pfs/9p-linux-errno.h new file mode 100644 index 0000000000..56c37fa293 --- /dev/null +++ b/hw/9pfs/9p-linux-errno.h @@ -0,0 +1,151 @@ +/* + * 9p Linux errno translation definition + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include + +#ifndef QEMU_9P_LINUX_ERRNO_H +#define QEMU_9P_LINUX_ERRNO_H + +/* + * This file contains the Linux errno definitions to translate errnos set by + * the 9P server (running on non-Linux hosts) to a corresponding errno value. + * + * This list should be periodically reviewed and updated; particularly for + * errnos that might be set as a result of a file system operation. + */ + +#define L_EPERM 1 /* Operation not permitted */ +#define L_ENOENT 2 /* No such file or directory */ +#define L_ESRCH 3 /* No such process */ +#define L_EINTR 4 /* Interrupted system call */ +#define L_EIO 5 /* I/O error */ +#define L_ENXIO 6 /* No such device or address */ +#define L_E2BIG 7 /* Argument list too long */ +#define L_ENOEXEC 8 /* Exec format error */ +#define L_EBADF 9 /* Bad file number */ +#define L_ECHILD 10 /* No child processes */ +#define L_EAGAIN 11 /* Try again */ +#define L_ENOMEM 12 /* Out of memory */ +#define L_EACCES 13 /* Permission denied */ +#define L_EFAULT 14 /* Bad address */ +#define L_ENOTBLK 15 /* Block device required */ +#define L_EBUSY 16 /* Device or resource busy */ +#define L_EEXIST 17 /* File exists */ +#define L_EXDEV 18 /* Cross-device link */ +#define L_ENODEV 19 /* No such device */ +#define L_ENOTDIR 20 /* Not a directory */ +#define L_EISDIR 21 /* Is a directory */ +#define L_EINVAL 22 /* Invalid argument */ +#define L_ENFILE 23 /* File table overflow */ +#define L_EMFILE 24 /* Too many open files */ +#define L_ENOTTY 25 /* Not a typewriter */ +#define L_ETXTBSY 26 /* Text file busy */ +#define L_EFBIG 27 /* File too large */ +#define L_ENOSPC 28 /* No space left on device */ +#define L_ESPIPE 29 /* Illegal seek */ +#define L_EROFS 30 /* Read-only file system */ +#define L_EMLINK 31 /* Too many links */ +#define L_EPIPE 32 /* Broken pipe */ +#define L_EDOM 33 /* Math argument out of domain of func */ +#define L_ERANGE 34 /* Math result not representable */ +#define L_EDEADLK 35 /* Resource deadlock would occur */ +#define L_ENAMETOOLONG 36 /* File name too long */ +#define L_ENOLCK 37 /* No record locks available */ +#define L_ENOSYS 38 /* Function not implemented */ +#define L_ENOTEMPTY 39 /* Directory not empty */ +#define L_ELOOP 40 /* Too many symbolic links encountered */ +#define L_ENOMSG 42 /* No message of desired type */ +#define L_EIDRM 43 /* Identifier removed */ +#define L_ECHRNG 44 /* Channel number out of range */ +#define L_EL2NSYNC 45 /* Level 2 not synchronized */ +#define L_EL3HLT 46 /* Level 3 halted */ +#define L_EL3RST 47 /* Level 3 reset */ +#define L_ELNRNG 48 /* Link number out of range */ +#define L_EUNATCH 49 /* Protocol driver not attached */ +#define L_ENOCSI 50 /* No CSI structure available */ +#define L_EL2HLT 51 /* Level 2 halted */ +#define L_EBADE 52 /* Invalid exchange */ +#define L_EBADR 53 /* Invalid request descriptor */ +#define L_EXFULL 54 /* Exchange full */ +#define L_ENOANO 55 /* No anode */ +#define L_EBADRQC 56 /* Invalid request code */ +#define L_EBADSLT 57 /* Invalid slot */ +#define L_EBFONT 58 /* Bad font file format */ +#define L_ENOSTR 59 /* Device not a stream */ +#define L_ENODATA 61 /* No data available */ +#define L_ETIME 62 /* Timer expired */ +#define L_ENOSR 63 /* Out of streams resources */ +#define L_ENONET 64 /* Machine is not on the network */ +#define L_ENOPKG 65 /* Package not installed */ +#define L_EREMOTE 66 /* Object is remote */ +#define L_ENOLINK 67 /* Link has been severed */ +#define L_EADV 68 /* Advertise error */ +#define L_ESRMNT 69 /* Srmount error */ +#define L_ECOMM 70 /* Communication error on send */ +#define L_EPROTO 71 /* Protocol error */ +#define L_EMULTIHOP 72 /* Multihop attempted */ +#define L_EDOTDOT 73 /* RFS specific error */ +#define L_EBADMSG 74 /* Not a data message */ +#define L_EOVERFLOW 75 /* Value too large for defined data type */ +#define L_ENOTUNIQ 76 /* Name not unique on network */ +#define L_EBADFD 77 /* File descriptor in bad state */ +#define L_EREMCHG 78 /* Remote address changed */ +#define L_ELIBACC 79 /* Can not access a needed shared library */ +#define L_ELIBBAD 80 /* Accessing a corrupted shared library */ +#define L_ELIBSCN 81 /* .lib section in a.out corrupted */ +#define L_ELIBMAX 82 /* Attempting to link in too many shared libs */ +#define L_ELIBEXEC 83 /* Cannot exec a shared library directly */ +#define L_EILSEQ 84 /* Illegal byte sequence */ +#define L_ERESTART 85 /* Interrupted system call should be restarted */ +#define L_ESTRPIPE 86 /* Streams pipe error */ +#define L_EUSERS 87 /* Too many users */ +#define L_ENOTSOCK 88 /* Socket operation on non-socket */ +#define L_EDESTADDRREQ 89 /* Destination address required */ +#define L_EMSGSIZE 90 /* Message too long */ +#define L_EPROTOTYPE 91 /* Protocol wrong type for socket */ +#define L_ENOPROTOOPT 92 /* Protocol not available */ +#define L_EPROTONOSUPPORT 93 /* Protocol not supported */ +#define L_ESOCKTNOSUPPORT 94 /* Socket type not supported */ +#define L_EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ +#define L_EPFNOSUPPORT 96 /* Protocol family not supported */ +#define L_EAFNOSUPPORT 97 /* Address family not supported by protocol */ +#define L_EADDRINUSE 98 /* Address already in use */ +#define L_EADDRNOTAVAIL 99 /* Cannot assign requested address */ +#define L_ENETDOWN 100 /* Network is down */ +#define L_ENETUNREACH 101 /* Network is unreachable */ +#define L_ENETRESET 102 /* Network dropped connection because of reset */ +#define L_ECONNABORTED 103 /* Software caused connection abort */ +#define L_ECONNRESET 104 /* Connection reset by peer */ +#define L_ENOBUFS 105 /* No buffer space available */ +#define L_EISCONN 106 /* Transport endpoint is already connected */ +#define L_ENOTCONN 107 /* Transport endpoint is not connected */ +#define L_ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ +#define L_ETOOMANYREFS 109 /* Too many references: cannot splice */ +#define L_ETIMEDOUT 110 /* Connection timed out */ +#define L_ECONNREFUSED 111 /* Connection refused */ +#define L_EHOSTDOWN 112 /* Host is down */ +#define L_EHOSTUNREACH 113 /* No route to host */ +#define L_EALREADY 114 /* Operation already in progress */ +#define L_EINPROGRESS 115 /* Operation now in progress */ +#define L_ESTALE 116 /* Stale NFS file handle */ +#define L_EUCLEAN 117 /* Structure needs cleaning */ +#define L_ENOTNAM 118 /* Not a XENIX named type file */ +#define L_ENAVAIL 119 /* No XENIX semaphores available */ +#define L_EISNAM 120 /* Is a named type file */ +#define L_EREMOTEIO 121 /* Remote I/O error */ +#define L_EDQUOT 122 /* Quota exceeded */ +#define L_ENOMEDIUM 123 /* No medium found */ +#define L_EMEDIUMTYPE 124 /* Wrong medium type */ +#define L_ECANCELED 125 /* Operation Canceled */ +#define L_ENOKEY 126 /* Required key not available */ +#define L_EKEYEXPIRED 127 /* Key has expired */ +#define L_EKEYREVOKED 128 /* Key has been revoked */ +#define L_EKEYREJECTED 129 /* Key was rejected by service */ +#define L_EOWNERDEAD 130 /* Owner died */ +#define L_ENOTRECOVERABLE 131 /* State not recoverable */ + +#endif /* QEMU_9P_LINUX_ERRNO_H */ diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index df84374b78..c76a53f2a8 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -60,8 +60,11 @@ static inline uint64_t host_dev_to_dotl_dev(dev_t dev) #endif } +#include "9p-linux-errno.h" + /* Translates errno from host -> Linux if needed */ -static inline int errno_to_dotl(int err) { +static inline int errno_to_dotl(int err) +{ #if defined(CONFIG_LINUX) /* nothing to translate (Linux -> Linux) */ #elif defined(CONFIG_DARWIN) @@ -71,18 +74,14 @@ static inline int errno_to_dotl(int err) { * FIXME: Only most important errnos translated here yet, this should be * extended to as many errnos being translated as possible in future. */ - if (err == ENAMETOOLONG) { - err = 36; /* ==ENAMETOOLONG on Linux */ - } else if (err == ENOTEMPTY) { - err = 39; /* ==ENOTEMPTY on Linux */ - } else if (err == ELOOP) { - err = 40; /* ==ELOOP on Linux */ - } else if (err == ENOATTR) { - err = 61; /* ==ENODATA on Linux */ - } else if (err == ENOTSUP) { - err = 95; /* ==EOPNOTSUPP on Linux */ - } else if (err == EOPNOTSUPP) { - err = 95; /* ==EOPNOTSUPP on Linux */ + switch (err) { + case ENAMETOOLONG: return L_ENAMETOOLONG; + case ENOTEMPTY: return L_ENOTEMPTY; + case ELOOP: return L_ELOOP; + case ENOATTR: return L_ENODATA; + case ENOTSUP return L_EOPNOTSUPP; + case EOPNOTSUPP: return L_EOPNOTSUPP; + default: g_assert_not_reached(); } #else #error Missing errno translation to Linux for this host system From patchwork Fri Nov 11 04:22:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13039636 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 10895C433FE for ; Fri, 11 Nov 2022 04:25:16 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otLZm-0000bp-Tl; Thu, 10 Nov 2022 23:23:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otLZl-0000bP-GC for qemu-devel@nongnu.org; Thu, 10 Nov 2022 23:23:33 -0500 Received: from mx0a-0064b401.pphosted.com ([205.220.166.238]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otLZj-0001ck-Sl for qemu-devel@nongnu.org; Thu, 10 Nov 2022 23:23:33 -0500 Received: from pps.filterd (m0250810.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AB40lZK022509; Thu, 10 Nov 2022 20:23:18 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=Z1EFyfpJay7EWFwsfrL7SqhObwALqYEYSsSwfkLansw=; b=GxAtGtaTEh5WCgoQ59DSy7yIaM1Ekm62LmxrXJN4mDawPGK/KpVmoXxAvZwk7HrA01Es 5sUThIrCgAeUF94XD5rv0esnHujoDOjE4o4DGFJaho3BSEnQ60bf0JsmNyDx9GdGKAHY RtwthXXJaGqqj367Onr6fyXEKzgjfdCPt9CxqgHTj7BOk2NwqeRu5qVfH93ep7bAO0wD pZOVBZStUFYZ4evvsFVTphDA6Mbdsh4AyCXNkKDhOKIkchUrcDIxn8crWJ6V4/uO6930 pT+6v14CYnQVI1cJOQ4KvRCdHkobpwTRBcoXH1UwxXisR+9TfHmC+EnLZ0Nkj99x5iQV NQ== Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2108.outbound.protection.outlook.com [104.47.70.108]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3knk43d9mb-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Nov 2022 20:23:18 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X6EVTWodOahbJ/Q2uS11qlzvDj5CnP+Qf6v3H0D4A7ZvL9CvolfYFcEaB++0yxamjwe4fJ4ffys8Ow5YdpWzO9Yh/AOBzgjljmL+M5gt9aFx0LRIGrH521zlqWbji4gmk6kNyN4Xgde08rH/ZnkjCa/Qdo4j6FqHuAGaIBLY8CaP8NhPl/54vRwlOOFFh9DLtGQSVFmVPnaro5etq6CADBWAWvWYqApvcQiDRXkWSg8XGfYmgTg95s/pHskUTQ0Dn6e82tSTNDJtOMlJmpVp+0shu3P9/seJGD4Nc3p5uotbQIZ0xHWdtDIO/9L3yrHBXJRRWzQqVWA6xeYh2xhoIw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Z1EFyfpJay7EWFwsfrL7SqhObwALqYEYSsSwfkLansw=; b=GcyvshqrX3RonRvnfEa33UMCNaBPRNsTMBgKAECplwZM5CCEKGLK6oCH9XEPiK35OGfmmx2qCFq7FQk41kNp1wVZt+Lea5MMAaMcaaE4749fcFjKsF81wQsqnikauK9lh3LhEaifqCDHjixs8Fnv284F4WafDY7bBXvuEDCt6kYSEjZfJPFd8569rxnPzBF5NqKK4plqNCNfZFl2IyAjH+2K8NrBZTq7qWGLwCQAnmxzUTkeNfjshLKAEstSd16G74umEwPolkwX8PUPhaIX9xPP9BXBaICks3Iv2G7czT3tRMKfO/86kfOVVrFm1eRAltV4SF+AuNxYO7nPuBv1nA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by SJ0PR11MB5102.namprd11.prod.outlook.com (2603:10b6:a03:2ac::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27; Fri, 11 Nov 2022 04:23:17 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::8e5e:71da:1e29:bc15]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::8e5e:71da:1e29:bc15%5]) with mapi id 15.20.5813.013; Fri, 11 Nov 2022 04:23:17 +0000 From: Bin Meng To: qemu-devel@nongnu.org Cc: Guohuai Shi , Christian Schoenebeck , Greg Kurz Subject: [PATCH v2 15/19] hw/9pfs: Translate Windows errno to Linux value Date: Fri, 11 Nov 2022 12:22:21 +0800 Message-Id: <20221111042225.1115931-16-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221111042225.1115931-1-bin.meng@windriver.com> References: <20221111042225.1115931-1-bin.meng@windriver.com> X-ClientProxiedBy: SL2P216CA0138.KORP216.PROD.OUTLOOK.COM (2603:1096:101:1::17) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|SJ0PR11MB5102:EE_ X-MS-Office365-Filtering-Correlation-Id: 5e00c2cf-4df3-40d3-02b3-08dac39c74f4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: I640c3OTYecY6N/UaqREwrVr/LggXVXvHk+yyDHn+urAz5oQ/Pu0YHqrm8n6btrEp0UP6L7j77mY4/RqycaBo9OSAPAEV1HRO+9rjItdXMv4vo9Iv8lvSnytH7xAEoZodD3s2ZsEqI9wVL0bWfE1v7osbXHWhXJVoTb4rVn5KCkss4XePvv1RU9ItZA4HHPiTyfM1ot2TYb5eIqk+MuSDGFNNd3CE59h8D0KkF5Eg7CkOKsk0QJgd7m+ymvSgYEs69DSjQGqMYXFGKUTbXpU8d8MfQQjQEcyrJklCWXlO9fO3SMdnJlxNFRVhhgtoJoUkJfNiCs8o6/oV/aPh6MxTIrRiQNIFZbXVM8yNjfvoSFs4McapcYLi1ezlnV8jDHNqKtVK+Jzgk/g9jQ343rdv/PdMYV4UvW94EorPtdyh5LR5MMbcfjHUwPf4owHq+Oppg262SvxSiMoDZ1wAQJ1+g9Sbwd8NpHzIq4hphl0lwVqZdHP6j/bNNyGJ8vlNG4oaLsaYXVFu9TP/DIg2DUWIENcwrIOIccixjlzm0vcnfz5lB2S6fQbebvJ4Vo1IA3XFTGw4RmCnX9jxiy+21IYhOfx6UwlPvc6jHReUTNrO0B88O8HqEDtc23yq9nqmpFO6hHM832rgrWhoMdX0HrCIAAcduH0DHXcE231QyD0+ha4iCs8VFEaQwQtIQo9Io4LsTiemW4AfHDbPvSbadzHaq9o1h+9QZFN/Sn+kdMDWdgvnwv0W3ZmxuVzolRqhEsRAbjJLwUHksCTnCB7iQU2Sg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5358.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(396003)(346002)(376002)(39850400004)(366004)(136003)(451199015)(66556008)(316002)(86362001)(8676002)(66476007)(66946007)(4326008)(38350700002)(38100700002)(36756003)(44832011)(83380400001)(52116002)(6512007)(2616005)(1076003)(26005)(6506007)(478600001)(6666004)(186003)(6486002)(8936002)(41300700001)(6916009)(2906002)(54906003)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: yHlQR9ws9mEn7woPOcZyYbYp70teHuy7H3/ikhNiFVRIT41YkzCdal/VDofQE7MlLHk3sG6MNxLQ4LyJ/ZJJ887xMbbKIrBa1OFGgULYigAV5t0EFz6gc8hlEHGO5NZOkxMYYGWcW/muTnByhyfJqXJpbte9v5DU8mjH81biRfT6o9xF3CzvRriaj+eQS+vKPqDoj+1yW7p2BpsMnuuG2yMV7OO3EBZSurpq+aWTYvJRKc+ipyGo+bYKpgZga7w88wyrqzpnmYjjADBs807USCLQFnTiM7gfqKsTaK0JsAxT0LSlQ0aQ1naqGTar3Irybt5VdlyYUKNBBhUqWKPl3q35SdJhcG0lCEbC2nLSrZJnuDeL2nXh7/LMiuKiMZAQVgDq3o+kDSh3Iro/LhNTwScstnjFqyIJRBdR18r23V1p6b1IxLGlNA04FAqt3IsX68Gj3/kQb3/WP73zbBuurGAmC6V40fpxIE0bYYcv5RfEoH0Pn15HCa6n9OQsI083w3wYITE3IxR5vf0HpELT/NR6gpRCucrYEIHX2EvAf+VEl1wQEHoY+41VreJSIKcFvziu2ssjvEKhsQ/BgMKE5Hxw9hitkf1hXTlTHjM6DBJntrXU5WKctJLL5ayuIHiK2KpVvQhc/bZKosCeNku7div7NmrDU7/gtov7ESgt0FncJCyIS5EDnOFSNhTmSdW9XyymW3HjpLVWDM+exbKVhKdCOgL0rBVCmCq7oeh5yEsSeCHHPYtzdC2IyeNym4wtTVjMINJvtl3t4OnzlvDg1AHRhAPjHv0y1tjwXOGpiiYqsmcMLtuoZQzrx5Jtoak0MqP5Itj2LNvAdbCsmIc7fpBh9dxBjyyj8xe2xVcne8PnbjfNRd8Q/BBSM4PHr6rstHBo+oGcDOyAmvYsR4IIMxkUO/GoDKvpMzzzooMKaUl2KRmrbjUAvjrlma1CJ1BtY6UR//S1o6lmcf4Y9BiVPgFl/BFRfjcR1wJSKmpiq0yaeIX1H+E4Sez07WKFszIL2xID2D96e6p8PM5i++c3LJhXfAFVUTyV2ZlblUL/gln/hLcdGCADM0iN9lWBjosjvYWGsKT8jjSjf74k3gnS5zqd4E6kLeOnm4YUZt9DHUmc8EoaYdvI4Ty6tTsLv63d8/b2d9uBr5bqQDsyz1mzWDN6iGYkcKQfYy8zaar2yzeKvknOSA2wAV1UZmJ6KFK7OfC0xBSsl31NzQTC1ABp8q+F9LL0iK7y1GL69oA0mucVXrkqP4zqrxZHBrsMlxpwjPvedSKc+krQNhKsSllNJ+30zz/nReZ/yQ7+ONPzPHe1E1heOQXtVLmgmChzVNLwrphuRXXSMtqPx/SsfDTvW4q9eTioH3yrzGya7bDsI6wKxzk26rwjcmiNZx3+Y6mEVjceZiciwuM4mUtdwqszpf+9gwquy0VNLoOlQWC8D9TGHO6DlJwxLs0IoAMmFgTqJLExfdJ9pFXTXt5BIeJu/+tEDeQkrpHLFzlrkIbc9WUyXrtXpLxz+Sw8Icf4X+ZD5iUot6/XqUFrl1vncnBjrFsVCo6MtJ+crC9pQrFGouhVSEeyZOiWZxvf0TPf753n X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5e00c2cf-4df3-40d3-02b3-08dac39c74f4 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Nov 2022 04:23:17.2215 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: gWpK8xb1gih06q/xcteT6prL83h/4frV2nH3jXjRPzDLBcc2bZUuKOgNzmAIPGsBz2J0liHWbIvSxX3IZtEYOw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB5102 X-Proofpoint-ORIG-GUID: D1eY8fKQEqr1TPajbr8NneuadcrEEqvT X-Proofpoint-GUID: D1eY8fKQEqr1TPajbr8NneuadcrEEqvT X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-11_01,2022-11-09_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 mlxlogscore=567 lowpriorityscore=0 suspectscore=0 priorityscore=1501 phishscore=0 mlxscore=0 adultscore=0 impostorscore=0 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211110027 Received-SPF: pass client-ip=205.220.166.238; envelope-from=prvs=83144312e2=bin.meng@windriver.com; helo=mx0a-0064b401.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Guohuai Shi Some of Windows error numbers have different value from Linux ones. For example, ENOTEMPTY is defined to 39 in Linux, but is defined to 41 in Windows. So deleting a directory from a Linux guest on top of QEMU from a Windows host complains: # rmdir tmp rmdir: 'tmp': Unknown error 41 This commit provides error number translation from Windows to Linux. It can make Linux guest OS happy with the error number when running on top of QEMU from a Windows host. Signed-off-by: Guohuai Shi Signed-off-by: Bin Meng --- (no changes since v1) hw/9pfs/9p-util.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index c76a53f2a8..598e2980e1 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -67,9 +67,9 @@ static inline int errno_to_dotl(int err) { #if defined(CONFIG_LINUX) /* nothing to translate (Linux -> Linux) */ -#elif defined(CONFIG_DARWIN) +#elif defined(CONFIG_DARWIN) || defined(CONFIG_WIN32) /* - * translation mandatory for macOS hosts + * translation mandatory for different hosts * * FIXME: Only most important errnos translated here yet, this should be * extended to as many errnos being translated as possible in future. @@ -78,9 +78,17 @@ static inline int errno_to_dotl(int err) case ENAMETOOLONG: return L_ENAMETOOLONG; case ENOTEMPTY: return L_ENOTEMPTY; case ELOOP: return L_ELOOP; +#ifdef CONFIG_DARWIN case ENOATTR: return L_ENODATA; case ENOTSUP return L_EOPNOTSUPP; case EOPNOTSUPP: return L_EOPNOTSUPP; +#endif +#ifdef CONFIG_WIN32 + case EDEADLK: return L_EDEADLK; + case ENOLCK: return L_ENOLCK; + case ENOSYS: return L_ENOSYS; + case EILSEQ: return L_EILSEQ; +#endif default: g_assert_not_reached(); } #else From patchwork Fri Nov 11 04:22:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13039628 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id E72CDC4332F for ; Fri, 11 Nov 2022 04:24:19 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otLZp-0000d5-Ed; Thu, 10 Nov 2022 23:23:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otLZn-0000c6-Vx for qemu-devel@nongnu.org; Thu, 10 Nov 2022 23:23:36 -0500 Received: from mx0a-0064b401.pphosted.com ([205.220.166.238]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otLZl-0001cy-DD for qemu-devel@nongnu.org; Thu, 10 Nov 2022 23:23:35 -0500 Received: from pps.filterd (m0250810.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AB4N5DO004957; Thu, 10 Nov 2022 20:23:21 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=M2j3E7ngWrmbtYmE4yi5nz0iPjbdn8UqvgKMNy/r2a4=; b=rrFiNqgNy6ptwe41MA506wGEz5vPr1gNJUrX6GbxeIdOg8Hq4VlF+1wIgliNI1b0oqM5 BPRcrT92b0X7ogp/C1Swd+rJo2J+4ruWd/nw1xZh0uA82KDYsA1E5P6ETK2yLJLEfaUX jzgCS3fEUmYNHh7vjPbZLJdMq/8Q5XtarP6HiNdpvZw5rwSVl8KfwtNzqI81UvfyLQRq ytkr9zeYcdM0FjvZXEazshVtvzjTVQDOcYccoFQyr7O4AQnCjZOIOCJs/T0TsqhxM2+g 6IYye5Skl05LXYyjvzsAex1JXM1wlggqneQAcvBqZI8H65Nsklp/EXvur/YyN4Wo6Tpa XQ== Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2174.outbound.protection.outlook.com [104.47.56.174]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3knk43d9me-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Nov 2022 20:23:20 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dPxVvyoqq/OiE+9Eq8EqRkC2pLAzjmmvCGPYDustvyTfYEtRhEHodGGfx6cAL/zsRCM9PVjxTRCSuOQYLQYJqGIhZrSGC5TrrjqSPIFCDqUge741JEHP9BQIHaRmeXh6Q6V9I1MPPqkY4DTspUqlGToHTQSB0vWYoe51xeQL5Aiz9PWjLiI4cZLYLv4ugwinNrNi9KnTuBr6H+2jymHXm56quSfo9js2QBtgqEpJ9LykIiDEUnm+6KGzl/hJ5gOuqfh1Y3bdhjuR2sVoFf2Y6zokIWrZcLjR0ZODz6Y2smFCHPF0Hm3JCGuK9zsCkpJTQEKifN9IB5ItbtTpjXoNSA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=M2j3E7ngWrmbtYmE4yi5nz0iPjbdn8UqvgKMNy/r2a4=; b=bC9pTMbLZSK0/9AKHpg5tzZjcIZalETD81y7dXf1PFv8hbjkVK2kZ8qagxcTfTUoPB8hQrTGt/4zsoZs6ndYyYObs6/5Dyb3q4kmldYF3JdlKOUzZzVjqxxatDIaG/kCluQ2GZV+rSej7SqeL5qEJZ8znk0P0jgD5vWCs28tbeiy2k9nOWGB8wFfrAhWMUB5z5xWrTx1a/rCczt2HnSnRsJMtM1DVlAGDViL9k4wWB3YVichYkijHsGsn+zgF99oqRnrZvDGVrWFQ9Ap5ndMUxljbWkxQdClQRVyXoKFTk/6RViOh32gMVhLGeyQaJ6B+rjqMfACy+4LyyJo6Bydnw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by SJ0PR11MB5102.namprd11.prod.outlook.com (2603:10b6:a03:2ac::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27; Fri, 11 Nov 2022 04:23:19 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::8e5e:71da:1e29:bc15]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::8e5e:71da:1e29:bc15%5]) with mapi id 15.20.5813.013; Fri, 11 Nov 2022 04:23:19 +0000 From: Bin Meng To: qemu-devel@nongnu.org Cc: Guohuai Shi , Christian Schoenebeck , Greg Kurz Subject: [PATCH v2 16/19] fsdev: Disable proxy fs driver on Windows Date: Fri, 11 Nov 2022 12:22:22 +0800 Message-Id: <20221111042225.1115931-17-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221111042225.1115931-1-bin.meng@windriver.com> References: <20221111042225.1115931-1-bin.meng@windriver.com> X-ClientProxiedBy: SL2P216CA0138.KORP216.PROD.OUTLOOK.COM (2603:1096:101:1::17) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|SJ0PR11MB5102:EE_ X-MS-Office365-Filtering-Correlation-Id: cab7f9db-755a-4f9c-b7fa-08dac39c7620 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: j//FDTAYSQwZ9tG93H64GtqECBxGuhAPdaWePLZ94huLTB8P+H8x1IxFjomT1jL9f2CYnQe1IqKOhmM6bsiKz2VqrI7CvVhtsLY/+rcsJA3XaXPxTPrghasP53DLPk1YFk7yIcLWD8T8Bkji/FJ2dYpfRdBfzGjF49/8bDRb2x0sO0RX2EEjrllF8C8JO1Dg79MwdvhQaM6vXpwxpcMdaeonP1TFuexl5eaP1ujBnVs/tprX83MgGICKp1HRp1NAu/B6tPZpr0h9pzlrXhmNyN/MEQdDWVSfIRNYnOClyzUaWvZRP+sXVMweEenCvFN0mHZPQi0bJp+zYWPZ6R9TsqnHIiXOLEa4R8zO1j6VmbMTaL8QqaHaV+NKHeX7nBGhqWtDnnwZgKQYolBl2FoWcMEtzzTPcyYvPv/20WTVygXUXCxNjKxOy8hfF3DAZir6w+NL6uezskk0KghcDjDD8Q0SCm5jNWMAP75vlAODnVR9Dx8jncREmgBc1yGqWYa4VUZoHNZUVDpckZ1BUSfHqjVBonDJAkEmCmwggaTeXLYk1FwkeEPdObIahTRJNPG0XrTdIA/jJOMcIho2bvmoEfokXV77t2hS+vyaYSy8cqk7v3Cjdc5KIRYQzLERLwHq6M4YLeKhBlonZpYlahrfI0kWs4LWmu9ydW/b2RVEo92xMAkuHTHvHieFFcriXYatyEgGnJs80KySEOP8QEbqtICxQSl0gJ1ecSaThyOnWqiXuGbl/9411XFm4L/7nbkV X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5358.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(396003)(346002)(376002)(39850400004)(366004)(136003)(451199015)(66556008)(316002)(86362001)(8676002)(66476007)(66946007)(4326008)(38350700002)(38100700002)(36756003)(44832011)(83380400001)(52116002)(6512007)(2616005)(1076003)(26005)(6506007)(478600001)(6666004)(186003)(6486002)(4744005)(8936002)(41300700001)(6916009)(2906002)(54906003)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wgJ7vwcOGoQJ/eUTlS4WQ13iNiG2kBWuoSoaors8eSjExVrmobNFUEnXm/wIfK2+Y97W1Xi1Ev5nqwceQ2c9KaPHPpxE/lxvenuQofYg9Ov4ca+3EUs60DjZcczNSp6++CRg+qiQxmVsggUP/ACnygSOaUKj40B2fxwxvVIUhx4EKTju49IOJYX0PdWPvPKSwq1ILyxA4sCigy+WzP2QCbhG0eYhCcTRb6vxD1iA79M9+iw1fYzlPNvm5Lo8wARxNkcuAVZHwfIT8OPzUnrYyQkyEvvKUaO7S0/U29/EtAxQxxvBq+iykI8Zj2tQG/aPy4C5fIQ3Owdp6tN/iYLrFgA08MA0/nkmGZQgwAk7RxtS4kUUte97onXa7MQgyAFIq2aEjLyuOS7QAKS9TfyqSfTzd01OQrL9DRbtbPhcx2hgf7ncsPeQgdtVcRZ6b7qNpoX4R/Pt8lgZRB20WrM12SRfdWJQDixzWgJ0TALoIT+ZFa6gSRnNwtzO11PXrCawmpt/0d/QpbNGQ8dliSmPHYppve/ZZiO7pYirJXN93Yc+puhpAfyo2J3QMK2qepSC7jmZxkbWbS32ciIhXZ/ZhKzCKmshOvE7+bVTFQ/nl9T+SBmDFcbpzT+2ZElXJJ+A/aV2OwNV0warNczJO+ybVZIZHHMjnllCkie9Qc2Tx5sah0KlvXj2joXCiWZSa5c6zLUf1k1/iEz20GjEmfMMFqpPlLnL5OWMdpia15p+1k2lANVs5cNlV6tgYCdK+VoWDEfS8H+c6j0Q1guAEKaQ8XIN5WmQHHtaWuas32G72a91pRkE+c5MBEhlz48bKThgQacqijY1Naeq7TlzGY9qgv9ICJOgJIrxVWixyLXsZQDaqEh4qoq4GMcooU6MY+99mCQ+GYDhOWi2S6hEuYNmXUqLi0YwxGcukcS7CuxJiDMz87W0Hbfj+mDFGj1Bx9WP5DPUywPQ5iIEn0DdPNe795yZWLTLLLZSsgbDdCwaaum7fTFefxSlFY0i0FqsmcDikMNtDxdJb0FTd5Ud9Z4eNH0fCaD3d/P0n/j5hfXWkBBTjlkyXw6MZiBnVdLO/O2nKNrHMNz0uU2fRscEBjvqYnFE6HZGWAx6VrpwCSHkv6553Vb5w+15A9nO/2OBTYL72PgI+4Nylcg2L0flpiNPWn1FftlnA/oGKmjDzxNgknXZy+mMLeF70J3yd6858F12l+jK7CGJl9eKT3OI+fIl/DgCKZY/HOJm4wGCBA1ONREJzKmUFDvrIPCnRmHNt4GKyl3v9QPZojVhPcJVOgjT3qpphHcRIfu/OFqu54fjJoeENH6Ft7nQZaM4pgeyTSyWtLpJNJyBhIZBtNDoe8ze+A6u6Ns3yVwzh0Y7CSF7tl3rRrsjsNnzYlsAmcWJxWgJJkjC5lM/vcIztjWd5MW4yYw65UzqJFwKwTPOyFik98plzhq2nXEAzXpHQU5Dm4P3Fvho2ffJk4UWVMzkDCf4rUj5jC3A5YL4dmedXhblynLUgZOeW7lKNHjPn9MujoS3gPBGMRALSqNgOJ74J/C70SJZguWTVTx/ySfSq+pZzf+g/ofGACLdWCWhwZ3IzZGC X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: cab7f9db-755a-4f9c-b7fa-08dac39c7620 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Nov 2022 04:23:19.3173 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: XTAICLoncrPjpCSC5zoDgkaXWJVjYJcr7ooGK2m43bV0NB59f8YeKykyAvhXDu4BSmvgFvsfnwzivEwustNOqw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB5102 X-Proofpoint-ORIG-GUID: nz3w7gHC8Qe2YUut-a2lPVKwbA7Y_I8E X-Proofpoint-GUID: nz3w7gHC8Qe2YUut-a2lPVKwbA7Y_I8E X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-11_01,2022-11-09_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 mlxlogscore=582 lowpriorityscore=0 suspectscore=0 priorityscore=1501 phishscore=0 mlxscore=0 adultscore=0 impostorscore=0 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211110027 Received-SPF: pass client-ip=205.220.166.238; envelope-from=prvs=83144312e2=bin.meng@windriver.com; helo=mx0a-0064b401.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Guohuai Shi We don't plan to support 'proxy' file system driver for 9pfs on Windows. Disable it for Windows build. Signed-off-by: Guohuai Shi Signed-off-by: Bin Meng --- (no changes since v1) fsdev/qemu-fsdev.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fsdev/qemu-fsdev.c b/fsdev/qemu-fsdev.c index 3da64e9f72..58e0710fbb 100644 --- a/fsdev/qemu-fsdev.c +++ b/fsdev/qemu-fsdev.c @@ -89,6 +89,7 @@ static FsDriverTable FsDrivers[] = { NULL }, }, +#ifndef CONFIG_WIN32 { .name = "proxy", .ops = &proxy_ops, @@ -100,6 +101,7 @@ static FsDriverTable FsDrivers[] = { NULL }, }, +#endif }; static int validate_opt(void *opaque, const char *name, const char *value, From patchwork Fri Nov 11 04:22:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13039633 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id B11D9C433FE for ; Fri, 11 Nov 2022 04:24:46 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otLZo-0000cv-PC; Thu, 10 Nov 2022 23:23:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otLZn-0000br-0T for qemu-devel@nongnu.org; Thu, 10 Nov 2022 23:23:35 -0500 Received: from mx0b-0064b401.pphosted.com ([205.220.178.238]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otLZk-0001ct-0m for qemu-devel@nongnu.org; Thu, 10 Nov 2022 23:23:33 -0500 Received: from pps.filterd (m0250811.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AB4N0iQ024928; Fri, 11 Nov 2022 04:23:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=HhvM9ZgPJi+DYq8Q/mtUG28QrtcJGsvXNZ7mGlaWzwA=; b=q/hw80tBuoKY8YQcpRgVzOvoXSr8UmIkozjr23210Et5+m6TbRLjS4TSfFqyO7Ey7Z5+ /jFJCxiGakNAk0DOu7nbYJkmjSJ8/3pTBunrm91hkffXNJxtkSTz7gZE63DkKHGYDcB9 BFIQ5x/pDSY+cNfBroa46O1W51+QwmeIC7qre830N2S5YgP1rmLizZ/ft2YKb2HHDD94 5Y/Mj2JnEZYC6C/MR5D7jfWHauvgguQXqZyCB0f1YBbcZA2rYaG5oZufVn7gvso1EQIq wZjOwMNH2bb2k1D+EUsc+q3twGghzuRWd6dE8Tyi2hf96x7mPpYdE+J7bTKADy8dl/QJ xw== Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2107.outbound.protection.outlook.com [104.47.70.107]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3knd21ndvj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 11 Nov 2022 04:23:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HJVsus9I4zlYWjW3CilfVL7Nya87qV2ZjMvegaJGSq2OQoFOxkrgYxtGifenvfVIfj07uvspvmsJfUJlz/oUemay+Eh0FPvAuskZGSEOpXesaE1AtipZ46TJOBlpjOUhy65l695YCBBREA8FQxTHaiXv+bS0e45Q80Gjr8/8GQF25g19d02sUvPYgsJWoW+rUZBJNktshI7zcUpE3Ovk4T0af4wwEsTTvnyNA/cbQMyEDaqSo1Ykoajh5mEwSRYfSyzZkRHWQIwRelx6uhMrds/FtkIx4F7f7sa0j5Qy/MwsQdJAH5upehF79GJs2ge68u+L7bfXl7OH7boz1Ka/gw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=HhvM9ZgPJi+DYq8Q/mtUG28QrtcJGsvXNZ7mGlaWzwA=; b=Eb/V0peuFcXv5rJI6JT+nKGf5VYrTvWnoJLqCvsVqfbGMPp6z8ObO60qo15+bQQ+ikGrtxIXbWQRDefZ7kmN1rUFBTg0UIriQXqxiyUxjidEke8Qp7Vq8qiR+xZOaxzobFLjuy05gS5e/xJ10qHOXG4udrTDUfZpobMtVG/NP+QyrtJVFQ2zUJVSs+u1vU+aeZyZ59gQGENt2WldySIce6xP6uI2AL8S9f1Yf4o/G+f3ZsC6wuRNcnGsc/q8e8T8D6kktsP+9PCSNL4SJ79mAiIS48A+UMte6kyLGzqVt5yob2CKO+x5p+RFS19dubJx1NmBvEP6as3MEmQGE2KzMQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by SJ0PR11MB5102.namprd11.prod.outlook.com (2603:10b6:a03:2ac::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27; Fri, 11 Nov 2022 04:23:21 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::8e5e:71da:1e29:bc15]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::8e5e:71da:1e29:bc15%5]) with mapi id 15.20.5813.013; Fri, 11 Nov 2022 04:23:21 +0000 From: Bin Meng To: qemu-devel@nongnu.org Cc: Guohuai Shi , Christian Schoenebeck , Greg Kurz Subject: [PATCH v2 17/19] hw/9pfs: Update synth fs driver for Windows Date: Fri, 11 Nov 2022 12:22:23 +0800 Message-Id: <20221111042225.1115931-18-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221111042225.1115931-1-bin.meng@windriver.com> References: <20221111042225.1115931-1-bin.meng@windriver.com> X-ClientProxiedBy: SL2P216CA0138.KORP216.PROD.OUTLOOK.COM (2603:1096:101:1::17) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|SJ0PR11MB5102:EE_ X-MS-Office365-Filtering-Correlation-Id: e1482a10-dfff-41a3-54b3-08dac39c7760 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MCAIxJhSx8j5j+57bsNU31y1fZMDOCD7hBma0XHYNhAaZrynTGc7lhEqVlw4aRF9kdBMglQRhFixo3wV0QUC/Dh63BgSZ3ic2cTiXCGhYeI618UIyOICZvW75UGAOLt3ecx32ZRqR2sJnIDQ+1I6c9LFNkRVP/HjMpGN4l4ntz7+4HIoKHl5h6jSy08vZ8z82zlISGXkhWy0MjZzbUs/UfXfzBUZYaBtfp2NJnixpIkl8qyDWcUSIWB6+cNKKvR1WVo9O3UXmQ+RQuv76DZcM8TaeTocKdECGZSaQG2scCDK3aG/jhjLqNCvk0YiayRBE6Vz0Dvfe9ovia6mmBGRbWd7j6c4aHubKeltM7QU1LlW+esxKlF2IB2aOBQ/NKyaPP4DFIc+vtmzUDvD8l47Na4IG4ssymOe/Y5FpKpWzf/du6cgIKTvBZYIaMFn29B+3ZxtERs+S4Jgvv7qNcUSnDxwlxDIH1ILjYvTypOTRc/cJuC/NsG6LccLXSEmd49PUX+TCgFu0x3ThIYLYkQpeJnki0Yq7H7uB6uo0NrUrhvnVaL6abNbP6VPNOWZmQ2xNJJs/+EFwAyTw2SNpQQPlaRxJs5FXiBQnOkZWj9vGG/6SBFU5kJbhyX6Js0aU6SONKNdXy5r+teOL97/17GtEZiApgbqp8V/67KKsI/cap51UWKhmhZ3AqV8qPKRJpDtEIN4bMvQH7JOrF/Fgxeo1137qaPci8OtaKJoWY0AWA52nnIjOJCHlmumHXzOWKHogSN0nrENMLVD9dTanZGzUA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5358.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(396003)(346002)(376002)(39850400004)(366004)(136003)(451199015)(66556008)(316002)(86362001)(8676002)(66476007)(66946007)(4326008)(38350700002)(38100700002)(36756003)(44832011)(83380400001)(52116002)(6512007)(2616005)(1076003)(26005)(6506007)(478600001)(186003)(6486002)(4744005)(8936002)(41300700001)(6916009)(2906002)(54906003)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +HXWuou49PGT2cJKQpH/+NhjYzTVHK3ZZjVI6ynk10KR3ORpugBJkoSgqVZLttwJrI2oRuSuQGdthp2QQW6QUbDvoMYPnL9kicTh0VB4QTaK5/uKqMJ+C2oORZAyOx/+UsU6NA0GU7u/n1xPKY7YsOJ0A5FOzRMd9zqjqq9t962oLRd5QKgeZliYy0xCYnmp5rU2ypXf9Rqo5PWnX27STJU/ALxKZP2z19echCuhBxbpkXLgnRz5XesUrupIBX7A59mU6Yr3eNyF4m4mKyt6lqGeuWTi/RWo4oi/JFfXQQhwYG1WlNXj92w4eaMFmUosIlbw9maVI6hLHxZyeizYhUqKCtDaKvHziQqs3AhAYK8Gs7pUYX4wEPASX2W3G3zTWMf1Pph1HJI65/aP+gA0kRS2bWTiJofmPY7apIU09SyE5/Gut4couL4xxTjQp2lq2/mvyzgIcoYHW4wvqpF0QGge4GIxHkNQ1ju+pKwY21kym1dpUarZ4bu9ND/zEKjLFs/nffYfIczIfJExqrVzFXXHEAERpJP1VS+COqbid7hNV2P33hISJw/exlRzlwiAlw7/NBELTwcXMrfAo4YSH6qxo1ihiPcexg2Hjtrbg9yAA2tufn3CpPp+0G9Pf8vGQW00646R307IWpVuuig2amvG9Szaa86v7M34+DRvXKon1ELaTqhwy2wTRaDMqQFoVS4882vro2qyEsPUkAexu2fbxpnr57jj3QAc8iq7HXL8Y1WquW6g+EvZ9Mqpo/AqBvt4iWfKLqSPJoH1p4eag7/Ah2vd7m2Qx6ugmGInr6Qhx9KfDqH/MN2XWvtD4P4RfJyaOc9Dbasoz3Qgw5yOjCT4jm1qCo7ThJ6wU9W1tiO7JAW1r5T4MsR06r3e6Km3sROh/oqQGqzPvbqwWR1lvIcU6kfgoVNEQij0lmCJ02urfFWBsXwSgwysjVR6MOsPdL46ug8q4wXmPU7V+/1/IF8WCBEbdoFMTQ4HgD88c10qFB+Fvp7a/K6pHgMNrBBJuDO2jk5mDdK4rcHCYA6cpShUBRkjSFhLCi5PZq8hHC+3gKnG05PE62VlYn5qoI2S2zVN3gVNVHFLgL0p6UfHacgk6uBWsxuAZLb+F2UbF63W6JqLg1dtUAk5Ol80KOw/j9Hnx4+haYTsS/EyP9IM3FX8MifWdVMV2QYy705h7McJtvDakUZpfrzhZt4AyPwd0r7gu3tOsMlDnRR400TtUz9VwOU89DNZZXenTzOheCWTdhVsY4Yv92qcIdxScPGxVbIcYzyGuk5t43Rpt6umwVY1goAWYXUPGLzOcQGoJM2N73doVJmIgOv22AY03dMGdUkHa4SwQpsMtVVs3t/LZm/+NJObbtWHPadPRlMX2VkBKwojRrwpMWYsPl6k4qQGendJzYyPhOQ1q3/RnY1GvwwXaDya2oYZTSfqxD5xA1ZoAXBfpZ+5F4rPu1PqMRwGkKxpqcZCzNCUIOnqg0JWBRetPHPV7iniiBnD/dzZHsfYu8fsD47/I1Zp0J9m7a4IxAIy9ye6ioKG+cqtpi3nXvQEAzrXYwKOLcXNX37CaARqOenu81sTvbkwJrC0TAMb X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: e1482a10-dfff-41a3-54b3-08dac39c7760 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Nov 2022 04:23:21.4118 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Edrd3YhQGIB1BLCo58/uVYa3pcbfVkRKP7f9/QJB+4VWxaMGYCdFdpOJYVaKm/4e3S7Qq0s2rKR2t/LjRhy3mQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB5102 X-Proofpoint-GUID: 9bmFtbLuG-VQuVSyOxWFLKdPzeK3MqPy X-Proofpoint-ORIG-GUID: 9bmFtbLuG-VQuVSyOxWFLKdPzeK3MqPy X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-11_01,2022-11-09_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 suspectscore=0 lowpriorityscore=0 mlxscore=0 malwarescore=0 adultscore=0 bulkscore=0 phishscore=0 impostorscore=0 priorityscore=1501 mlxlogscore=946 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211110027 Received-SPF: pass client-ip=205.220.178.238; envelope-from=prvs=83144312e2=bin.meng@windriver.com; helo=mx0b-0064b401.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Guohuai Shi Adapt synth fs driver for Windows in preparation to running qtest 9p testing on Windows. Signed-off-by: Guohuai Shi Signed-off-by: Bin Meng Reviewed-by: Philippe Mathieu-Daudé --- (no changes since v1) hw/9pfs/9p-synth.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/9pfs/9p-synth.c b/hw/9pfs/9p-synth.c index 1c5813e4dd..6d33eb1cf3 100644 --- a/hw/9pfs/9p-synth.c +++ b/hw/9pfs/9p-synth.c @@ -152,8 +152,10 @@ static void synth_fill_statbuf(V9fsSynthNode *node, struct stat *stbuf) stbuf->st_gid = 0; stbuf->st_rdev = 0; stbuf->st_size = 0; +#ifndef CONFIG_WIN32 stbuf->st_blksize = 0; stbuf->st_blocks = 0; +#endif stbuf->st_atime = 0; stbuf->st_mtime = 0; stbuf->st_ctime = 0; @@ -236,7 +238,8 @@ static void synth_direntry(V9fsSynthNode *node, entry->d_ino = node->attr->inode; #ifdef CONFIG_DARWIN entry->d_seekoff = off + 1; -#else +#endif +#ifdef CONFIG_LINUX entry->d_off = off + 1; #endif } From patchwork Fri Nov 11 04:22:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13039648 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 8402FC4332F for ; Fri, 11 Nov 2022 04:28:12 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otLZh-0000af-RK; Thu, 10 Nov 2022 23:23:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otLZh-0000a6-5p for qemu-devel@nongnu.org; Thu, 10 Nov 2022 23:23:29 -0500 Received: from mx0b-0064b401.pphosted.com ([205.220.178.238]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otLZf-0001cG-Mq for qemu-devel@nongnu.org; Thu, 10 Nov 2022 23:23:28 -0500 Received: from pps.filterd (m0250812.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AB4Fv80025971; Fri, 11 Nov 2022 04:23:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=rysNIk6lSMrISHuzxrKLFd7qLEqSoQDKkPP11ae2GJ0=; b=XGlfooJs7m9vWvprOy9lfU8hiQPX7hmXyJsmeHMjSpcxUAnt7A5YkqVCsx4LqMusqpfl n+wQYSrsapYxaUKjeEMZepb5fry3QxOokDqfw4YSGuOHySRzUQB7cmIKGY9Zc7xZ45tK SI/g3RrmAx1riyc9VnaHqnjxg1U1rKvXWoGv/SfXArJvrcdiyZ5kDi1p1FNzEIaHptf/ WWcr7vp0nPMQIqYCcnNMP9eVSJCJKlXB12bgPuCSgnlH5q45uYrPwTIExvphoJyCR2g7 m31z/Pb7JaGFHO9ivkX7EeXp86FMLy+h/6YSOZb1Ny7US+U7BSxiQUaeFRLvpIEvzxTg gg== Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2103.outbound.protection.outlook.com [104.47.70.103]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3knet9nbdy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 11 Nov 2022 04:23:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RP0T9qz0Y7XPjNaksTSGas1bc0LqOKN2urrRoHQYNkrVSs5/ktTSpCGvVtrDDZ24x9ExcBvZ7mwr1WC3npAJ/DoR+rzJKWbZrkYYY1Oqo47AYhKCj833i5otGf8yuiAvzciu11/PuYuLB8OSxdxGq2VXkejpokIkZbrhTQYZKPCGemopalK0Y8yWBsFS85ooRxBFmVryk6WBaDLrv132Rwq4Mr+Uyt6vIJj1r2rPwvI6gctVc+wxTualB21clfakFrQGHuoEfJNOOIq8lQ6oyKpXqF2p0t8u+EEeV8tBjKrXKVBNc1+ODkRH3+8YXjlgYvVW7ddUgPJSrD6tor10kA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rysNIk6lSMrISHuzxrKLFd7qLEqSoQDKkPP11ae2GJ0=; b=VvxPnAXl2x98TebGKqz3dc9uUVIcyU4w3Uoyk/5IaICz17GPTshmLd1YtChFd4Ise42FMc3y/5342iu9CQez6YH4mbDCwIE8OOukQdGFrTEUz6Y1fFPNTPFpGo5vBaB8rWwCrEEa0TSjbiiEWJ8sl4KsTznGP+AnL/2ospGuVN03pYq91462rlVmj9PHETPm0A+g+zoDI+gdzNyshGh3DU9XklVdNBe6uZj3q+xFknRJ43jD2p8ewANUApeqhRRI1B/qSbUOl37QBYvqdLO/C7ZHH2PLFx2vTkC0utQNd+q0hT1zPrXHw1wtZkKtOfZA+gecN/jtvUQ1+0CB87U6Zw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by SJ0PR11MB5102.namprd11.prod.outlook.com (2603:10b6:a03:2ac::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27; Fri, 11 Nov 2022 04:23:24 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::8e5e:71da:1e29:bc15]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::8e5e:71da:1e29:bc15%5]) with mapi id 15.20.5813.013; Fri, 11 Nov 2022 04:23:24 +0000 From: Bin Meng To: qemu-devel@nongnu.org Cc: Guohuai Shi , Xuzhou Cheng , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH v2 18/19] tests/qtest: virtio-9p-test: Adapt the case for win32 Date: Fri, 11 Nov 2022 12:22:24 +0800 Message-Id: <20221111042225.1115931-19-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221111042225.1115931-1-bin.meng@windriver.com> References: <20221111042225.1115931-1-bin.meng@windriver.com> X-ClientProxiedBy: SL2P216CA0138.KORP216.PROD.OUTLOOK.COM (2603:1096:101:1::17) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|SJ0PR11MB5102:EE_ X-MS-Office365-Filtering-Correlation-Id: c08acbe6-a7b6-499a-aed6-08dac39c78e6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yWHcTcuH0xXVcv0RcBMrptJqZzZR6+I0Pdq6P+oKzwa4dZydrhDh2nHJcHp2bOAPpwieDutl1FPeeAiktaRkszzBHj2ngyHaeQnb8dW7jpyvHhDLDPjGNbSGTzCS36FiBOplQMpLj0Gd/w31MOVAyANVY0Jna4/xhuE1z8/A61U/RVek5JorwD/Jt0PY+p17Efd+Gdo4QzVEaxvrG8oHdkD126Lap25/cFgHkQ6G7iMRCBos2yvgeYywGMqy64A3elDLfNUk9o77ThTSRdxcpnPblRjRqZo25M4yj5OsvtPGKgZQBEjzI5PZpea+smfiQ3TFpPR+bU4g+aDYJbVko15nCxlYdocKjd1+IMLD/KPFpPDhhFY9MY1RR5F4iWzItgcsWM3qgMs0s4rjLG4edFMcjXNQ3UKa+Asyvor//iEbnAG9WzvhrPJvWMl757Aw6TnoqBt2temECW5nvOvLwHRQ1RWDKv5iUI1HhJVYtQ7h0c7HwWdsavus9kpNgnwacHJIfdJv4+F8rOlGJ4FYot5SkSgT1KjNVSek99ZkOE3BgTZga7UDqjX/kQYLyOyyoqT8EgNknwh+xNJURGc/IxwnPRfWIAGHz3vErGVKPlE9vi9T2RaSQBQLuhi1WuXgWrqg2iDehQggWt+nPrsqfjAzcejVLWttpsnC2ZxMXe75R4sZadeMR+zaD57sGqlj2cKaXMVmusaDXBY8ii30eokwk+b7tJ4NuqKaab5Bzh0RmFQN3UDD6EionRmrJ+xc X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5358.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(396003)(346002)(376002)(39850400004)(366004)(136003)(451199015)(66556008)(316002)(86362001)(8676002)(66476007)(66946007)(4326008)(38350700002)(38100700002)(36756003)(44832011)(52116002)(6512007)(2616005)(1076003)(26005)(6506007)(478600001)(186003)(6486002)(4744005)(8936002)(41300700001)(6916009)(2906002)(54906003)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZdJf7Mocunb6LeUVmgFuZoc75xMoAwwtlTDya6c0fEYVIWkq9Xrb0kBPM4MWxEcfo1S0i6hxaD6VIh34nK9eLzzSgAY1nj5dpER3MVCvlg8KNV23p8Xom4goHeoLIFgHOu7QXZC/E2pTLn6wvlYe1b7LGQN2Uz5fjyo5zOXAhKiRFpFnoSLiohul6atN91aWaLdylk0Npq+I9K1Fe4uou5YRSgzEv2izfmsKVjws0ffVRTEUr8DtanaWPA4JDMFyDlBHYhcy3dzdMUg/1AKoIYp7kxvcKfJOf+llZ9pN3QB6MMLDNH/h92nC0y4nlf4Ebd+1Ym7Uoypbm7NjALT5x2QWhwcxImh4pNu0yRW8RLWCOQrWrE81M9zHzEKUpq5w4euDkIxYTmMKGWTBX8o4oq7HUet4tY7eik5bjjj+ecpOaXWnxcTGcvgw9ay5kfRTp/GTFwvnq0pyBWYj9KAHm1f8q8hwzVFYB7DN4Of4CXw7fw3dKgq1E6dg6rTllYPxPCDTQMr4aPDcSbEHuAPaCADQ+turgdSWfJklEj0LdgQ+KdYjdp9LCZ3eou7jqMN8xFkmgNm+ygOHsuoXq7c8vCQ2li1wPXfsB3QFnOTf5JPfpzcDb0rgoRhtD5jN4strcIQf+QOesH26ui7Q5BWm+HMKUp4qQzBRdh6HM/K9niKFSizKpRDgGBKBDLD/UKFp6UAcJ2yTJe2pZN6oZoz+Y582bcnykDJQ1F3JAN0rEAt+zYxjUxBwNnzBYZz8ZK5/mdkwkewnjCpsOWeBSA8Sn21FWr8VuTLfpuNljl+K8spcOmKu923BYZW4ZiBavsj8bxdOLWSrEOApGaq45sXy8e0rDBb1Foqjg+TCvGZ7uW0G8nGo2xoY0I/6DZN357vL7HNc17iYAtPUF5n8f0eRGVuhRsI4/yI6X45jnKwpN6+jUHOzAcdWqhSdQVsvsfl19/nSCIiY6nwJd7gxxr2awp1GeTtuiLUISiQvcAtxugFUvSF2xyGqxoz4GoxuRRsDiure7hUbotCVBUq69lsTf1R8lQjM/CjuoiiXRhBAiqq5LaYKClj3bwt/fIb1V3sFOCWfsB0i1dLHecutgtmo1gBOhvChS6UnhA6sSx08RG1Aq/s3SfO6v8m7dPOXIGzntEQb37Hwv1R0e4qUplZPOrzYpCs/H8F4qtUYMHHvUKeHeuZa9IIRJJAQ8Z8at1mgTus0JEEkA8KWvedyejAMIm03dvNFvGskkVe+Qd3qB8E1OhI+CyKIf52uMnzIxuNjbkkI5kfAqDof1McFoWIMnS5RAft0G5QvA51Yk9DSoF32ORsDecoHIO2lPmYhVb43kaE2LT9gslUpKe/B6k1ziJ2wWqV8HI0w/28xa9Mj4A3ml2A8GXl9jaTHI1xpoeexb2tN3Qs2H8fM7Bs1olgmR5rPUk/TosYXr6L4KffB3vlWa5nbsd8y33dWkp3NYuHpeRbLmlCKZSw303I/9zxDGqCF6ac1vlgimaZzCB+GAZS1fZPfiJMEKFu+/4aNMsnIICgPDQDl9yqDd43ixc0CpDi3ieAl6Menw+VJO6P8318DA2hEXf+HP3WoC9LDblK0 X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: c08acbe6-a7b6-499a-aed6-08dac39c78e6 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Nov 2022 04:23:23.9700 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: qaZlMGgvSyysbFHHIuzQoudwHqS2CctCmwsICCMaGh+pMYjk7NY/L2DWCVEAf5Uc5gNa5DkSHD7d//J1U1kK7Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB5102 X-Proofpoint-GUID: BidJZD_F0LqKIfWYF5PqbRVmjIM8XvRl X-Proofpoint-ORIG-GUID: BidJZD_F0LqKIfWYF5PqbRVmjIM8XvRl X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-11_01,2022-11-09_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 adultscore=0 mlxlogscore=992 clxscore=1015 malwarescore=0 phishscore=0 bulkscore=0 mlxscore=0 priorityscore=1501 spamscore=0 impostorscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211110027 Received-SPF: pass client-ip=205.220.178.238; envelope-from=prvs=83144312e2=bin.meng@windriver.com; helo=mx0b-0064b401.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Guohuai Shi Windows does not provide the getuid() API. Let's create a local one and return a fixed value 0 as the uid for testing. Co-developed-by: Xuzhou Cheng Signed-off-by: Guohuai Shi Signed-off-by: Bin Meng Reviewed-by: Thomas Huth --- Changes in v2: - Move getuid() to virtio-9p-client.h tests/qtest/libqos/virtio-9p-client.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/qtest/libqos/virtio-9p-client.h b/tests/qtest/libqos/virtio-9p-client.h index 78228eb97d..a5c0107580 100644 --- a/tests/qtest/libqos/virtio-9p-client.h +++ b/tests/qtest/libqos/virtio-9p-client.h @@ -491,4 +491,11 @@ void v9fs_rlink(P9Req *req); TunlinkatRes v9fs_tunlinkat(TunlinkatOpt); void v9fs_runlinkat(P9Req *req); +#ifdef CONFIG_WIN32 +static inline uint32_t getuid(void) +{ + return 0; +} +#endif + #endif From patchwork Fri Nov 11 04:22:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13039642 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id ACDA4C4332F for ; Fri, 11 Nov 2022 04:26:28 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otLZy-0000qf-Ap; Thu, 10 Nov 2022 23:23:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otLZx-0000o1-2J for qemu-devel@nongnu.org; Thu, 10 Nov 2022 23:23:45 -0500 Received: from mx0a-0064b401.pphosted.com ([205.220.166.238]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otLZv-0001f4-Av for qemu-devel@nongnu.org; Thu, 10 Nov 2022 23:23:44 -0500 Received: from pps.filterd (m0250810.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AB4N9pv004974; Thu, 10 Nov 2022 20:23:28 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=SXt4gl9FGVsN8kbuRE4IqSPgVdcZ+ICXN2rhjTe/dE0=; b=YYHEzrCDA3HyoQH0jfJkKZvmfyTYxduS50+K+CrmE+jICGmU6SUBemKDfD0OrQIGHy8Q qCX+Qf13ZYniaL2uZM36iszaf63t0Yf+dzlhwAIJ3Kdaer+7QDxgFuqyWma/lMMk+TdY QQttZ/UPIj4YbcalxOy60jPnfEHfhqFwxhGWj3jq9NrAgIeOTowFAHmGrsGy6EiX3xw7 RByju2a3auubWEnNFsdjhnDm1luytzBN69Tr7Qs8rFYl285qUOs+8G+B6dunHof5HGIZ GZNluB2Gopm+paGLNn5euP2wWeQNHducn7EfU+GH6Rjr924ijUoFLwHojDJWHzA+OpXt RQ== Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2170.outbound.protection.outlook.com [104.47.56.170]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3knk43d9mf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Nov 2022 20:23:28 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Bu2OjQiHDG5rnL6tYko+m641R07xWlb8c7KZcC94oIuJJWLX5+OnP7OwquvRWN8bXFsP0h1huF4uGH+Qdfo44ogb0foetvT7SpSpD9xY1F0yJSRhryZqamYhLfLSdl3G5azxRd0QVV8HrqOcC8XUSl0H2M6VJpZ6eLD2VnnjnypotHXDDMF15mnZnh77wZdC5CnCnDRZ6mAj+Mi/gA18nLlQiiO2ggy0zZyAT8/kQzDTqXWpoFTPzQ5ulPos+Xm6bFrsfBYIQZ4PyNxVbCHufeNXyAa9LfVHCE5hjMDYX5NQuhO901fUyKsgR8Uvp7b+f8JsCkWQ2lHO2EczwtZDnQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=SXt4gl9FGVsN8kbuRE4IqSPgVdcZ+ICXN2rhjTe/dE0=; b=AL98cAjQRLdo21Ft1s6uxoeHN768rZy+Dj9g4qvYAnXjrETRhH3GzdqGDTH/DK0ypHUgi3fcSCenRjpSMPMtmPxH6vAnlI3f45ZC1TXy7h4qiLbeOOOmd5Vw8TfR+dcRNSg7OtSK6GYyofR8i9nug9QBrRNgBS+M8tLDl/sJRS3V2OjFMPtEAIfkBSl/RElUIM6zjV3KMLrruOki+j5NQVHDH/7noVeiiQFRSPYfecnV21LHpkKxCC3P56l3opg9WVuDllLiY3ms6SZsNiec3aq+D/qK5xdBSDt3+tF/Z4mZ8ZWs8XnIxIWhpNzgiLEprGkPNYbHQ2J5vHMNG3z/Ww== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by SJ0PR11MB5102.namprd11.prod.outlook.com (2603:10b6:a03:2ac::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27; Fri, 11 Nov 2022 04:23:27 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::8e5e:71da:1e29:bc15]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::8e5e:71da:1e29:bc15%5]) with mapi id 15.20.5813.013; Fri, 11 Nov 2022 04:23:27 +0000 From: Bin Meng To: qemu-devel@nongnu.org Cc: Guohuai Shi , Christian Schoenebeck , =?utf-8?q?Daniel_P=2E_Berra?= =?utf-8?q?ng=C3=A9?= , Greg Kurz , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Thomas Huth Subject: [PATCH v2 19/19] meson.build: Turn on virtfs for Windows Date: Fri, 11 Nov 2022 12:22:25 +0800 Message-Id: <20221111042225.1115931-20-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221111042225.1115931-1-bin.meng@windriver.com> References: <20221111042225.1115931-1-bin.meng@windriver.com> X-ClientProxiedBy: SL2P216CA0138.KORP216.PROD.OUTLOOK.COM (2603:1096:101:1::17) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|SJ0PR11MB5102:EE_ X-MS-Office365-Filtering-Correlation-Id: d92f442d-93da-43bf-be87-08dac39c7ad6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XPVREbHM9+tD5WWa1ZPV6yX6F9gQoVK8+2CJrxitxTV+DBoc9RHtIimXT1K45OpgBuVu/ncEF7wHfNejfmXLgl5G0THx7cYO2gkt3/z+gYCUppfCBLiBjyq1diFg03WZJBvRW5evbURWPzB+UeInlJ4SP5CTcwyeSRRsWMR1UeUwIhuIhckdG2ZKJbtZU4ws5sc0iyjCzRVtaZ7Uro4aRvprxB5T40Fg7LNst+t2oezK1kYt19oYzCV8kILLVlKJW6yNYdNPMBR3HoMIYzvT67kUSgGG6uy/rShuPP6wzbBvuQ+VNE1tXDunw5sBu7RhdnPVSSAU+Ik5vd3vl3oDhyWbctJxKiA4H5Acy2emhuEir6mDPNA1PuZtyKbUcMhkzcK5q1oxJY8b26ZbkRVJ9dtbJvWbLxDxO1JMDBzMdDwiC5qfHziHwtQ7oCSFzB6pyz5f6AFbmQM4jpGTLyjCCNjJlZuvEPhDnseLR/AiTJYOIYV4DEs5AlQOihg+X+GaSEi13Xdgwb3Ic/pWQWW+X4X1Nxh4saTSy114NImdawEAl70nHgUWbsQ+OmhAP1vWs1tsa1B15+ECI+i5QrE/j3Bg+5K1X0/X/egsvotkvdjJGy4A9syb59RvGQo/N631erNTTcth+bL3GzZK3s2UFTurUf83fU+i41eJkDVTKPbs+1RciZfhRlWnjXiP3sFxBmEVXRDwlVaAREcFrdDRtPc8jbB+3oOrBYyykjtHZGtVK5LwUJSR/O+21g92W+jn X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5358.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(396003)(346002)(376002)(39850400004)(366004)(136003)(451199015)(66556008)(316002)(86362001)(8676002)(66476007)(66946007)(4326008)(38350700002)(38100700002)(36756003)(44832011)(83380400001)(52116002)(6512007)(2616005)(1076003)(26005)(6506007)(478600001)(186003)(6486002)(8936002)(41300700001)(6916009)(2906002)(54906003)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4hifVZgAiWRiPbneWXHMtEQ+UXF1ZmfphO+pawoj98FYpJeW3i59ry+XdtzgVxYdu+cNsig+2z2aea4vCUmplUijIYaUKnHvnWGDVmd3D6qemGrDPOykxJroWG2lcErI05Q3/uhZAvjt5WLnu47qAsD0i/LbJbPg+S16mT5iV9tblX1DK64Fav3Rr8Duu4Kc08q7RiHrkLZ9/LvD6K6FW+a4SpCY+q/zhjIHCOy5K9ITAUGlDnCmT6u+uwpCU8EGzdsiWp1rSPIceUZsPDVkrqBKyIyhAI5zG1DbLXGDGT9za8Mc85CLTqo4sCiyUxTyUg7WIkAmW/p4B/4NXHADx6OuKA7cxFL23SYY3ThMPEH4uZkpCvgF6Lk4KxbJxLA4dWuZlzeZ09QNxbVzF49xNionN8/23+HLTwSF24KzbwWlPQHTYuJsYcq8+iEykUhr6bL1585dEi7ZrLfo/M7h1ipPI3G6ih2f9E2K+L9G1Fx4kf+HRJiKmIcOf4gq/Bn0bsQYK4e0Qo/pTWTzPA3gZyMwhAOAYgTDkPpf0CfoQwmTQ4M+4sWwj2N9o/i8QhECDef8YeOByd2s4c6sp9+0/6uIbA9oQUnHZkqENW08Mvp1h/N+5ZASOhZEYvGsZ/8oJuoyCBlCpIrDf5ojc+yC+WjfHkeb138GDqCblrCcpjiKiYX1Qx6jPj7VKR+fEUKtz0U/FqIAlMDnx9Mbjf9Pdww4gWrF/72Ko6lNXV6aMq3JaF5pKgpW5fe9+9dkZBu40ZkP6/lXwArrVRkabj1ulZfRyjPPUOwknMF7lgqKWt74f32EIjBdxBbGXq2Y0NnN9FrfB4qKSy+rbNl7XcLUROLRnNkLyx7dsGM4Re1SkV2AJye0Q3td4GGG/BEEm3QTxEQn8pQHVfqB77HcArj34LcQ/ybxZsnAsrLfYYC21yhmyBNNfZsSL9z0Ke2OcLCKE5y4sSc6RpGHFntFDi0tD81xGy7cACvCLNLbugN3H7i7XTOvmt2d9PdoD9IszU7Gf5fnINFmItg8UuuCkQH73nT9rT3Fs6nMOzJD1Me3iQjbLIf4Nr3lwieenFbk06RTe1jTInzzlg1vrDB/ca25/71B1byqiZqznCUWC+J8LleAo5wpXNDqXr+LQVNDhUnfZRnUUpGmjJDQD9YUfWoCmpN+uv8wlpAPUe9w0O97ImjiyFFkIU3Nx7wwcQIqOCC8xOU4mbT7gSAe51UQPUgYi53+9fnZWGv5lnHSk5cTCc6Z+ke3X8fo3lgB+paQWMlisV0MSJAh/9vI0QJJ7wCdj7224nKXwMKKCs13pVj+uKaI0qFSR4IkW5HGKT6CqnAIkO4UE370TtwHdsvQn1RVu4o2H7yCrYjcs8oTPat4t5zUGAH01qSD6rHWMAGUx95osK3ZdsrT4BHmqNY2mhelsjaVKGk8MCAMnBssQX34C14+bZL8kd3g0DeIjTwqQmizA1zn23d3NslnxElkXMAg6zXHfRu/LgSA9d3GTymNiCP+unT1/SoXA/UDfIPGI05S8hvv52QhEDsoj7gwQ+Xv66TvErKRy3w3xTSz6zxGdBjZiUeWlo0LXpmJNsuLGBKJ X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: d92f442d-93da-43bf-be87-08dac39c7ad6 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Nov 2022 04:23:27.1117 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: /+Z+FzNOzets0KdmocrW/jA6DC1lWaFbxQ7+I9ypiJOEAhUqHL06mIteuV5sqQNY0N9EfIOr49Om9nNG0Il3vw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB5102 X-Proofpoint-ORIG-GUID: NQ3ci6uRpbGqnRmhm8nRY_KUBMXE58ox X-Proofpoint-GUID: NQ3ci6uRpbGqnRmhm8nRY_KUBMXE58ox X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-11_01,2022-11-09_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 mlxlogscore=678 lowpriorityscore=0 suspectscore=0 priorityscore=1501 phishscore=0 mlxscore=0 adultscore=0 impostorscore=0 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211110027 Received-SPF: pass client-ip=205.220.166.238; envelope-from=prvs=83144312e2=bin.meng@windriver.com; helo=mx0a-0064b401.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Guohuai Shi Enable virtfs configuration option for Windows host. Signed-off-by: Guohuai Shi Signed-off-by: Bin Meng --- (no changes since v1) meson.build | 10 +++++----- fsdev/meson.build | 1 + hw/9pfs/meson.build | 8 +++++--- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/meson.build b/meson.build index cf3e517e56..4b386556c0 100644 --- a/meson.build +++ b/meson.build @@ -1739,16 +1739,16 @@ dbus_display = get_option('dbus_display') \ .allowed() have_virtfs = get_option('virtfs') \ - .require(targetos == 'linux' or targetos == 'darwin', - error_message: 'virtio-9p (virtfs) requires Linux or macOS') \ - .require(targetos == 'linux' or cc.has_function('pthread_fchdir_np'), + .require(targetos == 'linux' or targetos == 'darwin' or targetos == 'windows', + error_message: 'virtio-9p (virtfs) requires Linux or macOS or Windows') \ + .require(targetos == 'linux' or targetos == 'windows' or cc.has_function('pthread_fchdir_np'), error_message: 'virtio-9p (virtfs) on macOS requires the presence of pthread_fchdir_np') \ - .require(targetos == 'darwin' or (libattr.found() and libcap_ng.found()), + .require(targetos == 'darwin' or targetos == 'windows' or (libattr.found() and libcap_ng.found()), error_message: 'virtio-9p (virtfs) on Linux requires libcap-ng-devel and libattr-devel') \ .disable_auto_if(not have_tools and not have_system) \ .allowed() -have_virtfs_proxy_helper = targetos != 'darwin' and have_virtfs and have_tools +have_virtfs_proxy_helper = targetos != 'darwin' and targetos != 'windows' and have_virtfs and have_tools if get_option('block_drv_ro_whitelist') == '' config_host_data.set('CONFIG_BDRV_RO_WHITELIST', '') diff --git a/fsdev/meson.build b/fsdev/meson.build index b632b66348..2aad081aef 100644 --- a/fsdev/meson.build +++ b/fsdev/meson.build @@ -8,6 +8,7 @@ fsdev_ss.add(when: ['CONFIG_FSDEV_9P'], if_true: files( ), if_false: files('qemu-fsdev-dummy.c')) softmmu_ss.add_all(when: 'CONFIG_LINUX', if_true: fsdev_ss) softmmu_ss.add_all(when: 'CONFIG_DARWIN', if_true: fsdev_ss) +softmmu_ss.add_all(when: 'CONFIG_WIN32', if_true: fsdev_ss) if have_virtfs_proxy_helper executable('virtfs-proxy-helper', diff --git a/hw/9pfs/meson.build b/hw/9pfs/meson.build index 12443b6ad5..aaa50e71f7 100644 --- a/hw/9pfs/meson.build +++ b/hw/9pfs/meson.build @@ -2,7 +2,6 @@ fs_ss = ss.source_set() fs_ss.add(files( '9p-local.c', '9p-posix-acl.c', - '9p-proxy.c', '9p-synth.c', '9p-xattr-user.c', '9p-xattr.c', @@ -13,8 +12,11 @@ fs_ss.add(files( 'coth.c', 'coxattr.c', )) -fs_ss.add(when: 'CONFIG_LINUX', if_true: files('9p-util-linux.c')) -fs_ss.add(when: 'CONFIG_DARWIN', if_true: files('9p-util-darwin.c')) +fs_ss.add(when: 'CONFIG_LINUX', if_true: files('9p-proxy.c', + '9p-util-linux.c')) +fs_ss.add(when: 'CONFIG_DARWIN', if_true: files('9p-proxy.c', + '9p-util-darwin.c')) +fs_ss.add(when: 'CONFIG_WIN32', if_true: files('9p-util-win32.c')) fs_ss.add(when: 'CONFIG_XEN', if_true: files('xen-9p-backend.c')) softmmu_ss.add_all(when: 'CONFIG_FSDEV_9P', if_true: fs_ss)