From nobody Thu Mar 28 13:35:16 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=windriver.com); dmarc=pass(p=none dis=none) header.from=windriver.com ARC-Seal: i=2; a=rsa-sha256; t=1675072480; cv=pass; d=zohomail.com; s=zohoarc; b=Y2Xd8PbZ3hR7kuEbyv7KV9fPN+7VAYavaQfjVFZ+IHwH4sdQQXpbxWtQ+naEpV8z0W6C48GPFt/P9V0sWnc9qJQotCOl5LtLkZ3qy48whi5RtgQkgRNGDDDbIrkfuFV2hSYljPz+xUfbQMHAbJBcK6xAXzdGpZce7p4RqjXUSLM= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675072480; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Xy/0/TnZzqrfJjp7JG4s8BGGuRiy5TjlmKMjhpcBLTA=; b=S6V24p7h+2QRPBdgvGYYCG+Ku9UHiXNp4805lznkNYvptACpaudCjPML/9vko8uVZAoFDEOtACxUAF8rNlQ79yRQJtYJOYqOdLhfi4IWVuvs97YpOq5UgQ6TVfef10kQ1FYKKBEU2mywmWxQNO/DYSYb+gRYjQ0x3nlHIknHmgE= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=windriver.com); dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1675072480846796.2263424066276; Mon, 30 Jan 2023 01:54:40 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMQqD-0002xY-7G; Mon, 30 Jan 2023 04:52:45 -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 1pMQqA-0002wo-Oc for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:52:42 -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 1pMQq7-0001zl-GN for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:52:42 -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 30U9hjuC015618; Mon, 30 Jan 2023 01:52:24 -0800 Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam04lp2046.outbound.protection.outlook.com [104.47.74.46]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3nd43rhj5h-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Jan 2023 01:52:23 -0800 Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by SJ0PR11MB6573.namprd11.prod.outlook.com (2603:10b6:a03:44d::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36; Mon, 30 Jan 2023 09:52:21 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9%2]) with mapi id 15.20.6043.036; Mon, 30 Jan 2023 09:52:21 +0000 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=Xy/0/TnZzqrfJjp7JG4s8BGGuRiy5TjlmKMjhpcBLTA=; b=H75mkmO0gmaJdkIwRGH2iBhwRHwocM9nUJx6+gBaj6tlCYtGWZQkZA5zyJS2Yjyhgtx6 e6sO0CdpWpK2LS9cAgkuVwJOGezHmVOH0FFb92WfVYCIr8nLZGO525xw7d1fwXCjzmBA 06+MnB0g2DBOu0U/+EtxJY3Abgxir0Bg0y3gDbqryafWxXYVToztu8N3g+VROxxhrfVh QrdUgYCGCfvTjXuNOsECxIUgRN1krccGIu+wwcuRiIhIghxheQ82f0ECBCCbJKliBWGx K9SBqEbp6+N6RvreQsNWWXrzZYGxklRhD00nxBBOVJcrl+2ZI/Oxr6LNT9xE+e/grSFz IA== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hX7tQeOpmAbFUwUJhMg8Y+4yzXlqWx9ctxH1ck0eJNrziIrzQQ7sJ+kLfqOXDEg9VJ/YjkwU9v+EKjABxv5b/pQu3oL06g3Z5JXTxwg0IEP8cAcjh+X9Sm8ZUUI07Kom1UQRcSdolIsQiWzSaz3S/0wYXSM07yiMGl9lK2yqEmrhfzo8kLNHwX7NoPptcyACsRWTQa9h73XanAZrYpyjT03fg4ZdpvgWTUErlVz6Bg5t5r0UvEjZwJ9hclpTmltNZkyCSbtrWLC36JkzYxP71ZQr4pggJU27k3pUA4sUzgQj65pnbjGtQVJV6F7PpIAW+idGMb9zbwNk/lWFYtlk8A== 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=Xy/0/TnZzqrfJjp7JG4s8BGGuRiy5TjlmKMjhpcBLTA=; b=JtpV5BbtNdsKyEaQ4Fi7rpcCzm8/e2rBboj/+0/QRP4qoHhGc0H8LUaneqV4s6kDR0Z8XWsCVHCJ+nodfBnlXmq2FlteIdxUQ++BQaF1+tU96E5OtaO1uiMB+nWN1hkoeKB8B7E/kWELoLyY8zEDFT1Abg2WlLlVkg9VIWlHKmsvyzodOYKKsVtNZ9XPj4Dkc0IXzkotXZziOXg7OXLbwgeoLVzXdy/7JRNs6u1YBsHgCePAsfjprL4PBGIFk1eQ18uXRjKv2bT4xeRFXF4McSgY9AxO1p/7QTHH5S6dg57ly+p5BcNvcMB81z+wjk8L/STSkqUzHnUNHzWkA9MyxA== 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 From: Bin Meng To: Greg Kurz , Christian Schoenebeck , qemu-devel@nongnu.org Cc: Guohuai Shi Subject: [PATCH v4 01/16] hw/9pfs: Add missing definitions for Windows Date: Mon, 30 Jan 2023 17:51:47 +0800 Message-Id: <20230130095202.2773186-2-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230130095202.2773186-1-bin.meng@windriver.com> References: <20230130095202.2773186-1-bin.meng@windriver.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BYAPR02CA0061.namprd02.prod.outlook.com (2603:10b6:a03:54::38) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|SJ0PR11MB6573:EE_ X-MS-Office365-Filtering-Correlation-Id: 19d35270-791a-4c00-c27a-08db02a7ae5e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2sPP+oKCynG+jhp8oRJ8ZCQ50boIhZkPB4DYFKf2gCleKWnCAGbnwErhz5GIw2o2sTLAVCD21fZ4p0z1TOq6eRc5yJKs3aM4haNBLs1XqQDckR267IYWajVqi76rAkNddnqmGSgSwjQGW219PauieB++7l30wb4IJ/xCi4ZiTRoRGP9tKzFhyJkLbk83uNw4FTKqO3tYbeVyvVbr/gW/DpomGQIxNTOFKCem/2tcNz+egxmcY87Swn950g1jbG5aRh8AxhsCK8F5XxxQAqWp1cvbIYKH/AoOEypUQmsTAxp7b2ZT/zDFeQtTwgKWk9IZqVcelwNJLPrVzPJzDC3ECxzqy9yX4h1MUbwE2bY2gWGmY3YxOj5TeVG0iSuu2lrPR0TunkAESm0ibcvlSNuMxQT3CHoNisCWgJc1oj5VOJy2a4DrY1mquXdsAcymqkgXFYH0smmCAx3WmWtQHC8ISVKSU98gGTG6fmjbZOVu5HIOQsQYJwzGODGIz6fkcCMhbeZ/Vjtre2SQzbzAJdpYQ9CxuFydikigLbJAXhFSda/+A6GDMDOLsFszIkPZJ1seGj6FxcqyLMc1b5QdWPICsJElAYYDioL1fx4JZcstE2tYcVvsPH5wSd9OjyWNBj+C0JanlX8EPRrV3EM9WGjIk4QFNdPo2KQtzHF4XpEBo29l8d6VFTU6I0fTz933ipE1sEhIZ0hCMVXxkhSusYOj1QYyGFv143XWdM1J0La2IGM= 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:(13230025)(4636009)(366004)(396003)(376002)(136003)(39850400004)(346002)(451199018)(86362001)(38100700002)(38350700002)(478600001)(36756003)(2906002)(110136005)(107886003)(6666004)(52116002)(6486002)(966005)(41300700001)(26005)(8936002)(5660300002)(44832011)(66946007)(316002)(8676002)(4326008)(83380400001)(66556008)(66476007)(6512007)(186003)(1076003)(6506007)(2616005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?2ineZShIdvHGjIovamP0qTIwbjGxB1L+eWl1UX6IX7F7lr4vZkDPxrXxFgGP?= =?us-ascii?Q?EtmkeaPB6OmH5yZSJ/74rfzQ01AUjE0ClY88ZkTZJqCWxxGptwqlwKyamwre?= =?us-ascii?Q?f0XCXupO04HUgG7U6aLe7ZyPsWgMK8ts1gRPWkm0QagF2UZV+dzjtlyUY1SM?= =?us-ascii?Q?j4yTDkIWAJDKIpDWl1yHtilbj2URxwhxoQ2oUaTYAUlU4yCIWCTcHrrx5IcI?= =?us-ascii?Q?ZHs/pSxYovF7H2kp/mGSZSY0pssWjGo+3FZ7deDFDh46IjSBoPOI3li8aHo0?= =?us-ascii?Q?nLtGu1k8PUYRUP0QLFq6LXH42kT6t2KohqtfQjlZAslWsSxmgtWEVPNQzzvW?= =?us-ascii?Q?7C08Y8ajR95ZU+jQlgp/ejR9XfzcgB2DR2LQIpwTu2wR3Ttfz7XOZP1iOjx6?= =?us-ascii?Q?IgEu08Z7raDMmbS1PUAXSCt2xoKar2Qi367KV3tqXdprsmZCKdbLjasMZ3sm?= =?us-ascii?Q?jqgLqrwe8sx+WnJBHnS4Q7dMgwshXGyR8UahVLq4k6vaAFr3Sifs8S+ifkC1?= =?us-ascii?Q?n2YBxLsj4i58iN3Ce4B4U7z3B9Al4+S36FAT9ZM2uta/ri0jrcetKHtZ6504?= =?us-ascii?Q?iXvioSdn0fHRAHI2Xrq+BcQLypYSzBHFTGmVdgpo9cB8xtTzXIAWcLBT4gXz?= =?us-ascii?Q?ds1eUIe4id2bKHqMQDRXYpORDf6bwcuJtY0DjWOymcRI4T2aVNnSQ9AgCXoY?= =?us-ascii?Q?wYPqRl6FeICZ02Si2T1a6AsckbiyFsGaugBGI+7gYsgGDBrLQaah150ZJgkF?= =?us-ascii?Q?YAmzI7huePzVcsAScUlr9zF5dxkF3TS7LoPuU7O/V3PR9M2PYQ8W2o+hpTZm?= =?us-ascii?Q?7uMUiiOybbJ7xMRdbjw5q+aCMaEfmeVmtgtEFLpJz7T9AU0r3+/o8DhY8u/4?= =?us-ascii?Q?jjIHAzwLnnMOd1XxIqlOQ6zf+TFU0QuYV+vne0u3+O0UiRc4aLScvdDs1R4k?= =?us-ascii?Q?kNqCEi/8Wm8w0TANCI9Xf8+mSQiiPsdmE8VJx7rno2c/AsHXBNvGl329T/a+?= =?us-ascii?Q?w5LlQqln4SsWt15a1ArpzmxleSnIxTrUHjK+1425SA8X0wKxM6FBnRNrSbId?= =?us-ascii?Q?Xk0op/p8/aDBpZMnZtgcSyDLGZRBbRfIbXRRTrFWV+0K6frSzzs1/IutNK00?= =?us-ascii?Q?hCYgCfAwswa1eYMoiUzLH6Nj1119jmK5dktpnNtbxQmiKMY7KaOjq3xSwTFK?= =?us-ascii?Q?iU8i8ozg1EwQxmefVB1Dh2CC+FTrAFw4PunWsL0SsgY66XPFwZ8L52OUjayT?= =?us-ascii?Q?juxNFzlw2kgUAqyNkV7QtFAK1ImRESA12Y4vDHXOcDa5HieLcEplsfGjQ25k?= =?us-ascii?Q?s3z8zPGFLYpJLVRmTezZCwgFpPhhBTIWfos+DrIpWs1d5byWp+StS+paM6Yl?= =?us-ascii?Q?CDuHLWh7r8/3QaFLCgaRL61r0PjkOzJZNjAqGP/rJDi9LZ0mRlVOTlmrthpI?= =?us-ascii?Q?+DP8504Mlun/qUPtUVnP7etwBf6qnYqv+w7PaTlDD2jDQ1oEJhn/NkklNNat?= =?us-ascii?Q?RTHtqhw/h6E5Wi0DQnEs0yK1ZnBNkxxKQQIkpiDrsnS2epV+9Hhr1ltDblPb?= =?us-ascii?Q?cwIJg+AUqUpJR21NdDJ8QonnvlJIaaQxoRpOdSmj9vHeWTdpQoPAczb8iBeT?= =?us-ascii?Q?NQ=3D=3D?= X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 19d35270-791a-4c00-c27a-08db02a7ae5e X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2023 09:52:21.4746 (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: J692MswqOVHd3tBUTQJMf2bccq4MOfFyTE9tQYfZZbCqhk7pZTwcIt2pDOWMJ74QxU3EYCslQQFry6gjnC3haQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB6573 X-Proofpoint-ORIG-GUID: 1ybrlnIfEigmWLG7rkGvIsin7zyMc9Y2 X-Proofpoint-GUID: 1ybrlnIfEigmWLG7rkGvIsin7zyMc9Y2 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-30_09,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxscore=0 suspectscore=0 clxscore=1015 malwarescore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 bulkscore=0 spamscore=0 mlxlogscore=748 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301300094 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.166.238; envelope-from=prvs=13943e2a21=bin.meng@windriver.com; helo=mx0a-0064b401.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @windriver.com) X-ZM-MESSAGEID: 1675072482078100001 Content-Type: text/plain; charset="utf-8" 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 --- fsdev/file-op-9p.h | 33 +++++++++++++++++++++++++++++++++ hw/9pfs/9p.h | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 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 =20 +#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 =20 diff --git a/hw/9pfs/9p.h b/hw/9pfs/9p.h index 2fce4140d1..ada9f14ebc 100644 --- a/hw/9pfs/9p.h +++ b/hw/9pfs/9p.h @@ -3,13 +3,56 @@ =20 #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" =20 +#ifdef CONFIG_WIN32 + +/* Windows does not provide such a macro, typically it is 255 */ +#define NAME_MAX 255 + +/* 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))) + +/* + * 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 conflic= ts. + */ + +#ifndef S_IFLNK +#define S_IFLNK 0xA000 +#define S_ISLNK(mode) ((mode & S_IFMT) =3D=3D S_IFLNK) +#endif /* S_IFLNK */ + +#ifndef S_ISUID +#define S_ISUID 0x0800 +#endif + +#ifndef S_ISGID +#define S_ISGID 0x0400 +#endif + +#ifndef S_ISVTX +#define S_ISVTX 0x0200 +#endif + +#endif /* CONFIG_WIN32 */ + enum { P9_TLERROR =3D 6, P9_RLERROR, --=20 2.25.1 From nobody Thu Mar 28 13:35:16 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=windriver.com); dmarc=pass(p=none dis=none) header.from=windriver.com ARC-Seal: i=2; a=rsa-sha256; t=1675072464; cv=pass; d=zohomail.com; s=zohoarc; b=Os2lGNU2sD2r3mthrVwmdVx3rW9Rzw+EYyjKz3mV88df4QZ7Tf/KCLmt1KVAMpKAJ+JdcKSR9gZUzDkIZKjbMb2833LytIOeJe5816BzyYc0DzQL9V6dWrb3Zte+QQntRb7V56mSEQ0B8MB1eK4+Fl2xmFqxlQfhCIy1WiaQSRc= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675072464; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Q51gWYJ+HXclbGSZ9Zlgv6+QfQYRST3Ok+cRzQ1RAzU=; b=Z/Tc+sr5rnEFwoZECa2FVMhk3jCSebRco8Ct/RmjFnNdPa5FQXpCuk/RWgH5q8Zxrgoir+0rM4CDUTy8w+tv3Y60foPFDe2WszeKev4Zr9gO3pzCv9pa9Usme+DOjPu8GP0oBYFx3SYW7g+e0qYl6Yl9FQ0M5wEXnEmBVdnLHW4= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=windriver.com); dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1675072464959948.7042161317476; Mon, 30 Jan 2023 01:54:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMQqJ-0002zk-8R; Mon, 30 Jan 2023 04:52:51 -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 1pMQqG-0002yd-KO for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:52:48 -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 1pMQqC-00020T-WE for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:52:48 -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 30U96eHX000968; Mon, 30 Jan 2023 01:52:31 -0800 Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2174.outbound.protection.outlook.com [104.47.57.174]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3nd43rhj5k-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Jan 2023 01:52:30 -0800 Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by BL1PR11MB6025.namprd11.prod.outlook.com (2603:10b6:208:390::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36; Mon, 30 Jan 2023 09:52:24 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9%2]) with mapi id 15.20.6043.036; Mon, 30 Jan 2023 09:52:23 +0000 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=Q51gWYJ+HXclbGSZ9Zlgv6+QfQYRST3Ok+cRzQ1RAzU=; b=Wi95UR7dl1x7I+0mclcCv9Mf3SiyOKFY2qGGasRL0gQ0s/p1MnIboWqcbm1ASEG8yd0w jcxg9Ai/yjb99s04sDG9CsxX4cy/NIE6Nt5rTvfwpDCZE0rPUcz/Jp8WjkM585aZ0Jy7 GT0i+R11UVIVYzFEqTrrtguVUmjFNh4rElLRHpqTSAPOzJquyIMuYdAZzul1hA5px+ki nzfbk5xlNXnHN5ZgFiAOUMMuZoKiAU0t0ZA6osZv7aJeNrSugVz7nmC7REo1PsbJwHV8 rZisPYrF3I/q5/nRQ8tPPvDs1JIetayZc3ANFG4ctPksy42e8AokD48Tnt0RNxqL54fX cg== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=adyR5r5mrgLuhO5KlprkrwgrMVMQYHRjHhr0Sy55xxpiVKNfHBQKDxO9lVwShzQiejiem6sHPv7ogtQEwXuWcxgCyiDZsrAs7z7iA5NU2W3rUjJ7YwD4ytUCPMLcw+LdkNWMtp5BhU/mmJlAi1xLaO2f8ldBnebvG6as7utFoaHoFL0//qa3tVBKmBKXO4P5UAebaH+Ev4cbDTian485vZXHI9DQ+pIM7s78nXkLv5ZDLrVm1MguKPdXG36Wy/tH7gVRvSnpvaA2ihML4QEBEMuwniN3HDOLtld2sdFcOAn27oq6g3XstqMxzWWP+xmnxQfjOeM/nMO8fpnMqhzDgg== 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=Q51gWYJ+HXclbGSZ9Zlgv6+QfQYRST3Ok+cRzQ1RAzU=; b=BvNZVLM3zaYbs6AF4qG7T5UtYfW3BUfWZJIBbmTLZBO4LHHFtynrzrwXjC34c0AtLgd2plZsGINAqJD0CmjS9UCM8QpPtgswOM2mIMIxamWiXPPwWyS7mDFwhfUUNVbWJ/aCy/qkbBzpI1bM0JB195G7DrMlGbk4V8dxuh8dBc1Pl91GMt6WRRkeD8SelsRVuev130KVnPqhmcRbEfz3hty37ij5vhu/VoM7QwTuQLfBfcewpnAudTHzXNOP2H11DQuyBy8P02bNcYLy0Rp+F8kMxhWAY0HMuJDnHb4FE8fbI+IJLGowJNb1eP3rTLMIGadOXtE+PcF7nNjwwaA7bw== 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 From: Bin Meng To: Greg Kurz , Christian Schoenebeck , qemu-devel@nongnu.org Cc: Guohuai Shi Subject: [PATCH v4 02/16] hw/9pfs: Implement Windows specific utilities functions for 9pfs Date: Mon, 30 Jan 2023 17:51:48 +0800 Message-Id: <20230130095202.2773186-3-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230130095202.2773186-1-bin.meng@windriver.com> References: <20230130095202.2773186-1-bin.meng@windriver.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BYAPR02CA0061.namprd02.prod.outlook.com (2603:10b6:a03:54::38) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|BL1PR11MB6025:EE_ X-MS-Office365-Filtering-Correlation-Id: 3b6d3d70-b91b-45bc-4731-08db02a7af99 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RuS7Vs5N93txuSw0V5zzXFfD6RiGhCgKqvpnZeoY6iw7TEUoq2Bt8SwexCEjua3pbZrPE1sGmXpYKJsZZuAtxWC3QXuBa6vSLrTEbOKkexoK3aakR1GeHW8nbatsWvZB30acsKk/a/a7zE4M7oOlen3unKERx/TAJFG3ANcTFsPQxXGsNQCL4F1FLWMD/yfF+LaHcS4+nPg86LCOvh/xzpcar6/Z3Q7z0P3VSsDoWq0dAyMS5WgkNRTAH1337BxqHEuNLdZ7EhhetSwt7jfXwghGAkkdNsPBpYFf1COuwF2w8Xv84UGySjp5KrKQz9LvlmWLtDQ2qnz2jQC7ofIvsnJpuym0A1rTuW4noJzbK6oyzrZPgsP5hSpmzPGmU7ysUtO9iFcjly6RFi2/H39dpVA5uTUUd3NGxF89ahCyx0AEJbhWcW9+FygJM0epj7UJZeT+i+ZzenEqQnLGlCI7LJJihIMpnwBgnCBCO09MAZmWNlR8JkL7P9TKN181FY0LGrlZCm9N7AUeGoJDODTOrGDN6fgZ6tHwX/J3t7gSDxZm9Nml0gYGdxAnB998jLKyQb+MWPiuI5CadlqN4FMQR1rAmpEEHRNkwGtVwTIl77PqvWInoF1ebx2CXnpzF6Wa7JDcD5OKpRNTCEtiQFiZw5sCTekGMig+OK5MVrVD0d6SfXPaQ6hTGd7ofD6TI6FJyNxp7a5wFMd1Q3p4q97KUDbaLk4w/FZp+k9s26GTZn4= 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:(13230025)(4636009)(396003)(136003)(346002)(366004)(376002)(39850400004)(451199018)(2906002)(26005)(6512007)(186003)(478600001)(6666004)(107886003)(6486002)(316002)(110136005)(36756003)(86362001)(38100700002)(38350700002)(41300700001)(8936002)(2616005)(4326008)(66556008)(66476007)(66946007)(8676002)(52116002)(6506007)(1076003)(5660300002)(44832011)(30864003)(83380400001)(21314003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?YHRCjO9FUEKfJY85CPeh/wmM9svKfILpCkY4PKSwPteYCzzoWh+Ifem4tVp1?= =?us-ascii?Q?vdqKcgvodg2uH2Hihz36uVyB8Pp6JArRdHhkH89PSmFUYfQwAh6atpqwbp8H?= =?us-ascii?Q?zLd9y871Hx8XgPUAWswiDa439R4yey8BoxkBTvaS9I+5Xo/5vNrRgRIuLLMj?= =?us-ascii?Q?TnxI9l/jXyQzMBvnUKEu57NHGftgX6Izv28oDi+Ajcr+1OaP/0LlAZ/fU2G9?= =?us-ascii?Q?DMUYiavMRgdOtLCxr+kejwMkPHD3QnXlV8PeXo9MEk8JiiIZ2nvjKg51xiqW?= =?us-ascii?Q?kHz/fijhWMvCxfN+73Vk+acD/hfo6YaLhxZymwCWHsyj8lCoeSMpDZy71rYj?= =?us-ascii?Q?vj+oDzeaF8fhi7+GAFIovo0sDgASW10bRrcsfso27DNsl4zseVV6Q4vafiXW?= =?us-ascii?Q?jWRGykTHxITDq1lf20rhFHnWhEg0NXvKT77ko/GAjatrEfryWIc5cXNOEaBU?= =?us-ascii?Q?BnhdJw9rEUDygPmLpa7pmM1q/4S9Ue9Mi5qHiXHuAw1d1K8duYv8xch/gPFu?= =?us-ascii?Q?xN08sN4uNoTlZg8eyLfW0Rc6xbyjUi7kXmwZjRcRBA+X/e1OTMzp5ol93mSs?= =?us-ascii?Q?B8aLFcvDzEzVlffwrWgxTAHv6NfQd3E9pK8Fg34g9nyg+TuE+NVnvRamuggi?= =?us-ascii?Q?CrlaOLHfc73tq6vtDzO5YiGYA28ylgeVZaqkLF1UOSjqppq6AAOm2YTsllAm?= =?us-ascii?Q?QNJZOgwgzqouKgmQy3UqAvf1PDcz0SppATjXQ6Zsfrp62L2kzcA0AMPMeRIX?= =?us-ascii?Q?W+KiDtRuNqb7yWuSObNG478qPoV3YWuLu1zu44K0HahZ8/DeZPVF7+SbdVEg?= =?us-ascii?Q?wRV9b3QfzTkqWyLCumpXpD0UPycP+lO1sXU773d7HWU55ly0tM++tWvsa0bt?= =?us-ascii?Q?wXjVviTdcFrjZf+zSUviYp6ZVjMuAZgRKmN+/TnxqoDD/C+0BBWKUzylpkSU?= =?us-ascii?Q?Ex42I9qnoTNmczEL7KNhnyVXDEpqFXvHGYY7sH93cJQ3iMWIrKHpdLDbBjhX?= =?us-ascii?Q?EdTEhQ94zd0a7PCZoNBneU1olBV8wJYxwDxAdIdOKgH19mEPDqR+40BGbHsb?= =?us-ascii?Q?4HgPm9zbYdi4f4sXp+vTI4WdkoEh5aymLlITQB2A0mVm/gF80bhdPj/bEyrf?= =?us-ascii?Q?SwkiXi2f4CImvnlEZZXM2Pyi7RtMyX9nm5o18pKqsm9GpmlpVcUlNlvL2Ufs?= =?us-ascii?Q?MJQ2qPshJsLzFlqOSWsiWVehiMM6NrxPPej3tL4PzV9f2W6huKPCeBoNfTnm?= =?us-ascii?Q?aKnE5i4V66+zWwPWkyW/a+333tK2xnbEDTDn50jF5v1bRHlv7AiZBsKLzNhT?= =?us-ascii?Q?4pz6ppviZLw910cZo+r0ZOEtYaybnV6NDiyC9lTMN2/O4jZ02YiEhpTb7F0K?= =?us-ascii?Q?23tbVLGtIFy/pq/wVT15aG4+Zz36WzUdE3tgqA7F0n1w30wez9gJ4q+LXZm8?= =?us-ascii?Q?MMrZEln74ol96VBA2r9fWgNxV/dr4FO7lBttSfEjmokup5n5/wUDE7Hxfl+1?= =?us-ascii?Q?XYaNXdb4zDz3az8k0MlovXqZvzR5CWnLQDTroEICc6r0+vPzRlvmbMwC2vQ8?= =?us-ascii?Q?szq6EmZAC2C7HL/HEG5bkRi2OWZTL+ufW5SQJwbWkxevjx1zbxYtxRmDxwlx?= =?us-ascii?Q?Og=3D=3D?= X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3b6d3d70-b91b-45bc-4731-08db02a7af99 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2023 09:52:23.7234 (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: x6E4c2/sNXZhPNomea6hzeVpjSJM1T1tIXCjaDAXHXFEgVxD4zUDuGWpqQ8HK9Y0rs5R+a/KWHhTbD9b1kdnWA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR11MB6025 X-Proofpoint-ORIG-GUID: 4rsPNIKJrfB3YFQskcEdvcGgow25ye0h X-Proofpoint-GUID: 4rsPNIKJrfB3YFQskcEdvcGgow25ye0h X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-30_09,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxscore=0 suspectscore=0 clxscore=1015 malwarescore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301300094 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.166.238; envelope-from=prvs=13943e2a21=bin.meng@windriver.com; helo=mx0a-0064b401.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @windriver.com) X-ZM-MESSAGEID: 1675072466006100005 Content-Type: text/plain; charset="utf-8" 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 --- hw/9pfs/9p-local.h | 7 + hw/9pfs/9p-util.h | 32 +- hw/9pfs/9p-local.c | 4 - hw/9pfs/9p-util-win32.c | 979 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 1017 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 32c72749d9..77e7f57f89 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 =20 +typedef struct { + int mountfd; +#ifdef CONFIG_WIN32 + char *root_path; +#endif +} LocalData; + 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); diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index c314cf381d..90420a7578 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -88,18 +88,46 @@ static inline int errno_to_dotl(int err) { return err; } =20 -#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 =20 +#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(HANDLE hDir, const char *name); +ssize_t fgetxattr_win32(int fd, const char *name, void *value, size_t size= ); +int openat_win32(int dirfd, const char *pathname, int flags, mode_t mode); +int fstatat_win32(int dirfd, const char *pathname, + struct stat *statbuf, int flags); +int mkdirat_win32(int dirfd, const char *pathname, mode_t mode); +int renameat_win32(int olddirfd, const char *oldpath, + int newdirfd, const char *newpath); +int utimensat_win32(int dirfd, const char *pathname, + const struct timespec times[2], int flags); +int unlinkat_win32(int dirfd, const char *pathname, int flags); +int statfs_win32(const char *root_path, struct statfs *stbuf); +int openat_dir(int dirfd, const char *name); +int openat_file(int dirfd, const char *name, int flags, mode_t mode); +#endif =20 static inline void close_preserve_errno(int fd) { @@ -108,6 +136,7 @@ static inline void close_preserve_errno(int fd) errno =3D serrno; } =20 +#ifndef CONFIG_WIN32 static inline int openat_dir(int dirfd, const char *name) { return qemu_openat(dirfd, name, @@ -154,6 +183,7 @@ again: errno =3D serrno; return fd; } +#endif =20 ssize_t fgetxattrat_nofollow(int 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 9d07620235..b6102c9e5a 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -53,10 +53,6 @@ #define BTRFS_SUPER_MAGIC 0x9123683E #endif =20 -typedef struct { - int mountfd; -} LocalData; - int 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..a99d579a06 --- /dev/null +++ b/hw/9pfs/9p-util-win32.c @@ -0,0 +1,979 @@ +/* + * 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 late= r. + * 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 Mi= nGW + * cannot detect if a path is a symbolic link or not. Also Windows do n= ot + * provide POSIX compatible readlink(). Supporting symbolic link in 9pf= s on + * Windows may cause security issues, so symbolic link support is disab= led + * completely for security model "none" or "passthrough". + * + * 2. Windows file system does not support extended attributes directly. 9= pfs + * for Windows uses NTFS ADS (Alternate Data Streams) to emulate extend= ed + * attributes. + * + * 3. statfs() is not available on Windows. qemu_statfs() is used to emula= te 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 u= sage. + * + * 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 hos= t, + * to support this and prevent security issue, all xxx_at() APIs are re= placed + * by xxx_at_win32(). + * + * Windows does not support opendir, the directory fd is created by + * CreateFile and convert to fd by _open_osfhandle(). Keep the fd open = will + * lock and protect the directory (can not be modified or replaced) + */ + +#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" */ + +/* + * win32_error_to_posix - convert Win32 error to POSIX error number + * + * This function converts Win32 error to POSIX error number. + * e.g. ERROR_FILE_NOT_FOUND and ERROR_PATH_NOT_FOUND will be translated to + * ENOENT. + */ +static int win32_error_to_posix(DWORD win32err) +{ + switch (win32err) { + case ERROR_FILE_NOT_FOUND: return ENOENT; + case ERROR_PATH_NOT_FOUND: return ENOENT; + case ERROR_INVALID_DRIVE: return ENODEV; + case ERROR_TOO_MANY_OPEN_FILES: return EMFILE; + case ERROR_ACCESS_DENIED: return EACCES; + case ERROR_INVALID_HANDLE: return EBADF; + case ERROR_NOT_ENOUGH_MEMORY: return ENOMEM; + case ERROR_FILE_EXISTS: return EEXIST; + case ERROR_DISK_FULL: return ENOSPC; + } + return EIO; +} + +/* + * 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 =3D 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 e= nd. + * + * This function copies ADS name to namebuf. + */ + + p1 =3D strchr(full_ads_name, ':'); + if (p1 =3D=3D NULL) { + return -1; + } + + p2 =3D strchr(p1 + 1, ':'); + if (p2 =3D=3D NULL) { + return -1; + } + + /* skip empty ads name */ + if (p2 - p1 =3D=3D 1) { + return 0; + } + + if (p2 - p1 + 1 > namebuf_len) { + return -1; + } + + memcpy(namebuf, p1 + 1, p2 - p1 - 1); + namebuf[p2 - p1 - 1] =3D '\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(HANDLE hDir, const char *name) +{ + g_autofree char *full_file_name =3D NULL; + DWORD total_size; + DWORD name_size; + + if (hDir =3D=3D INVALID_HANDLE_VALUE) { + return NULL; + } + + full_file_name =3D g_malloc0(NAME_MAX); + + /* get parent directory full file name */ + name_size =3D GetFinalPathNameByHandle(hDir, full_file_name, + NAME_MAX - 1, FILE_NAME_NORMALIZE= D); + if (name_size =3D=3D 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 !=3D NULL) { + total_size =3D 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 =3D NULL; + char ads_file_name[NAME_MAX + 1] =3D {0}; + DWORD dwBytesRead; + HANDLE hStream; + HANDLE hFile; + + hFile =3D (HANDLE)_get_osfhandle(fd); + + full_file_name =3D get_full_path_win32(hFile, NULL); + if (full_file_name =3D=3D NULL) { + errno =3D EIO; + return -1; + } + + if (build_ads_name(ads_file_name, NAME_MAX, full_file_name, name) < 0)= { + errno =3D EIO; + return -1; + } + + hStream =3D CreateFile(ads_file_name, GENERIC_READ, FILE_SHARE_READ, N= ULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (hStream =3D=3D INVALID_HANDLE_VALUE && + GetLastError() =3D=3D ERROR_FILE_NOT_FOUND) { + errno =3D ENODATA; + return -1; + } + + if (ReadFile(hStream, value, size, &dwBytesRead, NULL) =3D=3D FALSE) { + errno =3D EIO; + CloseHandle(hStream); + return -1; + } + + CloseHandle(hStream); + + return dwBytesRead; +} + +/* + * openat_win32 - emulate openat() + * + * This function emulates openat(). + * + * this function needs a handle to get the full file name, it has to + * convert fd to handle by get_osfhandle(). + * + * 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 fl= ag. + * Create a new symbolic link will be denied. + * 3. This function checks file symbolic link attribute after open. + * + * So native symbolic link will not be accessed by 9p client. + */ +int openat_win32(int dirfd, const char *pathname, int flags, mode_t mode) +{ + g_autofree char *full_file_name1 =3D NULL; + g_autofree char *full_file_name2 =3D NULL; + HANDLE hFile; + HANDLE hDir =3D (HANDLE)_get_osfhandle(dirfd); + int fd; + + full_file_name1 =3D get_full_path_win32(hDir, pathname); + if (full_file_name1 =3D=3D NULL) { + return -1; + } + + fd =3D open(full_file_name1, flags, mode); + if (fd > 0) { + DWORD attribute; + hFile =3D (HANDLE)_get_osfhandle(fd); + + full_file_name2 =3D get_full_path_win32(hFile, NULL); + attribute =3D GetFileAttributes(full_file_name2); + + /* check if it is a symbolic link */ + if ((attribute =3D=3D INVALID_FILE_ATTRIBUTES) + || (attribute & FILE_ATTRIBUTE_REPARSE_POINT) !=3D 0) { + errno =3D EACCES; + close(fd); + } + } + + return fd; +} + +/* + * fstatat_win32 - emulate fstatat() + * + * This function emulates fstatat(). + * + * Access to a symbolic link will be denied to prevent security issues. + */ +int fstatat_win32(int dirfd, const char *pathname, + struct stat *statbuf, int flags) +{ + g_autofree char *full_file_name =3D NULL; + HANDLE hFile =3D INVALID_HANDLE_VALUE; + HANDLE hDir =3D (HANDLE)_get_osfhandle(dirfd); + BY_HANDLE_FILE_INFORMATION file_info; + DWORD attribute; + int err =3D 0; + int ret =3D -1; + ino_t st_ino; + int is_symlink =3D 0; + + full_file_name =3D get_full_path_win32(hDir, pathname); + if (full_file_name =3D=3D NULL) { + return ret; + } + + /* open file to lock it */ + hFile =3D CreateFile(full_file_name, GENERIC_READ, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DEL= ETE, + NULL, + OPEN_EXISTING, + FILE_FLAG_BACKUP_SEMANTICS + | FILE_FLAG_OPEN_REPARSE_POINT, + NULL); + + if (hFile =3D=3D INVALID_HANDLE_VALUE) { + err =3D win32_error_to_posix(GetLastError()); + goto out; + } + + attribute =3D GetFileAttributes(full_file_name); + + if (attribute =3D=3D INVALID_FILE_ATTRIBUTES) { + err =3D EACCES; + goto out; + } + + /* check if it is a symbolic link */ + if ((attribute & FILE_ATTRIBUTE_REPARSE_POINT) !=3D 0) { + is_symlink =3D 1; + } + + ret =3D stat(full_file_name, statbuf); + + if (GetFileInformationByHandle(hFile, &file_info) =3D=3D 0) { + err =3D win32_error_to_posix(GetLastError()); + 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) =3D=3D sizeof(uint64_t)) { + st_ino =3D (ino_t)((uint64_t)file_info.nFileIndexLow + | (((uint64_t)file_info.nFileIndexHigh) << 32)); + } else if (sizeof(st_ino) =3D=3D sizeof(uint16_t)) { + st_ino =3D (ino_t)(((uint16_t)file_info.nFileIndexLow) + ^ ((uint16_t)(file_info.nFileIndexLow >> 16))); + } else { + st_ino =3D (ino_t)file_info.nFileIndexLow; + } + + statbuf->st_ino =3D st_ino; + + if (is_symlink =3D=3D 1) { + /* force to set mode to 0, to prevent symlink access */ + statbuf->st_mode =3D 0; + + /* hide information */ + statbuf->st_atime =3D 0; + statbuf->st_mtime =3D 0; + statbuf->st_ctime =3D 0; + statbuf->st_size =3D 0; + } + +out: + if (hFile !=3D INVALID_HANDLE_VALUE) { + CloseHandle(hFile); + } + + if (err !=3D 0) { + errno =3D err; + } + return ret; +} + +/* + * mkdirat_win32 - emulate mkdirat() + * + * This function emulates mkdirat(). + * + * this function needs a handle to get the full file name, it has to + * convert fd to handle by get_osfhandle(). + */ +int mkdirat_win32(int dirfd, const char *pathname, mode_t mode) +{ + g_autofree char *full_file_name =3D NULL; + int ret =3D -1; + HANDLE hDir =3D (HANDLE)_get_osfhandle(dirfd); + + full_file_name =3D get_full_path_win32(hDir, pathname); + if (full_file_name =3D=3D NULL) { + return ret; + } + + ret =3D mkdir(full_file_name); + + return ret; +} + +/* + * renameat_win32 - emulate renameat() + * + * This function emulates renameat(). + * + * this function needs a handle to get the full file name, it has to + * convert fd to handle by get_osfhandle(). + * + * Access to a symbolic link will be denied to prevent security issues. + */ +int renameat_win32(int olddirfd, const char *oldpath, + int newdirfd, const char *newpath) +{ + g_autofree char *full_old_name =3D NULL; + g_autofree char *full_new_name =3D NULL; + HANDLE hFile; + HANDLE hOldDir =3D (HANDLE)_get_osfhandle(olddirfd); + HANDLE hNewDir =3D (HANDLE)_get_osfhandle(newdirfd); + DWORD attribute; + int err =3D 0; + int ret =3D -1; + + full_old_name =3D get_full_path_win32(hOldDir, oldpath); + full_new_name =3D get_full_path_win32(hNewDir, newpath); + if (full_old_name =3D=3D NULL || full_new_name =3D=3D NULL) { + return ret; + } + + /* open file to lock it */ + hFile =3D CreateFile(full_old_name, GENERIC_READ, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DEL= ETE, + NULL, + OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); + + if (hFile =3D=3D INVALID_HANDLE_VALUE) { + err =3D win32_error_to_posix(GetLastError()); + goto out; + } + + attribute =3D GetFileAttributes(full_old_name); + + /* check if it is a symbolic link */ + if ((attribute =3D=3D INVALID_FILE_ATTRIBUTES) + || (attribute & FILE_ATTRIBUTE_REPARSE_POINT) !=3D 0) { + err =3D EACCES; + goto out; + } + + CloseHandle(hFile); + + ret =3D rename(full_old_name, full_new_name); +out: + if (err !=3D 0) { + errno =3D err; + } + return ret; +} + +/* + * utimensat_win32 - emulate utimensat() + * + * This function emulates utimensat(). + * + * this function needs a handle to get the full file name, it has to + * convert fd to handle by get_osfhandle(). + * + * Access to a symbolic link will be denied to prevent security issues. + */ +int utimensat_win32(int dirfd, const char *pathname, + const struct timespec times[2], int flags) +{ + g_autofree char *full_file_name =3D NULL; + HANDLE hFile =3D INVALID_HANDLE_VALUE; + HANDLE hDir =3D (HANDLE)_get_osfhandle(dirfd); + DWORD attribute; + struct utimbuf tm; + int err =3D 0; + int ret =3D -1; + + full_file_name =3D get_full_path_win32(hDir, pathname); + if (full_file_name =3D=3D NULL) { + return ret; + } + + /* open file to lock it */ + hFile =3D CreateFile(full_file_name, GENERIC_READ, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DEL= ETE, + NULL, + OPEN_EXISTING, + FILE_FLAG_BACKUP_SEMANTICS + | FILE_FLAG_OPEN_REPARSE_POINT, + NULL); + + if (hFile =3D=3D INVALID_HANDLE_VALUE) { + err =3D win32_error_to_posix(GetLastError()); + goto out; + } + + attribute =3D GetFileAttributes(full_file_name); + + /* check if it is a symbolic link */ + if ((attribute =3D=3D INVALID_FILE_ATTRIBUTES) + || (attribute & FILE_ATTRIBUTE_REPARSE_POINT) !=3D 0) { + errno =3D EACCES; + goto out; + } + + tm.actime =3D times[0].tv_sec; + tm.modtime =3D times[1].tv_sec; + + ret =3D utime(full_file_name, &tm); + +out: + if (hFile !=3D INVALID_HANDLE_VALUE) { + CloseHandle(hFile); + } + + if (err !=3D 0) { + errno =3D err; + } + return ret; +} + +/* + * unlinkat_win32 - emulate unlinkat() + * + * This function emulates unlinkat(). + * + * this function needs a handle to get the full file name, it has to + * convert fd to handle by get_osfhandle(). + * + * Access to a symbolic link will be denied to prevent security issues. + */ + +int unlinkat_win32(int dirfd, const char *pathname, int flags) +{ + g_autofree char *full_file_name =3D NULL; + HANDLE hFile; + HANDLE hDir =3D (HANDLE)_get_osfhandle(dirfd); + DWORD attribute; + int err =3D 0; + int ret =3D -1; + + full_file_name =3D get_full_path_win32(hDir, pathname); + if (full_file_name =3D=3D NULL) { + return ret; + } + + /* + * open file to prevent other one modify it. FILE_SHARE_DELETE flag + * allows remove a file even it is still in opening. + */ + hFile =3D CreateFile(full_file_name, GENERIC_READ, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DEL= ETE, + NULL, + OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); + + if (hFile =3D=3D INVALID_HANDLE_VALUE) { + err =3D win32_error_to_posix(GetLastError()); + goto out; + } + + attribute =3D GetFileAttributes(full_file_name); + + /* check if it is a symbolic link */ + if ((attribute =3D=3D INVALID_FILE_ATTRIBUTES) + || (attribute & FILE_ATTRIBUTE_REPARSE_POINT) !=3D 0) { + err =3D EACCES; + goto out; + } + + if (flags =3D=3D AT_REMOVEDIR) { /* remove directory */ + if ((attribute & FILE_ATTRIBUTE_DIRECTORY) =3D=3D 0) { + err =3D ENOTDIR; + goto out; + } + ret =3D rmdir(full_file_name); + } else { /* remove regular file */ + if ((attribute & FILE_ATTRIBUTE_DIRECTORY) !=3D 0) { + err =3D EISDIR; + goto out; + } + ret =3D remove(full_file_name); + } + + /* after last handle closed, file will be removed */ + CloseHandle(hFile); + +out: + if (err !=3D 0) { + errno =3D 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] =3D { 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) = =3D=3D 0) { + errno =3D EIO; + return -1; + } + + stbuf->f_type =3D V9FS_MAGIC; + stbuf->f_bsize =3D + (__fsword_t)SectorsPerCluster * (__fsword_t)BytesPerSector; + stbuf->f_blocks =3D (fsblkcnt_t)TotalNumberOfClusters; + stbuf->f_bfree =3D (fsblkcnt_t)NumberOfFreeClusters; + stbuf->f_bavail =3D (fsblkcnt_t)NumberOfFreeClusters; + stbuf->f_files =3D -1; + stbuf->f_ffree =3D -1; + stbuf->f_namelen =3D NAME_MAX; + stbuf->f_frsize =3D 0; + stbuf->f_flags =3D 0; + + return 0; +} + +/* + * openat_dir - emulate openat_dir() + * + * This function emulates openat_dir(). + * + * Access to a symbolic link will be denied to prevent security issues. + */ +int openat_dir(int dirfd, const char *name) +{ + g_autofree char *full_file_name =3D NULL; + HANDLE hSubDir; + HANDLE hDir =3D (HANDLE)_get_osfhandle(dirfd); + DWORD attribute; + + full_file_name =3D get_full_path_win32(hDir, name); + if (full_file_name =3D=3D NULL) { + return -1; + } + + attribute =3D GetFileAttributes(full_file_name); + if (attribute =3D=3D INVALID_FILE_ATTRIBUTES) { + return -1; + } + + /* check if it is a directory */ + if ((attribute & FILE_ATTRIBUTE_DIRECTORY) =3D=3D 0) { + return -1; + } + + /* do not allow opening a symbolic link */ + if ((attribute & FILE_ATTRIBUTE_REPARSE_POINT) !=3D 0) { + return -1; + } + + /* open it */ + hSubDir =3D CreateFile(full_file_name, GENERIC_READ, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_D= ELETE, + NULL, + OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); + return _open_osfhandle((intptr_t)hSubDir, _O_RDONLY); +} + + +int openat_file(int 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(int dirfd, const char *path, + const char *name, void *value, size_t size) +{ + g_autofree char *full_file_name =3D NULL; + char ads_file_name[NAME_MAX + 1] =3D { 0 }; + DWORD dwBytesRead; + HANDLE hStream; + HANDLE hDir =3D (HANDLE)_get_osfhandle(dirfd); + + full_file_name =3D get_full_path_win32(hDir, path); + if (full_file_name =3D=3D NULL) { + errno =3D EIO; + return -1; + } + + if (build_ads_name(ads_file_name, NAME_MAX, full_file_name, name) < 0)= { + errno =3D EIO; + return -1; + } + + hStream =3D CreateFile(ads_file_name, GENERIC_READ, FILE_SHARE_READ, N= ULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (hStream =3D=3D INVALID_HANDLE_VALUE && + GetLastError() =3D=3D ERROR_FILE_NOT_FOUND) { + errno =3D ENODATA; + return -1; + } + + if (ReadFile(hStream, value, size, &dwBytesRead, NULL) =3D=3D FALSE) { + errno =3D EIO; + CloseHandle(hStream); + return -1; + } + + CloseHandle(hStream); + + return dwBytesRead; +} + +/* + * fsetxattrat_nofollow - set extended attribute + * + * This function sets extended attribute to file in the directory + * specified by . + * + * This function emulates extended attribute by NTFS ADS. + */ + +int fsetxattrat_nofollow(int dirfd, const char *path, const char *name, + void *value, size_t size, int flags) +{ + g_autofree char *full_file_name =3D NULL; + char ads_file_name[NAME_MAX + 1] =3D { 0 }; + DWORD dwBytesWrite; + HANDLE hStream; + HANDLE hDir =3D (HANDLE)_get_osfhandle(dirfd); + + full_file_name =3D get_full_path_win32(hDir, path); + if (full_file_name =3D=3D NULL) { + errno =3D EIO; + return -1; + } + + if (build_ads_name(ads_file_name, NAME_MAX, full_file_name, name) < 0)= { + errno =3D EIO; + return -1; + } + + hStream =3D CreateFile(ads_file_name, GENERIC_WRITE, FILE_SHARE_READ, = NULL, + CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + if (hStream =3D=3D INVALID_HANDLE_VALUE) { + errno =3D EIO; + return -1; + } + + if (WriteFile(hStream, value, size, &dwBytesWrite, NULL) =3D=3D FALSE)= { + errno =3D 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(int dirfd, const char *filename, + char *list, size_t size) +{ + g_autofree char *full_file_name =3D NULL; + WCHAR WideCharStr[NAME_MAX + 1] =3D { 0 }; + char full_ads_name[NAME_MAX + 1]; + WIN32_FIND_STREAM_DATA fsd; + BOOL bFindNext; + char *list_ptr =3D list; + size_t list_left_size =3D size; + HANDLE hFind; + HANDLE hDir =3D (HANDLE)_get_osfhandle(dirfd); + int ret; + + full_file_name =3D get_full_path_win32(hDir, filename); + if (full_file_name =3D=3D NULL) { + errno =3D EIO; + return -1; + } + + /* + * ADS enumerate function only has WCHAR version, so we need to + * covert filename to utf-8 string. + */ + ret =3D MultiByteToWideChar(CP_UTF8, 0, full_file_name, + strlen(full_file_name), WideCharStr, NAME_MA= X); + if (ret =3D=3D 0) { + errno =3D EIO; + return -1; + } + + hFind =3D FindFirstStreamW(WideCharStr, FindStreamInfoStandard, &fsd, = 0); + if (hFind =3D=3D INVALID_HANDLE_VALUE) { + errno =3D 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 =3D WideCharToMultiByte(CP_UTF8, 0, + fsd.cStreamName, wcslen(fsd.cStreamName)= + 1, + full_ads_name, sizeof(full_ads_name) - 1, + NULL, NULL); + if (ret =3D=3D 0) { + if (GetLastError() =3D=3D ERROR_INSUFFICIENT_BUFFER) { + errno =3D ERANGE; + } + CloseHandle(hFind); + return -1; + } + + ret =3D copy_ads_name(list_ptr, list_left_size, full_ads_name); + if (ret < 0) { + errno =3D ERANGE; + CloseHandle(hFind); + return -1; + } + + list_ptr =3D list_ptr + ret; + list_left_size =3D list_left_size - ret; + + bFindNext =3D 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(int dirfd, const char *filename, + const char *name) +{ + g_autofree char *full_file_name =3D NULL; + char ads_file_name[NAME_MAX + 1] =3D { 0 }; + HANDLE hDir =3D (HANDLE)_get_osfhandle(dirfd); + + full_file_name =3D get_full_path_win32(hDir, filename); + if (full_file_name =3D=3D NULL) { + errno =3D EIO; + return -1; + } + + if (build_ads_name(ads_file_name, NAME_MAX, filename, name) < 0) { + errno =3D EIO; + return -1; + } + + if (DeleteFile(ads_file_name) !=3D 0) { + if (GetLastError() =3D=3D ERROR_FILE_NOT_FOUND) { + errno =3D ENODATA; + return -1; + } + } + + return 0; +} + +/* + * local_opendir_nofollow - open a Windows directory + * + * This function returns a fd 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 convert handle to fd by _open_osfhandle(). + * + * 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. + */ +int local_opendir_nofollow(FsContext *fs_ctx, const char *dirpath) +{ + g_autofree char *full_file_name =3D NULL; + LocalData *data =3D fs_ctx->private; + HANDLE hDir; + int dirfd; + + dirfd =3D openat_dir(data->mountfd, dirpath); + if (dirfd =3D=3D -1) { + return -1; + } + hDir =3D (HANDLE)_get_osfhandle(dirfd); + + full_file_name =3D get_full_path_win32(hDir, NULL); + if (full_file_name =3D=3D NULL) { + close(dirfd); + return -1; + } + + /* + * 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)) !=3D 0) { + close(dirfd); + return -1; + } + + return dirfd; +} + +/* + * 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(int dirfd, const char *filename, mode_t mode, dev_t dev) +{ + if (S_ISREG(mode) || !(mode & S_IFMT)) { + int fd =3D openat_file(dirfd, filename, O_CREAT, mode); + if (fd =3D=3D -1) { + return -1; + } + close_preserve_errno(fd); + return 0; + } + + error_report_once("Unsupported operation for mknodat"); + errno =3D ENOTSUP; + return -1; +} --=20 2.25.1 From nobody Thu Mar 28 13:35:16 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=windriver.com); dmarc=pass(p=none dis=none) header.from=windriver.com ARC-Seal: i=2; a=rsa-sha256; t=1675072488; cv=pass; d=zohomail.com; s=zohoarc; b=j0yeZpx+f5CG1BD1kvM8eJVA5gdFkfR8MFWKv8rW8xDA3hGSZ6diJ63GNth+8Skmxj9D29AL9FPEi6s+d0FL4/Ae4/8764lrcaPJibGc/jv0XbMGWRTMOGZVTwHtw7AbRangzeBooK9PkAvl534q7DHAkTQAO0Dy4qOeHEPnTIM= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675072488; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=AcLONJBR7YZJY6HYwvAhDEo4k4DfdL0PC/dq/i6N/SI=; b=hfSXtbvVDM+/YIeAKjYpIIPA1nw3Ajs6v783/C8NUoxi2nN81sPsl8HiFbld3eAluIiL5am7yfk5fuSrysc3Di2H6EYJnywPpEm6iI4zIDEl33cMlrRXfMtGuWI1cIpsF7Hq3Uw0H4gZb+lo32/SzK5hRgma3cpPIuVuUswvciQ= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=windriver.com); dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1675072488673649.8415786311592; Mon, 30 Jan 2023 01:54:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMQqE-0002xt-30; Mon, 30 Jan 2023 04:52: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 1pMQqC-0002xK-95 for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:52:44 -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 1pMQqA-000202-Dk for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:52:44 -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 30U96eHV000968; Mon, 30 Jan 2023 01:52:30 -0800 Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2174.outbound.protection.outlook.com [104.47.57.174]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3nd43rhj5k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Jan 2023 01:52:29 -0800 Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by BL1PR11MB6025.namprd11.prod.outlook.com (2603:10b6:208:390::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36; Mon, 30 Jan 2023 09:52:26 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9%2]) with mapi id 15.20.6043.036; Mon, 30 Jan 2023 09:52:25 +0000 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=AcLONJBR7YZJY6HYwvAhDEo4k4DfdL0PC/dq/i6N/SI=; b=L7bONpMZn+b+VKUgxSB2I16/WsovA0LuoUUMkQmFUMNgJS6/tLrQ4H6I3lxA7430MFjK 8Ap9y4eI4GEKUxT2yM3RFDM3KLphUREcauD5KGBvfPxT//UPnJbNOzSS+U7nRwJrPtBP F3qngI0xRT9nM6Sk5l33M2hawp6Xk1DqqtfHvRQjZhfk78NH6DSdJ+r1a121b2PqvOKT hnVALqH9X3HpPqBKO5nS6u55fYVnfO3needkassvyTdkhLZU/55s9FnruertlnzS5CMo sCCPD9HCUJfOOHXAjSQpFCB0AWZS6PLNZ8J0YoM5yUV/jKDncNR0u0SCVAA9rBG9Hw2j mQ== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M3EWO66G04tLkQJ1rWfPcbv5QAEGV+EVpAOFt1oWz4RlawpWRgBDepAQeSQf7S/7Wy93/ZaYQnmSSjM6aoxyEw8IJaTC7k36caa1weX40k9HCnYRI8HsXACWcF+xMVTTGWn8RuFx177w68cOEEbVbSgWgfkocy2VojbL2Xo9X0gfN9GeOJ2dqlRMBvdoApN2PS19LHZmsXWgv+ip+eDcS19vZsTdbjayXbAOp8ug/6VUJ9VoqQcD5p33IwSmUjASK0dIcBYLyw7oO+H5J63etT4Cwv1Pb7Zm8+Bu2o0sAFGoC63jX4G+2eJEY7yk8lke2fjErGdxWiW8v6CnNqgkbg== 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=AcLONJBR7YZJY6HYwvAhDEo4k4DfdL0PC/dq/i6N/SI=; b=PkqlQKfQlq/yvh68OnwNQhmiy5bE8GCcVuqDzruMMEkjHhisj4L/HFx1pdCniVun8XFa2hmURSkZeWxKw1Og1zVmWKCX7n3wZndmni30TGrPiKOI/Md0KBAKMMOqNaq9zj3MLvF8xwKRWKxaaVTNJEKAmQSygjQWjBZXLjmEVcvXXt0wDIJav0Z4skwFdaOGu8CZ+8YJvyCH4+WI93YkIZWP/6mVanB+FVt/0PZEl1/Oor6f9l2pwfUkJNujXT8ANkmCrOwfRmY7ychhfAIEcD2z8Le4O2lNzogZ61dRwSfHvGeBLRTU5O/fAuAM7Prjb6YTwgUVaDc5ItlfqK4KFw== 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 From: Bin Meng To: Greg Kurz , Christian Schoenebeck , qemu-devel@nongnu.org Cc: Guohuai Shi Subject: [PATCH v4 03/16] hw/9pfs: Replace the direct call to xxxdir() APIs with a wrapper Date: Mon, 30 Jan 2023 17:51:49 +0800 Message-Id: <20230130095202.2773186-4-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230130095202.2773186-1-bin.meng@windriver.com> References: <20230130095202.2773186-1-bin.meng@windriver.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BYAPR02CA0061.namprd02.prod.outlook.com (2603:10b6:a03:54::38) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|BL1PR11MB6025:EE_ X-MS-Office365-Filtering-Correlation-Id: 39c7772f-e5ce-4d4e-8ceb-08db02a7b0f3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GTNcykkF3fHx5/texJ+5vtbeFLN3N3Kcyrk//jnpIFTTJxlC39HL56g79AUJytiGxZ/xsT4uBWszFDz0vlIlvlaVpBpkxoxqwYTPSCllvoVAVu9UtWDaIxMTOozXyeG12A3gW7aMu/QG2ZDsmg6kPoyVzm52KLwnoykdfB4mpbs1k23HO95jiFXcVrAHHt65qhOYmn7YAyUoVf9VOv3yLkkgFbYJpzPXigGqIvQ+6iGQcfLKxvNMH2XGPyRzzkG3w36TEG0Ui9H9E3AvxGcWbTgN0Gzwoa1UbCYEW/oLq+lizBsZ/kRe3nY7VBuKPvIxY/isD5IYAwxOXPRwR90X9ly4WkhHZ5uxXBX2Zb4yLEpRrpnpAM1557WXt3mNlMsLJLsfsBWZr8igRP7zEFR5zem0zj1Ge4bxNuqlMG7hGd2P1JbTRh/IfKk3S2PyhdT7KIHpRRd2OmjQaowmzTbZitpVyXljWdntFoSyaqAkd0RiOu53KBfHT/QktS0vndLcjyDuhMz1dda2KNwBZ0z958X5aPJwaLGxDbinjNuOKRmF+8YtHYI1SQ8UcVtPap1sv3lghT1sGUTxTTreBdci7JqARkLWMmStH8zlOUg4UGR7s+i6p0tcLrucC6Oo67PybY7UxuNl7BqBcdNxYbsfbRflpn5btlvXDnMf+9RxW+W9MS4lD7nUCi0NV4+ys4zI1ttYNu/T2vaT8+6cOv41sQ== 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:(13230025)(4636009)(396003)(136003)(346002)(366004)(376002)(39850400004)(451199018)(2906002)(26005)(6512007)(186003)(478600001)(6666004)(107886003)(6486002)(316002)(110136005)(36756003)(86362001)(38100700002)(38350700002)(41300700001)(8936002)(2616005)(4326008)(66556008)(66476007)(66946007)(8676002)(52116002)(6506007)(1076003)(5660300002)(44832011)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?LSpRPatdMlpvdmdDb/qp0Kogic1+el8tvfFbVQ3DehIWuo6YEXtpXxU65ovN?= =?us-ascii?Q?uCV7pXGvYuN0DpfyAW7vTEnRGd52hDJaORYxQ2g7LKBrqGLM327pDfMBUVJR?= =?us-ascii?Q?EciMxsIgGH1trt/y7Y8vEhqk3kKUCYZlu/zNt7mNGQEQT9/7iyjToUGnucTI?= =?us-ascii?Q?lYoly7UKX5SG4GV408NdJrezfiWbECjy7iRJSvkVrzpltJd3NRuHCfiEWb2u?= =?us-ascii?Q?k8AcvV3WAzzEXtYXaN5F561EXSdYNPIu0DqMmixlLYdXfCMKtg+7uC+Kl+o8?= =?us-ascii?Q?vaTsyz+7Yxk/PkLWV1ZcSqtv3KwRKjsqNipBNawXAHC7FCwyFxtUiL6RXSA4?= =?us-ascii?Q?rklsp6yl/X5oPMkuHLtSOIisMTwKqXWqsfKAu43fjsUzLy6py5Ho9zynq9ul?= =?us-ascii?Q?XM+2V8wRySosmcMkLIDP6RpNN4OoCylFCi7PtSVU+Viu3pABQk37CC+8cxFl?= =?us-ascii?Q?mBXlwxhJkV/zgHC/EFuwdfCENw04tY0bckBJ5aTLqht2+PMWP1EhDLDtUygS?= =?us-ascii?Q?5NObOSqxYGWS6wVc+QIXUfXMDpWhRFgnDvoE1Z/5YNWzQdw8JWAaMK7Unyrc?= =?us-ascii?Q?JXhudO/b1aHtXtE0OYreeKUzfb2ZlJziryKRltY/E3OVIrGRyvd8DyZWSZLk?= =?us-ascii?Q?7GRCjSuwASAjH89yA0BoFazvUV7dUOQXMxYSVFb1AVodk/WJiw5SO0PO2Wv5?= =?us-ascii?Q?DjldGbL/T1hkbvg8M6rqXwlbL16gRS+CuDMnPXv4lQGWJNu/TSEEC4BCFa6y?= =?us-ascii?Q?kiy7uT39XcN+N/XAgf+FKhHwnn89wfcjew1/gAjZxovyMi2wgFJllvG/DMh5?= =?us-ascii?Q?95Oef7JSgh0Lv51OpqKtcxt7O1Q2dmVEjqj/zSYNn5DKo5NxMWWM00vy6z71?= =?us-ascii?Q?fLK+2vGr/Lz85vJZ5XJD2zGy+d3NdhpSNu4C6o4EZSApzIkNbtazKtmWsO3P?= =?us-ascii?Q?eCFlr3JD+cukr+mtMPyyZv0TGdBSOvbAadZiZKRYM0sJFFI+1h/O5t7r5m9Z?= =?us-ascii?Q?YHlQWOSoGToutL3LYr9tn7WeUACCaMbSXPyUGKlwqs41730It/n9bYi0g5k2?= =?us-ascii?Q?lPU0hx5oRzAOjgbuLFHrJnOD5w1PDc5BiDruHSQtcSJzX7UL6LVB11nDMXjM?= =?us-ascii?Q?3XsgNvcxnFDCM3kO4KUlVh1dsVug4BnoaHTZNp6qVd8aVN4nsZbDgv5jAyxn?= =?us-ascii?Q?rkODk1/oWtdmR5STr02TPaUfGyretnYtWq4u4srP13KxMM8jgKQxxKsrI+8l?= =?us-ascii?Q?LQvO5iXWUQb8ss5vlXVRCRoUA6zBBX59rcdovN0ZgUJhnzw/feBR8HrIUQl0?= =?us-ascii?Q?Euk7hnjEGA8JJ1qJ+uiF7ao45QcGgTBXqeHOu/v6Tdkqbd38wQfLTnOQTQbn?= =?us-ascii?Q?y4pciVNT+dnZdhpizVl+s0zjLwIHvmbJ7QQ2/guyVHdGHe+hFXaBWTwkitWq?= =?us-ascii?Q?/BWLljHjAGxeGG8uZ5NaViD3mTD/Wn1VvAEs/1/+Z2kiYSrfuZ+AuHZaSQnK?= =?us-ascii?Q?3sP7xNov+ehFsC0oGFEHhOz30xhEerfTZuxD49/xDmnSt4WY4IbheY8V0U4S?= =?us-ascii?Q?ED9SAo1cZbidKDdurxN68o8Tu63sRGkNb/lD7OoOS8qlgPfIEEPuCnEtmq34?= =?us-ascii?Q?2Q=3D=3D?= X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 39c7772f-e5ce-4d4e-8ceb-08db02a7b0f3 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2023 09:52:25.7570 (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: lKg9SYM+JP6pdIxZUPhcQj+CNHtbnXuJesdd4T90Bk7RwYitSKxxGtxqH2j80lFibUXCrOnS73L1CzcunWDNmg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR11MB6025 X-Proofpoint-ORIG-GUID: SZ5_Lwr2OZD9gaczTvRElF-rdyeSLLoF X-Proofpoint-GUID: SZ5_Lwr2OZD9gaczTvRElF-rdyeSLLoF X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-30_09,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxscore=0 suspectscore=0 clxscore=1015 malwarescore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 bulkscore=0 spamscore=0 mlxlogscore=705 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301300094 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.166.238; envelope-from=prvs=13943e2a21=bin.meng@windriver.com; helo=mx0a-0064b401.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @windriver.com) X-ZM-MESSAGEID: 1675072490085100003 Content-Type: text/plain; charset="utf-8" From: Guohuai Shi xxxdir() APIs are not safe on Windows host. For future extension to Windows, let's replace the direct call to xxxdir() APIs with a wrapper. Signed-off-by: Guohuai Shi Signed-off-by: Bin Meng --- hw/9pfs/9p-util.h | 14 ++++++++++++++ hw/9pfs/9p-local.c | 12 ++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index 90420a7578..0f159fb4ce 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -103,6 +103,13 @@ static inline int errno_to_dotl(int err) { #define qemu_renameat renameat_win32 #define qemu_utimensat utimensat_win32 #define qemu_unlinkat unlinkat_win32 + +#define qemu_opendir opendir_win32 +#define qemu_closedir closedir_win32 +#define qemu_readdir readdir_win32 +#define qeme_rewinddir rewinddir_win32 +#define qemu_seekdir seekdir_win32 +#define qemu_telldir telldir_win32 #else #define qemu_openat openat #define qemu_fstatat fstatat @@ -110,6 +117,13 @@ static inline int errno_to_dotl(int err) { #define qemu_renameat renameat #define qemu_utimensat utimensat #define qemu_unlinkat unlinkat + +#define qemu_opendir opendir +#define qemu_closedir closedir +#define qemu_readdir readdir +#define qeme_rewinddir rewinddir +#define qemu_seekdir seekdir +#define qemu_telldir telldir #endif =20 #ifdef CONFIG_WIN32 diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index b6102c9e5a..4385f18da2 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -495,7 +495,7 @@ static int local_close(FsContext *ctx, V9fsFidOpenState= *fs) =20 static int local_closedir(FsContext *ctx, V9fsFidOpenState *fs) { - return closedir(fs->dir.stream); + return qemu_closedir(fs->dir.stream); } =20 static int local_open(FsContext *ctx, V9fsPath *fs_path, @@ -533,12 +533,12 @@ static int local_opendir(FsContext *ctx, =20 static void local_rewinddir(FsContext *ctx, V9fsFidOpenState *fs) { - rewinddir(fs->dir.stream); + qeme_rewinddir(fs->dir.stream); } =20 static off_t local_telldir(FsContext *ctx, V9fsFidOpenState *fs) { - return telldir(fs->dir.stream); + return qemu_telldir(fs->dir.stream); } =20 static bool local_is_mapped_file_metadata(FsContext *fs_ctx, const char *n= ame) @@ -552,13 +552,13 @@ static struct dirent *local_readdir(FsContext *ctx, V= 9fsFidOpenState *fs) struct dirent *entry; =20 again: - entry =3D readdir(fs->dir.stream); + entry =3D qemu_readdir(fs->dir.stream); if (!entry) { return NULL; } #ifdef CONFIG_DARWIN int off; - off =3D telldir(fs->dir.stream); + off =3D qemu_telldir(fs->dir.stream); /* If telldir fails, fail the entire readdir call */ if (off < 0) { return NULL; @@ -581,7 +581,7 @@ again: =20 static void local_seekdir(FsContext *ctx, V9fsFidOpenState *fs, off_t off) { - seekdir(fs->dir.stream, off); + qemu_seekdir(fs->dir.stream, off); } =20 static ssize_t local_preadv(FsContext *ctx, V9fsFidOpenState *fs, --=20 2.25.1 From nobody Thu Mar 28 13:35:16 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=windriver.com); dmarc=pass(p=none dis=none) header.from=windriver.com ARC-Seal: i=2; a=rsa-sha256; t=1675072414; cv=pass; d=zohomail.com; s=zohoarc; b=EhXkZolGSSabzPGug9nQ036oWUH74TPfqX4nouScABDYxYU6d0ZGGsisR2KvAVhZ7/6qZKY/NmIXFLgVLtvtuJ878OmT3y9oUXo5KfJnwEAh5orxqkUVdcjg7QOENh1M3fB1ly+Ca4M3dGrGq7FN2JMxVPe7nJRgXUWRMzfapHA= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675072414; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=BQCA7lysoYViR5t3M8lScVMY2+PANKI1hG53nyjiWU0=; b=f/Xp4O2E8DggGREu1bvTnxsgsnZcVxh8S1LY5GqBTCwjmpHJCth8vjapB6fpA3LSAgq0VEgznhpRjCu3pvdKVJN1rOtEdhYmCGxKfG+q/Fb9KGJZ42B3XiVeeefIQ+2hTuxRQe5b4gIseYB5bw/oY57sPupfBQwy0ffvUtdgf78= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=windriver.com); dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1675072414052761.6134382710733; Mon, 30 Jan 2023 01:53:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMQqF-0002y9-25; Mon, 30 Jan 2023 04:52:47 -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 1pMQqD-0002xk-99 for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:52: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 1pMQqB-000209-1M for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:52:44 -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 30U96eHW000968; Mon, 30 Jan 2023 01:52:30 -0800 Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2174.outbound.protection.outlook.com [104.47.57.174]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3nd43rhj5k-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Jan 2023 01:52:30 -0800 Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by BL1PR11MB6025.namprd11.prod.outlook.com (2603:10b6:208:390::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36; Mon, 30 Jan 2023 09:52:27 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9%2]) with mapi id 15.20.6043.036; Mon, 30 Jan 2023 09:52:27 +0000 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=BQCA7lysoYViR5t3M8lScVMY2+PANKI1hG53nyjiWU0=; b=bGoIuyKzU7W6e+xm4m3xj1Iul3PLeKRd1i2mBP79WYLdOnERqq6op2FrSzcEkBFI+yYo JpY2FN4gbWkcSXRV/uOvHvu58VHJuJspY66SP/dHUFi/0VdQLgOaNlIf+wbWiT5AKsbs R5v5uKnegazbPM9svEZNcUJ7ElXrcO3knsqgb7Yz/3lGFKxKPOLHhjH+r6ndddHXXAmi tj5ZGgaGt798qHuvhYPDk7CrFTidIGncAtpoCUA/u00xFKaOLKvL6CrN/j94xXxC+Fs7 IYk6i33B7SOpxABCK+X+Bbk5haVCOgTX2uiX4lo8n9PI3EA3VszXFR0vG23JC/2GdY7r jg== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SPxSnABIxgwRrVNGNrnF3YhYwXnpJxRYPgTfYLJOeouWZ9lnmvcNi2ZiN9lgt9PGxdi+ts3G5slRyVcu328sY1b6ThIvFoAAKoWCKxw9vPglB28vtZTvwBgroyqM/vnikcl4UVNi/EvQZeEQxMErh+enPaQkZIb0Gb5Af8f5oMDhYFpz+Rskc751ou1dijtXKBkV0VGVzhUvV5gWcF92FsWGXT4z1pnu6oDa7CdNPTf/5NKGCgC9wg5ynve+zm4DYlNOH+zz3emnAP89TI7IIIRRnZTxeloJAndBsnF6sbK77uPbER7DeESc8f8zU9ah0c4DynTkhl0rHvYWVJ6Avg== 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=BQCA7lysoYViR5t3M8lScVMY2+PANKI1hG53nyjiWU0=; b=HvLRSqu4a7bQIcJ6WlcrhDyzBCxj3gh/RKSVxsc5/M7ICfGKg1mZlAL8iPZhDoE+2aymRmKmnuj8SfQ/8pLtlVpmjvqvkX25s9xW0A+yI/jhaV6KVzvGzqJ9A6WwUyKk2TmTnfLbqtE/9Sis8+CDlRXlKJWB7wygogompxexsGp/TZ/F/80WgZK66ON23+/iMQ5dZpP7ckNFvZ3PKKIknZFF5ZdFpDq5NKdQXtNAypttjzxKF/m5lI5oN9jQ/uJOSGpeUOlpmeW7wEaVALugvHzdJmRzJtj6fylud3mF4U1H0a5/VXmDqCvrf5uDmfCchMxDMxqjjnM/olj/eE2fFw== 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 From: Bin Meng To: Greg Kurz , Christian Schoenebeck , qemu-devel@nongnu.org Cc: Guohuai Shi Subject: [PATCH v4 04/16] hw/9pfs: Implement Windows specific xxxdir() APIs Date: Mon, 30 Jan 2023 17:51:50 +0800 Message-Id: <20230130095202.2773186-5-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230130095202.2773186-1-bin.meng@windriver.com> References: <20230130095202.2773186-1-bin.meng@windriver.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BYAPR02CA0061.namprd02.prod.outlook.com (2603:10b6:a03:54::38) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|BL1PR11MB6025:EE_ X-MS-Office365-Filtering-Correlation-Id: affedad9-7421-4fe2-a360-08db02a7b229 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VoInPnDgXc+A5mqrKlDgYY/eoymPLgkFuaFe9rsAK9hnxNo1YHVocclLKxLWjU85g7QBxHsK1Lp4gujI4Ja45QFxanl1AimCcOVA4sbsqRe7FC8+wNxROCeBeM+almWlUgGcCMnmynRuPo5sN0Z7ER9/KfI9ae8vTU4mwmgDtEY1anCSTGoZoeV4biht51SD+i+dkFPSh6Y3f6/ealp3hBDiOfyYIo9eFCHcBDbnr5IpXKeKjO9OrkyXwGB9IlFTo4xiuzg1i1dxhAPlfRMfV2mqJwDFGpgK8iRjBot8oG2w4KN43c9YDXJ938ByxlwU6WsnyZRo1Umi0PGODVVtyFlCx+Tz1LmiLrK9X1qhp90cHsdrWZE+r9ahDjFDSB4HtO+h9G9ea+XyWBb2B6UCdyfyZ1M/F3jxD5qACScR4jclG+uEyY1QN0gzuJ3ApFZvk0PftmR1OtUXOOGyEE2ptGjkx+dSfvbDvjfANqOv5H0KuAmSj4+ItgUMBEGB0izMBAwZSC1B2PZ6rae/v5UvlOAKy+eOqF0CWcCX5efTw253mjJ0KajpT5ed0YqjXkFfcyz916bBAtUf9p2UNuTnl82O4tgTaHzOkuFRtOHF4/13j7MwSeoen4ffksHoKFHvg5O1WmqWaGA+mOmefJVTiAcB9woveF/x1gPK18FkN/laZ+oqmLiCxB0QR9ILNO0wxqU9Rf5ZjGXhioiFliPmmA== 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:(13230025)(4636009)(396003)(136003)(346002)(366004)(376002)(39850400004)(451199018)(2906002)(26005)(6512007)(186003)(478600001)(6666004)(107886003)(6486002)(316002)(110136005)(36756003)(86362001)(38100700002)(38350700002)(41300700001)(8936002)(2616005)(4326008)(66556008)(66476007)(66946007)(8676002)(52116002)(6506007)(1076003)(5660300002)(44832011)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?PRmrThh7eXvhPUH5DImMSnX8Wi+w3IzKPGjQuz2NMiESNo6FHc13SEAiB2uh?= =?us-ascii?Q?NvmibvgI1f0SZ9FMx6Ye4MGKNQOWqjtmret28zUYcX1G5GIuL7NKsFHY3Vdb?= =?us-ascii?Q?vW7z7ipnREZ6nKdsXb2FKHa2VuAgJILS4QV1vhABMuZnh78fQAy65Jx8GY91?= =?us-ascii?Q?jJeHbiViXe0vT+nG5LJDtkm7CY0j7I7mzK9sd1obTSACwb0tq1KR5pKEC2ig?= =?us-ascii?Q?cpa7JjDQXty6VFKeryxfTSVeGV/lV6IYb89aZK7Rwdlo3dPiBBx6z78BXeTA?= =?us-ascii?Q?vd1Br4s+j0Qbo+1YKEV5PQgX6MPsRNp6xKYPUu6oq8G2o6Ctj3hN1kCCOLps?= =?us-ascii?Q?jRlZX8vmB/dD1sDRK2opqAmX0ZHhX3c82rEiYX3Gp8e3RrNwqY0oKioLMqN6?= =?us-ascii?Q?9+FjMveec+afYilPtrzz+nYVs3FO4t+Z5nPnFepfXzMu2B78ixF9w86nWaFV?= =?us-ascii?Q?lGu4MFukEykZNpyz5GFFmtukE+8kcGapSF4sgcn6kW2Gs/LAB/renzR3rEVq?= =?us-ascii?Q?JZLMRqORoP9GgOSoLxTc1l6ncDcjx9GYxZnJfKx6mHzpfPxsYfNWpr+34urK?= =?us-ascii?Q?C6obTUH5adNJWoHt1kbNBVtKdj2sHBac7RIWt44OwsMXvundyTqRao7p1EXx?= =?us-ascii?Q?m+BFXaohsAzeupI0eONU9psoMbHFs5j70hZeKbwOx8WcvnPVP9iflOUrnxOv?= =?us-ascii?Q?/fwhIJoOMbKgPs1MnjguG6CU01Vuj9BrjgeKAZEt6uY5M28Lyd64QIrSCcjX?= =?us-ascii?Q?c26EGVKMBnLKVSavJQE2lQ5njWRhMvuJmaB4Di0na6JiD+Mg0ICOfFcMGqL+?= =?us-ascii?Q?3oUbkTXRLAlF8uMrNpaOGyritsc/CP7h5XXVFACQ7LlErpIm+598282rJ9Gc?= =?us-ascii?Q?7gEtOGIKR5BHLu3HjcHhWqrrt0pr9uf8hO7Rqnl+oXxnTiMnMh4Ox0Lf8/0D?= =?us-ascii?Q?tJw+mgiB0ZxvsXKaNDHdKsvrk2WVLRxI4SnLFWputlSc9fmY1EU82pcQKCyB?= =?us-ascii?Q?yeMZRTz+vzNvs6h3+KWSry1zEzMQ8/cPV+Hyuz9zKXJHUuhSk7mt0cgc/24M?= =?us-ascii?Q?/KLZstVCLrWEwjXEcFJlyw9P6jyuuZqNH29Q3B99h0FFmjDj3pya2MreE2Dr?= =?us-ascii?Q?vWgigrJOcXYKAnWODji3lmTwuOiSr0iHINt0A0T1O1l0C7+QKvkuVDBiXM2a?= =?us-ascii?Q?LvH453Ee1oxMHecYUtHpiNQJBWRaKxri7FTsE33drUx+BV7sxaFWlmF4G5Gf?= =?us-ascii?Q?z82hLppCLOPQ0XFXhzXhcFU1nqju75qVXp33S6ueoqjZG4699rbTeaDxseUC?= =?us-ascii?Q?vMr5I/zel9Xc8tqXxNbn77UYas0FoA3mph9jlJgqEmAfq1GwGqdfvClGNZD1?= =?us-ascii?Q?A+wHYj0oWElq1qJHjteFpIj/8P2D3Ly1ekS7c8RIQcFtno6RxxivFQs+BCcG?= =?us-ascii?Q?Fe/1EcWpxAe9Sc2HZEd+HCgr3XiWl320zxS7x/LzgLpTfFif8F3KKMoKdVfi?= =?us-ascii?Q?fErZZO0bI1np7oJ9JIEEXjmdvf6+Zp5dQqNHzTLPnrFuLEXHbDNn5GJ6ETM5?= =?us-ascii?Q?fTI49WkbpgeSsBFyVcYu5vM0GWkY7BrPn8QBQ+KGyVExMKccWKZ02NFP4YYH?= =?us-ascii?Q?Qg=3D=3D?= X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: affedad9-7421-4fe2-a360-08db02a7b229 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2023 09:52:27.7891 (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: tci8n11+VfalVahG8CJA9yaL6YZhpH9QUWVbvHyYWeNlfcfbCB5Ao6MRHyz1LdwoEVZtoSQssjrZNs5dh8+BXQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR11MB6025 X-Proofpoint-ORIG-GUID: tYRGw5gleuFVfkAqk2RuM02CigX0_Rkl X-Proofpoint-GUID: tYRGw5gleuFVfkAqk2RuM02CigX0_Rkl X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-30_09,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxscore=0 suspectscore=0 clxscore=1015 malwarescore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 bulkscore=0 spamscore=0 mlxlogscore=608 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301300094 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.166.238; envelope-from=prvs=13943e2a21=bin.meng@windriver.com; helo=mx0a-0064b401.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @windriver.com) X-ZM-MESSAGEID: 1675072416005100007 Content-Type: text/plain; charset="utf-8" From: Guohuai Shi This commit implements Windows specific xxxdir() APIs for safety directory access. Signed-off-by: Guohuai Shi Signed-off-by: Bin Meng --- hw/9pfs/9p-util.h | 6 + hw/9pfs/9p-util-win32.c | 296 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 302 insertions(+) diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index 0f159fb4ce..c1c251fbd1 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -141,6 +141,12 @@ int unlinkat_win32(int dirfd, const char *pathname, in= t flags); int statfs_win32(const char *root_path, struct statfs *stbuf); int openat_dir(int dirfd, const char *name); int openat_file(int dirfd, const char *name, int flags, mode_t mode); +DIR *opendir_win32(const char *full_file_name); +int closedir_win32(DIR *pDir); +struct dirent *readdir_win32(DIR *pDir); +void rewinddir_win32(DIR *pDir); +void seekdir_win32(DIR *pDir, long pos); +long telldir_win32(DIR *pDir); #endif =20 static inline void close_preserve_errno(int fd) diff --git a/hw/9pfs/9p-util-win32.c b/hw/9pfs/9p-util-win32.c index a99d579a06..5503199300 100644 --- a/hw/9pfs/9p-util-win32.c +++ b/hw/9pfs/9p-util-win32.c @@ -37,6 +37,13 @@ * Windows does not support opendir, the directory fd is created by * CreateFile and convert to fd by _open_osfhandle(). Keep the fd open = will * lock and protect the directory (can not be modified or replaced) + * + * 5. Windows and MinGW does not provide safety directory accessing functi= ons. + * readdir(), seekdir() and telldir() may get or set wrong value because + * directory entry data is not protected. + * + * This file re-write POSIX directory accessing functions and cache all + * directory entries during opening. */ =20 #include "qemu/osdep.h" @@ -51,6 +58,27 @@ =20 #define V9FS_MAGIC 0x53465039 /* string "9PFS" */ =20 +/* + * MinGW and Windows does not provide safety way to seek directory while o= ther + * thread is modifying same directory. + * + * The two structures are used to cache all directory entries when opening= it. + * Cached entries are always returned for read or seek. + */ +struct dir_win32_entry { + QSLIST_ENTRY(dir_win32_entry) node; + struct _finddata_t dd_data; +}; + +struct dir_win32 { + struct dirent dd_dir; + uint32_t offset; + uint32_t total_entries; + QSLIST_HEAD(, dir_win32_entry) head; + struct dir_win32_entry *current; + char dd_name[1]; +}; + /* * win32_error_to_posix - convert Win32 error to POSIX error number * @@ -977,3 +1005,271 @@ int qemu_mknodat(int dirfd, const char *filename, mo= de_t mode, dev_t dev) errno =3D ENOTSUP; return -1; } + +/* + * opendir_win32 - open a directory + * + * This function opens a directory and caches all directory entries. + */ +DIR *opendir_win32(const char *full_file_name) +{ + HANDLE hDir =3D INVALID_HANDLE_VALUE; + DWORD attribute; + intptr_t dd_handle =3D -1; + struct _finddata_t dd_data; + + struct dir_win32 *stream =3D NULL; + struct dir_win32_entry *dir_entry; + struct dir_win32_entry *prev; + struct dir_win32_entry *next; + + int err =3D 0; + int find_status; + uint32_t index; + + /* open directory to prevent it being removed */ + + hDir =3D CreateFile(full_file_name, GENERIC_READ, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELE= TE, + NULL, + OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); + + if (hDir =3D=3D INVALID_HANDLE_VALUE) { + err =3D win32_error_to_posix(GetLastError()); + goto out; + } + + attribute =3D GetFileAttributes(full_file_name); + + /* symlink is not allow */ + if (attribute =3D=3D INVALID_FILE_ATTRIBUTES + || (attribute & FILE_ATTRIBUTE_REPARSE_POINT) !=3D 0) { + err =3D EACCES; + goto out; + } + + /* check if it is a directory */ + if ((attribute & FILE_ATTRIBUTE_DIRECTORY) =3D=3D 0) { + err =3D ENOTDIR; + goto out; + } + + /* + * findfirst() need suffix format name like "\dir1\dir2\*", allocate m= ore + * buffer to store suffix. + */ + stream =3D g_malloc0(sizeof(struct dir_win32) + strlen(full_file_name)= + 3); + QSLIST_INIT(&stream->head); + + strcpy(stream->dd_name, full_file_name); + strcat(stream->dd_name, "\\*"); + + dd_handle =3D _findfirst(stream->dd_name, &dd_data); + + if (dd_handle =3D=3D -1) { + err =3D errno; + goto out; + } + + index =3D 0; + + /* read all entries to link list */ + do { + dir_entry =3D g_malloc0(sizeof(struct dir_win32_entry)); + memcpy(&dir_entry->dd_data, &dd_data, sizeof(dd_data)); + if (index =3D=3D 0) { + QSLIST_INSERT_HEAD(&stream->head, dir_entry, node); + } else { + QSLIST_INSERT_AFTER(prev, dir_entry, node); + } + + prev =3D dir_entry; + find_status =3D _findnext(dd_handle, &dd_data); + + index++; + } while (find_status =3D=3D 0); + + if (errno =3D=3D ENOENT) { + /* No more matching files could be found, clean errno */ + errno =3D 0; + } else { + err =3D errno; + goto out; + } + + stream->total_entries =3D index; + stream->current =3D QSLIST_FIRST(&stream->head); + +out: + if (err !=3D 0) { + errno =3D err; + /* free whole list */ + if (stream !=3D NULL) { + QSLIST_FOREACH_SAFE(dir_entry, &stream->head, node, next) { + QSLIST_REMOVE(&stream->head, dir_entry, dir_win32_entry, n= ode); + g_free(dir_entry); + } + g_free(stream); + stream =3D NULL; + } + } + + /* after cached all entries, this handle is useless */ + if (dd_handle !=3D -1) { + _findclose(dd_handle); + } + + if (hDir !=3D INVALID_HANDLE_VALUE) { + CloseHandle(hDir); + } + + return (DIR *)stream; +} + +/* + * closedir_win32 - close a directory + * + * This function closes directory and free all cached resources. + */ +int closedir_win32(DIR *pDir) +{ + struct dir_win32 *stream =3D (struct dir_win32 *)pDir; + struct dir_win32_entry *dir_entry; + struct dir_win32_entry *next; + + if (stream =3D=3D NULL) { + errno =3D EBADF; + return -1; + } + + /* free all resources */ + + QSLIST_FOREACH_SAFE(dir_entry, &stream->head, node, next) { + QSLIST_REMOVE(&stream->head, dir_entry, dir_win32_entry, node); + g_free(dir_entry); + } + + g_free(stream); + + return 0; +} + +/* + * readdir_win32 - read a directory + * + * This function reads a directory entry from cached entry list. + */ +struct dirent *readdir_win32(DIR *pDir) +{ + struct dir_win32 *stream =3D (struct dir_win32 *)pDir; + + if (stream =3D=3D NULL) { + errno =3D EBADF; + return NULL; + } + + if (stream->offset >=3D stream->total_entries) { + /* reach to the end, return NULL without set errno */ + return NULL; + } + + memcpy(stream->dd_dir.d_name, + stream->current->dd_data.name, + sizeof(stream->dd_dir.d_name)); + + /* Windows does not provide inode number */ + stream->dd_dir.d_ino =3D 0; + stream->dd_dir.d_reclen =3D 0; + stream->dd_dir.d_namlen =3D strlen(stream->dd_dir.d_name); + + stream->offset++; + stream->current =3D QSLIST_NEXT(stream->current, node); + + return &stream->dd_dir; +} + +/* + * rewinddir_win32 - reset directory stream + * + * This function resets the position of the directory stream to the + * beginning of the directory. + */ +void rewinddir_win32(DIR *pDir) +{ + struct dir_win32 *stream =3D (struct dir_win32 *)pDir; + + if (stream =3D=3D NULL) { + errno =3D EBADF; + return; + } + + stream->offset =3D 0; + stream->current =3D QSLIST_FIRST(&stream->head); + + return; +} + +/* + * seekdir_win32 - set the position of the next readdir() call in the dire= ctory + * + * This function sets the position of the next readdir() call in the direc= tory + * from which the next readdir() call will start. + */ +void seekdir_win32(DIR *pDir, long pos) +{ + struct dir_win32 *stream =3D (struct dir_win32 *)pDir; + uint32_t index; + + if (stream =3D=3D NULL) { + errno =3D EBADF; + return; + } + + if (pos < -1) { + errno =3D EINVAL; + return; + } + + if (pos =3D=3D -1 || pos >=3D (long)stream->total_entries) { + /* seek to the end */ + stream->offset =3D stream->total_entries; + return; + } + + if (pos - (long)stream->offset =3D=3D 0) { + /* no need to seek */ + return; + } + + /* seek position from list head */ + + stream->current =3D QSLIST_FIRST(&stream->head); + + for (index =3D 0; index < (uint32_t)pos; index++) { + stream->current =3D QSLIST_NEXT(stream->current, node); + } + stream->offset =3D index; + + return; +} + +/* + * telldir_win32 - return current location in directory + * + * This function returns current location in directory. + */ +long telldir_win32(DIR *pDir) +{ + struct dir_win32 *stream =3D (struct dir_win32 *)pDir; + + if (stream =3D=3D NULL) { + errno =3D EBADF; + return -1; + } + + if (stream->offset > stream->total_entries) { + return -1; + } + + return (long)stream->offset; +} --=20 2.25.1 From nobody Thu Mar 28 13:35:16 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=windriver.com); dmarc=pass(p=none dis=none) header.from=windriver.com ARC-Seal: i=2; a=rsa-sha256; t=1675072488; cv=pass; d=zohomail.com; s=zohoarc; b=P386D7huWRsMy7aXYIuaKOqHdXAgxmNEUPYm99bMNRREBXC/Bx506HTG+mdQBwjEGfFPJ1zZmKPkoP0P7NC7ULAWaAFDuCNeeiS4e5RyHdYb6LvBcBSpf4Xj0CkG7KmRou9qMPrZpMTxteuesVJLIjFDjgmafiSeXCj1XkHCXBA= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675072488; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Sm74XzxaRiYXzO1G+YfdbqAZ795gmZJiLP55ipP9+Fw=; b=WJF1k28qIqc3rdVKDPtKET9VlUzCiV7Lv3bEQ/ZeT8sDX0nJWhmRxm5cu7oAtWwZhxhieAe/q0O5CpsoBA6tdXoNZpsuYvs9NBUOvUCx+sVMLF/Uc7LVw601C23G1yxgJkpbq+ZzCf3K6+o4vs8WR8qPetwA+ANuhUNvmtx2lPo= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=windriver.com); dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1675072488722513.9424572260021; Mon, 30 Jan 2023 01:54:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMQqH-0002ym-2Z; Mon, 30 Jan 2023 04:52:49 -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 1pMQqF-0002yG-AI for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:52:47 -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 1pMQqC-00020R-KL for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:52:47 -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 30U96eHY000968; Mon, 30 Jan 2023 01:52:31 -0800 Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2174.outbound.protection.outlook.com [104.47.57.174]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3nd43rhj5k-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Jan 2023 01:52:31 -0800 Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by BL1PR11MB6025.namprd11.prod.outlook.com (2603:10b6:208:390::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36; Mon, 30 Jan 2023 09:52:30 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9%2]) with mapi id 15.20.6043.036; Mon, 30 Jan 2023 09:52:29 +0000 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=Sm74XzxaRiYXzO1G+YfdbqAZ795gmZJiLP55ipP9+Fw=; b=PidhLCNlokkPOpAVlwcBfjmPwKmL1Yea2Oedqq9Cqy3DcNaCHhZEN7aOPgCojeH7bZf3 X4yV3HDVYQMzKx6PSBfjxMc3yeQ3rABs/L9Pxv2FxmDq7JTNqJ9Ozyp6tY5kI+STxdzE AsuCtmpTh08lvS+g2Dt8LvAzWPNJDWdah57rCeo7m2LFgBoMmXH5XAFv38StqQb4AeS1 YQHsoI3dBZDdUwyqtJaqAfxLaFZYRyvglPzqdWQshy3dvwTJju9pKKxRhW4n/6W4a0T2 L5pN2oi3/30/B8RVOlCdxsLxoSgIdm5eXNmwFxzFmSoQPloVEi5i3qo1noH0hLy0nkmu HA== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OaZTFcrk+Y8YCmCRL3rQsoEEocDffOMIwY5FKoCi3bjAWhC9aeg0mu4N5jGKgOhlTYAoKVHUoJ0+aWsOkWOQPkFV17b8BaCO6xTJwOp6z3W5JmGjre9AY762hjKNkHYpEsbPOp8zBOwf/kShOmpLQ3Lno831dPmu+5LH6GVSTJ0wrfqLZQ97mnmo3d2vg8q8b0OvQO6Zzxv7BlPk4e6O5CoAfIyYcdpB2uxh4ZSa0POvcdM61kAlWG2aKxB+/4ZikpOiZJRg+T8UwHP+7XoHbxBxC1So1/bJUnwJj7lVptygh209/iKb1Ex9+q8w6zbXbpu4jtDaU5cUZJ09xiD/uw== 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=Sm74XzxaRiYXzO1G+YfdbqAZ795gmZJiLP55ipP9+Fw=; b=hP5vJ5S3HUx9qnzW51Z3K62wjgHuf/TdwbG5iXVodZ197Kq3Jv1nuIea7LeJVNepvGvUZqGK+whbRDxMkNLz4Dq/TNNtwAblZM6JTFiOM1+1gfYUfo4iOFtrseLMqol96CSplrNdXvwziLY3w0sbDTYBX152CfP50yWn4Ac8GWi+DavzeZAB+SxFHskEzOosjrlWH/leoYZ5wY5y28nNCcy6DU9FdfMT/C0mpFziSr6srdin3mPmXWjjrhKAuoSIx2o80SFzG4sRw3XMWLWahHQ601fG1Xdh51XnQNZHdLTs6zl79WjmA7PYna+Dvo07b5axw9T8ZYmGoBrxa1Hf9g== 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 From: Bin Meng To: Greg Kurz , Christian Schoenebeck , qemu-devel@nongnu.org Cc: Guohuai Shi Subject: [PATCH v4 05/16] hw/9pfs: Update the local fs driver to support Windows Date: Mon, 30 Jan 2023 17:51:51 +0800 Message-Id: <20230130095202.2773186-6-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230130095202.2773186-1-bin.meng@windriver.com> References: <20230130095202.2773186-1-bin.meng@windriver.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BYAPR02CA0061.namprd02.prod.outlook.com (2603:10b6:a03:54::38) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|BL1PR11MB6025:EE_ X-MS-Office365-Filtering-Correlation-Id: 9611c38e-ca5f-4972-6836-08db02a7b35f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: u9FeBpLZlAOzyN++OWPPp6pkqBLTKY79T+BMe6ejtEhttShv57oCJmObLjR5vraKn+E6TYcED5WMux6bVnK/jP75wviGxw18RRfOS4CmzRy3LV5UdCSl+1jhlwVaA1berRiUII8K1LflSmKxlc/UUAYYPDJkCzQQAzj2fq3jl7bI6GPaT+ka1XUhmyS/He6ZWCvSn402KdHtuWusR2hGycSaa5D1w76tAKqG4hRThsRMJjp3ecAcTFbbWeLxH3MQMDIcgqpfHhF4el+Qyz5OadTVfKUePSu0HvirAdqlygxsCaZ6IB3vxqrGWPGEQudnYsQm5d8YNydl5aOnOVscWCWiGoLXOt757Moj9eWMG1Nub+ZP//s76BtJVSOgBS/MHgV6rVkXye05gPhid/Uqdc9J6P3DOCdqKuqiA+BOPu3A0ok9SoapyeAfwB65515z41jGxgo+Naikz0RAMOTYzCOk2kGJPnwATX+4/StOthRGwSFNiD61j5yBfhslTxoTPgxlPJae7Cxoe8PXXSz/si91Wo5Sm8NpgmOeZ7DxTm1SYJ6Y/o/Oht1aczylmkBDDEte8NdJZgefSZcOG+mvBJLS65506lSdX7otfASKqLCqrn4XPZRojq3DlMK3je3ki4shbrzjcvX9EaaraXSUxfIr67sW1UDjhsCiascyUwN8OoAeQbIUO8OHK4B+iKY/vngFIs8AiJ4dcCJ2iFvNeg== 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:(13230025)(4636009)(396003)(136003)(346002)(366004)(376002)(39850400004)(451199018)(15650500001)(2906002)(26005)(6512007)(186003)(478600001)(6666004)(107886003)(6486002)(316002)(110136005)(36756003)(86362001)(38100700002)(38350700002)(41300700001)(8936002)(2616005)(4326008)(66556008)(66476007)(66946007)(8676002)(52116002)(6506007)(1076003)(5660300002)(44832011)(30864003)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?guDbWtjmQv9Oia1NYH+COtiWQzIyrKBN+4yNTJM9k7G++3FK2tW65job6kQ+?= =?us-ascii?Q?t2YlnXmbv98xBaJsrasI+AY1TJNIMYWExxNk1FK7c0LAWR7A6d1EhjJKnk0q?= =?us-ascii?Q?I2agrmN1BkU76iRn9z2YpxGChqeISdvu9hVMhGH6ywawYXsDI3R7wMx2bDCV?= =?us-ascii?Q?vWE3HN3hFO1lKANjgYQrLjSsKKSVl8d2jEwqrN9/Y0t46EY27L+ykQg23YzS?= =?us-ascii?Q?KGSApEtAzM4Ue4QkFJE4dSVbwWYsV2srkr38QxhLvYQQWBym38iAfC4cSAJv?= =?us-ascii?Q?YU1Uivjg4nJnxCV/iFfi/F77M8sXl6QH4DdY21VO5wOtUmBdFf3AY/psHJuG?= =?us-ascii?Q?BCxCuWc87zpmBPZNdL799Am3w2I0kG/n88tei/O7t2ve5T7Bqa2uYPibKamw?= =?us-ascii?Q?j4wSwq3kqcC1eIghJbTmCXS41dmQjJ/16+7uY2a1P8A3RAwkk/nVipeJubt+?= =?us-ascii?Q?xMLO6fa2O810NeXai1e6+SrmDyulKP4UhZWQxVi1eoPjN7hKEbbCzOEm8u/u?= =?us-ascii?Q?HtJSm9nAlhxLBwwvUiZbH4u9hpSt0/C1jks8InEXTs4he65t2ZNWPjharcEZ?= =?us-ascii?Q?xBZo/Dxm/OtotPwILSwzEbW3n1BfwaSC3JV3GouTqr16uNWmIfcpWAGp0YDX?= =?us-ascii?Q?SAzAuT7YEjP0XuKNyVSswJRdg8/V00+t2yivIQ0XWH6+4UXcmYqxenvwf1ut?= =?us-ascii?Q?mtVpIuWOQ2UfUwTPNqywezJjqThakI3dU1rN/i+ipuBRKKH592+iz7KqJjr6?= =?us-ascii?Q?+f2CRZXmjTu28fsr6tw21oGGQ+9hYBugKYRYklCtgnao3VgcDtffQK7F1ogE?= =?us-ascii?Q?K//Ajr94PIEZX0+krjKg5iwkYJsN3cyvTqn4YEgh19++8uud/+HbY/8EoW1F?= =?us-ascii?Q?YrgYXm10v1KNvMz8Y2Cmz/O+c+cD8OcxAk/EjeXAm/STJg1oHhr5D47i2xRe?= =?us-ascii?Q?XEVrmxrUkRBrWkV/yD5qMOEnoBe6P6/xfjCw+bimb/RuslXzGQTFHIRD6PK+?= =?us-ascii?Q?cFm4DEmyUjOSZ67uCkdt0jzhCXxRofPmeWMIobndI1nRq951jSjiYHU6bHY/?= =?us-ascii?Q?OASDa2O+gzvMHP3skU01AyL/eeKCbEMA8XFRMk6MvC/mPkPpv2Oomr3MUzRC?= =?us-ascii?Q?F1w07XAzw72WV71TcI4nxiL4NAatqqpONyMGQauxx6+Dw4is786GGOLeAdBD?= =?us-ascii?Q?n/JBk3zhjssr6ortzrmswXQNLGJ1pkwWLOVZ3QL581/fFRwzII1nu6TAlWNT?= =?us-ascii?Q?jt/FyRe+7TOegkhej8FLO7b4GrPMqSkdI+/derg8oftj3WBrBgA3LHMAXy+W?= =?us-ascii?Q?XNHIeCId5FHIbWtNfEwhDcZJRGWpefeGYa6WI9j+T10dfCf8kozPd9XuihKo?= =?us-ascii?Q?QN6kn5BP6/GTDMdmhEAmLhYMnRgatd00wWF1jvWF/SaCpxRlT5IZk39D06x3?= =?us-ascii?Q?GH4bQjouZG6AjHjA+u+ne6vVhnJsPIrMWfyGzWFx1O4sandMwfjGBHErDYzm?= =?us-ascii?Q?B8RJbqIAUTFfVsDClK/2pdZ3vOdaeiFmUECZfGnOrm4OKRddSC9SKKiG7XQ7?= =?us-ascii?Q?F/wUgy00rHxFly3Bc+kkKQeSIgWidhNdL60457ly3xcq62eGWE7Y/bkLGQ/G?= =?us-ascii?Q?TA=3D=3D?= X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9611c38e-ca5f-4972-6836-08db02a7b35f X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2023 09:52:29.8974 (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: dQzaZ5DlOS34mrj9otRba2VW00GsFpXLGPyudJT0UPwRGEXXb69MshvQC213A3Mcom+NIeSjHFviek/R9wK2BQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR11MB6025 X-Proofpoint-ORIG-GUID: BLBOe1nisKsh4kmnXpgYnjKPaVCo8PtA X-Proofpoint-GUID: BLBOe1nisKsh4kmnXpgYnjKPaVCo8PtA X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-30_09,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxscore=0 suspectscore=0 clxscore=1015 malwarescore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301300094 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.166.238; envelope-from=prvs=13943e2a21=bin.meng@windriver.com; helo=mx0a-0064b401.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_PDS_OTHER_BAD_TLD=0.01 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @windriver.com) X-ZM-MESSAGEID: 1675072490118100004 Content-Type: text/plain; charset="utf-8" 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 --- hw/9pfs/9p-local.h | 1 + hw/9pfs/9p-local.c | 253 +++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 246 insertions(+), 8 deletions(-) diff --git a/hw/9pfs/9p-local.h b/hw/9pfs/9p-local.h index 77e7f57f89..5905923881 100644 --- a/hw/9pfs/9p-local.h +++ b/hw/9pfs/9p-local.h @@ -17,6 +17,7 @@ typedef struct { int mountfd; #ifdef CONFIG_WIN32 char *root_path; + DWORD block_size; #endif } LocalData; =20 diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index 4385f18da2..d308a88759 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -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 =20 #ifndef XFS_SUPER_MAGIC #define XFS_SUPER_MAGIC 0x58465342 @@ -90,10 +94,12 @@ int local_open_nofollow(FsContext *fs_ctx, const char *= path, int flags, return fd; } =20 +#ifndef CONFIG_WIN32 int local_opendir_nofollow(FsContext *fs_ctx, const char *path) { return local_open_nofollow(fs_ctx, path, O_DIRECTORY | O_RDONLY, 0); } +#endif =20 static void renameat_preserve_errno(int odirfd, const char *opath, int ndi= rfd, const char *npath) @@ -236,7 +242,7 @@ static int local_set_mapped_file_attrat(int dirfd, cons= t char *name, int ret; char buf[ATTR_MAX]; int uid =3D -1, gid =3D -1, mode =3D -1, rdev =3D -1; - int map_dirfd =3D -1, map_fd; + int map_dirfd =3D -1; bool is_root =3D !strcmp(name, "."); =20 if (is_root) { @@ -300,10 +306,12 @@ update_map_file: return -1; } =20 - map_fd =3D fileno(fp); +#ifndef CONFIG_WIN32 + int map_fd =3D fileno(fp); assert(map_fd !=3D -1); ret =3D fchmod(map_fd, 0600); assert(ret =3D=3D 0); +#endif =20 if (credp->fc_uid !=3D -1) { uid =3D credp->fc_uid; @@ -335,6 +343,7 @@ update_map_file: return 0; } =20 +#ifndef CONFIG_WIN32 static int fchmodat_nofollow(int dirfd, const char *name, mode_t mode) { struct stat stbuf; @@ -396,6 +405,7 @@ static int fchmodat_nofollow(int dirfd, const char *nam= e, mode_t mode) close_preserve_errno(fd); return ret; } +#endif =20 static int local_set_xattrat(int dirfd, const char *path, FsCred *credp) { @@ -436,6 +446,7 @@ static int local_set_xattrat(int dirfd, const char *pat= h, FsCred *credp) return 0; } =20 +#ifndef CONFIG_WIN32 static int local_set_cred_passthrough(FsContext *fs_ctx, int dirfd, const char *name, FsCred *credp) { @@ -452,6 +463,7 @@ static int local_set_cred_passthrough(FsContext *fs_ctx= , int dirfd, =20 return fchmodat_nofollow(dirfd, name, credp->fc_mode & 07777); } +#endif =20 static ssize_t local_readlink(FsContext *fs_ctx, V9fsPath *fs_path, char *buf, size_t bufsz) @@ -470,6 +482,12 @@ static ssize_t local_readlink(FsContext *fs_ctx, V9fsP= ath *fs_path, close_preserve_errno(fd); } else if ((fs_ctx->export_flags & V9FS_SM_PASSTHROUGH) || (fs_ctx->export_flags & V9FS_SM_NONE)) { +#ifdef CONFIG_WIN32 + errno =3D ENOTSUP; + error_report_once("readlink is not available on Windows host when" + "security_model is \"none\" or \"passthrough\""); + tsize =3D -1; +#else char *dirpath =3D g_path_get_dirname(fs_path->data); char *name =3D g_path_get_basename(fs_path->data); int dirfd; @@ -484,6 +502,7 @@ static ssize_t local_readlink(FsContext *fs_ctx, V9fsPa= th *fs_path, out: g_free(name); g_free(dirpath); +#endif } return tsize; } @@ -522,9 +541,31 @@ static int local_opendir(FsContext *ctx, return -1; } =20 +#ifdef CONFIG_WIN32 + char *full_file_name; + + HANDLE hDir =3D (HANDLE)_get_osfhandle(dirfd); + + full_file_name =3D get_full_path_win32(hDir, NULL); + + close(dirfd); + + if (full_file_name =3D=3D NULL) { + return -1; + } + stream =3D qemu_opendir(full_file_name); + g_free(full_file_name); +#else stream =3D fdopendir(dirfd); +#endif + if (!stream) { +#ifndef CONFIG_WIN32 + /* + * dirfd is closed always in above code, so no need to close it he= re. + */ close(dirfd); +#endif return -1; } fs->dir.stream =3D stream; @@ -567,13 +608,17 @@ again: #endif =20 if (ctx->export_flags & V9FS_SM_MAPPED) { +#ifndef CONFIG_WIN32 entry->d_type =3D 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 =3D DT_UNKNOWN; +#endif } =20 return entry; @@ -647,7 +692,14 @@ static int local_chmod(FsContext *fs_ctx, V9fsPath *fs= _path, FsCred *credp) ret =3D 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 =3D ENOTSUP; + error_report_once("chmod is not available on Windows host when" + "security_model is \"none\" or \"passthrough\""); + ret =3D -1; +#else ret =3D fchmodat_nofollow(dirfd, name, credp->fc_mode); +#endif } close_preserve_errno(dirfd); =20 @@ -691,6 +743,12 @@ static int local_mknod(FsContext *fs_ctx, V9fsPath *di= r_path, } } else if (fs_ctx->export_flags & V9FS_SM_PASSTHROUGH || fs_ctx->export_flags & V9FS_SM_NONE) { +#ifdef CONFIG_WIN32 + errno =3D ENOTSUP; + error_report_once("mknod is not available on Windows host when" + "security_model is \"none\" or \"passthrough\""); + goto out; +#else err =3D qemu_mknodat(dirfd, name, credp->fc_mode, credp->fc_rdev); if (err =3D=3D -1) { goto out; @@ -699,6 +757,7 @@ static int local_mknod(FsContext *fs_ctx, V9fsPath *dir= _path, if (err =3D=3D -1) { goto err_end; } +#endif } goto out; =20 @@ -748,10 +807,12 @@ static int local_mkdir(FsContext *fs_ctx, V9fsPath *d= ir_path, if (err =3D=3D -1) { goto out; } +#ifndef CONFIG_WIN32 err =3D local_set_cred_passthrough(fs_ctx, dirfd, name, credp); if (err =3D=3D -1) { goto err_end; } +#endif } goto out; =20 @@ -768,7 +829,12 @@ static int local_fstat(FsContext *fs_ctx, int fid_type, int err, fd; =20 if (fid_type =3D=3D P9_FID_DIR) { +#ifdef CONFIG_WIN32 + errno =3D ENOTSUP; + return -1; /* Windows do not allow opening a directory by open() = */ +#else fd =3D dirfd(fs->dir.stream); +#endif } else { fd =3D fs->fd; } @@ -820,10 +886,10 @@ static int local_open2(FsContext *fs_ctx, V9fsPath *d= ir_path, const char *name, return -1; } =20 - /* - * Mark all the open to not follow symlinks - */ +#ifndef CONFIG_WIN32 + /* Mark all the open to not follow symlinks */ flags |=3D O_NOFOLLOW; +#endif =20 dirfd =3D local_opendir_nofollow(fs_ctx, dir_path->data); if (dirfd =3D=3D -1) { @@ -853,10 +919,12 @@ static int local_open2(FsContext *fs_ctx, V9fsPath *d= ir_path, const char *name, if (fd =3D=3D -1) { goto out; } +#ifndef CONFIG_WIN32 err =3D local_set_cred_passthrough(fs_ctx, dirfd, name, credp); if (err =3D=3D -1) { goto err_end; } +#endif } err =3D fd; fs->fd =3D fd; @@ -921,6 +989,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 =3D ENOTSUP; + error_report_once("symlink is not available on Windows host when" + "security_model is \"none\" or \"passthrough\""); + goto out; +#else err =3D symlinkat(oldpath, dirfd, name); if (err) { goto out; @@ -938,6 +1021,7 @@ static int local_symlink(FsContext *fs_ctx, const char= *oldpath, err =3D 0; } } +#endif } goto out; =20 @@ -951,6 +1035,11 @@ out: static int local_link(FsContext *ctx, V9fsPath *oldpath, V9fsPath *dirpath, const char *name) { +#ifdef CONFIG_WIN32 + errno =3D ENOTSUP; + error_report_once("link is not available on Windows host"); + return -1; +#else char *odirpath =3D g_path_get_dirname(oldpath->data); char *oname =3D g_path_get_basename(oldpath->data); int ret =3D -1; @@ -1020,6 +1109,7 @@ out: g_free(oname); g_free(odirpath); return ret; +#endif } =20 static int local_truncate(FsContext *ctx, V9fsPath *fs_path, off_t size) @@ -1050,8 +1140,15 @@ static int local_chown(FsContext *fs_ctx, V9fsPath *= fs_path, FsCred *credp) if ((credp->fc_uid =3D=3D -1 && credp->fc_gid =3D=3D -1) || (fs_ctx->export_flags & V9FS_SM_PASSTHROUGH) || (fs_ctx->export_flags & V9FS_SM_NONE)) { +#ifdef CONFIG_WIN32 + errno =3D ENOTSUP; + error_report_once("chown is not available on Windows host when" + "security_model is \"none\" or \"passthrough\""); + ret =3D -1; +#else ret =3D fchownat(dirfd, name, credp->fc_uid, credp->fc_gid, AT_SYMLINK_NOFOLLOW); +#endif } else if (fs_ctx->export_flags & V9FS_SM_MAPPED) { ret =3D local_set_xattrat(dirfd, name, credp); } else if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) { @@ -1163,6 +1260,12 @@ out: static int local_fsync(FsContext *ctx, int fid_type, V9fsFidOpenState *fs, int datasync) { +#ifdef CONFIG_WIN32 + if (fid_type !=3D P9_FID_DIR) { + return _commit(fs->fd); + } + return 0; +#else int fd; =20 if (fid_type =3D=3D P9_FID_DIR) { @@ -1176,11 +1279,14 @@ static int local_fsync(FsContext *ctx, int fid_type, } else { return fsync(fd); } +#endif } =20 static int local_statfs(FsContext *s, V9fsPath *fs_path, struct statfs *st= buf) { - int fd, ret; + int ret; +#ifndef CONFIG_WIN32 + int fd; =20 fd =3D local_open_nofollow(s, fs_path->data, O_RDONLY, 0); if (fd =3D=3D -1) { @@ -1188,39 +1294,65 @@ static int local_statfs(FsContext *s, V9fsPath *fs_= path, struct statfs *stbuf) } ret =3D fstatfs(fd, stbuf); close_preserve_errno(fd); +#else + LocalData *data =3D (LocalData *)s->private; + + ret =3D statfs_win32(data->root_path, stbuf); + if (ret =3D=3D 0) { + /* use context address as fsid */ + memcpy(&stbuf->f_fsid, s, sizeof(intptr_t)); + } +#endif + return ret; } =20 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 =3D fs_path->data; =20 return v9fs_get_xattr(ctx, path, name, value, size); +#endif } =20 static ssize_t local_llistxattr(FsContext *ctx, V9fsPath *fs_path, void *value, size_t size) { +#ifdef CONFIG_WIN32 + return -1; +#else char *path =3D fs_path->data; =20 return v9fs_list_xattr(ctx, path, value, size); +#endif } =20 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 =3D fs_path->data; =20 return v9fs_set_xattr(ctx, path, name, value, size, flags); +#endif } =20 static int local_lremovexattr(FsContext *ctx, V9fsPath *fs_path, const char *name) { +#ifdef CONFIG_WIN32 + return -1; +#else char *path =3D fs_path->data; =20 return v9fs_remove_xattr(ctx, path, name); +#endif } =20 static int local_name_to_path(FsContext *ctx, V9fsPath *dir_path, @@ -1383,6 +1515,7 @@ static int local_unlinkat(FsContext *ctx, V9fsPath *d= ir, return ret; } =20 +#ifndef CONFIG_WIN32 #ifdef FS_IOC_GETVERSION static int local_ioc_getversion(FsContext *ctx, V9fsPath *path, mode_t st_mode, uint64_t *st_gen) @@ -1432,11 +1565,90 @@ static int local_ioc_getversion_init(FsContext *ctx= , LocalData *data, Error **er #endif return 0; } +#endif =20 -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 =3D g_malloc(sizeof(*data)); + HANDLE hRoot; + char *root_path; + DWORD SectorsPerCluster; + DWORD BytesPerSector; + DWORD NumberOfFreeClusters; + DWORD TotalNumberOfClusters; + char disk_root[4] =3D { 0 }; + + hRoot =3D CreateFile(ctx->fs_root, GENERIC_READ, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DEL= ETE, + NULL, + OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); + if (hRoot =3D=3D INVALID_HANDLE_VALUE) { + error_setg_errno(errp, EINVAL, "cannot open %s", ctx->fs_root); + return -1; + } + + if ((ctx->export_flags & V9FS_SM_MAPPED) !=3D 0) { + wchar_t fs_name[MAX_PATH + 1] =3D {0}; + wchar_t ntfs_name[5] =3D {'N', 'T', 'F', 'S'}; + + /* Get file system type name */ + if (GetVolumeInformationByHandleW(hRoot, NULL, 0, NULL, NULL, NULL, + fs_name, MAX_PATH + 1) =3D=3D 0)= { + error_setg_errno(errp, EINVAL, + "cannot get file system information"); + CloseHandle(hRoot); + return -1; + } + + /* + * security_model=3Dmapped(-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) !=3D 0) { + CloseHandle(hRoot); + error_setg_errno(errp, EINVAL, "require NTFS file system"); + return -1; + } + } + + root_path =3D get_full_path_win32(hRoot, NULL); + if (root_path =3D=3D NULL) { + CloseHandle(hRoot); + 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); =20 + if (GetDiskFreeSpace(disk_root, &SectorsPerCluster, &BytesPerSector, + &NumberOfFreeClusters, &TotalNumberOfClusters) = =3D=3D 0) { + CloseHandle(hRoot); + 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 =3D _open_osfhandle((intptr_t)hRoot, _O_RDONLY); + data->root_path =3D root_path; + data->block_size =3D SectorsPerCluster * BytesPerSector; + + return 0; +} + +#endif + +static int local_init(FsContext *ctx, Error **errp) +{ + LocalData *data =3D g_malloc0(sizeof(*data)); +#ifndef CONFIG_WIN32 data->mountfd =3D open(ctx->fs_root, O_DIRECTORY | O_RDONLY); if (data->mountfd =3D=3D -1) { error_setg_errno(errp, errno, "failed to open '%s'", ctx->fs_root); @@ -1447,7 +1659,17 @@ static int local_init(FsContext *ctx, Error **errp) close(data->mountfd); goto err; } +#else + if (init_win32_root_directory(ctx, data, errp) !=3D 0) { + goto err; + } =20 + /* + * Always enable inode remap since Windows file system does not + * have inode number. + */ + ctx->export_flags |=3D V9FS_REMAP_INODES; +#endif if (ctx->export_flags & V9FS_SM_PASSTHROUGH) { ctx->xops =3D passthrough_xattr_ops; } else if (ctx->export_flags & V9FS_SM_MAPPED) { @@ -1467,6 +1689,16 @@ static int local_init(FsContext *ctx, Error **errp) return 0; =20 err: +#ifdef CONFIG_WIN32 + if (data->root_path !=3D NULL) { + g_free(data->root_path); + } +#endif + + if (data->mountfd !=3D -1) { + close(data->mountfd); + } + g_free(data); return -1; } @@ -1479,6 +1711,11 @@ static void local_cleanup(FsContext *ctx) return; } =20 +#ifdef CONFIG_WIN32 + if (data->root_path !=3D NULL) { + g_free(data->root_path); + } +#endif close(data->mountfd); g_free(data); } --=20 2.25.1 From nobody Thu Mar 28 13:35:16 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=windriver.com); dmarc=pass(p=none dis=none) header.from=windriver.com ARC-Seal: i=2; a=rsa-sha256; t=1675072482; cv=pass; d=zohomail.com; s=zohoarc; b=QQMj7DzGX8AxP1n6FUYtuJ/KDMLCU1MXY8a7ByKXdpVyaQU9Hp5NnrcsZP9Ni5lE2wekbWBORIdaFeg7O8TBs8YJnDkyxOLqZYLgLdBpcpUNL3bMnFHs+zlhclr9arkqhel6Jpu9CcUlSokZch1SfLhqwBgsjAD+tGonH6eECqM= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675072482; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Ajqch1/tMp3Hvy9konbpmH0yUatw6197ofO1LywoORM=; b=h0nEMtgnhXUld1ywqnBaJbJ9e22h9ZUPmCzhTIjbcf8Zv+IE+UgwSr6KOtwUlVfTxJQiT95Xt2JxotwpsO1FTku5R7ceCIMr+lOpmWUP7BxEDkH62/bFhnMePTbRMKkUWdsHj/6pOY01/Ryj962OAwcIZXmV9WtHjH+DrYROp4g= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=windriver.com); dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1675072482933398.03765104278443; Mon, 30 Jan 2023 01:54:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMQqJ-000304-JT; Mon, 30 Jan 2023 04:52:51 -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 1pMQqG-0002yf-SA for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:52:48 -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 1pMQqD-00020Y-5b for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:52:48 -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 30U7qdkm025000; Mon, 30 Jan 2023 09:52:33 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2168.outbound.protection.outlook.com [104.47.57.168]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3ncrx3a45a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Jan 2023 09:52:33 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by BL1PR11MB6025.namprd11.prod.outlook.com (2603:10b6:208:390::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36; Mon, 30 Jan 2023 09:52:32 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9%2]) with mapi id 15.20.6043.036; Mon, 30 Jan 2023 09:52:31 +0000 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=Ajqch1/tMp3Hvy9konbpmH0yUatw6197ofO1LywoORM=; b=RAX1h5mh68ZwcNFPlN9OdyyavFLbvVXyWmv3pJ4AnkKCxfIuYYJNQ5KmBNtZLBogl+XL kMnHoFRkz/CazKx+tLRzly+N4xmIKQW110sM5M1p42Z3Z3V5xnfjS5l24/Jm5N4CZeRm n5ADLvdGmvS7I75z1R9by2EAzcEg7pPpI8CkoWi0RZ+s+HIZ8op/oxXm2rMeJMSnQO3f 3RuPgxYyXScfXQPVphSZA3NYgCOVhTKkyp0WNUnAqfPfWvpycCXutHmk2q0T13qeO+3r 57HTAfQfHTTSQBp8UQ1OvADO5hfr9cdwRbndqkl1l9/sh2Zm7VyXC1cQ4J04mr1PkUTn Jw== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cvNKRqHTrbrDk940nYpPHBDTG+q0bUTQXbnAV02vZStHZX0chGfsHHXpT+mwIwywND3qjFgGnr1GbDY0qtD4SquWpP34OoEZYpFP6lN6dHKiY3DIfsKHJwy7cE773akPzE5/yi3jap2PIo9LXYerqp65wFhp90jxy5eshzX2NzQMYsSLpYueXWRldrAp+RFKziY13n+RQOF+r63eQRoyom/e/vY3/jDfwRH4l7Jgi29RMIN63VLpAiaaNpkX0F7vKe4kXt4cWVjp6eIBNl8oTi5QiAodA8QM7nj7FdogPTflTDJ0PngUNTkIMIlVyCyQ4mkbjauhs+4lL3CDe0Biew== 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=Ajqch1/tMp3Hvy9konbpmH0yUatw6197ofO1LywoORM=; b=INSCroOAsR3Iujt7+8Nrom0P65nvYGoy7mnwrdybYLefgxI2Ms6wusloK90A+6vCVzP1KgRKJyOPjVYaoo8GfYFeWD0BUUccQfX1/1RVA6kubU/VKLCa8KttMp1IG5GwaZWAyqQAECwZz/t/YlJoYBh/3UPwp7CkbrFsZAJi9bkWZifOrhh1HlhxRVc2YXBMNs8KY3331XGSQ7V8sp2ibzcDSBBdcEwkVG3TON7/9JYQCh7C+y9NFQ4J6VYXI3CT2gUdPOB46rEDBIs37gXm9kTyJ2VIt1Fvg7k8zZC2VTrgZjJHIaubLly/alPG2mtN5Hv6FViSzHV9MBuINVaWLg== 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 From: Bin Meng To: Greg Kurz , Christian Schoenebeck , qemu-devel@nongnu.org Cc: Guohuai Shi Subject: [PATCH v4 06/16] hw/9pfs: Support getting current directory offset for Windows Date: Mon, 30 Jan 2023 17:51:52 +0800 Message-Id: <20230130095202.2773186-7-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230130095202.2773186-1-bin.meng@windriver.com> References: <20230130095202.2773186-1-bin.meng@windriver.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BYAPR02CA0061.namprd02.prod.outlook.com (2603:10b6:a03:54::38) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|BL1PR11MB6025:EE_ X-MS-Office365-Filtering-Correlation-Id: e6ab5f9c-dadd-48d7-a321-08db02a7b49c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Yin8cNGeCXPYkRWko7rSArrK3fdfYzDKdMguafuoo2HMreH+yce+hKJLgm7RRSlZtT083VraGy+Rx7DBy95SD9V0h5vCpmcclqn6N2gAgluzO+sDLxZ1MaPo3q4Sq3OUZ2rDmJ/5CLqH5E1fpHbHoYPRr4FSgPisY8y3HIjV7PZ8Bj5k5evKjHMrrTpSe2xvWEtU6D+qfOPqSNVhd5IYZsx/8s1bHqWa1sgyD0l29aT7r3+5tOmw+JsQErCUHvmTQ1DR/JqKplVf7eERwfliPkgMdCbWOpAfAZX7rPfFLvW9yR89TVrhvGyA6QqkMe+OSgcFai5RsVx0aEOVPGJqTEanTTD4hzhQOJzz7aVoR4Sj2eXnPMintbbBIhDQZbrEOm92Fzp6Hw9++irDGwFkAtnTSoS/2nntwBajHjCZDNOcuMDF6B55Ax3W6rI7XSbsUMSEONFawHxpCckld5qU9U1enQagvawihv4kthN+T7DJlXNSDQE2QEs6ucuDFU0Kcs5y4e84B5ZVSVhWhdfCle3cPF2RMIN9MSslI+t4FicyN0MlZ0Q6t4lJzA2+0QlXjO7RZ4IOQZ6FU4mSqr90vG+rx+Vxp8NuhwoR50ym4km1sSu4dJnOwFCYcj453Zt58ArKOtePrWowJV0TNWG9ad0UlLNn8gsybySRfubg0FnqCcvGPf4K4sAc8q+asksbF0s9/fNC617d6h060EQ+fg== 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:(13230025)(4636009)(396003)(136003)(346002)(366004)(376002)(39850400004)(451199018)(2906002)(26005)(6512007)(186003)(478600001)(6666004)(107886003)(6486002)(316002)(110136005)(36756003)(86362001)(38100700002)(38350700002)(41300700001)(8936002)(2616005)(4326008)(66556008)(66476007)(66946007)(8676002)(52116002)(6506007)(1076003)(5660300002)(44832011)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?/f5NW7XC2+XK2BUfRrKJhLlMe7JtOr9ZfRJ+i/LZNOla71xGJIvcLP8MR1ps?= =?us-ascii?Q?DCY+QCWZF85mlFSLAYDBFAul7JZ8EgARj5BsBDBz+EmXYRQ6Kg9X2cIT4+WP?= =?us-ascii?Q?FfcUor3zQKuyouRN0J1i4ruQ3ffSMDBiA90N+M1aHBdt7pVE/fI/1eo458ol?= =?us-ascii?Q?0gm4idQBRMe8xOwauXw9uxIRz/TuIywjrQFW4QU8Wf8BixJRgRgDPMJkAoW9?= =?us-ascii?Q?rP3/UOdPCB+p0J54OTx8ylEuFFoE64ewCo3lYYQRNylKPZv3jrNexNJN7l7+?= =?us-ascii?Q?VbwqbabUFQUARHCBCKJliW4m80c1hagSWqQTCkNBhrKwo0idTJh2QAIFQgHx?= =?us-ascii?Q?o/4kHnrMgbu8fJH6egAlwPsUorHDT8Zb5JPbWKilV1M8FEbfruV60lairBrX?= =?us-ascii?Q?xUCTppEBBiLUvtFcLDJew0X5GqL95oqaiUhqjNI27unChYXDEaN1TUSimpdh?= =?us-ascii?Q?YbW63zC/r8vXyEBVJFKtVsuopeTc3Z0Ugc9cacDVhvjcNFV6b+5lrwgOIh+T?= =?us-ascii?Q?/pWO8VTi3XUrEvzaaXgg56es0/jHZNJueOUIdJYO6zA4rEzuoKL0hT/K/FkG?= =?us-ascii?Q?Eb73hrpI1YLxnIBaPkS4YO96wX7dlXxg2GHOCr2cTGbhUCNToOs0XetoU0nr?= =?us-ascii?Q?SvqYSk+uEXCnOLgJ0QMbjOV69wWJR5GYhOkxVnO4AfdYj3QOiDq45k99VgZH?= =?us-ascii?Q?SR0XcVKcLCvQ5ggM2P+n+M+UkFMKs0XLFmZwtE0eL2ZkgUL7iq0vazHcDR5S?= =?us-ascii?Q?9FUmXGh7PSUwzthkS2M2qDHZm6Obyk7ZVjfJLIZp2TaY4E6j16NfD+EoHpg3?= =?us-ascii?Q?xbXlPXM0yQf3VB4FULVSbO2pFfz6IJ2TURscuhFutfn42AGt1VHWHQvcJ5m2?= =?us-ascii?Q?RR2k5gz8gF0Kh+tl6HGQtUASKn7MoR6kkY0PTdC7fdrgJUywRBUO+KgOpBmM?= =?us-ascii?Q?NC/lG2nMHr5MkmDXh5a13DeG6LxaF5uAxP490oNgKF8EIj8AqwXvmCrfxwPI?= =?us-ascii?Q?ZhwWC1s+GvKPZsS7qBAjmk7BmKqqNkAE6vnTILnlHacKv1BrZpgo5ND0RLyU?= =?us-ascii?Q?/wrmW6P85njFD1fZxt8CS0iA9bF0QMIDkcVMYDSi/SSmIE+woyprIY9iLkfO?= =?us-ascii?Q?/ft1TJcdANqGX/lCsXVdaVRgGRuwcB54/yyZ7IfXV3qoU4ZZJiHM+sZgdayL?= =?us-ascii?Q?eR0Fne1pLCobX+Gz7kakX8GialQ+7gJPF9DXXPiioTDQ0+KmOV/cm7HcPMze?= =?us-ascii?Q?kBUQOqM2Dj1/IpTcsNWI3aGSClBXpj08vpFD44NKZZRK6iWwICPLxcc9aT/g?= =?us-ascii?Q?dsCzftpl3tDD61eT4FF3yDzRpUHJIV3JYnoLOP71cwnE5zXUo7VVwmjaBmxn?= =?us-ascii?Q?7GTZEj+wQc/yoEX1DSsSUbUX9wDhsv9JiWmZT8rAXHa/JxMUsFhF2iXxIO/Z?= =?us-ascii?Q?PSJkun97Zpk/QtapwkIdQvfRIVmRh9Sx16NBfVP5V3xCEpywDIdioHOXv81Z?= =?us-ascii?Q?GOawc2xoz6LYTC+fDOa7WC7op3JcDfKYM1iesZvUBxaF3AjkIgqncXVBDeOx?= =?us-ascii?Q?VO9kaAiOtq9oDJzauuaaQemFe6yaRX/W7OjAsgzffx9GygL2hlveWEPuueGe?= =?us-ascii?Q?/Q=3D=3D?= X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: e6ab5f9c-dadd-48d7-a321-08db02a7b49c X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2023 09:52:31.8983 (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: oOIJbnV7XeUDfk2nBj1KEazdmfu1KeLUJ67iD58NJvEhyzPYY/81JzIN1omo7+5AnnERV1CJUfKTveXDDQMUPA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR11MB6025 X-Proofpoint-GUID: NitqZcDEcVqyVu157G339zvIkds4YKmn X-Proofpoint-ORIG-GUID: NitqZcDEcVqyVu157G339zvIkds4YKmn X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-30_09,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxscore=0 lowpriorityscore=0 suspectscore=0 phishscore=0 impostorscore=0 adultscore=0 malwarescore=0 clxscore=1015 mlxlogscore=999 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301300094 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.178.238; envelope-from=prvs=13943e2a21=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, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @windriver.com) X-ZM-MESSAGEID: 1675072484091100005 Content-Type: text/plain; charset="utf-8" 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 --- hw/9pfs/9p-util.h | 16 +++++++++++++--- hw/9pfs/9p-util-win32.c | 5 +++++ hw/9pfs/9p.c | 4 ++-- hw/9pfs/codir.c | 2 +- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index c1c251fbd1..91f70a4c38 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -19,6 +19,10 @@ #define O_PATH_9P_UTIL 0 #endif =20 +/* forward declaration */ +union V9fsFidOpenState; +struct V9fsState; + #if !defined(CONFIG_LINUX) =20 /* @@ -147,6 +151,7 @@ struct dirent *readdir_win32(DIR *pDir); void rewinddir_win32(DIR *pDir); void seekdir_win32(DIR *pDir, long pos); long telldir_win32(DIR *pDir); +off_t qemu_dirent_off_win32(struct V9fsState *s, union V9fsFidOpenState *f= s); #endif =20 static inline void close_preserve_errno(int fd) @@ -220,12 +225,17 @@ ssize_t fremovexattrat_nofollow(int 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, struct V9fsState = *s, + union V9fsFidOpenState *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 } =20 diff --git a/hw/9pfs/9p-util-win32.c b/hw/9pfs/9p-util-win32.c index 5503199300..050c177d0c 100644 --- a/hw/9pfs/9p-util-win32.c +++ b/hw/9pfs/9p-util-win32.c @@ -1273,3 +1273,8 @@ long telldir_win32(DIR *pDir) =20 return (long)stream->offset; } + +off_t qemu_dirent_off_win32(struct V9fsState *s, union V9fsFidOpenState *f= s) +{ + return s->ops->telldir(&s->ctx, 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(V9f= sPDU *pdu, count +=3D len; v9fs_stat_free(&v9stat); v9fs_path_free(&path); - saved_dir_pos =3D qemu_dirent_off(dent); + saved_dir_pos =3D qemu_dirent_off(dent, pdu->s, &fidp->fs); } =20 v9fs_readdir_unlock(&fidp->fs.dir); @@ -2537,7 +2537,7 @@ static int coroutine_fn v9fs_do_readdir(V9fsPDU *pdu,= V9fsFidState *fidp, qid.version =3D 0; } =20 - off =3D qemu_dirent_off(dent); + off =3D qemu_dirent_off(dent, pdu->s, &fidp->fs); v9fs_string_init(&name); v9fs_string_sprintf(&name, "%s", dent->d_name); =20 diff --git a/hw/9pfs/codir.c b/hw/9pfs/codir.c index 7ba63be489..6d96e2d72b 100644 --- a/hw/9pfs/codir.c +++ b/hw/9pfs/codir.c @@ -167,7 +167,7 @@ static int do_readdir_many(V9fsPDU *pdu, V9fsFidState *= fidp, } =20 size +=3D len; - saved_dir_pos =3D qemu_dirent_off(dent); + saved_dir_pos =3D qemu_dirent_off(dent, s, &fidp->fs); } =20 /* restore (last) saved position */ --=20 2.25.1 From nobody Thu Mar 28 13:35:16 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=windriver.com); dmarc=pass(p=none dis=none) header.from=windriver.com ARC-Seal: i=2; a=rsa-sha256; t=1675072448; cv=pass; d=zohomail.com; s=zohoarc; b=Gp++gAZTqqFeZldjksv7SfGU1d3iX+nTsQqK7o1TWFJmf1zVYtzyjqeuvwEtXb/VMsfLcWuSnNYaiCTxbii94AC505+v/Z26UGCL6eMXrxUExctXV2iTETbrVgqJUsf7WGdfERtUDLM9yaw40/FqRUMY7r2AGjzEctdP2YeC9Io= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675072448; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=eID1K2fGtFaSsEv6+j+egSlY1Ky1o6R09v+FidCa4Is=; b=Ty+HuC/LhtR9rEfBf0bUb2/maOU5t36lzqS3x6OB1RBJNe4C/bXRgF+ol4q1j4oSmv4xMRk9j3P0zTV44cHf3HCY3UBj6c6+GZDeeR0FFh+Tzltoib2WHU5T8qo79SmHy9tz6LXM+mjYbIbdU/19hG+nidyevQvyj1W9GP4+9y4= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=windriver.com); dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1675072448815473.2412322535382; Mon, 30 Jan 2023 01:54:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMQqK-00030U-2K; Mon, 30 Jan 2023 04:52:52 -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 1pMQqG-0002yg-Sm for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:52:48 -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 1pMQqE-00020q-Sq for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:52:48 -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 30U9qYwE013139; Mon, 30 Jan 2023 09:52:35 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2169.outbound.protection.outlook.com [104.47.57.169]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3ncrx3a45d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Jan 2023 09:52:35 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by BL1PR11MB6025.namprd11.prod.outlook.com (2603:10b6:208:390::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36; Mon, 30 Jan 2023 09:52:34 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9%2]) with mapi id 15.20.6043.036; Mon, 30 Jan 2023 09:52:34 +0000 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=eID1K2fGtFaSsEv6+j+egSlY1Ky1o6R09v+FidCa4Is=; b=NmwcwkSCbCXBH7YdBHjDD8AbeXnxoz3yhRJGYjb6q1FMUexBX/9CxpMH99tT7qwAJhQR Q/crT8pfUFnqJ+Pfym+NGO4G7asU0MBr52oD7luUerzVQzECgfbpa91DW1IIe2T+paeB 52BbgkELWkOqsI2NiaN9Kf+AbQ/55GQdw9kWJyOc32enkqImk2MEHdvZjH46bF4v8ZB3 0KAvXyt2gaAxF2bjnRAzvYOl75fTAYb/ROWXfMX4ug07riDJ1ZB4sqNuUTwir8byET2I gma3Z4ZPCBLmZxXyj+FNhN+G0EkBvX5dkOaijPkWRaDPwUDzoyOFPYSP0SxvXu4m6Nfi zw== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZgqKD4lb8RDotS2xpOWFqZrDMHRA1MrVP0kjlakew/wXP/son0jYHV5+FKaSMDVpRuttjZTsIuPW5WVKtRgzLidGaEEZXTz02SNSQQ7nIb5ZQgApFWFYnNudYoypnD62i7fT2a7jJAqXx9Z8l3rorfZ7cpOd2dgXcKbDgLlnDG4irM9jHxvYYmmxm2jIgftisZeW+94FHThUattw6J10hnYDgTt4nlRiPx9ijgcpTMXrQGRvaLrqyQhZl1KCUm5hjgqr9dmz41iTWKgzG64RhkWfjH4xpAub9HiTJi/41hj/W8ehbdWmvs8E/ofAQvGZSw51oQVRKuTdtJJAxTPdYA== 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=eID1K2fGtFaSsEv6+j+egSlY1Ky1o6R09v+FidCa4Is=; b=kw/VrfJpy/9n7fJSviRosxr0gk1UFgLkAzMTcQAXmvs+AuLmmlPNro1hfaMsn0xoCzjq6XjVYrpi6Yd0wpQFA2yvwN3Y0q8Mb0Ck+ad7dieY8qxVIhNL6QzDWmkXG6Nn16kVLsN1voi4Sw1a7/1ecp0ilfRDiN9daAlfOvYAqtc98iOlxjM0IrDWfSRn7anSChAwj51YcYhkrwXuou0n3DllwvTEZ2svJxc+hx9afZnutZ0Un38MQgNn6Lsz+JQncQrDGTXBJ+JOmECS6KhzgHhu9TpHckGFJJftI9J3PmSicJv0EoWOOSR1DMW9vi14YATq6joVGp6X6gin23jkKw== 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 From: Bin Meng To: Greg Kurz , Christian Schoenebeck , qemu-devel@nongnu.org Cc: Guohuai Shi Subject: [PATCH v4 07/16] hw/9pfs: Update helper qemu_stat_rdev() Date: Mon, 30 Jan 2023 17:51:53 +0800 Message-Id: <20230130095202.2773186-8-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230130095202.2773186-1-bin.meng@windriver.com> References: <20230130095202.2773186-1-bin.meng@windriver.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BYAPR02CA0061.namprd02.prod.outlook.com (2603:10b6:a03:54::38) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|BL1PR11MB6025:EE_ X-MS-Office365-Filtering-Correlation-Id: bcc51f99-b417-43dc-c79d-08db02a7b5d4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dOOehaQ7j8XLw/PqmdDUqcbmYYwI+OWPJ8ThHuX1WgpMpaXczcr0VlVHO/htQ6AdRh6cmRkQVTyFSTrI3l/e1OLD0+zAZBAaA84bURf1/QzSpZZMiPSNU8+pPZDCV6Gj/IurrGgBYKGCQoA5mSxsLXJ8UGWo192WKFhqgfitlieR4Z4/yB7cwA6L64B5/A7f1w7P1+mt8cfRfL8KqP9Z2nobPRgO2Jh2n517wahHNkD+Io6Je7LpIyWefst2cIFkGXTZ/r00sQR4AmXpalCZN28b/mdFHGzMH/E8HaMyLDBSEeMODVqYA/NnvqWa1Tc/EtiW3eGrSYEeFS+bCaIOuDJquvT1OO8gSOVYPfflLtKF9KtnEnijzz2PT6h2fsqZg8gjOehRwStz2qmKIMpGhDIWK/l9jJP6Aulf8icUkjjPRGcfVuhNu9iJmjm7vttk32nfZKCnG9uXY9cuBXSoB8UAzfPHNYMJ+64Vagr2MD0YqVpQsGyMOK/gcY7O85Cx9s8rfPkZj7B/J+L0k/wtHlLjJq7RkE09DbAyQOdnbHVPTr/E44nl0e0h9Kvy0eoC/6pEb14Ih84Z4uvw38WDoXiXcPYTyUAEz1a4yC14jzNlJpwlIGPnxbXk3+7Ty+ZT2SeUfuedpFG6mtyE/9gyn+P6AfkdFCGahM2CvY++xD5F33xgqvPm2UXxB/VhoV08I0K7YVyYM9ubcBS+v825Mw== 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:(13230025)(4636009)(396003)(136003)(346002)(366004)(376002)(39850400004)(451199018)(2906002)(26005)(6512007)(186003)(478600001)(6666004)(107886003)(6486002)(316002)(110136005)(36756003)(86362001)(38100700002)(38350700002)(41300700001)(8936002)(2616005)(4326008)(66556008)(66476007)(66946007)(8676002)(52116002)(6506007)(1076003)(5660300002)(44832011)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?4FHavViznTQ8MeQvUHwMTo9MBKPCu2I2tCENlnFNAFfMFMA2d1YP3OaIeyTS?= =?us-ascii?Q?4vPzyK4vBduKbPGYy80ecKnr6m1yOhCouVKrBWG8uSRZU9KuMcXrhpcbXpHs?= =?us-ascii?Q?PvQuwTIWBmovT1U/Bm1H5Y82ENzpNGK6c4aDYIqW6T+LolsDXtB7TgjsqiiL?= =?us-ascii?Q?dGumsOGRaX0OJUd1I+hRQx93511Gdao00wikCK+TS2tI0fLJ1NaaVbe5Z/2I?= =?us-ascii?Q?CL0Xh5AXnS3BOXsStr6UXvigQ61W/7zd+R149I/cCx8YwHsP8i/EolX6D2Ey?= =?us-ascii?Q?criunpMaDJmo/2Y9mfPEf5U4wzncsD3RL58owhd0WNJEodugWN0h/iCCYc+B?= =?us-ascii?Q?Sfm1mL0c2G152FQFWIsFSyRxZfOjqVQfsTjw5TljtdjGd03rPWJ7rztShIt1?= =?us-ascii?Q?6jkUg1Sm9XfPwMWaQscWXDUloV72WsEqRn5yqK857gmtTL0Me275Ak0BrPD9?= =?us-ascii?Q?PAlDSNe/TTiK69jXqvO/LLCzHNF1/qtYto5BvVeEW/WRn2tsOQpysSrUF4S3?= =?us-ascii?Q?WNL7pq85E3jG6iv0MJxrTy/DzgLMOhifUO0zA4Ru9zY0CpbrVOvGa7YHO48U?= =?us-ascii?Q?goyzHY/Vr3GgfUK0FDtGZafC6R7Zu/jFIzLgBLlfRXNPmVk8gN8NY2MHQ8k9?= =?us-ascii?Q?zIa8EuUwLoe1hR0mUXIqJQdKnQEJ8R3V+0Y5deCsL2KZGlNDrGND8020tGCD?= =?us-ascii?Q?MQNV+1KbswTWJJ91NW503J/0a/UG0MdXzstmyr+kL+TqMn2I8/IUvEul7UmH?= =?us-ascii?Q?/RDrmm+mjeI/+mXNHP8l7Zu/ee6sZtYRNTTk+5AIBRR+2GcTDnXKjDZT/vsW?= =?us-ascii?Q?K/R6gB9n4QAJk9qLCVlFNc7bXxNmwpn5nWUlOPR3ILyTWUhZOmLhWGsIVPis?= =?us-ascii?Q?yvKi40tVSUKFqugBH6qoBYmnwA9TQTb7hOPHmPpGdnmlhayi8dwYMxglMnit?= =?us-ascii?Q?QuIuvpVnbnww/c1tr0a/yyhoNhPKgDQCeN0AU1oADsfn3M0yq8xe4vhtZ3se?= =?us-ascii?Q?lVrotugsVuKEWVZIWKgPG4kptq3u9mU8UB82GAl43ZsAJ7NMG1pVsB1W6PM5?= =?us-ascii?Q?TGURZJmjzeMUUUDpvYiUijPRs6rKuuj1Mb6rv5/Vo5cgc+612UzvWQSu0/Ze?= =?us-ascii?Q?jhm4cmh+2THQEVkqPNlhTZDTvvsbkESa/5l+aF8A639q1DewrZEvGMItA9Pq?= =?us-ascii?Q?NO5c4WRo5TqMPXWFXqnEAtPahKBdS7+924SOTr8L8AYthNTxngJE9QJz+Y42?= =?us-ascii?Q?A4f5Kj4HKw54wpvdBs9M22kWm4E9+puTMRdjROR7g7Op6AjVUTRUm/tfat2a?= =?us-ascii?Q?nlyHYMPXyiiEQLZ2lrl8U0lvfxSMnMgnaeFwv0HKAR0LxHaMv5LtfJ1xasy8?= =?us-ascii?Q?zoUMhu4zqYUV+oJaiSTO0XIufyWduXWKqPyfZ3TqnHFU7zWzhOVMTjBff/1N?= =?us-ascii?Q?Gcdk3J6jGg1fTNsIrbXXq1Li42vSAR9E+fKrnL5Zlf9YCBNEvdPA4EGLf+bl?= =?us-ascii?Q?7YBPJUYeIhe2A/0tTb43CWjjda0QRSI7CZY6plt+BVfFJOHrXX527L+JDXLB?= =?us-ascii?Q?JZAGjO4Xg9dzBqq6jDuRrqEl9R6EfE1Vii/7HHMNEZF4p3nMDTz4vdnCoPXS?= =?us-ascii?Q?jQ=3D=3D?= X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: bcc51f99-b417-43dc-c79d-08db02a7b5d4 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2023 09:52:33.9595 (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: 2+ktV4laJPx16UpgqoPVFFXey9Ku+XPx9eMODxkjGFV/dbXNUChbUj515RWEyWh6Z84uxCxs8xjDOar/GaThzQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR11MB6025 X-Proofpoint-GUID: L267bUFytw2q0ycZd7-4OyqZqBROfD5c X-Proofpoint-ORIG-GUID: L267bUFytw2q0ycZd7-4OyqZqBROfD5c X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-30_09,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxscore=0 lowpriorityscore=0 suspectscore=0 phishscore=0 impostorscore=0 adultscore=0 malwarescore=0 clxscore=1015 mlxlogscore=999 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301300094 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.178.238; envelope-from=prvs=13943e2a21=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, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @windriver.com) X-ZM-MESSAGEID: 1675072449922100005 Content-Type: text/plain; charset="utf-8" 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. Co-developed-by: Guohuai Shi Signed-off-by: Bin Meng --- hw/9pfs/9p-util.h | 22 +++++++++++++++++++--- hw/9pfs/9p-util-win32.c | 18 ++++++++++++++++++ hw/9pfs/9p.c | 5 +++-- 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index 91f70a4c38..1fb54d0b97 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -22,8 +22,9 @@ /* forward declaration */ union V9fsFidOpenState; struct V9fsState; +struct FsContext; =20 -#if !defined(CONFIG_LINUX) +#ifdef CONFIG_DARWIN =20 /* * Generates a Linux device number (a.k.a. dev_t) for given device major @@ -55,10 +56,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 } =20 @@ -152,6 +155,7 @@ void rewinddir_win32(DIR *pDir); void seekdir_win32(DIR *pDir, long pos); long telldir_win32(DIR *pDir); off_t qemu_dirent_off_win32(struct V9fsState *s, union V9fsFidOpenState *f= s); +uint64_t qemu_stat_rdev_win32(struct FsContext *fs_ctx); #endif =20 static inline void close_preserve_errno(int fd) @@ -269,6 +273,18 @@ static inline struct dirent *qemu_dirent_dup(struct di= rent *dent) return g_memdup(dent, sz); } =20 +static inline uint64_t qemu_stat_rdev(const struct stat *stbuf, + struct FsContext *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 050c177d0c..5f6d43b62c 100644 --- a/hw/9pfs/9p-util-win32.c +++ b/hw/9pfs/9p-util-win32.c @@ -1278,3 +1278,21 @@ off_t qemu_dirent_off_win32(struct V9fsState *s, uni= on V9fsFidOpenState *fs) { return s->ops->telldir(&s->ctx, fs); } + +uint64_t qemu_stat_rdev_win32(struct FsContext *fs_ctx) +{ + uint64_t rdev =3D 0; + LocalData *data =3D 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:\") + */ + if (data) { + memcpy(&rdev, data->root_path, 3); + } + + return rdev; +} diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index be247eeb30..36916fe581 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); @@ -1346,7 +1347,7 @@ static int stat_to_v9stat_dotl(V9fsPDU *pdu, const st= ruct stat *stbuf, v9lstat->st_nlink =3D stbuf->st_nlink; v9lstat->st_uid =3D stbuf->st_uid; v9lstat->st_gid =3D stbuf->st_gid; - v9lstat->st_rdev =3D host_dev_to_dotl_dev(stbuf->st_rdev); + v9lstat->st_rdev =3D host_dev_to_dotl_dev(rdev); v9lstat->st_size =3D stbuf->st_size; v9lstat->st_blksize =3D stat_to_iounit(pdu, stbuf); v9lstat->st_blocks =3D stbuf->st_blocks; --=20 2.25.1 From nobody Thu Mar 28 13:35:16 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=windriver.com); dmarc=pass(p=none dis=none) header.from=windriver.com ARC-Seal: i=2; a=rsa-sha256; t=1675072454; cv=pass; d=zohomail.com; s=zohoarc; b=U9WOEldFE+9Qqm3Uh8gEf0L0tH7GuLGLW0ZY7iCPl7fhAdHUSTaknXKLYOEN9krxViaHDTUuaI70bWHEkymqoU/N5clb6kLDesX57ofxNDbLuFE7pK4DpYTFxnLWvOQwdGPKvVbnUE4ax8z4UIdYifbR7817PppUUU+oe3OFvq0= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675072454; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PkUIwXcPmGDDh7XO6a8+bxOq5aULYYoUZNE5Gf50AF8=; b=X1fMtQe7fJ400xRSGqBWAaszzeaAMuVoY2SACzI+Ab9Hhl9BG4uEZyQE/kjMNoNtbaO5HchSrPTcQ8uUrKmS35mSZ/o2/i2L+L9ETrqa5e6I6sDxICqe6x2YZmhAB1zA5u+M++0F+HV41qPi+666rXsDCH0KexaSsRfv2rL/BXU= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=windriver.com); dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1675072454478759.3783177913405; Mon, 30 Jan 2023 01:54:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMQqI-0002zg-JI; Mon, 30 Jan 2023 04:52:50 -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 1pMQqH-0002yo-2K for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:52:49 -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 1pMQqE-00020r-VC for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:52:48 -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 30U7ovuD022584; Mon, 30 Jan 2023 09:52:37 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2175.outbound.protection.outlook.com [104.47.57.175]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3ncrx3a45e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Jan 2023 09:52:37 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by BL1PR11MB6025.namprd11.prod.outlook.com (2603:10b6:208:390::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36; Mon, 30 Jan 2023 09:52:36 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9%2]) with mapi id 15.20.6043.036; Mon, 30 Jan 2023 09:52:36 +0000 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=PkUIwXcPmGDDh7XO6a8+bxOq5aULYYoUZNE5Gf50AF8=; b=BmWEcPi55uUm6ZAfe3tEK0oBx9MSW2HOIyNhnAHRVLBjfl7Ctaz8bOVVU5Rw39pj61Mg LcPNzVYXSg3KzdBRJxYCXKxXgxRl0IMyHtvV+mddkWnqkylWEcDmW3ROrFBDmcHlBWlM 0eXMnKc6Wk4s12umUi0eI3VlP6wMQ3PPUDxCxXWnXFaJ/avhILUoIqEI8ZZsbssNNX+v x+RMBD+6AfmHTf5ZjGJwp3jb89nJoEGj7sSRnJ9khKOZLPDUuZch1jw47DJlLoy1YUPS NYAjhzgebfaABqarWVEbLEEvKVTq7MbRUt+altsyqMTFjAdrUx5aGpEugN2RBJoE3ein RQ== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YPgoa7wumEAJ6QkqifYT1bP8zS2mJpW54xbfr/dOz5uCGvFZYzjt3sNamtewQBXQadue1Ro/wMCKjdVT0i0EB2dh2+up9ZMdjb+Fh8/IwCL9uyNzqrmF80rnIy0fZk+5jWA4UjHRuijt6HCLy70ldmn+kl/UWenl6ppgXieWWNj6PtTQc5XAQzHaT8/LMsLyf3EriyU0HRA9gzfJ/Wih5mHdnZ/Zjf0osEYjr0LaaWd4okTB8h31pNI/BbtfOu2rttE0+jX0Pbs/fEzOF8XD5TUjOauq3FX2mlfKegr6tN6iMiCMpsAj2HbuUXc7hbXk68CefwZ/CixjjPNWVl3gTg== 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=PkUIwXcPmGDDh7XO6a8+bxOq5aULYYoUZNE5Gf50AF8=; b=Kytiygs7t5d7YVYU4MXnZ8vIysI7tzq7Z1LqgbBKDwMzrXdM2YhY6VgocJmmuiV4z4FIEukHuKAQ7Crjx3jZ9Eqfq2OkOtgpf0sXWLh2YfMXkBo3L1YUCL1Fa9iD5Ye7dAV6pHGvC/v8REi1zqXmzDpcxDihBj0WFIYhdXmZE0g9KPwcs8OX9AhaSQDIftg9hmju18Ab6hNsz5Bx7GU6KJoMpsKcpqcVpJCBvONdFfBl5u6Ug8kZ07VWA5dNWyxnHLzkb2sXLbPTGRwFA8jLu9J4dOzCcFvex6HBGYnLNNcWlJO9VAEGmpSa8zB7PMtnQfqR4v1YQk67x5TSrgbtgg== 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 From: Bin Meng To: Greg Kurz , Christian Schoenebeck , qemu-devel@nongnu.org Cc: Guohuai Shi Subject: [PATCH v4 08/16] hw/9pfs: Add a helper qemu_stat_blksize() Date: Mon, 30 Jan 2023 17:51:54 +0800 Message-Id: <20230130095202.2773186-9-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230130095202.2773186-1-bin.meng@windriver.com> References: <20230130095202.2773186-1-bin.meng@windriver.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BYAPR02CA0061.namprd02.prod.outlook.com (2603:10b6:a03:54::38) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|BL1PR11MB6025:EE_ X-MS-Office365-Filtering-Correlation-Id: d8d086af-92a7-46a1-9677-08db02a7b70d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: p1kV7PJBC5i27NYqDPWgWdbEGZgMRoFACgyjxCAxYeAceAsvd+e32omz/NeCOOi8CINpRY7njHeUpFBk6f45RMund10VNF7NJ4V7RwodXHy5cYlmD9HLFEyMhD2zxu2TlL9Win3Ju6adjmxMqxZPYbEzxai4ph5i6lvex5azXzA+eeISedfhCGMwmM0xSBpyJy+hvQAbwF/G1m6e/kEbgKIX5fRWSyTMRE/GLNrde6zytOAotNMrf9zPSSnSMDisbAYYNZWSxzYofDCQOzOSPHnonjhnsYN9x/RiUXigFU94cYmZxPymn/nv/ESrabmHwRYXYuLibK3i9/WZ5WKMQfuhmP5CLIa2Zx7C1CpAPZXCifYqSn/h9on47fjQhdAqmf1litoItrRhwmf9GZ034xmixdAfjAnIwjmqmMJkwcrQK8wL5CIjJ3LAuEIh/M6pUv7q+49p8+3gFMd5d+yNc6NqX21iuhQnuWfIhOXZ0uWkkyH/fo2E4w7a31lEAVSwLIQP9pbYRT90az5TEtJ92h+xqKQ0v/bC/OMwq68qn5gVmJE+sr89Hz+n41PMpYvQvwF5XJ82PzABAYX/F4l2w7SXzxOHoxw8KyS7DWdp9pitYLAlmH6BCFLXW0My6PWMD26m4BvX7FZWF8BGH3ICKz5HT27r8TW+nuI1LgDkWhZcdtBcLQqUl420LHuQPsZegrUNf8OMwZqSQBicvivXgw== 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:(13230025)(4636009)(396003)(136003)(346002)(366004)(376002)(39850400004)(451199018)(2906002)(26005)(6512007)(186003)(478600001)(6666004)(107886003)(6486002)(316002)(110136005)(36756003)(86362001)(38100700002)(38350700002)(41300700001)(8936002)(2616005)(4326008)(66556008)(66476007)(66946007)(8676002)(52116002)(6506007)(1076003)(5660300002)(44832011)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?pOlvmteUV7ci7kQJpFUSG9zTPM7hXCKx8XIVNIqoL0d0cqEc3LtXncVLbpFF?= =?us-ascii?Q?CLGy1vSxYeM3KLOAaJHkxqEbNkA3rXpnPNUmO7lwRY+KHw+6a5/IJRJzbCnZ?= =?us-ascii?Q?ZL9hyson7j0etdHcUTYHLK2uNCh0ZWAalsbHv7jzISvhAfREVTqHnij746kL?= =?us-ascii?Q?C9iCyhQW3/4QQU+w6ZZAxuIOVZUF/Vkx56BzHLRS0srg/nVzzyOXhBzRXtrN?= =?us-ascii?Q?CVnIhJOI9D0y1CQ94fOYi/uzecn2k8QaKI42OVj3knrR49TIIlv++7AYkgdV?= =?us-ascii?Q?/VH1qOGMfisCgjpX+HuRC3Oy/hN37BOnaymWoV2QPt+gi6ironsQ4oa6cA48?= =?us-ascii?Q?BqSQnDgYw0Gu2TQd/7lPE/aIPBY5rRVg/t3xZlr6mS5N8nnYwoTg1n/0Z00V?= =?us-ascii?Q?wIGry+LOPF/rJEXs+iAPGnRPPRhpuV665Zpx8p+WKpRwHLZnw152IUzWw3V1?= =?us-ascii?Q?VjwxtQPeBXIZasYuE8xE67+/O+S0dGOm78wpUhM9rDcyQL0uupqnFpNh4J8z?= =?us-ascii?Q?Mg8XgOZjcIDqrDk3FCp5FoVUPBpuxmxQ3I00Ld9KqHqAt5AYSNYgJMKfFUT4?= =?us-ascii?Q?Ixu1E2YwMKcMWiZPjnoFf30khkyESCT2I00QTtsmphNgFQNacXwig/6jsB9H?= =?us-ascii?Q?iM3V9FI8k1H86p8HLBKGNej0NJOHDcTwAExIkkMeqSbHw8quMEgkKIdO8Qu5?= =?us-ascii?Q?u5LQ760rzBwu7/1Xw13aXYwdQ6d6qfgtUE0rGWZqByLoyj20cp5/k44eGpYT?= =?us-ascii?Q?UgmN/fi2vHGoI8HrqUvyZ1APu5JTJkklmroSxHlxrfv0sWINXYrsIoY1uJue?= =?us-ascii?Q?HqIiVLQ9M49ISv000JaoygHmN8laOrxT8xjTwnFPjFMNS37V392lYgpqOZN2?= =?us-ascii?Q?qNaMUQnneDGF8JIrSoVlJSFFmDRztczX3k/+ijGjnfZrRn2uruubbzGojRBW?= =?us-ascii?Q?HitJoxnP46qM1Jqu3tMYq2RK2pgK98EslnE0KjdpxB5NfBMxH80FcqkNBR+O?= =?us-ascii?Q?IaOItKuUNWirzqs7RH8oH2wzVJDFPuEZD85+wiMPobWQOqrSTJNQlgWjq2i6?= =?us-ascii?Q?f/rqSh4X1WXgCkq2WdKOywEMW/dSyd7vVGmVVhnfJ86jUeR7bIbV8UXWG31T?= =?us-ascii?Q?qdDbRbN5+YRdO/c+AyGz/EYRq/5SLXva5TlsivIwtC/Shqkf0b/oGDA67D/2?= =?us-ascii?Q?3phzNhA1xA82aUHDcB+6VKlSvmUrr4lnWNIcBLQyTbVD1+B4X0tKPya3cpGJ?= =?us-ascii?Q?ivXxks2A4p1YNbz41Eg8iE+1JLthct3vkvkOrvdjAINUSIO89FY9LXTMtBiA?= =?us-ascii?Q?wHRjoDlUFdQiZdmXyCLHHQ+UkEutqfKoPulzMF/UMLYnig3jqXQqXGYH+dCj?= =?us-ascii?Q?+ot15zrx4JUKnsCkExd4jwVyOGvfFUYyNdNl6G9MwmC9VcaLPZN9GmmT5BrA?= =?us-ascii?Q?uzh3+6+EUuMdHfgVf9cr6YZQgp9yIQrX7w/E74sU6JO8Q3yQC8Ogiy6UHzrB?= =?us-ascii?Q?bTYb0e5+BwgAuEAIEpws0Ah0FusmbQbMu9RUnxfsu6GHepEtVDYHfLkzJAT3?= =?us-ascii?Q?ox1y7N9AQ6zMJzIPL5bBZ78I+3kuP1PXiKqqK4TTwvrSmWNviZjUBNidjLOq?= =?us-ascii?Q?vA=3D=3D?= X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: d8d086af-92a7-46a1-9677-08db02a7b70d X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2023 09:52:35.9784 (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: 3zMoEnRd7KlZiJ9IoAOXi/29THNQnGPTxPJZH8yWL37f66hZx6/FEwHxVgtdzoYMW94/aVIUo8IQj2mVbVfinA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR11MB6025 X-Proofpoint-GUID: cqhlAtBoy9gwQ7IkqNGMvBUQpg6rTDfY X-Proofpoint-ORIG-GUID: cqhlAtBoy9gwQ7IkqNGMvBUQpg6rTDfY X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-30_09,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxscore=0 lowpriorityscore=0 suspectscore=0 phishscore=0 impostorscore=0 adultscore=0 malwarescore=0 clxscore=1015 mlxlogscore=999 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301300094 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.178.238; envelope-from=prvs=13943e2a21=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, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @windriver.com) X-ZM-MESSAGEID: 1675072455955100002 Content-Type: text/plain; charset="utf-8" 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 --- hw/9pfs/9p-util.h | 13 +++++++++++++ hw/9pfs/9p-util-win32.c | 7 +++++++ hw/9pfs/9p.c | 13 ++++++++++++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index 1fb54d0b97..ea8c116059 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -156,6 +156,7 @@ void seekdir_win32(DIR *pDir, long pos); long telldir_win32(DIR *pDir); off_t qemu_dirent_off_win32(struct V9fsState *s, union V9fsFidOpenState *f= s); uint64_t qemu_stat_rdev_win32(struct FsContext *fs_ctx); +uint64_t qemu_stat_blksize_win32(struct FsContext *fs_ctx); #endif =20 static inline void close_preserve_errno(int fd) @@ -285,6 +286,18 @@ static inline uint64_t qemu_stat_rdev(const struct sta= t *stbuf, #endif } =20 +static inline uint64_t qemu_stat_blksize(const struct stat *stbuf, + struct FsContext *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 5f6d43b62c..5ece1db7aa 100644 --- a/hw/9pfs/9p-util-win32.c +++ b/hw/9pfs/9p-util-win32.c @@ -1296,3 +1296,10 @@ uint64_t qemu_stat_rdev_win32(struct FsContext *fs_c= tx) =20 return rdev; } + +uint64_t qemu_stat_blksize_win32(struct FsContext *fs_ctx) +{ + LocalData *data =3D fs_ctx->private; + + return data ? (uint64_t)data->block_size : 0; +} diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 36916fe581..def85a57fa 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -1335,12 +1335,14 @@ static int32_t blksize_to_iounit(const V9fsPDU *pdu= , int32_t blksize) =20 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)); } =20 static int stat_to_v9stat_dotl(V9fsPDU *pdu, const struct stat *stbuf, V9fsStatDotl *v9lstat) { + dev_t rdev =3D qemu_stat_rdev(stbuf, &pdu->s->ctx); + memset(v9lstat, 0, sizeof(*v9lstat)); =20 v9lstat->st_mode =3D stbuf->st_mode; @@ -1350,7 +1352,16 @@ static int stat_to_v9stat_dotl(V9fsPDU *pdu, const s= truct stat *stbuf, v9lstat->st_rdev =3D host_dev_to_dotl_dev(rdev); v9lstat->st_size =3D stbuf->st_size; v9lstat->st_blksize =3D stat_to_iounit(pdu, stbuf); +#if defined(CONFIG_LINUX) || defined(CONFIG_DARWIN) v9lstat->st_blocks =3D stbuf->st_blocks; +#elif defined(CONFIG_WIN32) + if (v9lstat->st_blksize =3D=3D 0) { + v9lstat->st_blocks =3D 0; + } else { + v9lstat->st_blocks =3D ROUND_UP(v9lstat->st_size / v9lstat->st_blk= size, + v9lstat->st_blksize); + } +#endif v9lstat->st_atime_sec =3D stbuf->st_atime; v9lstat->st_mtime_sec =3D stbuf->st_mtime; v9lstat->st_ctime_sec =3D stbuf->st_ctime; --=20 2.25.1 From nobody Thu Mar 28 13:35:16 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=windriver.com); dmarc=pass(p=none dis=none) header.from=windriver.com ARC-Seal: i=2; a=rsa-sha256; t=1675072411; cv=pass; d=zohomail.com; s=zohoarc; b=jGSFrppeeAnuPciLF0IUT1sgTB2iDZFZyFN8rPCXFBd9sQMY2mYKFq5mCXX7riuJ6cqE2oyb1JkCeiWxKQZtdU7ZUPoXgvuENRdTaKC9Od/QxXEtvANy1H/uk03B+JYjXyetmMrwyrY6Be0S49o6uPEZyz76YZKIIOk3CnSa0b0= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675072411; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jquWjOk/2bQifIb1iccPzCgXb9Qy8aYd7A+unbyQWmY=; b=TryCdy2LQsA6c0v0U3Ozc7b9Mekj54SYuhYx/zV37I6xsDCYdfLu1ha1J0rz8/fxieCFUfN/pfSFV1coS+vkjNq38Cay0kJqCIoBuhpF9Dtjlj/O9LB1M1gyxoSLwZTF67nfy3pcyd7YjHPut4XreALbwChpcg7lczxwqYjmA2E= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=windriver.com); dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 167507241177266.31809901443467; Mon, 30 Jan 2023 01:53:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMQqM-00032W-0o; Mon, 30 Jan 2023 04:52:54 -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 1pMQqK-00030z-NT for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:52:52 -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 1pMQqI-00021i-Qg for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:52:52 -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 30U7wgu9004336; Mon, 30 Jan 2023 09:52:40 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2175.outbound.protection.outlook.com [104.47.57.175]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3ncrx3a45g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Jan 2023 09:52:39 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by BL1PR11MB6025.namprd11.prod.outlook.com (2603:10b6:208:390::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36; Mon, 30 Jan 2023 09:52:38 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9%2]) with mapi id 15.20.6043.036; Mon, 30 Jan 2023 09:52:38 +0000 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=jquWjOk/2bQifIb1iccPzCgXb9Qy8aYd7A+unbyQWmY=; b=d0ru7RA8OeFEhfoxd9fGkUK0JhWt7aEB5Hfr+af5IseNU1z6EQfSt2L5giaFzPFqYaoV /e0g4kV2rmHTlQAOc/3IHzeeD7LRfo4CF15+DvC0YaZ9Zr4pQ3IsQ3Dv56vP+tc+KFR0 +rurggc/KBr4mzmlZSGAZDA6C/yWr+y1rzNAqgC/axkpVFKrWAMZPKVeDmpN7XMxRJrL TuyMYYQ1Bgp+KT/5x6S4y+6nY5ddtW7cEXtHZXR3wTD5eQr4m9PpO+5u25xAFSWLbu4I Cq/0i7b8aG5AE9SA78PgITBa/BiNbOvC9uoXtVwUkJKd/p2vEtn6+Q5fA2ngIXv9LpJU Xg== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k5UsWgzCExT5Vf3FfDXQI4X37LOsMw4jTxlTLYYvPJnz2VscTuHzIKUsLpKdP1zKmBKlxFazrczT5oV6VMegl80QmUgx1IZ7J8ofmoVumznwpBM8+nnItqsG7BhzNBF6MyWIkoCfIIq6CnTulik088bEaKoP8wLFC7m/7xWD94b3p7Bqey2ZzomUOq9kcAubbna1wlfoMlMEjbN+58ravyl7eyR7/lqeEZtwDoJSbqlB0D4lxgUMFNRSgMKVh8tSGcDjoodhoUpNLubc6yVi+3QZpDG+ss0SSqm3PNhceStel8G4c9mlc+E/KJuxDMfGfq5pBwcUJo/JT9uX7I8hAg== 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=jquWjOk/2bQifIb1iccPzCgXb9Qy8aYd7A+unbyQWmY=; b=M7ByR1u7FLqyw1pZYzc1PQCRZgWSyBRSWML6wgfi4jvDhEDnVaWj9FzIvvh2t2UZuXqaqn2xFBdPmM13Z4vOsXFCvld0/dNscMYABq0Ij0kK++9mJTJ9l8gOvIsCqKIxuxgY70Y8yXfSVnh7ttlUCmc64LwhWJoLIu0cxZsvcUlMxi4mtZlDl42OEwIn39quPO6qVkM1QN6p0t1jCE1e/7E5UYIv6AxVPneTv5TjDLcOHPUe6gfh0yD7/y5txh7oBy8cZqLmUzCC76yycu7G4fCixo2X0Z1utqK+4/wamJ3tYwLcFkoYzVjjEIpln4uZWfuhpKsobJK4zFSXPcvjxw== 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 From: Bin Meng To: Greg Kurz , Christian Schoenebeck , qemu-devel@nongnu.org Cc: Guohuai Shi Subject: [PATCH v4 09/16] hw/9pfs: Disable unsupported flags and features for Windows Date: Mon, 30 Jan 2023 17:51:55 +0800 Message-Id: <20230130095202.2773186-10-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230130095202.2773186-1-bin.meng@windriver.com> References: <20230130095202.2773186-1-bin.meng@windriver.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BYAPR02CA0061.namprd02.prod.outlook.com (2603:10b6:a03:54::38) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|BL1PR11MB6025:EE_ X-MS-Office365-Filtering-Correlation-Id: 8268ed78-b6f5-4871-aea7-08db02a7b843 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9FwD9m+i3gDmB852P6jqc6dftgdIq9+Yj/svVb0fk9tvg1BUsYLjOdqTZB/ybdSBn42BMYOuoRHFaOwwmaF8dYlH5+DBjPcZpIK7DIR6CVhN+ksGWkey0VeqFkV3KQlv4sk88pUp2GMu0wuJHeiKdlO88YDQ9iwjKs9oSo2xjF+xTRYxuNmzxItJ/ekfKw8gnTpOT/6oh3DleFd+XKFxlLOKqdVMe4k/M7soNeHaaIEZPnMDPJfhU+I2ZSlKu/sPeg4ahQRtmH7VE1HNvyNpViEUC/JfpnODIm7/W/4OmYBjEVrqPW1wiJGubEt0gPV+fFgVSTKyKVgGrP/JYJcIsctMbu43ST9S6RDdNSv19DKfSY+CrYQNOB9rTKXpL7aCDYkW0hCzIOGAtuwZlLtT3ID5n5Z91Dx6zOozRUAM0kfczf8OJPA27BFaYqw/he2JanQ7GU3380EJqjXO8+aV14P3spzia+oKoFdgfG1+pS+YLYGb2EzfpGi5Grh0IYXvVqNcstWOKyIYFaoKG0u7r2spcVZlGtK98mc+wiO7VgLwQfvMSXZyXjY39/OwHSqvQ5wuvzYmoqcUlhMDx6RYZd1R/FRPIEpsbI1R/d7sI9+YOfqUcfKhlW44/C2vkHCfwKbZ2BII2FD5oO2mC2bgpFa1l5ctznM866gpYf1lxM29Mhfj8d7pftG8xsjxQx1IXV9lczt9QXMRVkxaGa3VxQ== 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:(13230025)(4636009)(396003)(136003)(346002)(366004)(376002)(39850400004)(451199018)(2906002)(26005)(6512007)(186003)(478600001)(6666004)(107886003)(6486002)(316002)(110136005)(36756003)(86362001)(38100700002)(38350700002)(41300700001)(8936002)(2616005)(4326008)(66556008)(66476007)(66946007)(8676002)(52116002)(6506007)(1076003)(5660300002)(44832011)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?d0rd3MuLvK7nta4ven3WxKwnCtGlvSNpAvCfx5KTUJUheZ0y8f3p2O42dPcv?= =?us-ascii?Q?OCIGsEEYYo5VDPjS8ErkVGRrRm3en/6ndeJnPIVV1g9rqPYNHpIbKOJ9nLxh?= =?us-ascii?Q?Vj0NxzC0nS+ZsxdWxdWGbW8qH/yPaIrHgijRJaHfzq2FO1RKBDvYBCmAci+2?= =?us-ascii?Q?P3ia4adtmvVfgsySf4g+pl4hXHqr9RsRMAwJ43BJsz0NwO06UCy+S6qQJyVk?= =?us-ascii?Q?2V5qfNm/+3lDp3RI9BibxJj4WuYlBl/5Fm4krnqbTvxFD7vKiz3SR/rskVsx?= =?us-ascii?Q?lwbM58nTbyDDh6HIMb2zTctU+KFugDIBVYjpZBvUmgcIAXRISi47lnOPEuop?= =?us-ascii?Q?kicWPDKHjVXYKjlCFUTN53Z24MrSiJ7bdJ617XdKXgM0tO52OWEBdtu0g59m?= =?us-ascii?Q?Ur5kC50ZXk85TSZoQzvU1QPNoT65GcDgYLuioSOFFiACU1pwSsCMocd2kLkf?= =?us-ascii?Q?idtAN2tq0Ezn7EnnWXdjQq5nVYLloujYNYI61Zy3r7AfcGive44cNDryDF4r?= =?us-ascii?Q?7PhMFe62u1hdY8eeRiEeMnXbX6+afM9j860Qp+oBf9oGFq/W6bkXJEegziRQ?= =?us-ascii?Q?KhSf+ZpiMsyEEfBRKu+8ZV0tkgu9UQinSLLWXRlQFTOTymTlhpH5COJpc/oZ?= =?us-ascii?Q?qXOti9pWSQfSuWuPV3h2Ka4IaFN2aNNv6+C/LTQZCs65qdyyX2Bt8YNiecHJ?= =?us-ascii?Q?zb4PIxNl+zvKn5NHQYsQULrysctrfP9STRgIb9QAlzlDSUqKZs/3gKZ6/o/h?= =?us-ascii?Q?cyBvAY2pIPyTcjqjVI495BVIWwbu559/9mAC0PmXdR+5iJJh1lTXQtRBoyA+?= =?us-ascii?Q?8jCSlByTCk5NNEbJC+kER7vCTzAaKXqHgzzSu+1LH6UJa515O5UaCDn8ZYQ7?= =?us-ascii?Q?0AVgtY51yMAKzZOzCtsxcTmz0P4OjeVbHoXBJ1ToWJMlq5hS7ZjM4FAAFO8D?= =?us-ascii?Q?s9jyBB94lHSjYxHTcH7e1F667vt0MlfjU2LpJAQxBf/1gRFRFzia2e+yBowt?= =?us-ascii?Q?34G43V9Hz8SRGvFXZcyLUS+/0WmDQYodVMmtcFQWu1gELDu1a+JfXC37E9nE?= =?us-ascii?Q?uPfEc94VkjIlbpn2wBUhc2l2v3l9VHv9i1xocfch+DUg0VuCBcqZjGDYkf/n?= =?us-ascii?Q?ljAq5a8/doDvrlzthOmv3Jiy/W1Ak+Ii1/En01eAqQN1qViyC4xpWbURASvI?= =?us-ascii?Q?ukdcAO+c+Z9MIY62mp39JRpqsO4aJ0KmFzpbmWtQ041AzVznJfBHCbXuG2V2?= =?us-ascii?Q?+VA8S8hAsB5cSgOhstXGWjnpSeFF1ER71eA9K9Rm2D0eEcBgDi3YE642HMeE?= =?us-ascii?Q?hv6fwM8PWHj3AykWVmcrB4YAwJSO/Sztp5ec1+gz0w0tFyfzhyCtry4wWT0o?= =?us-ascii?Q?ZrkwjOq9ZRbLVIlHr+DC7k++OXWh/caeqQPbuedBe6PiC3mibcju5xO9HYTw?= =?us-ascii?Q?Yz+cz/kBSCgTr+SBSHQfuYrUaPg2UdFk3kBsKzoSlxV6LSqc9t+SUD4GTDo2?= =?us-ascii?Q?t0rSXPUZtcCKlFDlC1gk11yVjEHvtdPTNulV/uHKwDrC1kcbX6fpPZ1V6sMq?= =?us-ascii?Q?lPTEGCVB2kSEEVG5zeT2ehM7VDM++Br+hFfTwX0TlcObs7bs8bpK5+5Bd9xr?= =?us-ascii?Q?ow=3D=3D?= X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8268ed78-b6f5-4871-aea7-08db02a7b843 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2023 09:52:38.2275 (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: vx/KTqeWVAyM/nnTGfLyS3pj8gYAElq7c4gWaQFDxq4bjnv7ic5HVXcSz7a1H63EhBOjF3a4Jj9yEvYwnGhzng== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR11MB6025 X-Proofpoint-GUID: 2Rb3cs8tQPYnRWFhRnfCBnhdluKZDKDa X-Proofpoint-ORIG-GUID: 2Rb3cs8tQPYnRWFhRnfCBnhdluKZDKDa X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-30_09,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxscore=0 lowpriorityscore=0 suspectscore=0 phishscore=0 impostorscore=0 adultscore=0 malwarescore=0 clxscore=1015 mlxlogscore=999 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301300094 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.178.238; envelope-from=prvs=13943e2a21=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, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @windriver.com) X-ZM-MESSAGEID: 1675072414267100005 Content-Type: text/plain; charset="utf-8" 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 --- 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 def85a57fa..2497a06f43 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -39,6 +39,11 @@ #include "qemu/xxhash.h" #include =20 +#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[] =3D { { 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 }; =20 for (i =3D 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 =3D dotl_to_open_flags(oflags); - flags &=3D ~(O_NOCTTY | O_ASYNC | O_CREAT); -#ifndef CONFIG_DARWIN + flags &=3D ~(O_CREAT); +#ifndef CONFIG_WIN32 + flags &=3D ~(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, V9fsStr= ing *extension) if (mode & P9_STAT_MODE_SYMLINK) { ret |=3D S_IFLNK; } +#ifndef CONFIG_WIN32 if (mode & P9_STAT_MODE_SOCKET) { ret |=3D S_IFSOCK; } if (mode & P9_STAT_MODE_NAMED_PIPE) { ret |=3D S_IFIFO; } +#endif if (mode & P9_STAT_MODE_DEVICE) { if (extension->size && extension->data[0] =3D=3D 'c') { ret |=3D S_IFCHR; @@ -1203,6 +1219,7 @@ static uint32_t stat_to_v9mode(const struct stat *stb= uf) mode |=3D P9_STAT_MODE_SYMLINK; } =20 +#ifndef CONFIG_WIN32 if (S_ISSOCK(stbuf->st_mode)) { mode |=3D P9_STAT_MODE_SOCKET; } @@ -1210,6 +1227,7 @@ static uint32_t stat_to_v9mode(const struct stat *stb= uf) if (S_ISFIFO(stbuf->st_mode)) { mode |=3D P9_STAT_MODE_NAMED_PIPE; } +#endif =20 if (S_ISBLK(stbuf->st_mode) || S_ISCHR(stbuf->st_mode)) { mode |=3D P9_STAT_MODE_DEVICE; @@ -1369,7 +1387,8 @@ static int stat_to_v9stat_dotl(V9fsPDU *pdu, const st= ruct stat *stbuf, v9lstat->st_atime_nsec =3D stbuf->st_atimespec.tv_nsec; v9lstat->st_mtime_nsec =3D stbuf->st_mtimespec.tv_nsec; v9lstat->st_ctime_nsec =3D stbuf->st_ctimespec.tv_nsec; -#else +#endif +#ifdef CONFIG_LINUX v9lstat->st_atime_nsec =3D stbuf->st_atim.tv_nsec; v9lstat->st_mtime_nsec =3D stbuf->st_mtim.tv_nsec; v9lstat->st_ctime_nsec =3D stbuf->st_ctim.tv_nsec; @@ -2492,6 +2511,7 @@ static int coroutine_fn v9fs_do_readdir(V9fsPDU *pdu,= V9fsFidState *fidp, struct dirent *dent; struct stat *st; struct V9fsDirEnt *entries =3D NULL; + unsigned char d_type =3D 0; =20 /* * inode remapping requires the device id, which in turn might be @@ -2553,10 +2573,13 @@ static int coroutine_fn v9fs_do_readdir(V9fsPDU *pd= u, V9fsFidState *fidp, v9fs_string_init(&name); v9fs_string_sprintf(&name, "%s", dent->d_name); =20 +#ifndef CONFIG_WIN32 + d_type =3D dent->d_type; +#endif /* 11 =3D 7 + 4 (7 =3D start offset, 4 =3D space for storing count= ) */ len =3D pdu_marshal(pdu, 11 + count, "Qqbs", &qid, off, - dent->d_type, &name); + d_type, &name); =20 v9fs_string_free(&name); =20 @@ -2912,8 +2935,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 =3D v9fs_co_mknod(pdu, fidp, &name, fidp->uid, -1, 0, S_IFSOCK | (perm & 0777), &stbuf); +#else + err =3D -ENOTSUP; +#endif if (err < 0) { goto out; } @@ -3983,7 +4010,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. @@ -4000,6 +4027,8 @@ out_nofid: =20 static void coroutine_fn v9fs_xattrcreate(void *opaque) { + V9fsPDU *pdu =3D opaque; +#ifndef CONFIG_WIN32 int flags, rflags =3D 0; int32_t fid; uint64_t size; @@ -4008,7 +4037,6 @@ static void coroutine_fn v9fs_xattrcreate(void *opaqu= e) size_t offset =3D 7; V9fsFidState *file_fidp; V9fsFidState *xattr_fidp; - V9fsPDU *pdu =3D opaque; =20 v9fs_string_init(&name); err =3D pdu_unmarshal(pdu, offset, "dsqd", &fid, &name, &size, &flags); @@ -4061,6 +4089,9 @@ out_put_fid: out_nofid: pdu_complete(pdu, err); v9fs_string_free(&name); +#else + pdu_complete(pdu, -1); +#endif } =20 static void coroutine_fn v9fs_readlink(void *opaque) --=20 2.25.1 From nobody Thu Mar 28 13:35:16 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=windriver.com); dmarc=pass(p=none dis=none) header.from=windriver.com ARC-Seal: i=2; a=rsa-sha256; t=1675072462; cv=pass; d=zohomail.com; s=zohoarc; b=JaPb/b57OzfUZkLNePUrvHZ+fBdxbnnT0OWX06lQ6jCBPuDRPLiLZ+faFYnPFNyLq6teoTCaGkRnftMeZAb0TlxH6Xc17hJsoYyigr30Yrrc0U5LNP1Qs14OGQu6KyBNbxMeeh0hJDLo+54pin1HXD6WN0I55VIX1UYw5vQhzHY= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675072462; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4A1e6sHVcoUouSxEStJohMBnC1urIIH6KVBurlDY0lw=; b=DSNBFGLO0vN8If9l5BMtvNbQmmzPCtV1CxP6xmCmBEpqQ5PSSTRdm5J6rIyxJtbT+OhPGgNhQoB4b9vPnATGgqEui7jAY8CtDHozV5jXkTGHftOibXRo1u/I6TWoAi98P7xU3ldlZjzpR0tIOCl+u/HTJc1o4ErWadtE+531Ob0= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=windriver.com); dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1675072462302102.96511674919475; Mon, 30 Jan 2023 01:54:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMQqK-000314-TT; Mon, 30 Jan 2023 04:52:52 -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 1pMQqJ-0002zo-BS for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:52:51 -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 1pMQqH-00021P-NJ for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:52:51 -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 30U99Kg7008133; Mon, 30 Jan 2023 01:52:44 -0800 Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2171.outbound.protection.outlook.com [104.47.56.171]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3nd43rhj5t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Jan 2023 01:52:44 -0800 Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by SJ0PR11MB4992.namprd11.prod.outlook.com (2603:10b6:a03:2d4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36; Mon, 30 Jan 2023 09:52:40 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9%2]) with mapi id 15.20.6043.036; Mon, 30 Jan 2023 09:52:40 +0000 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=4A1e6sHVcoUouSxEStJohMBnC1urIIH6KVBurlDY0lw=; b=ffM7GSXkQij7+jZkwhSw+DpgeEjxnP8QlApBMRkETptrCTag0F/SvrpBI+n8fsZYX/Bi Nm9WcF1vsdvFgoR+nmD4oqhedEMVnL/Ns7eUB0NEwQMPIT0K98XJAvo4Enueu9Hi0v1w cAk1Cq/9HrTSfHv5JKqLaZRkluYcnAEsbjbHwoa8yXH2rSBNWQKuS47sWtRa8MLVaK2W e+kYW0TOndB49r1Y5xoWZs97Dmtwmz1ayQI+woBhS9xiP3ZEO8tEp42XTAnvVvZEG4xX 78F3LdmUEzKXZ3O3CaWUOaC4wLq0t7G7/3+AvaYc6sD3GV5EAU9FyDfSreTRKg5nQZjh QA== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h26c3vAFm3TLEcVKMw6PRT683hew7M7Dn5sYRvdT1w55BGfn58AVbXpOGhFwBbY7/NHB/lqhOJkRk2rvIR//Y5Q9byOf9UZixCvS57RYrFjyUciyu8NxzmQreT7BvRoIlX1Kw/3L9WrYgwuT5agF9Ljs/Q9Du/pK90nrbpuwEzLE6V1UoBsfVdziNnAcH0TzUNUNqFJlIAvtLsA0BgaABdEziZiu4KfjRW7mr/IrfkAHxPJsG36Sa67lfSDsDzc/c0CW4kcqCLCWf550HU8KvMUi4sA9J04jgxqli4ft0ibpe+bLwqrH7xF+bCrSEJc3pP+K11m8CgrrtMKMqz0rHA== 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=4A1e6sHVcoUouSxEStJohMBnC1urIIH6KVBurlDY0lw=; b=Y93lxhrTHMHxDJvpSspVPcV6+ftaJVrEjWm5y5YTMvkYoUS19V0KF4dII6UoiHAPEUqGuL0qSX0iZTelc4sPy90jczbkygJrJk+atJd0mUX77N86dLVc/vddRVOSx0Ugf4OqBSDLBYl7B9ruXClK3ShVVMKf1ujf9LMJ68prBe7Yul8DAk+ApPpYvemMCkZo9t1bbZRnxBQKXdILtOMJe0yAfKCuNfezRrx1t+xnYqEzvVXcvuXS7/zCh5I5+uLIJuRBJnGCorQBNuhNCBfoauzUSUWXTOT8Q/fwamfcHEAUV1joBy+JTXw7uY24DYRAA8BL2oAH/xDMzStvrby5eg== 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 From: Bin Meng To: Greg Kurz , Christian Schoenebeck , qemu-devel@nongnu.org Cc: Guohuai Shi Subject: [PATCH v4 10/16] hw/9pfs: Update v9fs_set_fd_limit() for Windows Date: Mon, 30 Jan 2023 17:51:56 +0800 Message-Id: <20230130095202.2773186-11-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230130095202.2773186-1-bin.meng@windriver.com> References: <20230130095202.2773186-1-bin.meng@windriver.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BYAPR02CA0061.namprd02.prod.outlook.com (2603:10b6:a03:54::38) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|SJ0PR11MB4992:EE_ X-MS-Office365-Filtering-Correlation-Id: 18824923-328f-4ddf-b850-08db02a7b993 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pcDQReDa8ocJvtKi4O0/kPALl15AxfFPQve7wAghu4NDp5QHpgLQBA734efl76nLYXr7Bts0E1VVqyOIkmj4EneeqFE7R1XKMYQ3ltTfi8iJPgnGuZsKMYSmqFneKbTj0MRU6m+LHRlOgiLmhUppQt0jP/g3R5w3VUS57+gk5U8AOMsAliCbCU6Cs1PYSRDJjpI8ny6cw1O8zlOruS2Yddty3V4gxb7GYFsVecrkTYEqTAjNJu9Sz+7fYVMenaMoIe1ZWRpVPq1cT3A7Ae/8whYiTVIGNLDqr1mE1LY5iCGgG5xFxK6X1YBRPQ0vFl4TJZsQZ3wXPPZ4LygdDQwkesmb4qul3GTKREBQYWsnx2OX3lhjUbJdLq4UQt36IVb6DfotBy6pO1dAn95Tod62o2D9ovvAxH/BcA38iCr0BGYCtn9ewCFh4Pv5swoGoOjByZbcWbLKvZnbSEj6OV+oLrJnPZ6R7VpROEg/3F0FPXdclPmUu5vNapkpZpXbsteBLUalUWlBDC48HKICkaJMiNBlQDadjc89SZHnTecXB7bKdPCZ0ZPhuy1dl2G+YgFV9GSOt1CGhGj3KZS94tP5n5nNCOPuFkO5fUWA5kC/OgdjQYHfiQH6Q47s70Y18k328Pc6Wyx9hISm4bHduIcdou69hDohx1JrsYqAcGxhSNSyG75wqmcfThjaKwCbWZkTIcmpBqxAJbcgZbje4PIN7A== 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:(13230025)(4636009)(396003)(376002)(39850400004)(366004)(346002)(136003)(451199018)(2906002)(83380400001)(66556008)(41300700001)(8936002)(44832011)(6512007)(26005)(107886003)(6506007)(6666004)(1076003)(2616005)(186003)(5660300002)(86362001)(38100700002)(38350700002)(66476007)(4326008)(66946007)(316002)(478600001)(110136005)(8676002)(52116002)(36756003)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?CjXESg/o2/N7SPEvzkmgrDBYIQM05+G6mEyXucHf972PpDwmpkUxtqfraJrn?= =?us-ascii?Q?/93avBhEtUgZZpRIpUmMTqrucmxrUZuOQFvpPKzJ4PGVCnmNMy9rUIxRBRkp?= =?us-ascii?Q?jAhoe800R1CQuff8jWIsWkl3YY7S5StCEKYg74YPncLTenTgpgz0GX8OpqzJ?= =?us-ascii?Q?c33pNoIc0Qts/G0OqUnKq9UWqtQ/IWi94YVUV7hlXYp4T2pX5aTRr0xPSl8H?= =?us-ascii?Q?tZaGABOaUdphJ1gkTZDlvl1XWHlFthJMKJoaxV8aPyu0TpTPOrvwahVHaZW6?= =?us-ascii?Q?nqpFQFrWrtzcbqelzoxhirEA3d8z6zT/WdkmS/Drk6HpQBob+3yIIv+SRyXa?= =?us-ascii?Q?+dZK/WPEOyRzILad5ixLdh3IkRS29U8GBJAx8vs4jTBqw29yW8OcZLGEqSpF?= =?us-ascii?Q?xIeG9GdamgE8J8r1BiCYnaQOWd/FO4ixDbTRLOMpzgP553cNpGEmS/1JadGL?= =?us-ascii?Q?zgr7LG25xcxRW7c++iRV3ixML25DQBsggQBsfm4AYZIGXVTE2kyKLVmvtZYP?= =?us-ascii?Q?TgTuk9WI48kBpJFfu0vemjYBIx4quAEV+lrFRKIY/lYKf3qpDt1Z3OnXEXZZ?= =?us-ascii?Q?aQzuerS2O7x8q27jeO5mT/78xPEglG+Etbmyp/3NGfng3nXCpFdP0t3cMUs1?= =?us-ascii?Q?2GLWKgVOAcG+uIYfSCoG99rYZJ1omQO88WQfB0LAbPO85iFg71GGhZY1LZ4k?= =?us-ascii?Q?zmttc6pbtxj8ZvHJlfnzqPgoY5qPlObPUc1uUtSMtrw+5iDZWmR1OLMoG+GC?= =?us-ascii?Q?MZOvkLzuedNBUnd7lg+841oAbS4UhCihtx58N39eCtcHT4SkDADmDP3aF54g?= =?us-ascii?Q?Vi5zua3WhN0/p7wF1aI3axUEShjT5qS/mzkav31n0hiQpQ2IjDszQ0ZTlket?= =?us-ascii?Q?Rf++C94yC0c/UuQ/iIBVYiB9C9PvK+MeTHOJkT6IABKFFqpomQoYf0BYW7+1?= =?us-ascii?Q?VknTkftc4CYRKwCG6bO9MftY0IC3673RHKZuUre9yXvVuHOAXfF+dUMqxCKM?= =?us-ascii?Q?WjqyC93Hl4KowCViU4Crxir0PAa0mcGRnQhuORsqbVIH9woARaYVUgFUDPGA?= =?us-ascii?Q?56g7oSVWe2bPx3B5IhAsKvbBqbDYr2R/3g9kGeKoBqobLopa1mF1r0iX/5xg?= =?us-ascii?Q?agpzCGMbAbGMOf6hDRuRaeVAkhK5F53U3n8AJxZKIMeLK1sL+/Q+SwL+xkYo?= =?us-ascii?Q?SjdbLRLLkDuSGIStzQv4wrR15/ZlCpbrhp1jCSDk3CE8BP7fZMx02+2IiSNM?= =?us-ascii?Q?/6rnIPjih/cX1U6lMzlVMfchxe9oqH58bQgcQflKANouBKY1vBEWkfXhU3Yk?= =?us-ascii?Q?p5uLbx8kz5gsB7I5f/m5PSlYReQTnNSWe7Ze1ZbsVkmnfxmaR6FyYq3F+kuU?= =?us-ascii?Q?tWyLdGREpNHJ7ZWPaYQDzhqiH0KMYa17/pVT1wD/GV5OIEvOI2209jEMqVvD?= =?us-ascii?Q?VpNQhz3xdjXf53Ll8kDxxtZG0+u8eT+mnQSCWAWL1um4c0rpe7iWV3pqZuVg?= =?us-ascii?Q?oRa/aV+SlB9HxmHxmoGD4j3Ei/5UJdLB9haHMxKYj9XeFFkT6bzISPW2c711?= =?us-ascii?Q?2os2E9nwuk95KQG/Do04TBMmdHeQqOpdgvpky2xy9b/r54P+b/orHHOUiYnL?= =?us-ascii?Q?oA=3D=3D?= X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 18824923-328f-4ddf-b850-08db02a7b993 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2023 09:52:40.2284 (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: j0COJKFxAY3MkCFAOcmjle0ACpNeDN2msj5xhoeZwUsdpnxuZzHAn3ZX/6zxk4FMl+091QgqVCl1Gs7heG2U8Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB4992 X-Proofpoint-ORIG-GUID: Kw1z-u4MwuW9zm6tn4mY74p5V3ChgZzZ X-Proofpoint-GUID: Kw1z-u4MwuW9zm6tn4mY74p5V3ChgZzZ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-30_09,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxscore=0 suspectscore=0 clxscore=1015 malwarescore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 bulkscore=0 spamscore=0 mlxlogscore=995 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301300094 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.166.238; envelope-from=prvs=13943e2a21=bin.meng@windriver.com; helo=mx0a-0064b401.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @windriver.com) X-ZM-MESSAGEID: 1675072463977100003 Content-Type: text/plain; charset="utf-8" From: Guohuai Shi Use _getmaxstdio() to set the fd limit on Windows. Signed-off-by: Guohuai Shi Signed-off-by: Bin Meng --- 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 2497a06f43..b55d0bc400 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -4396,11 +4396,28 @@ void v9fs_reset(V9fsState *s) =20 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 =3D getrlimit(RLIMIT_NOFILE, &rlim); + rlim_cur =3D 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 =3D _getmaxstdio(); + rlim_cur =3D ret; +#endif + + if (ret < 0) { error_report("Failed to get the resource limit"); exit(1); } - open_fd_hw =3D rlim.rlim_cur - MIN(400, rlim.rlim_cur / 3); - open_fd_rc =3D rlim.rlim_cur / 2; + + open_fd_hw =3D rlim_cur - MIN(400, rlim_cur / 3); + open_fd_rc =3D rlim_cur / 2; } --=20 2.25.1 From nobody Thu Mar 28 13:35:16 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=windriver.com); dmarc=pass(p=none dis=none) header.from=windriver.com ARC-Seal: i=2; a=rsa-sha256; t=1675072485; cv=pass; d=zohomail.com; s=zohoarc; b=ZNzzZRucArDGs3mS2doYrun2gjK39pZcbGv1gfVbAwPZw9aCpuqGpl25BOPaw5w8xdwZvlnzrMYttrlA5AXOxWkou+lgXyviDx+xrS6AnTfRPhBkhjaaVDMrZBXTfYGLRn/omQ4TP/uJz6yXzYzzqJEoL3PZt344e16bLsz6WVg= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675072485; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=iDJXqj4XOxb/nnwKqkF3Hh2hAAii9wCHHUvqDsYvMv8=; b=irurL6FqiHV0hymjkD5dPdQ2MGiuDovlHlLKxjJiql493UQxTNQt67FFRUHQsblbD3NuxQjZ3f2JIRobu2sLVTTuInoLgeMmEOYYZ2kiP4o40lcDVhc64IDY85PFiVQpOEfSa6QARi4t7TGTVGio70J6t7O5esTGb6pmubNOMSM= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=windriver.com); dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1675072485228539.93940838228; Mon, 30 Jan 2023 01:54:45 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMQqT-00038t-Dl; Mon, 30 Jan 2023 04:53:01 -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 1pMQqR-000388-H7 for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:52:59 -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 1pMQqP-00023T-BA for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:52:59 -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 30U8OtRH025559; Mon, 30 Jan 2023 09:52:46 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2042.outbound.protection.outlook.com [104.47.66.42]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3nctpat10m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Jan 2023 09:52:45 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by SJ0PR11MB4992.namprd11.prod.outlook.com (2603:10b6:a03:2d4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36; Mon, 30 Jan 2023 09:52:42 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9%2]) with mapi id 15.20.6043.036; Mon, 30 Jan 2023 09:52:42 +0000 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=iDJXqj4XOxb/nnwKqkF3Hh2hAAii9wCHHUvqDsYvMv8=; b=PopFLyGiJl+77ex8Eo4MkYql5nV8S/BI9G75TjiP7Xk1N+xdZ31UvbXtsAwXCP/ii92T xpa3XFC+L8ZORiQnyVqZTb2iQfC8Df5Y/ecmYoc1DIIkIBxWif5eWRICoB9VUHH7OHUF R1F9tH3//4i/nskt7vomNwMsaDqzz1bZccaWL6KRHMIEPLT2ASyDHXHsLFBg8mska/Ms 9MxiEcAN+TzP9jNHY7Jgjqs8AIvc5mU0D0NygmbjLBROZ3y3USD03oIMQ2LMZyyccDkV /X446n3H6t72aXvUiUqQnc6an/Xb6ljblprlwbTrSNGJMtbCcMVSor57IISQ6TLAfmX3 +w== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BCYWGZOcUgp5y2noO7P9LBwPshn+Tbr+KdESo3xoQQyBM4uZGNWJmT+pKAg4izSp7W22aSOvSB/+FlJ3MMOi5oLe5HLOzq/FNzXH+YPnxh6JtIjWC/PJVKOjvB2q9AH0hRvYAjjW6/JcCyo0OpGxMJohgQZuRe95b1JHip1XZ3hX6iJWuT0HkSC24k8AEann/xAkSGrLrN74w7pWgUSM6uag/qwhAn4Rp1Ru545+06bjh1n7J8cTgR2/WAyMTtGQeli11Y3ge01AbDb0m2eXP/IEwDkoTZem7eNYus0+6Gdw+hWuICD3zUFMt9XfAuOuMGPVmi9df0/upFQZJrQfrg== 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=iDJXqj4XOxb/nnwKqkF3Hh2hAAii9wCHHUvqDsYvMv8=; b=dr9TF6frCexJ5u8GSEnSl0IqbQnwh71MAtAiMVQrCGyJc2lQLnpFzAYBiLslAQkktV9IDxqjL47qD68kr72QxEp+J4S+9LQU5eYh96uPw4uQmEC99fcxbmOMN3ilkld3W72B6GHd1BdhPOfpTYpoBjJm0lH0Wx62BPt4BkPAETNvKmyXqSapQ0Zex9TIiaKVH4rjw85kBqQrujGcba9R2nV2ozfrvgruoxam8pgfCEzacuSdO3dTawo+YDRpv07rLQBKRsdIXqG8YBnxf8MWsxrHN2I1Xdjaq6dpIRqOHJDLUcqYt3zNnb5uwHh5qBTRJJgLQGBU2jstYt7Usjtprg== 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 From: Bin Meng To: Greg Kurz , Christian Schoenebeck , qemu-devel@nongnu.org Cc: Guohuai Shi Subject: [PATCH v4 11/16] hw/9pfs: Add Linux error number definition Date: Mon, 30 Jan 2023 17:51:57 +0800 Message-Id: <20230130095202.2773186-12-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230130095202.2773186-1-bin.meng@windriver.com> References: <20230130095202.2773186-1-bin.meng@windriver.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BYAPR02CA0061.namprd02.prod.outlook.com (2603:10b6:a03:54::38) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|SJ0PR11MB4992:EE_ X-MS-Office365-Filtering-Correlation-Id: 01ccb3b3-6f05-408f-781e-08db02a7bada X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GTi5w1H2QZHAt6QDRk1gDjUESgQEkeezFIqkeBvLijIVNsMNBuiV2h4z9yrHA8Ap657D5FLAr4NGvJv0udHqkixkFuipeZDjpqn/v+sRqoy1wE3/pzecC4ngL8aifkm6YE8uHUQBcmjisghvpedcPEUmsuXERTKKUnLfBjrtxaUtbwORd5ILEGjbB61FpD2KWaOrGBjRgQuwodnRUhHXkm5dPUn0ZBkpPQn8qbYSheMsUrRFlicSszt38T4i4kiMX2ryBOtZ75RN9TJh6ybZR5ymadmDIL225k85dwFFsAM2olxsI3IRc07IYOnV1W6NJVi1sNHijuktjm2LaD57wDIMjgWz2jrhcVhaP9zYknKlfyYol9vdjxHOhX90ASh8Uaswi71vnsZnKT+IVazkp/gAC7X9mxsOIIcO2+W0Z4SKTgs72m2I+B+Kmu8nNhsNSyfqaxIL7Ua9Fy4qVwodW/uoG69XUWB71WFf3RYy8zLQbOsYgIKMQR/4baXvSvkOJqnO1e5J7gStNQhNLGFywfvjRZPeoC7sNTtM3kqlD7949Gudn5X3K/PXB26R5+7kY1naI3a9S8sTz4QychX0ktFtEb4KJJy+RRF00lYZR4q05H7YpMQtz65q3EDNVgqyYU2Zu3JfNBlLFWcStLzytSasN6d3PHyXhkkkbHAOZOQkAx5V0Gmg82yFmYw+b9uu 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:(13230025)(4636009)(396003)(376002)(39850400004)(366004)(346002)(136003)(451199018)(2906002)(83380400001)(66556008)(41300700001)(8936002)(44832011)(6512007)(26005)(107886003)(6506007)(6666004)(1076003)(2616005)(186003)(5660300002)(86362001)(38100700002)(38350700002)(66476007)(4326008)(66946007)(316002)(478600001)(110136005)(8676002)(52116002)(36756003)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Db0Z0Hur6iknY6ja4hM9Fjb4WgXAhlFr+3kGqEBlVAm951kBRJeYfPWca7yM?= =?us-ascii?Q?F99kTxePpEY6bB5OYMsWVvNGbwZfAVEL+Cv8eoGywVsmzMkIaiYAY53WTWqr?= =?us-ascii?Q?TSA6/nyMf4TjRiHeG1zvGAn0rqsCuQjirfHyI3AzpUPqXiia9txMVq7QXY7+?= =?us-ascii?Q?ahlbp3oW66ZkAesy3ip2MWC/1e+J+KcPkhf+OaABgvaicP2uv0xC9sssHpzP?= =?us-ascii?Q?svo2WpGpdEEEKkiZCLdd6WLOi+au25UKTXOOEoJXQjb+lSHA6My5K47hgtF+?= =?us-ascii?Q?UwMWqqhNwMuDwOFqWDn76llUo8PHW64lCpbogqqWaUlmQSTFh+nWKvXM2MkH?= =?us-ascii?Q?ZQhkrDyxFuEOhjGo5RtGova+ZIB3B63FY/Qxoq6iak8GtxIeCpTk6d6KssyP?= =?us-ascii?Q?WwVNjkOZKYlgAflBgUqXGgKESb/LA1m7ceAyqaff+9zzt13zzkCehk+CV3+7?= =?us-ascii?Q?OBtDkNds8cTuf5NURJ0fO4Fnli8UWpuTK/edT7VVJyeNnsO39xpb2Y9krndk?= =?us-ascii?Q?iZ2bk5U18PnOrmbke9aky1kKXOaWj8JKMhB2RVqbwBd8Fb2+jGpOphBhKSNo?= =?us-ascii?Q?ofcG+5A2gtF0StM80Mn2Qe0d3x3tLJpSyM2qWHtQuhe24DIDWJfI/b9t7jE7?= =?us-ascii?Q?EN/5b2MQR1Z9xEKy4QrQuWRGmZU4XISbnwnI5DzExRVfhhTjsNgUopXEpgDU?= =?us-ascii?Q?ObnKCbKFq/7/W7ln082BQHXMk07c5SdfiEj6NpwiA7gf2bTqN+741BJrJVuk?= =?us-ascii?Q?/iW3/JtB4ONqSQNSglYsiMlO/8uhTVg4AMmeRQUjzk7+vZS07aYzriDwZape?= =?us-ascii?Q?akCxElI2Xf3eBYoRrJBT5QnbBae1KFI8JxMoITfbkpOkWzdCX04U44FLuRt6?= =?us-ascii?Q?YWkINuiuUOirg6NrGqr7JHNE92ESQtcRKXbUpnCzmqLbuO4pALvDyM5qWEEG?= =?us-ascii?Q?4031bv74bjzYnYUqm1fxmQrYwUZILw06+XrVuetaHHyHHACYF/1NrBLf7r8u?= =?us-ascii?Q?BPRhGPGkjJxvdFgyZU9nEk2KlcQJD6x3SMxUAQX2uqMXS+zfcEtPE1k3QLbP?= =?us-ascii?Q?j5O8DOQ7+gNLCSLPTPI3R+nLO56zWRBKXFSQ+Sp72fGWIVk6cBpF+x7tZ2BP?= =?us-ascii?Q?5YUJHFjn+tm7Wmj2sk1g+QNXGdS5kUYMUYabcjDtaVRT8peiTZ9czLMDvcum?= =?us-ascii?Q?JuUPejNfbICKZl+DrvsNT4sAgTsiVtzH8jG6X97xvgoxCBfkDKFWAkuTuulR?= =?us-ascii?Q?NU4c2Oc7qFWM9IzylnyL26DUvdXs1PzGK9lIcVAFqzVrKCFGRATBTc2Kb0Aq?= =?us-ascii?Q?um5pcoeL8WTwqhn0vVZhZxIxWBE+YXer0KmrXXyZ1vIRrrXGROgPiS/BR9rM?= =?us-ascii?Q?nWO3kKLLtCkMt51jEurMIQImHAoCco851bMOOoQj3WeSobehGYfDmQvIJngx?= =?us-ascii?Q?407T0ovb32rnLUoNMKN9Y50FoYCfIlCYjGCv8aSAjzG6wpIaynTVbIpFYTvG?= =?us-ascii?Q?FhM1k3UJZBaa8YnT6bA7LbR/b6EWmDloe6R683RO1M3wZoISYb4bGQpymgcl?= =?us-ascii?Q?+XIuNGLQy/TJOdUYaJvjny6jt/3qefBC2u2kodFyIpdgJ0jhql+qwJSSnRhn?= =?us-ascii?Q?OQ=3D=3D?= X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 01ccb3b3-6f05-408f-781e-08db02a7bada X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2023 09:52:42.4324 (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: NQINPiZkAObLNWwsGZ7tkxyY9qa3vG8LiCkQPh88fCV8xyx1n1kv3cT3nty0y1mHoe4avD7pX+mwg5KubHWvqA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB4992 X-Proofpoint-GUID: wLtP4AkZhmDrQidncmJdTN4u2K3MPmjV X-Proofpoint-ORIG-GUID: wLtP4AkZhmDrQidncmJdTN4u2K3MPmjV X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-30_09,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 spamscore=0 impostorscore=0 malwarescore=0 bulkscore=0 lowpriorityscore=0 suspectscore=0 priorityscore=1501 mlxscore=0 clxscore=1015 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301300094 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.178.238; envelope-from=prvs=13943e2a21=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, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @windriver.com) X-ZM-MESSAGEID: 1675072486063100009 Content-Type: text/plain; charset="utf-8" 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 --- hw/9pfs/9p-linux-errno.h | 151 +++++++++++++++++++++++++++++++++++++++ hw/9pfs/9p-util.h | 24 +++---- 2 files changed, 162 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 late= r. + * 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 val= ue. + * + * 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 l= ibs */ +#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 resta= rted */ +#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 en= dpoint */ +#define L_EPFNOSUPPORT 96 /* Protocol family not supported */ +#define L_EAFNOSUPPORT 97 /* Address family not supported by protoco= l */ +#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 r= eset */ +#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 sh= utdown */ +#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 ea8c116059..778352b8ec 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -65,8 +65,11 @@ static inline uint64_t host_dev_to_dotl_dev(dev_t dev) #endif } =20 +#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) @@ -76,18 +79,13 @@ 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 =3D=3D ENAMETOOLONG) { - err =3D 36; /* =3D=3DENAMETOOLONG on Linux */ - } else if (err =3D=3D ENOTEMPTY) { - err =3D 39; /* =3D=3DENOTEMPTY on Linux */ - } else if (err =3D=3D ELOOP) { - err =3D 40; /* =3D=3DELOOP on Linux */ - } else if (err =3D=3D ENOATTR) { - err =3D 61; /* =3D=3DENODATA on Linux */ - } else if (err =3D=3D ENOTSUP) { - err =3D 95; /* =3D=3DEOPNOTSUPP on Linux */ - } else if (err =3D=3D EOPNOTSUPP) { - err =3D 95; /* =3D=3DEOPNOTSUPP 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; } #else #error Missing errno translation to Linux for this host system --=20 2.25.1 From nobody Thu Mar 28 13:35:16 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=windriver.com); dmarc=pass(p=none dis=none) header.from=windriver.com ARC-Seal: i=2; a=rsa-sha256; t=1675072454; cv=pass; d=zohomail.com; s=zohoarc; b=NzvULK4Uz4s3L4xSAyW9tgD0c6MEf/NULhW02UaYVEm3CSjYRjiTR6ULT0BGSk/PtqXrg52uRtnccH6iUltOFmBhinQQZGDCmzINnGaUc+FjbC5hTk6f/S8d5uJUvE3WMWfASsv1zNUUr/PATB/RmbeZ40omDKp/fZnzvN+8WEU= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675072454; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qVi+cX+axJVFtj52FK6mlqj5ScHeG3UF/5wRyJEMVdk=; b=NoW3gH4wT1hTkVwR5mO4V3e4EMqEtrjIzvd1LMkmD0EoxxtEK9ZhNHuB/UCh/uOLULWYzOYsiNzyOOW0GMO/taBRZ89UGwUb+ql01IU6h///tKQdSBb83BBVJKf8wm0/gwJAleKu4AoiCzf6Ett7OFCk3N/bN1XneHGhhfYD8tI= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=windriver.com); dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16750724546881016.2707902508361; Mon, 30 Jan 2023 01:54:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMQqa-0003Aq-Em; Mon, 30 Jan 2023 04:53:13 -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 1pMQqT-00038y-Ob for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:53:01 -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 1pMQqR-00023g-VE for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:53:01 -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 30U9iKOg022663; Mon, 30 Jan 2023 01:52:46 -0800 Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2175.outbound.protection.outlook.com [104.47.57.175]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3ncyv89rk4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Jan 2023 01:52:46 -0800 Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by BL1PR11MB6025.namprd11.prod.outlook.com (2603:10b6:208:390::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36; Mon, 30 Jan 2023 09:52:44 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9%2]) with mapi id 15.20.6043.036; Mon, 30 Jan 2023 09:52:44 +0000 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=qVi+cX+axJVFtj52FK6mlqj5ScHeG3UF/5wRyJEMVdk=; b=NVVaY7UX7Lg5+lL/ksQ5PGH+GmjkA4fL9VBmxIl92vRrSds9OIpQ2YYc6M0t7JWb5KjF NIxZVAap5FOcRKWOozxa3sIa4tCJ+6uBkD1jXSXffikjr1l938tUfe/TvXJ6qIH7pL3j 7VPvYu2EoD++gP+JWBQe17uxfQyhDp5U1QLe7Ges+wozR5yJuahF0VXEReutBccDxKUS PsT0k9psP3QsPbo/a0d8Zs9BvBkLehtCPUxid2hxf58+CPBISt66hjvBcNLxiSBEtZwV PWLs39PKohsDo0S1Z6SSp24njuhd55hJnAvbj16NiuJ0lELk0ksI6R6/eKmvBDQSFaUi Rg== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ffy02g6IiBzAZWb0sl26iEbFXqKlkC0dYnTz02DRbVOYp9yH3yNVoSOst/bACUneKZCdpUTNZqLGE+FQsyd2wgqK8dg0nt+E9mwvIq/to5mXBLMW1atijygSjdXv4XrUZP7d/WeBWTwV9aLTLr1obEqCGjLJMTpQLqtyzbkiCF/u52OxIi4ubkYFQ+IZTiO6tJvl8O0SPix2IxFqx7I2vUB5BjcrkKs89h97eQy9K1RuQYU0UqJf0XEUW6btI2/PkALq+KMx4HR4kjLhmZaoZEV+2UX0DrY6Co92PVeWQa1Dl1Wl4mJewbyIek3fov3ZLr5NvZDjpMmoPlWKmryF3Q== 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=qVi+cX+axJVFtj52FK6mlqj5ScHeG3UF/5wRyJEMVdk=; b=aGyABp3GKPwIO0+DKxzAzvpBA9kE6lha9WYskCHy4h22ilmnly5tdQWI5/CPP2BSb1E2jCxsZmEu34KKC3zZaY9rZJiBstkKznDtiXZ/nAUDN64gL9H6pAm0SKV7W8q96G2uj9WBCCXj256u0we4jT1paAZIshbHBqO8kMcMKFxFnw9uz6xK2fysKcmJ4n+zgDvASDtEARPCfpkG76q4z53LTLy9WcAFFnPkg8GLTUVX+IFfN0ZsHV05kWpfMZgq7bINbND6N8Tn/TAPcy553pQ4J3I0K3BswPwvY8otVq10aWjh9Jm6waQ/+duPGH34Sj5kwg8fFw0D/tQkG03AlQ== 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 From: Bin Meng To: Greg Kurz , Christian Schoenebeck , qemu-devel@nongnu.org Cc: Guohuai Shi Subject: [PATCH v4 12/16] hw/9pfs: Translate Windows errno to Linux value Date: Mon, 30 Jan 2023 17:51:58 +0800 Message-Id: <20230130095202.2773186-13-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230130095202.2773186-1-bin.meng@windriver.com> References: <20230130095202.2773186-1-bin.meng@windriver.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BYAPR02CA0061.namprd02.prod.outlook.com (2603:10b6:a03:54::38) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|BL1PR11MB6025:EE_ X-MS-Office365-Filtering-Correlation-Id: 5d401cbd-bd08-493f-988f-08db02a7bc12 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HppBHrh+3q2md8KWg8P/PFDei1nrD2co3gQHIV0yQ7cNbLJi1yk3V47m25soc0YGHKUhwRtmg3n9XEKqxDM9OtIlg6R5jrlh/fQ0gh8Kl52c0CIRYxwRV6wEUFmwKd+09siTSysXsD2bp8yHTlEO+kZ9vKOWysFO5J62f+DOSc3J46fvgZRXeI3IDcyWpgbBKfIP0yp5NQg24jb9TZxsnlKan0mGf+KNc4YulT47SI9G4RqpL36vV2vZyj+zBG2Py0gTQyEGjI4rpcW27+xLd+7dXjQBf+2oZl9YWEWEQTUe79qq8IqAM92grUhFtZsF8xIoVu0f2F1izZUqxo7KNrIkWDQ6wvirObQY68Bmp2nmmSdQMtsmvNtpgVzBEnSkYn8n08+JIia5qVT3DZiKuNYRz6f4wLcACQI4IvbklX6rct78ShYOt+khyWViJC6LqFRzxbwtrf7J9pAiKvFvl/nQPnnPJg55mboMqYVosYnzZDKK/wlF6HZINcKnbpg57i/gSXuDFBIrZzR5NrYeurQtk+LzqMhCVslpFzTLcGTjfoUH5nGrr9sl2DwWE6CFLdBUyQq9jj9D5SlXqWS4GZSHz+6Ynk864bZ4E0qOk34dLDGW4FMw3KeRght6WlJgsk4xiiCzW/YhqrBsokVA2GPxo2NRzC1dPxwi3GtCzHxgaacODF4VOOwQjh+ZTNkAHpcdXYHD8sUcj5rJ9Vk95A== 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:(13230025)(4636009)(396003)(136003)(346002)(366004)(376002)(39850400004)(451199018)(2906002)(26005)(6512007)(186003)(478600001)(6666004)(107886003)(6486002)(316002)(110136005)(36756003)(86362001)(38100700002)(38350700002)(41300700001)(8936002)(2616005)(4326008)(66556008)(66476007)(66946007)(8676002)(52116002)(6506007)(1076003)(5660300002)(44832011)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?dd/zWTJ2cR6FoRHgE2lf1ZJRo0zru8qldrez1o34Z8VLQcOhdmfHMX1ZXSyc?= =?us-ascii?Q?3EVcWhk3+CqCM9qnR2IASoKyxRMJkwFBiIga1lH4dH0/ag1qeoIo5Apzj3LP?= =?us-ascii?Q?DksdvS1+X99aP6o6w4A8wwluL6wuXKGx5tnr8FWvYKnD+fStZ/42r4axPIvT?= =?us-ascii?Q?DGpmeGByGLcbhpURlVUe4tWJq1F+2FYMeqQfoVVVP1DM3CxqFIAt9Aqb5X3J?= =?us-ascii?Q?BxknGHbFzOJ/QcbkhhJMH6sixd3VRQH4MUrJbMixwB1o2wLERT96kP20AGNq?= =?us-ascii?Q?atQT3vUUAlIzg6YgypRhatUMjcMJ+BsoqXY8xRFjVhpDJFDvAoou/gYB65Ia?= =?us-ascii?Q?iLBsOE4wNRpKAQhK11QuPo/s9yHcDhaCNa9aSoVYSOfLNO1xmJynY1DE7MjA?= =?us-ascii?Q?v2daRGB429xv4nS723y2YyYlu37EY1BzzCuqofLOy+sLx8RQkdVlX8I/enOi?= =?us-ascii?Q?oI9KO0qR/3vBLztsXmVo4D4jVGaz2+oTyWmPbJpoQZvn0VohI//C8v9XtwTS?= =?us-ascii?Q?JDkr6PXiPQpEIXMujfnDzPAsNEYos41GS85RtFwuDJ8MKAWSPUM/gJEid1aO?= =?us-ascii?Q?4TY8+Dn4Zb3ntyKpKNQSttkErZ3TWmXMX++R815TqOH0SZ5liKeyJyqi6SJS?= =?us-ascii?Q?HoNtEXe3f6qdOG+GoHk19C8d8OfYPj1AdQ/4Q34XChR/zieFf4eiDB/0fGlP?= =?us-ascii?Q?cuPdmeAsxf9oS18gP2oujBcon1PM4uyf2tI2KKzbuyiPdM4rsrV+8IGzqrgL?= =?us-ascii?Q?y/tAjrmTUKHSrtt2MxIsQbkJbJWU/dd9AlwBTCwE+HMjTEHy/Ebsh0EfRzKM?= =?us-ascii?Q?AHtKR+cHv4bFhSg2vpTxpSuvQD6V+AwZaV8PPPs7JLZh9grgyLCS5Mq89SvK?= =?us-ascii?Q?UzTJS0dP3L5glLy6CwfRE1DkSKnSFWka7ZOoK+z5CXImiuQgfyZU9kjkREyk?= =?us-ascii?Q?TzrO3pq3AaqSVePNsbdrxcE+tHhkeagGrugp+ydzrI78Vr/FTh31a39xLjiy?= =?us-ascii?Q?b4HP8kWmXLbtNQWmST+NKr9FQFWUNUfi9uck+jATTeB+wujYlGE5wUWyooUd?= =?us-ascii?Q?gY2Drc3HZ60rLu3hqTHC9POfajn5rg8/SzGNSuuk1Pe/yCkehyz1JJPQKPMK?= =?us-ascii?Q?+LeMQBwo8XwMocOa9yJF6oDcdupFYCaERlc3jdWaDa5TaOAGi7Bcpir2GsVG?= =?us-ascii?Q?3LASHVtHr0mppR5KYELuFAnSzWCsakF/GHONEPEUZK4KR4mECryiBTiZvR7l?= =?us-ascii?Q?85HYrQOfZoqKFdWxUeCODtggllDziPeHk2uMo7Yk2Q7KLssNSHVMOmo5TiRj?= =?us-ascii?Q?xmtpMlmw901WltI2agrhgBOh3CD5OZnrHJ/qPBvM5XCLezInmcYAMWNjJ51b?= =?us-ascii?Q?coaunHJnoh+6XRfivlfZUv+noPLmZ9iPnjV8eewUrU6zNbTotMbX7vNbGjsC?= =?us-ascii?Q?KFYv+5lTxCfIW1QW699yNNCY2Olpmthaz4w4SZBFu+Wk9tYjWtZNza2lDGna?= =?us-ascii?Q?JPOXV7VaXXi+GLofOX/+qDATzUsVSjl9oSU4fHna6ApYTYy2EwrES1aAk2D2?= =?us-ascii?Q?MWGJjKTFooGIPE5oGOVHzP+jh19vO0ATR54oToFchjI9pZnsE6T4+8rGxPAl?= =?us-ascii?Q?Ug=3D=3D?= X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5d401cbd-bd08-493f-988f-08db02a7bc12 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2023 09:52:44.4311 (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: YD8jUiEDo2GT4C08ayD2fm2R7h7SUwapEoJeqzEoZAw+0BYTyVhnnYR0pHxULRYdnHPZRhXTZtQeICcNgvGzbA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR11MB6025 X-Proofpoint-GUID: vagcdxnEzmk3WoqgBlHKdH6dZohn2hGU X-Proofpoint-ORIG-GUID: vagcdxnEzmk3WoqgBlHKdH6dZohn2hGU X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-30_09,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 impostorscore=0 priorityscore=1501 suspectscore=0 spamscore=0 lowpriorityscore=0 adultscore=0 clxscore=1015 mlxscore=0 malwarescore=0 phishscore=0 mlxlogscore=703 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301300094 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.166.238; envelope-from=prvs=13943e2a21=bin.meng@windriver.com; helo=mx0a-0064b401.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @windriver.com) X-ZM-MESSAGEID: 1675072455947100001 Content-Type: text/plain; charset="utf-8" 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 --- 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 778352b8ec..824ac81ad3 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -72,9 +72,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. @@ -83,9 +83,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 } #else #error Missing errno translation to Linux for this host system --=20 2.25.1 From nobody Thu Mar 28 13:35:16 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=windriver.com); dmarc=pass(p=none dis=none) header.from=windriver.com ARC-Seal: i=2; a=rsa-sha256; t=1675072419; cv=pass; d=zohomail.com; s=zohoarc; b=f1jK8FAvuE+mvfMNh4B8/fir6azE0CZiT/zntkehsEQraD/wd5F35rKFWMxP4bqooMdOtzAPr1MfEDFDzZYbRIbSHecAB1uJyBD0YDC/Kck2YRkZENHTMUq2iReHebvVl1Al/pIUWYdQbIlwwY+Kbu3M8cE5sZ44tfP/yx6sXV0= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675072419; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=sdc1sBW+ClvCoAfMr2NakYHq4WgtRTi5ldHN/9cqbdI=; b=EwwSR4MWszQsJuOytSBs1R4Ytwup87AU8g/rBKpm3S/nnBdp/9pey4TrqpB7ypICGeKrnoMffvJRIj8jICov3GjWxESYP+UOiCmkepdkIS5fcMUoNm/enPbkJLbt+kTPxU2knqzBNa3sly18J1wF+/7mQ1sruZ+CiNaJOTbY5ZA= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=windriver.com); dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1675072418984795.5761996609547; Mon, 30 Jan 2023 01:53:38 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMQqY-0003AO-J0; Mon, 30 Jan 2023 04:53:07 -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 1pMQqS-00038Y-Gk for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:53:00 -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 1pMQqQ-00023Z-T5 for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:53:00 -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 30U8cKgI019681; Mon, 30 Jan 2023 09:52:48 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2042.outbound.protection.outlook.com [104.47.66.42]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3nctpat10p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Jan 2023 09:52:48 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by SJ0PR11MB4992.namprd11.prod.outlook.com (2603:10b6:a03:2d4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36; Mon, 30 Jan 2023 09:52:46 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9%2]) with mapi id 15.20.6043.036; Mon, 30 Jan 2023 09:52:46 +0000 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=sdc1sBW+ClvCoAfMr2NakYHq4WgtRTi5ldHN/9cqbdI=; b=XOjh3n4GijSSrXa00liZuIqlauSCygfCNpUC6ohPcvf94ckp3r204lGci5/plEXNgsyX cUdAUiHCiu6QcOp5PNyyqoWz6I5Ze0pR8qrVMt9Ew9jilRJTcnx7Wf6RwlfyfkcDsY0T TIYAQNUYVsNav4p1RWeQJzPwgibH/EKOtpBeIhSy/MfLNnDXj3sb8YA/YAQuOgJNdKUF CdWwojBxRH56vtdjAoNUVLJdPBa/l5e9KmGuCLnTONwlPAghYjXSdSZyQ034ZcevY2nL CEZ/xLk9oYn2vhAh6PhjRL9Blzjuk+W12mRf/L3rYhMRIycEM+D+r0jSZlNUJXXdUzzP kA== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B1Zsrd1Aqv4zo7buhzlhzFo574A4T+lYBBHsDmvL+bMrf393AD231tKaKnYxYSthLHqajbN6aqOpEZrs4OI3r8RmfNEyBxJzlIaFUHPd+N9UjvxKrlKuJwr5SzMQ+1N4HsQ1HxXJlz48AObRCkClapW7x268Io593b/sbp1qbu/A6PjWYbwM6IGrn9/HQ+Ec6QlqC3Q6RpjICmdaejhWdAeFBUzT7GajUU4iCuXW5oh3yMxMVvMPK8sPSjaosf2tKmvFcmXK+l5mZV5kxo9fMbO5ytBRrRGxtoO055a6g4MUmkt+fWYYvdrL8o+IuuW7Dh7HG08IUQjDMkzGjr07RA== 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=sdc1sBW+ClvCoAfMr2NakYHq4WgtRTi5ldHN/9cqbdI=; b=fIEawzISyuVJjcBdD7Ap0gKG4W7X2KxrvqGpky8li5pG+n5ThVkZQSUOe9xy2uvGE6ulJ1GPVRvqVUK2GiQrweLxCYvw6IgSGnuQzCFiJz3E6G++C2zvL9+vcngXVTOuTPstgraXS/ZEnsv7frYQ4Y7ZYLKZjqLLyK7oN6upIQY7L+AAO3++eXNtTjgYZsvw9HlxNdqIpoSDyjEwCnRieMyDCLZ5MDjKgZQsRW1gEOTstZ/Mb1hyvfoQ2TVx06rx/O5qtrHExLYUB7RV4AKsq8RM+hC5Zvov3L3P0uLs1VnySOoOVFMt/qFcuZRupdcAzrg9yh/tTILuPVDrfXApMw== 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 From: Bin Meng To: Greg Kurz , Christian Schoenebeck , qemu-devel@nongnu.org Cc: Guohuai Shi Subject: [PATCH v4 13/16] fsdev: Disable proxy fs driver on Windows Date: Mon, 30 Jan 2023 17:51:59 +0800 Message-Id: <20230130095202.2773186-14-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230130095202.2773186-1-bin.meng@windriver.com> References: <20230130095202.2773186-1-bin.meng@windriver.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BYAPR02CA0061.namprd02.prod.outlook.com (2603:10b6:a03:54::38) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|SJ0PR11MB4992:EE_ X-MS-Office365-Filtering-Correlation-Id: a6b4ef69-037d-49dc-e28e-08db02a7bd48 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dshwUJpQ5GDPK8Bqx5rovjRXCb4qjwrXWqev94DuhUVlcXgyQSbhNlyugsgiSeSc78ndcrPM7uXxwbyG1wv0vo2a9VxC8qF3jZVvHr/wQU5dgeR2ucXiFNev2C6DipE8mOKn3/fp9Cfs1/ot/pQaZBENeglqvDN+oSx1RUyiE3xKLZCOsRkOM1FRZ0ICUkTPMVFJrZ7oAtMLOMtneOn3Xr/+Hoszcxc5MXVMgUNTBh/PBT52Q4ZXZ10Ic9gKBqNf0mgkZ2ZRDREdUPq/aAov2c22ShJN7BPuEHFYkyebKgM0wK3rdaeob1zb6lYMqwZnMTjQXPGVjzyC2DbDEmFNfBd1Pd8vtScqp5IhZqoIcoL+M7xMDiK6A1YPa/PFUP2GIWwyjOaRJZv9nifh/fPV9Tz6PpPl2Gx+D7NGW1F6TANqvC1sfKvhrbnZerYmjIC59dZ1I6IzvRWVWxoRpGiHQMZDK2yuWMuf0MEg6SX11ER8kBqpnZsQmEzzOiJcLQ1NAZl81Ndr1XNZPayKsGaqHwhR5/EiaWE/trecmUoKijYMfnZD6N04WDcmCqqn5UYndOFBwBvF2Bv9ryLc6KEPuUNIg2dN6hRdLFayfTj+J+ZWSweZgAk3eRcBavhEcub1DXOcNqC9E2JNFlUYuE96Nl/Zgy2Z55L+neQMce/SaunoVE4ADmKicLhgB/nD2yFmuli+rAvT3ontV/+24SPWOw== 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:(13230025)(4636009)(396003)(376002)(39850400004)(366004)(346002)(136003)(451199018)(2906002)(4744005)(83380400001)(66556008)(41300700001)(8936002)(44832011)(6512007)(26005)(107886003)(6506007)(6666004)(1076003)(2616005)(186003)(5660300002)(86362001)(38100700002)(38350700002)(66476007)(4326008)(66946007)(316002)(478600001)(110136005)(8676002)(52116002)(36756003)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?CGheJ0td+CI/4BwwsruJh9xtqVKj44o1wCnDzLe1W4y1rmYldj1zqa4dOgH/?= =?us-ascii?Q?yTyRMOUFNTlj46du4KQh2C4eqxPh9+Xx9tEaOdue36e6IMdmMWoG7yqloJU1?= =?us-ascii?Q?/d7diDzImlsiEQCP2EcFWrtRcIPXKh9gk+YRkrYRBAG126EKt+7tateyajMH?= =?us-ascii?Q?OUM9W+hUFCA/ek5yXSQWw7xGaB2ra4lpwSPpgJcgDBimpbJwSYpwDohN5MhU?= =?us-ascii?Q?qOwXULLpU9W7lqAyHRHNdJLTrppXlv9FwGfoVMJymVjx35nIzlB/UPnucnkM?= =?us-ascii?Q?i8yl5+axgxZqq2QAWXstpW9YpvowLgN3LFwFUVx64segaOE8zjmhmt/Y1KC/?= =?us-ascii?Q?Okdm1ZENs4iWc4FF6XMj10HhWJ9i7lL7Jf5z2YRolLNbpLD6ZJJ++kDTQ2AF?= =?us-ascii?Q?8v0r9vLEB0zuhSVBocAyen51GqilttAtGjhIYqzR+ejz/thKI1s0MeupYX6I?= =?us-ascii?Q?WyoeriznW/4cpjsOmlPH2VU1g1Z/q58nO/hoxeXxfvnX5tEbSW4rYafkO9iv?= =?us-ascii?Q?pvqn3x9ydMLrAE5/fgAXfrJlSJqUeR7tMEAFWegsizmCynz3gC1YDE/ymsfZ?= =?us-ascii?Q?0w9Xu1F4A6nQlnbaC0yzGMo6EaF22nDngaXoJfzDOGIzBNoqmBlIfNwr8Pq9?= =?us-ascii?Q?sQ3awXztC2ESBqEEYDAIV2u6Y+txRCdBY7STupq2lF//H3Z/8dlwbX1HM7+m?= =?us-ascii?Q?Hj6KkOM+tvmYzZR+bcuJr2A7fPHnY3uT9COM7MYXU6E+RL35qET1wb/SU2Bk?= =?us-ascii?Q?u5xvhyMJ3iIcUKRfSFpHS6Dk+Qx3OTZJQuRxjp+PoW1aOT/rGL+saeIfJB2y?= =?us-ascii?Q?h70msuAv0ox/53rOmHFjkHzw8GFkVn9gxampy3GUpXkgrrdKQpVzeBUbq8lr?= =?us-ascii?Q?0ljDLzyWEhiDDk6M2X6uCY2dq+QllB5XgLCyHECN340jPjhSWKooqbCDZy4m?= =?us-ascii?Q?F0isNvtJ+Lo/uUy+/7jZNAmUiDOmHFxXEHMU81yZGM9Lql39Iww/AG/7f5SU?= =?us-ascii?Q?kBr7efgcwGvVS4q7Fyc7ZBuk597LVpNPL34ljVWWY1yms/c1X5yuKk+IjaBa?= =?us-ascii?Q?72XQ/1mUee5R+0CaKQuVTBbrBgqx3gP9kzYviaphxq+bkKDrzAt/Fj6zAyjA?= =?us-ascii?Q?IqLWn4cffbZ2o8YtnR3Z1TrIyKnFG0WIXs3dGTXNyKYZ0NWvpJeWtaIV0v0l?= =?us-ascii?Q?V82KNd2YADhoK/+hHLqA6mLmTzO/k2eVljwW9Lu6TXzixVKuXKPc+VPCW/W0?= =?us-ascii?Q?F7QPboGbPhrv5NG1fyUPbrGJXTa6LgRTrOMzsGgQXn8M94xLns5YBIsAceZ7?= =?us-ascii?Q?IN238gMQxyUGy0Tm4zfCB8K+BFXLpBo6atLjSJm5AwoW7MzG0GO34xgWbeVf?= =?us-ascii?Q?rpjtDl76mpMfXrMvFnEF3PU0ObI4/LVpsXmtzx2bX2RUG+axygTu8hps0UIj?= =?us-ascii?Q?SYhW9a0xf+6x7GjU1PYZGGMDfILG2cO4Nd+VFaQNBuR29F+RrhiH5d9oy31s?= =?us-ascii?Q?rC2eqaoH7+QCbD2LAyCc7cV/GFBAAL3vCdmDEek7mfSp6eOjkJ+ko3oIrO6C?= =?us-ascii?Q?0CwK58al31/Ts8lcKhTdZyKpwt+M98e0m4HY0M/ZsowXa6LWE/XQVvglqouO?= =?us-ascii?Q?WA=3D=3D?= X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: a6b4ef69-037d-49dc-e28e-08db02a7bd48 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2023 09:52:46.4333 (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: eu6azlQGqCRJYJmxMqGmQejVhRzA/BHFc2V/wGFFHXknh5Z8VzfIA1vkNe3az75TxO7RczvTW14RqxkMdwlQfQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB4992 X-Proofpoint-GUID: eojn1l51hplSqWfekzneQUg2RU84LIVL X-Proofpoint-ORIG-GUID: eojn1l51hplSqWfekzneQUg2RU84LIVL X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-30_09,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 spamscore=0 impostorscore=0 malwarescore=0 bulkscore=0 lowpriorityscore=0 suspectscore=0 priorityscore=1501 mlxscore=0 clxscore=1015 adultscore=0 mlxlogscore=738 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301300094 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.178.238; envelope-from=prvs=13943e2a21=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, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @windriver.com) X-ZM-MESSAGEID: 1675072419840100001 Content-Type: text/plain; charset="utf-8" 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 --- 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[] =3D { NULL }, }, +#ifndef CONFIG_WIN32 { .name =3D "proxy", .ops =3D &proxy_ops, @@ -100,6 +101,7 @@ static FsDriverTable FsDrivers[] =3D { NULL }, }, +#endif }; =20 static int validate_opt(void *opaque, const char *name, const char *value, --=20 2.25.1 From nobody Thu Mar 28 13:35:16 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=windriver.com); dmarc=pass(p=none dis=none) header.from=windriver.com ARC-Seal: i=2; a=rsa-sha256; t=1675072446; cv=pass; d=zohomail.com; s=zohoarc; b=ReFKk9AGyHhrGNk28YgIgUTKoE5a8SfxggxwQHEgfTR717W9P+unNE2DzH8nOXzPEx6R4E5H/gZZHfwmw2MT8KN+W/DdlYeGyUAe5rfvoKGy+uAEtepm0zPNzIhjvsMVb6ga9OP6TJlIFIcYzA4L8mVgMg36SLAvqCgLTRSG3J0= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675072445; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=nuUMh1QaGvriG9gaT76BowvaIQgTa1Bz5THTubxNj78=; b=NImnH3Ws8RrsjLYfV1ETmdwqLpTyPjC7bm7r5WShbl590Fy4Knp/XgH3iSzDq+uAz4wnU1yVw96nUpoeG9oUlYOzCOQn7z2tnCGL8Nrd5cQRsn7QzMRFyU+SjjaTmUEsQ8SWJSPnOKOcLp8U7xQSUH75cKsRy4pk4/tITXA5YMA= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=windriver.com); dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1675072444954246.95253540052204; Mon, 30 Jan 2023 01:54:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMQqt-0003DT-S8; Mon, 30 Jan 2023 04:53:27 -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 1pMQqX-0003AG-5z for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:53:05 -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 1pMQqV-00024E-Fy for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:53:04 -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 30U91W7r003981; Mon, 30 Jan 2023 09:52:52 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2043.outbound.protection.outlook.com [104.47.66.43]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3nctpat10v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Jan 2023 09:52:52 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by SJ0PR11MB4992.namprd11.prod.outlook.com (2603:10b6:a03:2d4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36; Mon, 30 Jan 2023 09:52:50 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9%2]) with mapi id 15.20.6043.036; Mon, 30 Jan 2023 09:52:48 +0000 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-type : content-transfer-encoding : mime-version; s=PPS06212021; bh=nuUMh1QaGvriG9gaT76BowvaIQgTa1Bz5THTubxNj78=; b=Vw+iOaTX40BquGg6OlC2P9mPRQRcXWksFiW7tgxXpriuQsgDUvqr/OGQAneIWG5b0dQn XUYNqPo2s9VYT98RLVU9c9O/P615dHUjqrFtPQIrbsXbOGzWeGuoh1bGaNYHgmc0WcaZ aEEpH9yJ5o6s9nxR+uPUFnAj/hc9XJnrQGXWcZCIP48+do337yBiXDkOHa/UC2MTpLBM q5BckCevpckD7zueaXBicupzg3qwB2b0aWM1Qasrsg4jfWp9Nz3Kh8VHZgCuvzdqtD39 rf9zjZAkQOBJE+1sp6+rmOCw1xXlwZox45U9Vn4VDk8jyI5hf1kScRswWOYZeEgnWauG 5w== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EwucTqDJ5qOpG1g9nWmQAv8pc7GBx6c1SedDZvWWpsGOwR/iNb4kCIhGzBKQFCZgGDNRYDrVfgJCU0b//HBJpxqeQjZBy61N09JeHzx8gQubsZRZmPZPaAGOaCtdfOatqaWrDk58tJBAD1AE57NZqECqQ3X91gO83W+slgbtDU3GcSD3byhr2KDrMnR3p/Srco6zwDgENUpk6CsMSNaP9ah0JCbwPSYuSpy4zJRFMekxm+FTbuAd06q8PC2F+rAbbqwPxD9AA83jEpghm0kg0GauSRtu6U3QTSmnTsoFCQcT34TKftH7zIW6dup3dMv67Dq7IPG5DaUNTTzlwFZcCw== 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=nuUMh1QaGvriG9gaT76BowvaIQgTa1Bz5THTubxNj78=; b=GOj5s7DdlHHTlymZPT+Jn0PZELxn07bUZjF+Rxkbhq05bdbWuinOsqkLTYjHosVULN408fu1BFJ2vtSxCP1rQogIE8mQGw/uRzQ0jj0e8pOqxISjS2jlNgrd+3G2YDqHDQyyQT12ii5kYnlF0ZLf8G0dnS86XXH2+8ytMF3nQ38f81dNdfxlUdwar/yheD67fWNvdYSp0VpAHYM1aeJgRt005sYV0UANzOAD+bZLtdRrZp7hj0rlHrlwEyZVoAXzqvdxDGLWwM56LmDZNPEIAhwnx7cc46hOkUzc+pDP4LvGlO5N6J+2HlHpsYbU9HhtGZjbQCCKB9ItYAdikoXHnQ== 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 From: Bin Meng To: Greg Kurz , Christian Schoenebeck , qemu-devel@nongnu.org Cc: Guohuai Shi , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 14/16] hw/9pfs: Update synth fs driver for Windows Date: Mon, 30 Jan 2023 17:52:00 +0800 Message-Id: <20230130095202.2773186-15-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230130095202.2773186-1-bin.meng@windriver.com> References: <20230130095202.2773186-1-bin.meng@windriver.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BYAPR02CA0061.namprd02.prod.outlook.com (2603:10b6:a03:54::38) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|SJ0PR11MB4992:EE_ X-MS-Office365-Filtering-Correlation-Id: 5243b51e-affa-4859-ff86-08db02a7be9f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5z5hNhBzCzcjdLxQEGdjY2OmYPqVfLnFH83R410bkgMvKdgaywQlMY/tOMlAyB9CWnE6OqOhlDZSyXpvL+JXsKOocCUA6oqHUvWeRjQIaL9/lxZa5ZZwgEyydShlYRINERntP+ZbQNogR92Hmbw1hJp2YPeYq1KYCHy5GKlxYrOkhXqWpgnK1tFEY2ecxxt/sHAkL9/qPSecAfmlgH6MvymxfvalOLi+ieczOBbbfNoVVukt0of2mhji8VR3MebJjnPx3vIMfSoJ++9ZihZS0hsmVWpiv/e83kGUZRGWbtPjT9gW4mNfLOBNmXulmqG5qmBQtQpngQKWmgenXaVAvPemqFNUheRF8X2zAd6mqFhug38TWcM0u6TKtEedodtrUWX6JgwykVSji5x+gk9C39qVSCc8hPPTWOSZhQV0mIDjvO9Fkb2f3Ep0TRmWRVxIXF6Dn3GU8SHeAgt0CJ4q3Zj2ckQFcMnbSz7zMId9QElLLM06mQl/Jt3M3qpIilTZKKOPcMZQ67gyhgSXHIVKZNhZv8cl2SUnfNeQROtQgFgjtZhhKhRPtTDo4FawjNe7c1trTBAqDvr12IDpdqn7NRFGSSpRE/iIyVuBsvJZYdCbbszlmjstoNCY5r+iwEcHBVl5qbvzgwWXMsi8jxKN087ceGCXvH+p19eptw0ohQ16dArUKH3IGEBmXYFhV7sdH2CGqSi479L8M5nDlTW5iw== 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:(13230025)(4636009)(396003)(376002)(39850400004)(366004)(346002)(136003)(451199018)(2906002)(83380400001)(66556008)(41300700001)(8936002)(44832011)(6512007)(26005)(6506007)(6666004)(1076003)(2616005)(186003)(5660300002)(86362001)(38100700002)(38350700002)(66476007)(4326008)(66946007)(54906003)(316002)(478600001)(110136005)(8676002)(52116002)(36756003)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?RGUxejRKVmEzZlh1ajNNWW9ONlZyU3FnQjhobHhaOUViNFFETlpRU1dRMkcw?= =?utf-8?B?MGZhMkIwZTFCczNjZjMrWi9NQkdzQ1FkNUNOQ1A2a01Ib0JJZHBhVXRldTNm?= =?utf-8?B?RnRBTEpmRGFaa2NEdEh3NU1DeEVaVlFFaVNRdkJpKzcxS21MT0tpVFJKb2pE?= =?utf-8?B?U3QzZ0tIREl3eTF6RlZ1QTBFRjhwMzNIZnJybkttOTFFMWMrdC8rT01tMHJG?= =?utf-8?B?U2J6TmRxRXJxR0o2UCtCNXZJSjd6QUtmbm0ybHZRMlczTVZOazZuZ2VNRXAx?= =?utf-8?B?VUdYMkhNYVlCSFFxdTMxQktTcVR6MTBrRFpTcjNPazdyMWtrK2Jjdlgvc3J6?= =?utf-8?B?Ri9tUjlUdmhVZENuM1RucWdMb1VLRjJhZ2hVS2RPbE02TndJSjc3SExrclY1?= =?utf-8?B?L1grcU0wbW5DcHJ3bXQ3emdBOHROaC9NWjlWek1ib2NnbHlnN0hub0hyMkNs?= =?utf-8?B?bExTMXljS2hMbzcycmNMK1B3T0w1WVQxQkhwc0hHWitwZlR5K1ZrZUxNbXhU?= =?utf-8?B?RENJS1crTzZiSFdPdlplS2lsSmEzMlFxNEFGbk4rRmtuZjg5T3J6bm5kczhl?= =?utf-8?B?N21QZWZvdTV4SjBzU2NRQklCbm1FaG96N1pCNnE2SlFaZE5COENzVFZ1bFlm?= =?utf-8?B?QWRxNHBpMTNKM0RvV2dZaWdRQW9WUlpHc2hkOUFJUzdVcHMwUWdyMTZweDFr?= =?utf-8?B?aEdvR0xqTUhpbG5Hd0V5cmNTdFZqNTY2SDM2ckdIejU4TUNNY1FxZW9QS2o4?= =?utf-8?B?SmRUb1pVWEU4d1NKMnI4NTBwekFUK3QzVjdWYnp4WGpXc2o0emZrM3NCWkxW?= =?utf-8?B?SnV3Q1U5d3lmUFp5cDBtWmNZNlR1d0ZnbGowK2VERGsvdEFGYnY5VUpGZzVw?= =?utf-8?B?S01rdTNleHdzWUJ3SEl2TGlRQ0ZmUGJ0NzVzaGxmUUlBT3JnaU1CU204ZEdB?= =?utf-8?B?RmtqM0NZR0JwSlZ6dUJmMzVwaEJnelBtSFo2OWpKQXhoeHIxOC9XbThoVHla?= =?utf-8?B?Z2NWSlhCTG01WjhnSW9Pa0x3T0VlK1MyWHRkNmkwRUptRDJXY1F6UTZiN0o1?= =?utf-8?B?UTY0NUpudSt6c2VDMWF2R2xaYVdXeXBXTjJuWjc0SXA1L3dxUXFqaXBsdC9n?= =?utf-8?B?eUdWOXY0QXFpUlJHa0dSTnVtd3FnWXRLcTRNM29tNFRKNEU5WnoyUE5UZW1o?= =?utf-8?B?VmNZWjZjYk5uT20rV1RZWFFVQ1Exb2hvN3c3dHZudlBIT01hNUl4ZnZZRldB?= =?utf-8?B?N0QzaU9ERGFPV3NBazJZQzViSVB1MWpZVmlTci82SEpIcWtGREdMZm9xaGo4?= =?utf-8?B?aWtLdWo2L2YrcU8zcWdReExVcFByc2FlVm1LV3dMRGZ6K2FxNTk1UW05SlFk?= =?utf-8?B?cmw0VlU3SXoxSjYvczNheXo0TDBkVkE4QWpuRlA5akNESHhKamVLVG1OUTZn?= =?utf-8?B?cWdBTDBmMVJvL28zNU1uTHpscjZNMFFzRHNwNVRxZzM1aWZMQzhQSFhLeXN6?= =?utf-8?B?cG1XOU1FUTVPTnhyWGhueTVwbi9TM3VZZ1NUM0tQTDRIMENmQ2FISHFYQmdz?= =?utf-8?B?ZkQvMlNJdytwZ3BLY1lkSDM4Y3NIS1dUUTNEeXZqUWpJaTUwVzcrU0xWV2w2?= =?utf-8?B?cSt5dHRkYVpzcC9iUDlCMVlnWlpLSk82cExrVUZqaUJ6dzBZK05UUlVONXFX?= =?utf-8?B?aHRER0ZkSjJXODhtVmRFTnlYejUrTEl2cmtjK0EvRStONytrb2FOL2lUMXpk?= =?utf-8?B?cTlnTVdNbEFsLzkrcHgzSmZnNTJCZ0FHeXN1TmlsK0JCeUFrczRDT0M2ZVV1?= =?utf-8?B?cnJCNXJjN3ZLbDFGNW5EckY5UWoxb2NBNkg5RXF2R0dkemMwaGY3aEYvSjR4?= =?utf-8?B?VzZCcHB3Mkt2ZWhmZzVqNG1ZeHM2UVd2YlBueWRBZlVWWTVKMFlPQytoYy9M?= =?utf-8?B?MElSdjJFR29TWVpuKzB5Q2lpeUh1VFA1RDNYdWxCRTlUVGNwT1N3VnNIOHRB?= =?utf-8?B?ODA1SXp0VmxKSjlhZ1VpQUI3RCt5ZU9iaXR2RnRwUWRTVmNsOTBQdU9mZlRY?= =?utf-8?B?M2NhRG5pa3FEcWpPZmw5ZTIvZ1FoWndvSUlqcFhZakZRWmtleEU2ZG82bGRl?= =?utf-8?B?eU1NMTNEVWxsRUVrbVlHZjJqSVBXUjd6MXFUaEVZMDFDRWoxUFk4akNjaE5L?= =?utf-8?B?NlE9PQ==?= X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5243b51e-affa-4859-ff86-08db02a7be9f X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2023 09:52:48.6819 (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: nF1gfaTaQuPT5QGVUU39z0jN1tBWWco5xQiRjWlKhFtVSl1VgpLeFnWISpRpQt9n/5RDMfZ/TUWNoReMWImu3Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB4992 X-Proofpoint-GUID: ZxZA_mnYh4WDk6UwJG5NEI7sPFsfyIfr X-Proofpoint-ORIG-GUID: ZxZA_mnYh4WDk6UwJG5NEI7sPFsfyIfr X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-30_09,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 spamscore=0 impostorscore=0 malwarescore=0 bulkscore=0 lowpriorityscore=0 suspectscore=0 priorityscore=1501 mlxscore=0 clxscore=1015 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301300094 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.178.238; envelope-from=prvs=13943e2a21=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, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @windriver.com) X-ZM-MESSAGEID: 1675072447943100001 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=C3=A9 --- 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 f62c40b639..b1a362a689 100644 --- a/hw/9pfs/9p-synth.c +++ b/hw/9pfs/9p-synth.c @@ -146,8 +146,10 @@ static void synth_fill_statbuf(V9fsSynthNode *node, st= ruct stat *stbuf) stbuf->st_gid =3D 0; stbuf->st_rdev =3D 0; stbuf->st_size =3D 0; +#ifndef CONFIG_WIN32 stbuf->st_blksize =3D 0; stbuf->st_blocks =3D 0; +#endif stbuf->st_atime =3D 0; stbuf->st_mtime =3D 0; stbuf->st_ctime =3D 0; @@ -230,7 +232,8 @@ static void synth_direntry(V9fsSynthNode *node, entry->d_ino =3D node->attr->inode; #ifdef CONFIG_DARWIN entry->d_seekoff =3D off + 1; -#else +#endif +#ifdef CONFIG_LINUX entry->d_off =3D off + 1; #endif } --=20 2.25.1 From nobody Thu Mar 28 13:35:16 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=windriver.com); dmarc=pass(p=none dis=none) header.from=windriver.com ARC-Seal: i=2; a=rsa-sha256; t=1675072503; cv=pass; d=zohomail.com; s=zohoarc; b=YFFy3Eu83f3HjMXDPPkqxVlpKec2cu51nbmn6EofuKq1K3E40ZgcHtI6wCpb4zA8WSNlt2cLY3kf/w+Za7513jTXnkyJ3/JTVv83YwKfTmJrSh+klI5na+s4HCE32/kmMFLudoWlxRAJhf4pDEFat2FYgsRGnv3YzDmtVAWafxA= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675072503; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3vCoOHxbCSjHUbC+8+fF0U3s0PhEtrD3RWGpqDkLTgw=; b=PRZV9SGG5U61XXDwt5oRlEkEE18rBvM2pZcgXjZ4S76+PO4IKp9NioA4IN50Jkcl7eMTz1zHBjTN9Y3xy4aTzSrlkSbedKM7zpmdpQCFZRWpArF3VB4wCYRBEp0IZKddLF31zk99onqW+pv0hBeE25PJ5SVV5lt/5pUe08k0Gak= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=windriver.com); dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1675072503051425.4939645869033; Mon, 30 Jan 2023 01:55:03 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMQqy-0003J3-PK; Mon, 30 Jan 2023 04:53:32 -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 1pMQqc-0003BO-3M for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:53:13 -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 1pMQqV-00024G-Pd for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:53:09 -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 30U91W7s003981; Mon, 30 Jan 2023 09:52:53 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2040.outbound.protection.outlook.com [104.47.66.40]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3nctpat10w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Jan 2023 09:52:53 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by SJ0PR11MB4992.namprd11.prod.outlook.com (2603:10b6:a03:2d4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36; Mon, 30 Jan 2023 09:52:51 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9%2]) with mapi id 15.20.6043.036; Mon, 30 Jan 2023 09:52:51 +0000 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=3vCoOHxbCSjHUbC+8+fF0U3s0PhEtrD3RWGpqDkLTgw=; b=s8oSLHGsc2skE68kjNpPEJFKvMxEFjSz07mlClBapytTFYEOMpQO1hfMK4oECYmhY9Bi pCVy4AyAWfbj4BmI2phKJJvkSNp6C5P+mb3nJ67b2OSbhsM6by0QC4siEyhfsXg37AqQ 6UoQws7kzdpi0fBXoVRFb0QLs9qSlwxiGYkD+VT4Qj61SzuHc1+bGOp8drhyC9AVZroS eeGhDN8d6U3u8eINeyYe9iTP1CAOK7yRKCdozQrA6B7usfT9f1vGHzionaseAW+nfGR9 aMEG7EuBfbrP9xPqpOm4VwQ9iBWOgctWzL34EklHlpb8aOIYoLe1uPtPfmh2mfDilnjQ bw== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HqTdkS2AVpkCoAcj8iiSrabBQEdWkbJIJJM+m15IZ8lBz465krp+cMB5TLDj/KOyoH55PU34MOb/HDTtuQasdxDkNg4CrGg/Qty4AELhEABAjmhr01cvZxPpI8n6tr1LTvoD3vskQaSC6Kv74EQmtVDqznFYy0ip4ziLYeAIlJ17eWjReItPLbW7SyJkU/LQTNSrpSXZIs5pSYyXsmiKKvMB6t59qA+XJUFxD9R/d8WmVwkqBN8PMJMt1f+VJBWtwwjXoXWEudZihIy9mUN3fmEjKLeSsvwmbO9TVi1AgrMBAdg1X2TZ2bcJ/i9zUzU2+qmcy0viIQAHm6mVcenidg== 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=3vCoOHxbCSjHUbC+8+fF0U3s0PhEtrD3RWGpqDkLTgw=; b=MibDSnx0ZQMHIbjQWkygFYvadS/XpOo3T/sxyUXvfup8d/qUo7kYQhpZAzlneRQDx9of+9LGF24RB6r/w9VPRv/gVujSbpCzUxsTdKJkR3TZ0s874kPB22Rat7Sb/AcI7an8r/OTcmUgZ1fRPqwF9EqSF760w/H/S3IAsFsziig854BclazpQ3f7IHxtOfc6qN0iW04pI8lOzHiK2pHHiHA628Zv5ZfvfzYjbG5nISUXmwPTkK3A1+HDAVrl95GZaWxdsFs6ilomjONOMrDSpot1Unij6BaSR+MYZHN83l+EbpAkbi2z3OrowZN9Sk4EkkecE6tZzDy9qtiVWracbw== 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 From: Bin Meng To: Greg Kurz , Christian Schoenebeck , qemu-devel@nongnu.org Cc: Guohuai Shi , Xuzhou Cheng , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH v4 15/16] tests/qtest: virtio-9p-test: Adapt the case for win32 Date: Mon, 30 Jan 2023 17:52:01 +0800 Message-Id: <20230130095202.2773186-16-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230130095202.2773186-1-bin.meng@windriver.com> References: <20230130095202.2773186-1-bin.meng@windriver.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BYAPR02CA0061.namprd02.prod.outlook.com (2603:10b6:a03:54::38) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|SJ0PR11MB4992:EE_ X-MS-Office365-Filtering-Correlation-Id: 355b998a-af23-4f06-51f1-08db02a7c060 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: T3/9jNoXe1SIL/vtbtOLtS7JYpkB5u2ns+G4XhxbyIwis9nkAjgcB8HFR73th5a79/BYTl4OpMRCy311pSnlyXETJ7v3db9Rk9D7WxiZWmOPXkzHDaRUhymu3nXaiW4u1SovwfJRTgb0Rrf5Qb/LbS5/cCkVuaA9eoWFz+ZBlYtjsyiB602owEWsyL1OFwan0W61Oq8UwQ6LXeaT66ey7QqB2Kp21F7xFRlCt8RYL8blUVTwCIZZUnSy/UctYnx4bVeezVTQMaPPclR8oaaSignz+WTUdm15/bfMNXhoGQ1k/ZkvKS+h6wxgFdF1wLgYht9jL/jRW4OMHS7fJdFliLlanFITCZDpuS4hZTP1+ex6iPfjFMe/Dr9udVa2JobADfqzqNFdUZHmsJhskjIAeOQ5X/up2CFiBd2TE+IXM4UwGLxtg+r3eA25CFu9LoIbzho8clS+ncXdMbevZZ9njA2mqKsSBo6yOphiSrsgn0R263xUxRT52CMOsIPVHk+aUkYLVurg/c3HbFM9zTeHUq7TvWmnwppamk6CEYTFOpIFbQC9jFz+GjKq8iC6G4hl1oy0XQcuYHppMDdnnZqveveJmP9sOrMbofvhV82GINCAT//lfQM8MwY8Xd0Iin0zaGaRPC6oyGC5vFsM/GmwfVjb8OkOcxOP0bQmeIiTwMqV+JHJPtSqom6PX+rx4Vl1Qaf51XT92Mox2k4Vfq+DXw== 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:(13230025)(4636009)(396003)(376002)(39850400004)(366004)(346002)(136003)(451199018)(2906002)(4744005)(66556008)(41300700001)(8936002)(44832011)(6512007)(26005)(6506007)(6666004)(1076003)(2616005)(186003)(5660300002)(86362001)(38100700002)(38350700002)(66476007)(4326008)(66946007)(54906003)(316002)(478600001)(110136005)(8676002)(52116002)(36756003)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?NVltrcNcRx8++QKs+6/KR3geQ9UqDkI937TRTKKB1BIuKTjtd4BH8kwobOZx?= =?us-ascii?Q?RHqvhlpx5Mw7GFxml7GdM7QNHdJu3obkNSiMfCOQojIv1X0M1xf0vAFzed9P?= =?us-ascii?Q?1EfYa0bLHLu/rCfWn3FbeUjx8Dzdng7HhB+S7z/h2kNfONyNrEu7W1Pzv2QW?= =?us-ascii?Q?vN68dcVfVy+ZJxDAph15BirqU//mNA92v5whIjAWgy2Xfd0QSmR5yyd8eKZ0?= =?us-ascii?Q?YwwYVXT+gWPvesualA87f3YRfPzeSvcaQl4yQQxG7iBwpi4M/chUklxfbx17?= =?us-ascii?Q?21Q9TFN+TVPUImJD67pKDViDgrlqzrKc0f9kRVIeDEBt70lWTp1skm8okRqz?= =?us-ascii?Q?tpQxNh6TW0YeQLImH8zuoJpNCH/qb83yo7SmuWN9weTwloGeepyxXnly1YNp?= =?us-ascii?Q?AojEmjO20R2EgyezjWQiEIp+nDPvf3Z8sBeh3DVyVljCLUQzkYWMvvDx81VM?= =?us-ascii?Q?Scwm9BGBVuKrPmhHp/dQ80cQuMV4piWBk6MIxfVbljzGcWwWDo8A0NTgMiUr?= =?us-ascii?Q?fhtT1uPaeAu9X2PcjX5BCrOG4y5UrPNSNA01F54+cSsHx4g3jwRe4pHGtH93?= =?us-ascii?Q?chu7UWY+NYKDayf2x+n7POIKxZDqbGZdJHzosvh8HysiALZ2I7dIJSvndgN9?= =?us-ascii?Q?LPVpoKBN/WF3PnE556jG22PTwVv71OXJhaoaPpMogf0zCo2wNvt7PVHxluGT?= =?us-ascii?Q?r+aUtELi6IqA4TWbtPjatbPidmyDi07EFJYP4Pat1iJOTh6D9C1Pv1pmXfC3?= =?us-ascii?Q?9JNVhzg9oAxKO/dzaI/UHbl9KvFhSJ30JyjUgENXIOFo9yyjKTPnOdtNnboT?= =?us-ascii?Q?MxXHD6eGKsv68ZSXKu1Jxr7kwjPMKMaW1ZPau5jrDuIikKGXBWUFbUtqg30g?= =?us-ascii?Q?dAfK3prD2kRL/MmIQb3iMlhQOSj/ZJtN2usiGhvQmxG89Q9bFFgOnBR0jp7w?= =?us-ascii?Q?zHl53uWS0eJwlVPqClVYXSvwH2ldPRdKJQ9ANYfKHWfRNqCHESgolJ+ZW6mL?= =?us-ascii?Q?sk9rYKGCJEsBln1+sQRkAd5zIHU5H+2aFbuXB7zJkn++uY8yn6wCS2nhJNh6?= =?us-ascii?Q?uAWDvmKREJ59iGjV+9rTS+awrjA7TYwDZJofAjQR9ZH7zBdwNyqBYPlHh0H4?= =?us-ascii?Q?995pybTyunBmoPIVlvm8k7TZFNxy0QcZMIzvH3o4by4ZFMuhD/JFcO9Thkrr?= =?us-ascii?Q?ez/CJbilXX9s+cQzoTtMhjVmR/XAOi/sxEDYnUcf/JtJTxZx4FA9qCYmoahz?= =?us-ascii?Q?vsDb2xnl3R6wTm5Q2HP2sBorQrgKfC+Fuy5+HIyB9/CoxTiOqk7eJRARatft?= =?us-ascii?Q?2sSf9olg13S1081XdMjA0BXnFBC/zQgVdcxGy749YKW/nCPuacUpyvdHBP5W?= =?us-ascii?Q?iT0llVG/LjtD4GsfAMdu7Ygqj8AUpJ9R/xh0U0K4hSIGLP6QynMz9vWD1Y7/?= =?us-ascii?Q?dvRMwySdkZPDxLAfSI6lTsh+dilbMtEUkuM6yITJ8xjOGZKEScjX0UdMFwH9?= =?us-ascii?Q?j1GbcVGmhNibkhw4/db96nrZvvgDhz5A7NKdBXd0kIGxuXbLpO8SWYrcKaE/?= =?us-ascii?Q?BTogYw+VK8MTUticHxVMghdUu1yhkjOtPSzMpgdTo2AdTPOVO4qEaA15dFLM?= =?us-ascii?Q?1g=3D=3D?= X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 355b998a-af23-4f06-51f1-08db02a7c060 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2023 09:52:51.6370 (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: hU4XKEl/N5riscI4X5Ln8QPJsLiI/N4t/1Tj/ShBcfw7VZ35QHtyfAZc5PrETZKyEc2zNNfDxP+E6N9LWxrncA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB4992 X-Proofpoint-GUID: 8oyvZ28CR2nL6iupOWosAqBllq9Bbe7a X-Proofpoint-ORIG-GUID: 8oyvZ28CR2nL6iupOWosAqBllq9Bbe7a X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-30_09,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 spamscore=0 impostorscore=0 malwarescore=0 bulkscore=0 lowpriorityscore=0 suspectscore=0 priorityscore=1501 mlxscore=0 clxscore=1015 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301300094 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.178.238; envelope-from=prvs=13943e2a21=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, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @windriver.com) X-ZM-MESSAGEID: 1675072504137100001 Content-Type: text/plain; charset="utf-8" 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 --- 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/vir= tio-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); =20 +#ifdef CONFIG_WIN32 +static inline uint32_t getuid(void) +{ + return 0; +} +#endif + #endif --=20 2.25.1 From nobody Thu Mar 28 13:35:16 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=windriver.com); dmarc=pass(p=none dis=none) header.from=windriver.com ARC-Seal: i=2; a=rsa-sha256; t=1675072428; cv=pass; d=zohomail.com; s=zohoarc; b=MIAtkzfUlUIBA/PMsElb8N04Y4rwlrMbKTbh+yeCxKJnEQqmzOywJykiimgrwZVGhwNpsrsc553Vlzqzy4zkMBfGqEwBDrHlj0EXtcMmyixAEyI+i4JX+7NS7w7/rc80JZbOvfTDnjy2FxzhBrSlxC0NC5u+R1KSR68D7AaH6Ro= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675072428; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=scX7/GExEU1Y5uS9tlcdpKJc4lxQrcY+YBKv1AXl5YA=; b=mh5Ksbm3xE9d14ndq9LemmTp8MEVGz+z57GFVFFHfNLP7rfmbjEKcHH8GT4e3K7sXo5Ts+CwR/zVRCn5fvE5x7emNzkceztC9Ao9VZgMS1y8gMLsgJNO1IXnbNfFF/lZgqfIGoNqvQOEXqfjh2dlLSwBNjKreE6r8rG08tfVBAw= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=windriver.com); dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1675072428454476.72684487535344; Mon, 30 Jan 2023 01:53:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMQqt-0003DW-U2; Mon, 30 Jan 2023 04:53: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 1pMQqU-00039r-HJ for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:53:03 -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 1pMQqS-00023q-Q7 for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:53:02 -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 30U8OtRK025559; Mon, 30 Jan 2023 09:52:56 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2047.outbound.protection.outlook.com [104.47.66.47]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3nctpat10x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Jan 2023 09:52:56 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by SJ0PR11MB4992.namprd11.prod.outlook.com (2603:10b6:a03:2d4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36; Mon, 30 Jan 2023 09:52:54 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9%2]) with mapi id 15.20.6043.036; Mon, 30 Jan 2023 09:52:54 +0000 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=scX7/GExEU1Y5uS9tlcdpKJc4lxQrcY+YBKv1AXl5YA=; b=kOeXnQQffAbSGo97+Cog5tatlFbfok+T2+Uf6BlLED08eu1SVYHWBD8BMFSGKKVYIwMa 9NmS96otRXM+3d8cQYwhUvsckK3bRnUp5h9NLVLUrbxpFYun9fOfuwBT8hrB9HO0Krqm Eq5fwmovvUK782jMQ6oNy1Jv6tRRM1DbEDvJb6aITvFKix9GuWbQ0wMHooTSMt0qpyR+ QcwwqISIFCfP7iOmE8nKYX2sAA5TbCOSsepihpgwsmKoht31EseACrNhxw2uff8janhO j4Wr88LLWKKyv6Gl7Ti2ECPBn2V4HpQSiXeXsGmD11PcKAonW3ULrwis1j29yHxrtaGk Lw== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ofYjYS5ctjHnB5Td6JNQ3985ycsLZZKDuE/uY6Du4wlD82V+niutX59G2lr1pI9L8EEHmID0CYD9IvOuxbSUyDKdIZiA2Sr356n+fYSHHFdO+SsJTVdHEPBvEg+KDO5bwSEhVATALfhOONOKK2VRBKiam7/gC0BfCIBrHhktCRPR6UnQtIhcod4KF2r9944uP7/v2LU/q6e4fKm7PfHcWLFCMw82202YaffmTQDpkU0oOFA4iaeIrHJCSaYQe3QjFvV+lTMQ5RHuIBa9HAdZn2VdfL27hhM1Q6xsRXyGVoF1RxiAHfQrF5Uvt59bKGdfvQ4d5BMGpw/RwwG6XM4SgA== 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=scX7/GExEU1Y5uS9tlcdpKJc4lxQrcY+YBKv1AXl5YA=; b=WAUtz/szGey/E8BYLGwEbWRkLhGusyBMp25zl/xaN5f2qFhfms9HkRXmKwj4ckWJhj1JlKQ+VHTRY6KiTU3q1Dn9YfTGQVjKB8iRGJ4wIoOK699qEZ0205hDUxlicAqIhIx4MfQFmZlfFLNAwShaUETRDAP+A/J4Jkh2ABlQPy2TZ8eb66bI1Nv5RSA5oHoaazxYz64p+KeIObj/QF2D5LqrECLCJySErBCkxVzdwTFmROfjVkIDdn0LjLttsoxmk3BqrLUlM30bIHNq8Jq4/JpTIb03zsjJZsqagZF1k09I1VNwwlIGbZN5ky+T+JgbDVCGAFMwQcKNVMTW5Gsqqg== 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 From: Bin Meng To: Greg Kurz , Christian Schoenebeck , qemu-devel@nongnu.org Cc: Guohuai Shi , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Thomas Huth Subject: [PATCH v4 16/16] meson.build: Turn on virtfs for Windows Date: Mon, 30 Jan 2023 17:52:02 +0800 Message-Id: <20230130095202.2773186-17-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230130095202.2773186-1-bin.meng@windriver.com> References: <20230130095202.2773186-1-bin.meng@windriver.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BYAPR02CA0061.namprd02.prod.outlook.com (2603:10b6:a03:54::38) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|SJ0PR11MB4992:EE_ X-MS-Office365-Filtering-Correlation-Id: e518301f-6713-4e87-2d1f-08db02a7c236 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LKzu4wtHYICGXchgaaZgpyHuL37pn3cNUlEENodYT8A4vnPYG9EkS3XRS/80Se29HsFZUD9ysBPgKeHl3ywJfMxqIr+jCtLcHTNDe3oJqfouoxiFnfPeAyUV5szt1FQWvqus/yjdeA9NTFKGwCBQhVmFV6sJNGPrKP2tw32NwwPCoEjnFn2gQRsinRdIrVJ0wOZcmMm8YFzYSH8WbEuDQqQUft1YSky0PN/QabEL+BzpqxHxdvzIOyXAx5dkXPg5/oIXgK8353g+8BDibu+ury4ll2XIUCm11nuWMLx87JS3SLMLoxBu+HwLRsUMh6P19qHKahEGM45kfnplb5w2YCr0Jg9K8kkk70BWvP/ZGf8/TicFbAeCRu7Pz+M29Vj7TqT5R9LIblMw15W4Kox+NtLGPMTSwsiei4abGt+kLbprQYF5/vKZmfFTEJgIj4bv8+Xv2VKbGmz1HLZwUrWV8BlTvK0Hog0UvjYcqCQAxHV85vW4rA8mmdyXfVCoxkijEc5ThquYiXFuzR4a4NWzFsObM2ykjfmCBpmtzS6r3DYNgoQ7MBUE4q3nacvJ9/b1aQ6Jhtnn5UhMSWvHEpF2lRMxnSTQTTHU3PTE660jiOCeM9wlLKnTMYPKBPq3eLg3+AG8zib611/Ul10XeiiXMNlfjr6OEUpGOkX8lPH3PaccfByhhVeFU+1f9ZPy7ObPZ9sqndzTyKQ2sKfdUSXBKw== 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:(13230025)(4636009)(396003)(376002)(39850400004)(366004)(346002)(136003)(451199018)(2906002)(83380400001)(66556008)(41300700001)(8936002)(44832011)(6512007)(26005)(6506007)(6666004)(1076003)(2616005)(186003)(5660300002)(86362001)(38100700002)(38350700002)(66476007)(4326008)(66946007)(54906003)(316002)(478600001)(110136005)(8676002)(52116002)(36756003)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?aDNmtD5fsRhMc29CDN4mXwfefnq1tGWmZzAQa/54PM4yycZAKcWr9uG328BI?= =?us-ascii?Q?ZYK2l2Z4JjR2OAdfIebOc28d9oF+vXmyFFRuHBGH6HBcklZ2n5t4Snfh/Mnd?= =?us-ascii?Q?6Lmqz9FCIGk3A1E2kMRzpHQAjrlFbdXCQnTbIWqfs8ElIE7UbLe3vSt9846t?= =?us-ascii?Q?vhWUlt0h1jxd3GBu17a1cSMzmsflHFD19AEEVIvLyZQ+7m7zT4+4yaieFMB4?= =?us-ascii?Q?zIm149LklSScFzMAGTDCxmq1OO8bwEV/yYCBY8ROysFjb2lDSQ4fl7AlhpQg?= =?us-ascii?Q?FlDleEX8Lyuw2j8KgnhWtWlYYhP043gEnKogof0E98/1zsctYtbjJ001HNRo?= =?us-ascii?Q?QlPFz0T9A2PqqYNgSETaSsrBxw/9cNr0MDUDmvpykrqJO8na7O7CpGz1Bm/H?= =?us-ascii?Q?ey05pNphvHvq+IRhEoLd5Ye/Xx2ef8a+6na3Ms9Rhdz6NMedlKqLJcRsZivK?= =?us-ascii?Q?qfmxwMv1cfJs9M1h5Ye9jzM88OL986PzWcX27+uV/P1Kg0RVjbHDjDM3e9Hu?= =?us-ascii?Q?BQE9TwI4e+GjqESUbgBFW5wgXaQa1+NDq2xynFMlCeRnyRYazmo4n2jiQUYf?= =?us-ascii?Q?uhK/H0QNsKGEfQ+KPpsF6+tba7H20xwiMQKQVVG6Unj2+MiGBY57ibtYmER+?= =?us-ascii?Q?3BtBD9TF5cE164hcFww3F3u9YCKrIJAw6tONSB/m5HEacX3QSvhWOesDy9ON?= =?us-ascii?Q?3g/9w8GgwILyvfgwvVgZUnRVMgrOK/Q5DLn4kkEIu9yHYkmTFBq34XwyQWYZ?= =?us-ascii?Q?qKkf8NZINvAirbHY4G4kigZ3ShLUm2RQRb47+K2w5NPX0AchLtxx7Jb87kOc?= =?us-ascii?Q?iKcr13cq9ZgeQo1JN/LIrh5v9GjGLaM3NS5AwNsvUlcE1jvMr440uvazJM6L?= =?us-ascii?Q?cgyHmbJTArxa7gi/LEQj+erEdHa3uaq+0XahqYNeiAJ4m6m2zsf+d8fWD1Cl?= =?us-ascii?Q?n3Qx3tPpC3yv5UsF/vswOXZrri2mezSaWw9/earQ6vo1r4/hVa+HVTKPpNqA?= =?us-ascii?Q?MQ8tv3yReaBDGaNW3+9ztGESPftG9wOQKDOvYYxVJjHOG6jbsNYYli2UPxu0?= =?us-ascii?Q?vJSsxgwfP5zozf7hVFU8rOJrmUNmvagHUQf94avuxSnVcds5/bzh7Gr54wPI?= =?us-ascii?Q?T7uQI0T2OmRp8t6q5np6A5bP/p0XwS8KNUtuJEQ7VVs0KcAz3JbUrW/OuolF?= =?us-ascii?Q?K5kJooG1WIHdW+OIXn/BAj/oSJj0ehMHxlJfCDvh6qFYAgrchAb1IMs/PiDh?= =?us-ascii?Q?aUQA4UZme13CDQcTbf1zLQuH46dZLcpz43k/nvBqkDK5oM/r/eXlJDiAg6T6?= =?us-ascii?Q?p+6lpSq7uzykBMtnyxFIWt+B0EI6/Rrp6kp1nLmRYQu2X5QRBt8WAwui87Bo?= =?us-ascii?Q?m+T4d+/LiebyG+k6o8knkOFZmKRjV7iNDfc+FbhXIJZBkfLTIGgF7ovRKrdT?= =?us-ascii?Q?D4nHeergqma4Yyt6EMtLO9GfrvDlK8JNvOv3OdQ3Wfgmd4ymG8fdnHOsyHg+?= =?us-ascii?Q?J6h2EQX6bzxdhqOgKdhRdxNOzfjXXdowoENxlOfgwNcH/Usu2yt1m1XfB1C/?= =?us-ascii?Q?ozJjb7LNwiheXMFxt/Kme6loIXqKcJ1Kj8j0XIRPC4eXi5VDxthFjBTCrG8o?= =?us-ascii?Q?+w=3D=3D?= X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: e518301f-6713-4e87-2d1f-08db02a7c236 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2023 09:52:54.7318 (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: Wf3+hLvGuHrxy3Wgc9oEK4JwgyEd6zJqPKNPPw7l87jU3k6ZDKUyS9JGGbI/9xkyao9e1vx4LKjBiD0Xb0FRDQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB4992 X-Proofpoint-GUID: IEoQJcG0g5ostKxyf298g-cxnCKJOk0B X-Proofpoint-ORIG-GUID: IEoQJcG0g5ostKxyf298g-cxnCKJOk0B X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-30_09,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 spamscore=0 impostorscore=0 malwarescore=0 bulkscore=0 lowpriorityscore=0 suspectscore=0 priorityscore=1501 mlxscore=0 clxscore=1015 adultscore=0 mlxlogscore=803 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301300094 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.178.238; envelope-from=prvs=13943e2a21=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, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @windriver.com) X-ZM-MESSAGEID: 1675072429897100001 Content-Type: text/plain; charset="utf-8" From: Guohuai Shi Enable virtfs configuration option for Windows host. Signed-off-by: Guohuai Shi Signed-off-by: Bin Meng --- 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 6d3b665629..8123136fdf 100644 --- a/meson.build +++ b/meson.build @@ -1751,16 +1751,16 @@ dbus_display =3D get_option('dbus_display') \ .allowed() =20 have_virtfs =3D get_option('virtfs') \ - .require(targetos =3D=3D 'linux' or targetos =3D=3D 'darwin', - error_message: 'virtio-9p (virtfs) requires Linux or macOS') \ - .require(targetos =3D=3D 'linux' or cc.has_function('pthread_fchdir_np= '), + .require(targetos =3D=3D 'linux' or targetos =3D=3D 'darwin' or target= os =3D=3D 'windows', + error_message: 'virtio-9p (virtfs) requires Linux or macOS or= Windows') \ + .require(targetos =3D=3D 'linux' or targetos =3D=3D 'windows' or cc.ha= s_function('pthread_fchdir_np'), error_message: 'virtio-9p (virtfs) on macOS requires the pres= ence of pthread_fchdir_np') \ - .require(targetos =3D=3D 'darwin' or (libattr.found() and libcap_ng.fo= und()), + .require(targetos =3D=3D 'darwin' or targetos =3D=3D 'windows' or (lib= attr.found() and libcap_ng.found()), error_message: 'virtio-9p (virtfs) on Linux requires libcap-n= g-devel and libattr-devel') \ .disable_auto_if(not have_tools and not have_system) \ .allowed() =20 -have_virtfs_proxy_helper =3D targetos !=3D 'darwin' and have_virtfs and ha= ve_tools +have_virtfs_proxy_helper =3D targetos !=3D 'darwin' and targetos !=3D 'win= dows' and have_virtfs and have_tools =20 if get_option('block_drv_ro_whitelist') =3D=3D '' 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) =20 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 =3D 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) =20 --=20 2.25.1