From nobody Thu May 2 06:33:09 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=1676888148; cv=pass; d=zohomail.com; s=zohoarc; b=QoGdtz3h3OY9FdFCPhpy3DMoDGRNLRo0XXL0IHM4btQFo2sPeJxaXvFyGE3neFZT/J3HsGm+eayuwS5iZbGss+l+IjZ+TDVj3gmExDSonZpPHbAnZWop4jsjUe3lpbg1bY2GUGm9BcoLSgf+jfzJlxM551T1TDuhh2+Nq7aLzU0= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676888148; 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=E6O2Zu4G+T//iYKn0dTlpImH/zQUwSKL72dijN3ckXKjwYiiWoEy0o3pbZ+l+H8ehALPMyEAE8dF203gzRvwGq+TH25Chuxk2JzVjrgJbYR13c1jhCK5twEc4h7T/tA1MOwB4Hylk3FjVLxagjR9kVxZbt4hMJEwDROTH3KWZY8= 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 1676888148900707.8695410731425; Mon, 20 Feb 2023 02:15:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pU36R-0007z0-4z; Mon, 20 Feb 2023 05:08:59 -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 1pU36O-0007wP-FB for qemu-devel@nongnu.org; Mon, 20 Feb 2023 05:08:56 -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 1pU36L-0008TK-0z for qemu-devel@nongnu.org; Mon, 20 Feb 2023 05:08:55 -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 31K8wx9d029409; Mon, 20 Feb 2023 02:08:33 -0800 Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2173.outbound.protection.outlook.com [104.47.59.173]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3nttu6sfs3-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Feb 2023 02:08:33 -0800 Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by SA2PR11MB5066.namprd11.prod.outlook.com (2603:10b6:806:110::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.19; Mon, 20 Feb 2023 10:08: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%4]) with mapi id 15.20.6111.019; Mon, 20 Feb 2023 10:08:32 +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=ReS50mlgw+CtluUV3LDudoPljMRu5eLL8KVmv+0O1SZWE3oKZU5EdobDh8bom6zF6o97 XCPYp7Uxr2MtR83/Ftcg7ymlLcYFMo+fKuuTrWXFFqB+NZe7qYcRRjno1L2kyJYKXg3R NyJunnGEXm+b+CDIzm0A2ewA4pkTEE1Hhsdwjw/ptsdPl1QoXoXTTZOmbkk/hDkmB3B6 IboBTsSn0kDTyzju0yC93r0HipR/Kb0K2u+LfLf0bOMKulTfKHr4ruiM8kxm7GRMUcfx 6SJZ1yQV/2cc0T0qneL538G1oM94T3daLLhwkl2ukjncqsJE94CU4rxewSstyHNfXJ0S Bw== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iH2yxUWtD5Cnzyc3KoEVKRqteASwPdgF97rIHylTkTm/+jhNW1p5eDaALMt9URF4/By/j75fs7reaZwVFKDG08PWU654dI9bYfcYqWXk2H5U2l1mL7mOb5INw6nMsYC6L8uEFzx881ZZoQ/y96LcVLL4rxaHUwa4BWe9Y9roblWGAnbzYS2Fnh1bPf9h0oy1FGQGjbGg7vTy2umTUybTJS5EQuVRDzMr+a+/+itCjSO7T2MrutW02HEIpqN3P4DigDv+TUjm8LjX5zwLd49rVnC1BF7V6B73DhXyzBftzpnx4KbjQ5PPiiX6hznrvTMsdkp0RUj67wSo+vXPSY43zA== 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=YtcqGV1Hy0blXY6LwEtK/R4Kyg4sHNXogKmsCEDEX4eJmKp+YTSm57+oTC28h2JscWdVl3BzYNkJ26P/uRxFLho0NVnWWKS1WPIHWV0Da5bURQQ8c8DE1QKU1kMojWdgCkpw6BN5IiH6kPtPpVQzvxdt5IVHopRiwEs5gvKr3dO973MjmTG2EUyKLHNg80s/tb0WoU2N2YnxT3xXIHjVqPDUFhpklQ84I9MmcSdpGS6/wV9+/PQDlbQfV8TK6j3fTtxtYA62nGq7DT3/nYBSmDdYPBWKD/F49mDt5bZr6ZqnOxjoQwoyr2yQ5usP/ecGrw97u0/z+bxFDgqAmy3hsg== 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: Christian Schoenebeck , Greg Kurz , qemu-devel@nongnu.org Cc: Guohuai Shi Subject: [PATCH v5 01/16] hw/9pfs: Add missing definitions for Windows Date: Mon, 20 Feb 2023 18:08:00 +0800 Message-Id: <20230220100815.1624266-2-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230220100815.1624266-1-bin.meng@windriver.com> References: <20230220100815.1624266-1-bin.meng@windriver.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SJ0PR03CA0220.namprd03.prod.outlook.com (2603:10b6:a03:39f::15) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|SA2PR11MB5066:EE_ X-MS-Office365-Filtering-Correlation-Id: 9aa00de5-f255-4fdf-e597-08db132a6b96 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bebMYaIgiif4e0dR61rGXtJLtSpOAnSobeYI8AJixAJuSdHISQc1nDOygHb2FRZ+bIzitWBwxA4r+T1TtPfxgXqJfpP0ejtGTmwG+e6GvdMn6QHBpoxBWqdJsI8i0vsToA5qZUz0c2RxpU5x1R2gkhdM+iwI3XYj65A6eA6oltQ+6omeCxPZWCyyh44r524q8Cq8MJtfpnhpv7Xia/LPDwtJ0tAnYrp+VT+TUMykof8NxqBYeKtPE/aRRQtdMvBwSCo5yPyKOZbD0rBg5rSbXS/OmPgRqzkIHFNnOBct6Q8rJLl2Bs6Ydbs3AEDaLtNwSbJI58lpBzzy6KdeoB/B0ijTiKLA4XJpdaGFZCg9ApJwC8qiVGNdcY1OmQLEf6DOhotF/bcD2xO7W9sCMJZqPJ4HAdg9YGkCXAamNneUaIdzlC/H65UJsoyZjfnVLQv5r+CIez066SI7u37LY0DM5eI9buj8v2ypNFqoxUwuGG00EA4qUVoR3eu8QTXQlD+SUtT6COdsYoHDHPKOdG0EDqkUWiNONn8vCeNxX4q23KBqeItaJIS7XKwiw7k3+OneyR3t2A0jXQrQ7WY+yQdjWoax8VIRhkQyXR6XVfMGaSAKsbxN8GtTkcvGf9EsS2NfFqsH5IBHYUXEeXUA0ofcSjMqSgmLC2ymuW6w5R1VInPsgWhTwCDvJ/ePfDjoZ7SB 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)(346002)(376002)(366004)(39840400004)(136003)(396003)(451199018)(2616005)(4326008)(66556008)(8676002)(66946007)(83380400001)(66476007)(5660300002)(8936002)(6506007)(6486002)(966005)(107886003)(6666004)(1076003)(6512007)(26005)(186003)(52116002)(36756003)(478600001)(110136005)(316002)(41300700001)(38100700002)(44832011)(38350700002)(86362001)(2906002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?M5scc2bkTxop1sjdm/BelKGLpFJhEHY3Z+pzvG/Qw/FAzURYv5so/OPgZ0XO?= =?us-ascii?Q?hn7Sf7ejhk1dgGIRLSMuu5mQUBMb3rD5oOKXiI+kIH09V431uTcQFOd1XY6N?= =?us-ascii?Q?c534fMzOchNhD4wdk1euoS2HjFgLUQieOGgg5YhSU5vguIqfhU8sX1kCBpqy?= =?us-ascii?Q?FGtSnrUzosnT0JV/0UskqohhcB6H+MQgzh+unAglvmiuGHY7nXb1iX/d5LKd?= =?us-ascii?Q?kVlKZaKZRhNNHvoUWYlYxxTI0fgN414OO8Le4rADjjeneczt2zLkUhuqPZG3?= =?us-ascii?Q?DcHid2jYayJJbRhtGBDzgOCUP+EIhUtTquRAMzZTfAGS7FLYKneUYYp0mmst?= =?us-ascii?Q?8lqAdzseviPT8voaGD75uo4bNTlMpa9JaRXOd/o/j/Iy/gfplT4v5NqobTSN?= =?us-ascii?Q?1ztTyNtlK/O8cUNsK+ncAMcgv1m5ERh25VczGxX4SfFSObiYrKbKyB7M1uYu?= =?us-ascii?Q?438a5jtI8QuZAKYdwLKERQSI0Ad/AEWNUyrs0RqLzPKBWtyMfmMmX1n1xmv0?= =?us-ascii?Q?6Nt2b7I4dmCY0uPOQ2qTpBIDZAIvy0Sx8zQS8x3VUjJlFDD5J/UAJhNDu+ek?= =?us-ascii?Q?nDl6QWLzhcJS5WEWiNq6A/anPVtQ009TYPgW6UlcM8/uiSEahRsAU2beaYEh?= =?us-ascii?Q?/XUpA8O8iRfkIv28QLCb7lpqBOvaZ9UByNGj4g+UsvXmDf6IMdW69vy24Jm4?= =?us-ascii?Q?b4zBAF9P5NUK6JX7vdcSjedvyJI/pIIPMy3k7iDyRzKambFtlFw/Y61qO71f?= =?us-ascii?Q?Nqv52NTRZhx2HH3TRO0uZgmOKE1FrW8FtvScL5cso/1ka2EBmSFF/4SamNRv?= =?us-ascii?Q?sJXMGBzSqLtb2861pbFJdytTKqYlOf91RxcWcS0/X2R/5WrvvlpMcHbUBeR1?= =?us-ascii?Q?q5SakGdgSxLjD0c5Yei97hrrRw9HLpb+YTmmlDKCq/SaviyqNhPor2AqAsj/?= =?us-ascii?Q?U4/y9wLW1rDHjToH2buM6zELZPRijaaJ1cJdYDMdKO0KQq8JtID8mkkXPwye?= =?us-ascii?Q?oiCZJY/RjrcL7zvkfrf0ERo7gLNO1k09zcNItXV3iMcm0Jpi4UDmhzdLjFw/?= =?us-ascii?Q?lfsmFil4SCZkWdx66cs49EqxGoNJ61LkDbRT37CStX+0ef8hS4Dg7YX2w4eX?= =?us-ascii?Q?si9CdHGFjLxUrCEnRrohnI2UlLDS1s3P5aDYMuRpC7YJK0kNK4Bwx4D0JtZa?= =?us-ascii?Q?lS6+6Vb47I0MkiQbeVEbXp7MYIGTQwWoRT9TPD2HUl993SttlzePQMD7KBqH?= =?us-ascii?Q?XbinqZUrRHTkW9Y95MezgjIEFXC0fFgrpIiuyV3Kw0Xuf+vP8C0tnuynjCCV?= =?us-ascii?Q?bHl08c59urIWiAZX6jYI5qpknTpApBvkK9M7WEDhgWKEIaGv1+Qhe64Hz03g?= =?us-ascii?Q?TuKAsKDRAKxQN4g4Y8qK62pvrGsJZszIZbGmDVrGG6iekn00pMTFwpxDPBQG?= =?us-ascii?Q?bQfNrUVkvH+aba7aPluPXJQezMHhA5MkaEJ6ZOWMVsWVnUwF9ujU4jrKrnZC?= =?us-ascii?Q?z6CwW5qI5CiTn6B8nydJmx7Q+ChFpaDU9ZUzgeoOR9zzcphKIHOuBwAsfS+B?= =?us-ascii?Q?JvF9izN3MgdzMoVzAXIECRUdl3lwVJPjjR5TKtX+bArAXhceaSrvWtaQgrWd?= =?us-ascii?Q?ag=3D=3D?= X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9aa00de5-f255-4fdf-e597-08db132a6b96 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2023 10:08:32.0943 (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: jFoD36Gh2m87df3gwsSz9oef+1EPjCp9JT5dNo4u2NrWMyu/crT6j/w+e8aPRlVxJXubDUlbDbj+3PAK6c1VwQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR11MB5066 X-Proofpoint-ORIG-GUID: 9qgRexscISjMVtL7wNdw5Xt5ercsVgo0 X-Proofpoint-GUID: 9qgRexscISjMVtL7wNdw5Xt5ercsVgo0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-20_08,2023-02-17_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 impostorscore=0 clxscore=1015 mlxlogscore=819 mlxscore=0 lowpriorityscore=0 priorityscore=1501 spamscore=0 malwarescore=0 adultscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302200091 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=1415163841=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: 1676888149285100005 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 May 2 06:33:09 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=1676888002; cv=pass; d=zohomail.com; s=zohoarc; b=f3l/6gxPbaet9aU+yxmDEDGtokYPUgmExpOWhKUCA/BKdTs3Pqg0qCxEBUZrwhtGny9vqVuJXUTQ8zwmbJ63I3fjPhVS/x78yn+XQqY/fM9TWfC1K9Lb0Kq2RTjLqIo2LUD3ADaxjp/HA+//rdch99+Gdx6rpMWxb5nTPkDiIto= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676888002; 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=FVWibOpPNdHfIzDefYh5YCe562mBZsNdJDyVfE7klGEES30D0kTeYZRJXLwB4/yybtWauMis5ePRhiKL59c6dsukRpl3P254VJAdYCRMj+nmaTuT7X4DMxPewQRZIhgcRRvmjP9q/RVb1tuTMH7674WuKjK1rzajj2SNmuoJ+4k= 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 1676888002836811.2238332695126; Mon, 20 Feb 2023 02:13:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pU36S-0007ze-H5; Mon, 20 Feb 2023 05:09:00 -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 1pU36R-0007z4-4a for qemu-devel@nongnu.org; Mon, 20 Feb 2023 05:08: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 1pU36L-0008Tv-0m for qemu-devel@nongnu.org; Mon, 20 Feb 2023 05:08:58 -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 31K8sfVd013057; Mon, 20 Feb 2023 10:08:37 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2173.outbound.protection.outlook.com [104.47.59.173]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3ntpem1kwk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Feb 2023 10:08:36 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by SA2PR11MB5066.namprd11.prod.outlook.com (2603:10b6:806:110::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.19; Mon, 20 Feb 2023 10:08: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%4]) with mapi id 15.20.6111.019; Mon, 20 Feb 2023 10:08: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=Q51gWYJ+HXclbGSZ9Zlgv6+QfQYRST3Ok+cRzQ1RAzU=; b=e7uAHvzETM2rDAYlc53vLRaTR3SLp/Z3uaDl+np5MjhrXw8Ypi57If73cIgxXmhF2n82 HDvcUJYNzM0UT3FOXGHKeZBmdtRQbxIvHMggmDUQcQ3R1Q/l6yCn8RppbihReeoFWCfs zzpIcc7+SV6w2KYuUonoVmAcRn4X5wjkrXXjnza/TOgTAch8kfWE7ZdG5iq0gL8jOR01 QT593C3nCDiRk6LHLZES47Sr4D1ZFymoUsfsj469V1EWs7JiWqMMEUc27jjl8Grneg4j PW4rtFtIlCSw/mELeY+UViiwGhMw0AArv93l0PQrmDgeumIxV1ZwL+tmvifCsSzrbV8g KQ== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RWSpjn/pS9EzvESBcw8KjjoqYYAizdEAZNqupZxR/pGnbYpH73jgAEv6j7WcHtFHF7kVcxD2H1n9GDbPL9NTIlkMiPQ1vVRvDk+CffM3SSrDqDytvAzQ+o7byIMxquIfBTSRkCoqXv0/wLDUWYraHJ3W2liPN0trvbFWMQQ60H70wEvOUld2fUQmnIGtsA6U8yCSFZm56dfoCUsYBwJ5N2dA0jRuYgMBr3MRQadmrH/Bm5xiwA0xyWwkdEInu0obobrVXQzYuy07VRMKnVICjpJ84zVkozHjA+Secgb1kF+knN7SugZ1FKItb8CJBcBglcBaxQKWXzeAAOsMgzGppw== 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=MKKJbjRgaRPnQMFehzqpXBex7jOVK089pWnSdo/cBFGCKyvpINjoJw788YUvBgjWUT5Y8WOenC4u65d93R88mP2MeUni5szhMdVvZ1nkea4kOt2yUR2wp8CB5gDfuNAnjBlrVANoNVocP4p11FuDD6GH2kJBUtyqSO9JtIi6LkLg6piatbT8o3976Yvoo/bl+70XgkNXYrcFnIySIQrzlVax6ILBdo+ZTQeZ69QJXVXkDomoUSU0TMLIo/DobxP8a1yBr0fwoX4e+GNzaWpUCAjfnkGkBausP8YTYQUWD2jGCfg13Oh6UJqUUOd96Ak/C3nMYMKixpGXwPT92vXUFQ== 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: Christian Schoenebeck , Greg Kurz , qemu-devel@nongnu.org Cc: Guohuai Shi Subject: [PATCH v5 02/16] hw/9pfs: Implement Windows specific utilities functions for 9pfs Date: Mon, 20 Feb 2023 18:08:01 +0800 Message-Id: <20230220100815.1624266-3-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230220100815.1624266-1-bin.meng@windriver.com> References: <20230220100815.1624266-1-bin.meng@windriver.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SJ0PR03CA0220.namprd03.prod.outlook.com (2603:10b6:a03:39f::15) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|SA2PR11MB5066:EE_ X-MS-Office365-Filtering-Correlation-Id: 2f4fa0ba-a2eb-4cb0-fd52-08db132a6cbb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: a0VJKb2F18DQX5W+beLt8fv+9r4qqTAALAOc0GmuTZqJzI/u9ttSi+j5X67zxAoRWLnOO1unYiYH7JeHTSUQ3TpGjvKuMFL3VAgEvivFY2/51bxputIx+0KSSkopBbASrLqpBcwEH+k7xvrqrQEcxZmNA734QmsP4CRlVUt7cWWoYQA6Ub77GEzh387ImRm4ScgfDbAwuSVErj9rgM4mR80TW5yO+AHd+oSnEW8u1EFKCg3yZ2qX6a/XbTZiLTgqlXbxF+Q3RTvnPR4po1NatE4qVzeqPx1hWa5d7zvcZxMS2BkYMXreDX/ZC98c/LuwtqH/5magQ1OpV1Qcot8C3wfgghqycivOmusblPlQpkVlhRdSm9mtntTrWiuYJ+ZgZ+NGEgivN+1vgS9QLkUSDEOLsHBYAoto6kjc3NBhFxp9Q77dekFjoLzcO3MoGXy/n+doo0E9juBBcl4FsYfkePx8ZXVU/scC+LqnREUVnQs+/674bVfQ50cweZ1B1UdUzcss8TY2yce6YqKbICHUawJoIcmhpVIHCUlxFfBOMZU2A7EXdomXrk01h4GIXewIQdnlruAh7/72LykLEZTsbwfKULXdkEkRtn9HgdAmRVxtmwCfxX+vyl9nOXOsVXSwic2ogG8GQYAlhliXkkCkgXTU1bie/Qj9edD0qHDPJ0F0ONgy/ncu3mzgan459Gn3CUIc71CM7mbGJZRiszQ/PMNWxrkAWAmEmUwFIPB5n1E= 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)(346002)(376002)(366004)(39840400004)(136003)(396003)(451199018)(2616005)(4326008)(66556008)(8676002)(66946007)(83380400001)(66476007)(5660300002)(8936002)(6506007)(6486002)(107886003)(6666004)(1076003)(6512007)(26005)(186003)(52116002)(36756003)(478600001)(110136005)(316002)(41300700001)(38100700002)(44832011)(38350700002)(86362001)(2906002)(30864003)(21314003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?n4VyVbERhKeP+X9n6hW0Xw0xU/J6EsPWqYYybols5ov/8ef1fW7ZKhGHxs1p?= =?us-ascii?Q?bzMirkbeNKhkIn7lEbEb7UHIeZLdOZXIoDdbm8iyPrSO5q9KE8dHIFVoLptz?= =?us-ascii?Q?XYKX4nn00dN/pwsaOcX2u2KWN0WIwBScJ4PE07R4aV7fgzZ0B2O4VEPPThVp?= =?us-ascii?Q?DcOMDy4ZXNh1WjppiFuP6EnZUq/TLmmguCKNbT96QintnmeBmlV6dwc44L0X?= =?us-ascii?Q?VSDfNRF/uzyYWFBdfxAc65lJFLvxYTKGJrKri/B/dCXXthSifexA65zREbUa?= =?us-ascii?Q?aM8kcl+rF0a2olgOnmZaJXYAeSn6ajfMoP7WEZ/5dbasAV5vTB25j8+ICbU4?= =?us-ascii?Q?3cZ7u67MOolFkKdBwb+Z6SmJIkMqcpo1/my31NpMqE9x6Rh2PNEvDDidlD2k?= =?us-ascii?Q?m8iLgyKzLk1Kzjfgg7nBim5TzIim0CTBTbvWZ7UBTa4NS1AmxU0AS/YE7lDp?= =?us-ascii?Q?qb/YN7cwsmYi9jQbhmXqi9giTk/6jXB8905LVl79jByRobvn+4iKSRRkMEwH?= =?us-ascii?Q?rfNfUnnGn3jLV2hp86kmgOUXOWewW5gvsm8vUpM6TZwrHcPsmdsN/QqvmS6E?= =?us-ascii?Q?5O62Rsm3OhXYi6mo6G9KAYlZIxXBVostgvVEVAqzJHETXCdlhhAywslxb8i9?= =?us-ascii?Q?Do6QteDSuYBNQPTCpzqyT7Nse3tVs1P/SbqzYtmzcMvi6MmfJqL+471+bzsI?= =?us-ascii?Q?kK8xFHWKZoKcRyl8abwFpdlk80BHpngIS4otCUyWl9RKwSOxFk27i1P7acDI?= =?us-ascii?Q?7ifPWZd76Kl6gQJPPOFfr1pCqivKkKtr5AfV8CuliugIOO8QX1qXsQWGy8O7?= =?us-ascii?Q?hnjaFz7hARQ4zasJV3vyrVG0i79qaNhcAGPIone+akO8gc9eUeiP4PQclV8F?= =?us-ascii?Q?O/DqLM5/eVbvPCklsFoMqvZ2KrdAWTtEKIS68GCLF2GXQroLRzvZ8Qq1kN+T?= =?us-ascii?Q?7uDVTW+BbXQVES6StadO8C3HwSOyDGT0x/Ky3wrscedvTrozwdbcL6V9qlsL?= =?us-ascii?Q?ZyYr4I6SBWvK13dSgESo0cssPjHvpcVCjdtjty6uStGydzR1UXhiCosG9kGp?= =?us-ascii?Q?Lr8LU8lbQgMxVjPb0RkP+r3gF5Dt01vAFf1hwPEB9PKb4MUO9bhWajBlsbnf?= =?us-ascii?Q?u7Ao17x4U6DIoJif+zn9voPijJOsoxox6cIyeVyVgnMiPr4F6SgfaLB1MYq3?= =?us-ascii?Q?zLzKesWKR0KtFcbx1AEHEt4H7Yluo4dCw1qJK2xcMmFkMRwS2ygUOsjb0kTW?= =?us-ascii?Q?04FDwjoE+P8cVvrAfOWwXLaTYJjhLUiSiIHkRm2zCS6pZQGjAv+QEawaxqTU?= =?us-ascii?Q?7VTdAR6ZPbaRD/oespeYmykJt9283QNXkcQJRfavzGNwFb9lZfPinqOkUzga?= =?us-ascii?Q?uhMutRJAn9rFy9RecYkzb9o7jQZiwJnqDfx0k0kpN8c427wAecE4O+kyw6l4?= =?us-ascii?Q?wnVyy9cTiTeFYVg/DlIYZTt4pqjtO/9+6hDxEyZk5VFNPina6A/iUMFeHlTn?= =?us-ascii?Q?g+btc4nmlpFsvDg1sZ0zrgrQPCsDblIE6OU3jU+FB3aFQSTe6azattjtwRED?= =?us-ascii?Q?c3T2C+k/vLZltORx2L0azzJsPRLshfS7dsl0aeZX/EIe9FW+w1weYt+3qT26?= =?us-ascii?Q?Sg=3D=3D?= X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2f4fa0ba-a2eb-4cb0-fd52-08db132a6cbb X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2023 10:08:34.1713 (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: RKmuVVZ47P3QX8/+WeDmsZ58F5u+rldLCqpDZyjsm4rEL40KmZTEWbhWIUL3ABrlbD9rW8jia6qxeZYMo5bJ2w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR11MB5066 X-Proofpoint-ORIG-GUID: UYtz02UArNVfB6hYBePofkVM74RHX1eG X-Proofpoint-GUID: UYtz02UArNVfB6hYBePofkVM74RHX1eG X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-20_07,2023-02-17_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 mlxscore=0 lowpriorityscore=0 priorityscore=1501 suspectscore=0 mlxlogscore=999 bulkscore=0 spamscore=0 malwarescore=0 impostorscore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302200089 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=1415163841=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: 1676888004400100001 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 May 2 06:33:09 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=1676887763; cv=pass; d=zohomail.com; s=zohoarc; b=ETjFud6H7yrwxHGLs0IT0iM7bkWFA5CcXCfDpCBkFpuVD2OpF1/mIJB4VSTlzBpn9PZEmJCDoKw0oAAZNyNPajPqFtpvTpmP7kb6zjZWCGBBnEClTczWRDJimc9lRuxk00SWwoxa4VWBPZNiezg7CdPT+OuCAxt6JTGIOUoj9eE= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676887763; 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=ikataGgARMU32IUh1y47vfFMQt0VG8HlHBFtTENbRLpMZxka3gy7lx5iX6IlWG1u7tvKBhG73dL0AhVkSNMqOXcHoTDQd/VZP7rFIlXPJhu4s/fH8z7QW9Kff76kDLVbSzgusTOBmh3Xz8BtVmDKrg/1xjGIn1PVEK8aty9vdW0= 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 1676887762978639.5733076173645; Mon, 20 Feb 2023 02:09:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pU36R-0007z2-5o; Mon, 20 Feb 2023 05:08:59 -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 1pU36P-0007yT-LK for qemu-devel@nongnu.org; Mon, 20 Feb 2023 05:08:57 -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 1pU36L-0008TV-19 for qemu-devel@nongnu.org; Mon, 20 Feb 2023 05:08:57 -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 31K8sfVe013057; Mon, 20 Feb 2023 10:08:37 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2173.outbound.protection.outlook.com [104.47.59.173]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3ntpem1kwk-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Feb 2023 10:08:37 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by SA2PR11MB5066.namprd11.prod.outlook.com (2603:10b6:806:110::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.19; Mon, 20 Feb 2023 10:08: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%4]) with mapi id 15.20.6111.019; Mon, 20 Feb 2023 10:08: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=AcLONJBR7YZJY6HYwvAhDEo4k4DfdL0PC/dq/i6N/SI=; b=YU466U1MfqIp96KuusmOvOCA4LmEQWr+h0ThCIxIDGtx0weDAMA/fRk+STai+omW0ooU xk4DHwlvxDXPyhjWnHfcfeENczBNSvjzXRK5lDCkp8eOuilO8Mv1TTu8/uyY+BqrZNcH qkN01k69nf6hp/idxHWtbwX/9mCVqMgB7K3EsBOyWYNLfJ0PpNp30f7rJcRI3K15pUYp U6kZgxIdyjB1/Ts5wRH2GGi64kILK3TXG6gPISB5F5eEfSwbPcOJFpqDWsuEcQUeC2cW wxlrXs/0ZtwZ3Vv/7WavHs+eYPxPFC5c91M/CKKItoGKCZ8DZOTc0r/ckW5q2FGsGAV2 JQ== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FZyLTs68ONSfjsbthbLSUFa3AWhaGGv3EZAYnzYNRGCPixNJ2bJ0SWW2KAyVCgecI4vOCOC5Ser9Bm5TJDHMrsnBQb3tTsntFcOMNznSM07YXhLnw00KT0l1gSwAaLjoz8yyTnckrbGMQgCg/tEvu3kayvz76HDhBrGw0xF5NFpMJrf0N1NacLhLNp0bFKVJxMQu3sWwfrT1jkgpwbKjiwj7KhQsXPx+YJA0DK9T4vG/hIDg/euOEu0hEEdK0q0dwAcLywpXFTYpb135AI0s4OFJrOevtji+K5iaFyumwCN7kEBe7deaBM2TEVdg+Q92jbKmhFKYN3fg4/y1ddaJwQ== 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=aJYhGHq72Hh//I2ZwfkSxGCiWgOYXoLoh8oYwepPfX6NZY0r53C+DcnugTZd/90636fD0cCTGiPT2rhH+VNTDJyXdDxfM0xDvn/85OBvf1DiUw9QhbWu12zlluex4Bm++u4Gqx/ip+nhBhi1uAE/s49XezN71Z96/pAkDUKmYi1Enr7WJYqQ/SRLdK0fQhxUsvTRf6Jejc/bhoYbB9eTbNv1n4+fEfaU+4qqxC7p8aNEICPipOJnqtqc/8JBSN0uN884cSgrmwtA96HAzdPhi5oQ9aw2SzKQkkskbZ8Zme46R1hBffwB6D5Vdw5zEH62XOMs7eh693Px+iqX6qy4wg== 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: Christian Schoenebeck , Greg Kurz , qemu-devel@nongnu.org Cc: Guohuai Shi Subject: [PATCH v5 03/16] hw/9pfs: Replace the direct call to xxxdir() APIs with a wrapper Date: Mon, 20 Feb 2023 18:08:02 +0800 Message-Id: <20230220100815.1624266-4-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230220100815.1624266-1-bin.meng@windriver.com> References: <20230220100815.1624266-1-bin.meng@windriver.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SJ0PR03CA0220.namprd03.prod.outlook.com (2603:10b6:a03:39f::15) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|SA2PR11MB5066:EE_ X-MS-Office365-Filtering-Correlation-Id: be19cd4a-64fa-4b64-74e1-08db132a6df4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3YWXH3SfEvt0waTp3UIaRFGVee+hTF6HoCtZv2r8us866nfJotapURklq0bnHQHWWzhpbtIzv9GCtExN29MLG9IRPLSDhQ6pOI3YDSHKBuH3fO1kid8sHdEuzgPhn3HFMUP3TqSN2aJrB7zdXE/gu73SwyR6hxRbba7ubZhScsYV640fRc734L35OgvxGR1j3qHg3Bb1ZuJhxoDMlZnjCtu9hNMlRWUhWiudQOhCREfFJ6YIPZy5m+lgjaeRFIQi02kc2/UtAwLNAB05rNAkY5Ca8VljGjisqsEedzofQUonTy5zk+wV8T17DUVKeAAuYNiGMJP8lyJwXXugq1W9uzNcT9l2R0Snvzxbg/Db2PVVnkYrB8fObkj/VxUJqqWNd4GC2shWesJ6ulsS9Ei8Ea2F8SqyNQJChDNJKAuTXu712qV+QBZE4uQWPXU9jG/gyY64QUvBUFwaB8clvoekrL8Rh5MbzFQ0eNXuaMwDlUGkX6Uj4mEckAXcfb9T/TiPHgsBHLxU7NDZNDbkY2Ja6qaAw5e3/IJlpj/r1TL5sg5rRJfp4g/4oCz2AmW7sQ0E/FG417DS+60GZRE6t0mBNRXwOs70B33M7k7mdsdN1s+1cqBDgg5aHQDXffG17GRrOgJjf3m9wHGeqcYg3vxoj0Pc51ATAYbT8otE9SGK8MSIocg42gKfrGpoWmK181PCJsPU8BOsjlxewwO/N6+7JQ== 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)(346002)(376002)(366004)(39840400004)(136003)(396003)(451199018)(2616005)(4326008)(66556008)(8676002)(66946007)(83380400001)(66476007)(5660300002)(8936002)(6506007)(6486002)(107886003)(6666004)(1076003)(6512007)(26005)(186003)(52116002)(36756003)(478600001)(110136005)(316002)(41300700001)(38100700002)(44832011)(38350700002)(86362001)(2906002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?GXmjM0xmddb/69u8QFRmf94YSbEKd6eqi2073+1rziQIWlR8otzf2pinMCMc?= =?us-ascii?Q?MGB4+IlTeBcbduISslAyZqnj408jkQpGR5CiOzkMyPnKipOyosQZ3D0EUNFw?= =?us-ascii?Q?ds79uU74xowEBF76CXs0mGSQGlB/Sh/6JxypBg1OvdK4zIkjImoLuwMTURm7?= =?us-ascii?Q?d5yiHLpw1vVaeorHRKmsilbjmqskqvW7gP5sIqQfKTKtFoc5PdvfbMpXsHrz?= =?us-ascii?Q?nylQeKGR4pbwXlEbh8xJzOhW4ZUS1MaxEZxSkEMuKgDDdLlhqZlJ91LRRsfs?= =?us-ascii?Q?5r3F54gS8MLreB90KSTGLZdpsxyuDCO3Vt+vwp+TPUCJRZ/KKXjnCrud2uyR?= =?us-ascii?Q?Hek+ypNzsL405UkfGADVEzuOFcOEN5NYt4dTdHbHFHtTiEnHOx1JXyG/uf/z?= =?us-ascii?Q?OqE5iVnF3h0vtjHN9RWCJweQQVQboTBJ7D9hBIpw+S/8jvzajg0clb2EZztC?= =?us-ascii?Q?wLSgJk5h4/dfpVfBYJDUxICHp90Os1hMNVqkUHc840Z3moNHuWSqlxuvN0uM?= =?us-ascii?Q?hYPCo40GHD2duV3SOuUk2Nm4zJZsCsUnpgVQwArcCimHw9TeS48ixfGmVnnD?= =?us-ascii?Q?THClKq515arvmLxa+dKHkGGTraJrfZ7u0amTlya3PwRX20iQGguPlNXClwOp?= =?us-ascii?Q?4rM6EInsSySwTyynYbew484hRNRXQkSHlPF4C00VQIBWBaYFlLRRpC7fPyu3?= =?us-ascii?Q?e8TGwa2rIyX0o1xEFVnrUFk+ba9Rne7a1P2MBApUECrKCQOXYBy7SMe44zXH?= =?us-ascii?Q?Iep4RcRwba/ATHmpEkL49neb5tX+rKwO1jaUYbNtQVdwzX5Upa+FisWIiWgZ?= =?us-ascii?Q?E7il14hpW5zssoo+3fIICPuf0XYTvPMfjvzEUx6aQHXB0jXgw/Kv82EvkRnW?= =?us-ascii?Q?IXLdELnBKqugYWbpPb3XKL8DMLkdYn+2okVMigAnN1Xm0Zreu59KGArly7Bc?= =?us-ascii?Q?LYP9GoLKJ4QmXV5l1Wqdv3RWQo4RC7W282i3H6I0pxO/5p27tRhapzgsIK7X?= =?us-ascii?Q?nKelLXYzJ/N5oT+3rowtKK/Myqxc82RwyU9fviV7cijyw8XiTT3KRhmksSma?= =?us-ascii?Q?0PAkCXV8xYquCsM6Hm47UAKD4JeC4a+ji6Wtcnqmh5z6pTx0WNnLSZAwXbfk?= =?us-ascii?Q?oRXyOz13BJQxzD1J75IE2oKPFsfHwO7ASbZ7clXHK7JPmVOp1Bmhnpjmq/vG?= =?us-ascii?Q?/YW83qd3KthSRY18N1ccs/i1v3ExN0uh+U6HYn5ig+UNml7sC91f0G28cw7v?= =?us-ascii?Q?i5OP//9PL9vv7+InRaJP8lsX8a1B1LCflUfJiUiVXz20HBZsdwEDDK8Fvbr1?= =?us-ascii?Q?23t6zrWYi9mCA/mUukmqPxoARU530AsJLdt+2U83/+x9vYO6bPKNHcHZVR4I?= =?us-ascii?Q?8N+WRvM0PJ3wELBSP6v3z7waS0ZGsU6z+q7027v8mQGCHMJN7pawuAUpXDYB?= =?us-ascii?Q?hAtWgxQIf2FGEHzfXaUlHyknw6SIZRaq/ZHAfJ/0hl2nmhEH4K+rE8ayoC8R?= =?us-ascii?Q?1UQOtoOEwhgUTgNPkinjJ3ZcW9tqM/tf15p5WGmTA0qWc9E0EotVVb61QC56?= =?us-ascii?Q?8ucTtauPw9kSSod+3ZsPnvFNhUi0M5LrXYp3G3evkyn720pKhqUoCxW9O6LO?= =?us-ascii?Q?CQ=3D=3D?= X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: be19cd4a-64fa-4b64-74e1-08db132a6df4 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2023 10:08:36.0316 (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: Gm77nKrghdkYqaLn40pUUAIcTnA9QHMyHmEF7LfPCoWht/1gEh6YpmPVDMO4Eehp8C6dEFHBtopJLpp0+xNMJA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR11MB5066 X-Proofpoint-ORIG-GUID: ozAousc-xasex_2BQ1NLitQQm79dvm71 X-Proofpoint-GUID: ozAousc-xasex_2BQ1NLitQQm79dvm71 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-20_07,2023-02-17_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 mlxscore=0 lowpriorityscore=0 priorityscore=1501 suspectscore=0 mlxlogscore=774 bulkscore=0 spamscore=0 malwarescore=0 impostorscore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302200089 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=1415163841=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: 1676887765107100006 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 May 2 06:33:09 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=1676888078; cv=pass; d=zohomail.com; s=zohoarc; b=Mul8WgWaYHEAVUmQeVnYwYWLoXNsdblUDj8dvScntAxZ8MJ5UBiK3xyLWky3f/PAHTnP3KvDYuycfyKs3P9xdOjOSaqClbvgIHvO2Ikjd3z1Xn68h+vkcMZSlOmDwfejUtlA7rd8b2pHf2G30u7l0P+xIFaHhp51D6PtNbfL8g0= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676888078; 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=op9BZ0rOkqmdwuRMJ8UbP7oCV0yE2esAem3+VcQpVjc=; b=IW9jglgqeHkyj0vioZBcex+bMmLiAtLNo9Vxqrcgxij0m7/wHhSkmRiygGBpApB2wOdzBhJeJvd27CVWnuCUVZGDfMvmO6AW7M7fRh1P1DW3U8IyHBjAAGvpZw74XISJ/nEQA4TrA3o94yRun1xs1IerLmJxN07pj3spsXhRzaI= 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 1676888078657539.0281274355275; Mon, 20 Feb 2023 02:14:38 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pU36R-0007zS-Uu; Mon, 20 Feb 2023 05:08:59 -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 1pU36Q-0007yl-BV for qemu-devel@nongnu.org; Mon, 20 Feb 2023 05:08:58 -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 1pU36L-0008Vy-0y for qemu-devel@nongnu.org; Mon, 20 Feb 2023 05:08:57 -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 31K9fSWS030356; Mon, 20 Feb 2023 02:08:40 -0800 Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2177.outbound.protection.outlook.com [104.47.59.177]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3nttu6sfs5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Feb 2023 02:08:40 -0800 Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by SA2PR11MB5066.namprd11.prod.outlook.com (2603:10b6:806:110::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.19; Mon, 20 Feb 2023 10:08: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%4]) with mapi id 15.20.6111.019; Mon, 20 Feb 2023 10:08: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=op9BZ0rOkqmdwuRMJ8UbP7oCV0yE2esAem3+VcQpVjc=; b=iD4CgipeBu4/A+lnHapmNGmU53LKAzap7A/Znogy/PnkZFzoXpSN054SPhJeniWatwnL 905gXqihxUeMGx8ihXLRmH6FXSEULs1NKkqMX2ORjBvV3tyzfG7KGXHs1BiT5iq/6VsJ 4KYLEbaYnx7d0v2Svqg5NmeaHfSW3dvu42bxZU5cvjzmQanfQg2r8efoU9fD3cJj06jt CRBgZaHJ5Di83ez7uURLPaKpvXj1MEkhmRAw/4usyWeZ3gnDXuER+5TOcHFiywnWNsHo IvEfQ8TSYTNaW2PNUYOSgdjKfBUFb4zi9LAD7t1O07Sh/h8yPnbpS+DkgNascKv/DB4Q xA== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MrubD7BGAJ5BdgSjNtpAMUrtJ5WYARTBvZoTtbeFxy6mjAPKP2T8pa8Ov14ydHEJFo7Dq5Dr4+Er5ZZFsiBAst3G4bescLUYnb0d1ZBDb7Fx2w9qfBDZjkuCCiuIO4D50E4Ut6FAjNvL7xk5CblUTY8e1WNPtzPjfPm7LsKycwCFC34MVNkM7jmwf9bvFwAyZ+6UttiWwImvOEIr40oIKnvUlOuAbZ25kWdyDvSs9aSehRBxrgIW5P3AYoHD4Hhkwmx/OkUgwQLsNYrixttSV/NMYv0SvN0Ms2uxnblUmy/Ir7hUchi8mYPDo+7lPbVZVab5j2BzT3H1iLcco8pvuw== 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=op9BZ0rOkqmdwuRMJ8UbP7oCV0yE2esAem3+VcQpVjc=; b=g5oTRfYrN6353IHJvDPg0oPMmhp/kK7ff1GvWGamEQQNSlnbmelTtw3tjmeAeMrOiY7/KAX3GflwObxK3f+/TvSy3yc4wYSCCw9i8nYmycoYqkBwT/L7DgCty76gKMBk7QZ6nr9J39N5UATkVRj6jqZy9OB8ohUDKedpiAufOlotibHYUXMautXRESTdve6a4yL1sIu24GhFuuFVDUa61ezavVxi1JK3b/rID8tTx3dHXqnJr3CfQgcOTJPUyLommk0VblAQPzY296VDyxKwXf1S6vFMJB3nT9OovWa5DbZx/iCjpS1yoBmbAc5y8Auo+JIumpG0tkji3oEAeJ3avg== 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: Christian Schoenebeck , Greg Kurz , qemu-devel@nongnu.org Cc: Guohuai Shi Subject: [PATCH v5 04/16] hw/9pfs: Implement Windows specific xxxdir() APIs Date: Mon, 20 Feb 2023 18:08:03 +0800 Message-Id: <20230220100815.1624266-5-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230220100815.1624266-1-bin.meng@windriver.com> References: <20230220100815.1624266-1-bin.meng@windriver.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SJ0PR03CA0220.namprd03.prod.outlook.com (2603:10b6:a03:39f::15) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|SA2PR11MB5066:EE_ X-MS-Office365-Filtering-Correlation-Id: be0fa702-b9ca-4878-13b7-08db132a6f15 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zvu7z+wK6iegcCYMfJKVXQMyvc1KTX60Y0I3NLNf1v0O+gSWKZldcAaH3hr/IqyowHctHjLacGD1SHDdrdbOXjWNX1U8npWxAwwqvcTSbi0AEVlqrNrvEEIRqtY3LjdDDJi/ntHf2SeJZJj2skrzzwZQGUJlHpT5omUlZMHI/7gFja5PE1PrOmcQmiB5xHR/ye7neLppY4daBHNzVKEaoLdTzXA2WGLCgNR41Kw3Z7djR+IDETr1FW9MMYUWvMCLnKHMcRgRdEkX108TAPDLOM6Yg2t+3rC3tIgMj6TE99lsJDd4npRW7ym/PzV9nIrfR85xnz+1YCmrZ+g9e6KprKd8jqLS2JXOKeQDDooQbTSETTsbkH6o9Y29kGHRXTb4cYp/EshgxR/54sUyxxJbTiJx3ZGsM50YT0P5umSIbzSomoZjZAo5Y/g6koXkZ3dHpKIO9elTwcMPxP+K+WEq/HQPZerpLV3Efzn7xhWTLGFlhVFlmjLXO5sGFw3FAKZAlsClrStXVL88yTA7skpW1wM3Jwu0l/DLeb5buqXgwyBqwYBUrW5bXYz/BZsGIb0hMDQ0rFH06d/stIi9S45XJiRn0cS4xLoBOqF6bHbxey755zPRGg5agJsBaY+NhWhJ0NEgu4rsZpqrXHaqOCPUkzK3oVauYwRTXbdlQgfUqa+YYd8GBEPCZ+EuHRrDUamg68fFNtib/pcoFvW2ocBAfQ== 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)(346002)(376002)(366004)(39840400004)(136003)(396003)(451199018)(2616005)(4326008)(66556008)(8676002)(66946007)(83380400001)(66476007)(5660300002)(8936002)(6506007)(6486002)(107886003)(6666004)(1076003)(6512007)(26005)(186003)(52116002)(36756003)(478600001)(110136005)(316002)(41300700001)(38100700002)(44832011)(38350700002)(86362001)(2906002)(30864003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?IqBSAAIVsqHP4BV7JGxB59U+QoCGCSN8d/5ZvJePD9tLbdqSGybkXTJrtvCG?= =?us-ascii?Q?cR8rZU6IvWUS//DIH3WH+iA8Z3ATXMFONX9Zx68ujZDziqrE9zPEt6C+w4nZ?= =?us-ascii?Q?L5XVb21mlIL7+rCIjYHINFLL8kbIIS0x18znXLIfzAwy+34eKR2ofkUujxRz?= =?us-ascii?Q?Yt5u6oKdhWs3KhcS9I0kXxxPrqlCXq0y5gPOOJakoVAjhaHYR+GpT8y/UOv0?= =?us-ascii?Q?Xwe/WxVCEa1uCydi4I0HbPuGaom+b3JXwwl3kZMv8pZLylBWB8pCepw9KhKd?= =?us-ascii?Q?jWgot3cH2xb+My5TvavPTLlbUquGT7s+Wy/66opFjZupU7v6TLiLJ/oHViLI?= =?us-ascii?Q?DfacPT3HvBLhvpvPiyJU3nTfej4+pS5l6v1Nw85VUHCGXGAzsGQ24z8Odq5Y?= =?us-ascii?Q?oxE5MUltNzAfqmQV0yb57C0q4JoxtkzgPAWexF1t+8mCFYxiK7kbxeVwpp9X?= =?us-ascii?Q?plVcrIXdsoDpQriR++1w9HK6CpLxmXbfcQI3Ob/HAi1b+jFWshikuZmFfVGO?= =?us-ascii?Q?rRMXHl1TzlRScg5Fh11bMwxPZMxjW49Qa2v5TPbrsAslhVywVaz32FJq/jLq?= =?us-ascii?Q?UqhrfbsFQZGG9s5/RsqWmq1HL4QlqB0GrgYJVJn0zQOrhepP3LbT+sVYkmib?= =?us-ascii?Q?PCRyDykO5RXks+BKS5hIH0i5EaIgpYx1vOnBReYM+BT7MrfXYS8DyWpsPbZq?= =?us-ascii?Q?W6Mtj/mPxQOZLtoB9svXbO1q+Ly1mZgfwviLOhwG0KIgEwR+vuX+7hC5ujWU?= =?us-ascii?Q?lh8LzBAxJtXDwDaDNpBORWHzWL97hqvL9mpdnj6lne5qIOyfMXAMcdJ6A0Cr?= =?us-ascii?Q?bsijmEXSe4fCIxtBxbDjKsGtl17B8r77JEMFJGByZqYbKuCoyu6Fwik7o14s?= =?us-ascii?Q?GyEMhr4yDepB5bmL4MzUK9Mcwds7aZ2EBaBd6bgGi1JkxeM9vnWBRV4svOk+?= =?us-ascii?Q?LdAy8VIxwlXatGh4dpb41xdpYhPszEODudgLppaGtUSTHl8vypx7shBrKwd+?= =?us-ascii?Q?ABtfD+lL6RNjWyhj6Sx3C3lEDcrFVYcwR3jmLnsddQF/Adb72PJzavktt5tT?= =?us-ascii?Q?IQ557P6Ef9lLP2vsS17GATrPQqXZVd/ClMMhhSdDRfbP3cYjV1qkBuoL0ThS?= =?us-ascii?Q?i60bUrobdohuwyAc6a8A5VF7aoZE2MIkySL5usR8ZYZ91UEEeYfW/ZUe+ZxZ?= =?us-ascii?Q?9kfK264Q88+KcLNdTDQjihTYVMEPN6mzcfgWaS82ReHt4hwdZ9O2fdp70gk9?= =?us-ascii?Q?oKV/QOSVfmD0mD5aJuH/kO+Lo8sFIIPXo9HHUgOKdm4HKi3yZWp4f23jkZ7M?= =?us-ascii?Q?nNQBiXRaXCwJzzPqGeAuxyHnrvvobXMMVYX7TtVXAclikTqv4SLqayyMqGdb?= =?us-ascii?Q?BeixTVslajah20eDaWxz/HU44yrZjsTlYi3ffbvATX+ZO2xknkXQussdUJZl?= =?us-ascii?Q?gSTmCSpUvzek2Im3XBJYRXE8swecEnzY/7VX2MlHmwb89ONVho1Qu9Sqih7J?= =?us-ascii?Q?9ivPm1a9vKSNopgpKt3nI6vAydYWb/x7oWrYWEAwHI/mR54y35lGtGzWf3sz?= =?us-ascii?Q?Ai6Se59Gi2hH7rpGUjSE7AIt83HQgraUvNioDLfphp+zrdO/dOxAMT9H9mv4?= =?us-ascii?Q?Ug=3D=3D?= X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: be0fa702-b9ca-4878-13b7-08db132a6f15 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2023 10:08:37.9231 (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: ZGNlv0/ccmmj8BIPpl9P8KFujn6xht5x9Da8BklFuCUV4hd0weCjmprvutRJeYGdU5c9hV5I6nz6K7IHAldyPg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR11MB5066 X-Proofpoint-ORIG-GUID: q9IdMR4bCORemXk5IsIUjF2rWUwjEnC6 X-Proofpoint-GUID: q9IdMR4bCORemXk5IsIUjF2rWUwjEnC6 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-20_08,2023-02-17_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 impostorscore=0 clxscore=1015 mlxlogscore=577 mlxscore=0 lowpriorityscore=0 priorityscore=1501 spamscore=0 malwarescore=0 adultscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302200091 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=1415163841=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: 1676888080942100003 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 | 443 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 449 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..e9408f3c45 100644 --- a/hw/9pfs/9p-util-win32.c +++ b/hw/9pfs/9p-util-win32.c @@ -37,6 +37,16 @@ * 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. Neither Windows native APIs, nor MinGW provide a POSIX compatible AP= I for + * acquiring directory entries in a safe way. Calling those APIs (native + * _findfirst() and _findnext() or MinGW's readdir(), seekdir() and + * telldir()) directly can lead to an inconsistent state if directory is + * modified in between, e.g. the same directory appearing more than once + * in output, or directories not appearing at all in output even though= they + * were neither newly created nor deleted. POSIX does not define what h= appens + * with deleted or newly created directories in between, but it guarant= ees a + * consistent state. */ =20 #include "qemu/osdep.h" @@ -51,6 +61,25 @@ =20 #define V9FS_MAGIC 0x53465039 /* string "9PFS" */ =20 +/* + * MinGW and Windows does not provide a safe way to seek directory while o= ther + * thread is modifying the same directory. + * + * This structure is used to store sorted file id and ensure directory seek + * consistency. + */ +struct dir_win32 { + struct dirent dd_dir; + uint32_t offset; + uint32_t total_entries; + HANDLE hDir; + uint32_t dir_name_len; + uint64_t dot_id; + uint64_t dot_dot_id; + uint64_t *file_id_list; + char dd_name[1]; +}; + /* * win32_error_to_posix - convert Win32 error to POSIX error number * @@ -977,3 +1006,417 @@ int qemu_mknodat(int dirfd, const char *filename, mo= de_t mode, dev_t dev) errno =3D ENOTSUP; return -1; } + +static int file_id_compare(const void *id_ptr1, const void *id_ptr2) +{ + uint64_t id[2]; + + id[0] =3D *(uint64_t *)id_ptr1; + id[1] =3D *(uint64_t *)id_ptr2; + + if (id[0] > id[1]) { + return 1; + } else if (id[0] < id[1]) { + return -1; + } else { + return 0; + } +} + +static int get_next_entry(struct dir_win32 *stream) +{ + HANDLE hDirEntry =3D INVALID_HANDLE_VALUE; + char *entry_name; + char *entry_start; + FILE_ID_DESCRIPTOR fid; + DWORD attribute; + + if (stream->file_id_list[stream->offset] =3D=3D stream->dot_id) { + strcpy(stream->dd_dir.d_name, "."); + return 0; + } + + if (stream->file_id_list[stream->offset] =3D=3D stream->dot_dot_id) { + strcpy(stream->dd_dir.d_name, ".."); + return 0; + } + + fid.dwSize =3D sizeof(fid); + fid.Type =3D FileIdType; + + fid.FileId.QuadPart =3D stream->file_id_list[stream->offset]; + + hDirEntry =3D OpenFileById(stream->hDir, &fid, GENERIC_READ, + FILE_SHARE_READ | FILE_SHARE_WRITE + | FILE_SHARE_DELETE, + NULL, + FILE_FLAG_BACKUP_SEMANTICS + | FILE_FLAG_OPEN_REPARSE_POINT); + + if (hDirEntry =3D=3D INVALID_HANDLE_VALUE) { + /* + * Not open it successfully, it may be deleted. + * Try next id. + */ + return -1; + } + + entry_name =3D get_full_path_win32(hDirEntry, NULL); + + CloseHandle(hDirEntry); + + if (entry_name =3D=3D NULL) { + return -1; + } + + attribute =3D GetFileAttributes(entry_name); + + /* symlink is not allowed */ + if (attribute =3D=3D INVALID_FILE_ATTRIBUTES + || (attribute & FILE_ATTRIBUTE_REPARSE_POINT) !=3D 0) { + return -1; + } + + if (memcmp(entry_name, stream->dd_name, stream->dir_name_len) !=3D 0) { + /* + * The full entry file name should be a part of parent directory n= ame, + * except dot and dot_dot (is already handled). + * If not, this entry should not be returned. + */ + return -1; + } + + entry_start =3D entry_name + stream->dir_name_len; + + /* skip slash */ + while (*entry_start =3D=3D '\\') { + entry_start++; + } + + if (strchr(entry_start, '\\') !=3D NULL) { + return -1; + } + + if (strlen(entry_start) =3D=3D 0 + || strlen(entry_start) + 1 > sizeof(stream->dd_dir.d_name)) { + return -1; + } + strcpy(stream->dd_dir.d_name, entry_start); + + return 0; +} + +/* + * 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; + HANDLE hDirEntry =3D INVALID_HANDLE_VALUE; + char *full_dir_entry =3D NULL; + DWORD attribute; + intptr_t dd_handle =3D -1; + struct _finddata_t dd_data; + uint64_t file_id; + uint64_t *file_id_list =3D NULL; + BY_HANDLE_FILE_INFORMATION FileInfo; + struct dir_win32 *stream =3D NULL; + int err =3D 0; + int find_status; + int sort_first_two_entry =3D 0; + uint32_t list_count =3D 16; + uint32_t index =3D 0; + + /* 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 | FILE_FLAG_OPEN_REPARSE_= POINT, + 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; + } + + file_id_list =3D g_malloc0(sizeof(uint64_t) * list_count); + + /* + * findfirst() needs suffix format name like "\dir1\dir2\*", + * allocate more buffer to store suffix. + */ + stream =3D g_malloc0(sizeof(struct dir_win32) + strlen(full_file_name)= + 3); + + strcpy(stream->dd_name, full_file_name); + strcat(stream->dd_name, "\\*"); + + stream->hDir =3D hDir; + stream->dir_name_len =3D strlen(full_file_name); + + dd_handle =3D _findfirst(stream->dd_name, &dd_data); + + if (dd_handle =3D=3D -1) { + err =3D errno; + goto out; + } + + /* read all entries to link list */ + do { + full_dir_entry =3D get_full_path_win32(hDir, dd_data.name); + + if (full_dir_entry =3D=3D NULL) { + err =3D ENOMEM; + break; + } + + /* + * Open every entry and get the file informations. + * + * Skip symbolic links during reading directory. + */ + hDirEntry =3D CreateFile(full_dir_entry, + GENERIC_READ, + FILE_SHARE_READ | FILE_SHARE_WRITE + | FILE_SHARE_DELETE, + NULL, + OPEN_EXISTING, + FILE_FLAG_BACKUP_SEMANTICS + | FILE_FLAG_OPEN_REPARSE_POINT, NULL); + + if (hDirEntry !=3D INVALID_HANDLE_VALUE) { + if (GetFileInformationByHandle(hDirEntry, + &FileInfo) =3D=3D TRUE) { + attribute =3D FileInfo.dwFileAttributes; + + /* only save validate entries */ + if ((attribute & FILE_ATTRIBUTE_REPARSE_POINT) =3D=3D 0) { + if (index >=3D list_count) { + list_count =3D list_count + 16; + file_id_list =3D g_realloc(file_id_list, + sizeof(uint64_t) + * list_count); + } + file_id =3D (uint64_t)FileInfo.nFileIndexLow + + (((uint64_t)FileInfo.nFileIndexHigh) << 32= ); + + + file_id_list[index] =3D file_id; + + if (strcmp(dd_data.name, ".") =3D=3D 0) { + stream->dot_id =3D file_id_list[index]; + if (index !=3D 0) { + sort_first_two_entry =3D 1; + } + } else if (strcmp(dd_data.name, "..") =3D=3D 0) { + stream->dot_dot_id =3D file_id_list[index]; + if (index !=3D 1) { + sort_first_two_entry =3D 1; + } + } + index++; + } + } + CloseHandle(hDirEntry); + } + g_free(full_dir_entry); + find_status =3D _findnext(dd_handle, &dd_data); + } 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->file_id_list =3D file_id_list; + + if (sort_first_two_entry =3D=3D 0) { + /* + * If the first two entry is "." and "..", then do not sort them. + * + * If the guest OS always considers first two entries are "." and = "..", + * sort the two entries may cause confused display in guest OS. + */ + qsort(&file_id_list[2], index - 2, sizeof(file_id), file_id_compar= e); + } else { + qsort(&file_id_list[0], index, sizeof(file_id), file_id_compare); + } + +out: + if (err !=3D 0) { + errno =3D err; + if (stream !=3D NULL) { + if (file_id_list !=3D NULL) { + g_free(file_id_list); + } + CloseHandle(hDir); + g_free(stream); + stream =3D NULL; + } + } + + if (dd_handle !=3D -1) { + _findclose(dd_handle); + } + + 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; + + if (stream =3D=3D NULL) { + errno =3D EBADF; + return -1; + } + + /* free all resources */ + CloseHandle(stream->hDir); + + g_free(stream->file_id_list); + + 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; + } + +retry: + + if (stream->offset >=3D stream->total_entries) { + /* reach to the end, return NULL without set errno */ + return NULL; + } + + if (get_next_entry(stream) !=3D 0) { + stream->offset++; + goto retry; + } + + /* 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++; + + 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; + + 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; + + 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; + } + + stream->offset =3D pos; + + 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 May 2 06:33:09 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=1676887763; cv=pass; d=zohomail.com; s=zohoarc; b=a4CRabYfpF/GdaJXZb144lS8d5/txjchhEJDjndaz/8c5yMDBhuHvO78Qvz7kN7p5kiK5kkpUjbdRuHQrDIekV16tIisaWzIRJDTxcI/MdX3VrxTS29VWjmOa5A36LrNOlEjCiqlz0wWtWkH+7nT7nGRILl9QjRfv8DWPGkui3o= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676887763; 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=FpuKvV//5xvEABr0NKjlQv+TTffrOnORhm2uz2LnAQiWbuY0+DznNzupKOMPbyQBomLDgnycJ894vpyChI3hh6UmUUzEPw0hD4U94koR6qs+fGjWHOqpxx/m/0ssIplV7PtgU2kD7MxHI8/l25GcSA9QQGs62QsPT6iHA4W7Vvw= 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 1676887762910631.5097802170477; Mon, 20 Feb 2023 02:09:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pU36U-00084r-KS; Mon, 20 Feb 2023 05:09:02 -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 1pU36R-0007zU-V6 for qemu-devel@nongnu.org; Mon, 20 Feb 2023 05:08:59 -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 1pU36M-0008WS-MM for qemu-devel@nongnu.org; Mon, 20 Feb 2023 05:08:59 -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 31K98SeX018476; Mon, 20 Feb 2023 02:08:42 -0800 Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2176.outbound.protection.outlook.com [104.47.59.176]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3nty2psabu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Feb 2023 02:08:42 -0800 Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by SA2PR11MB5066.namprd11.prod.outlook.com (2603:10b6:806:110::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.19; Mon, 20 Feb 2023 10:08: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%4]) with mapi id 15.20.6111.019; Mon, 20 Feb 2023 10:08: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=Sm74XzxaRiYXzO1G+YfdbqAZ795gmZJiLP55ipP9+Fw=; b=PTToszAU0H3uCjmTSfvVrXtdXOTWBDDMrrIJtYU12QOtKsL5TUxtk9i0n6vbnUudqgdN yxT8DOX6PCAEbOJ9/4KvIhsoWOrh7cDREX7dx3dXGiDqyeNvrNx5EaCYsUs1S/bXNvXi txFAcwKDdZyXGkuv7Hfj7Uj6zHISPUotesWPnlOyb78m1qZiNON5WQW3tyXtxRn/rxK/ emRFj5Zg726MgBO2wSHd6B7l9YJLv1sCpsZqA4Ut9+Z4PDyDB9LYO8UmwtrLA1JJ7hC4 KItx/s7w8esjt+fGvR9hv3koOYB3GGg2kG0inBL2SdI08j17kSBpldNRcuBvAmmpRoEH oA== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mVRX8GqRY6mVhSg9wa+CyUcGLlRNCkGK6QDBE+vn4QIHLMtUYsEXtX6bDizH+OFywbDQgl3rjANINS5/sqqlswOYEc82FZGeleW4NFoJRwbPPCaKcG/IgoNiVDJfTt10ZC7RRYQ7uEYnMhENLdx7z0eggEHugA9hnflcaMgivwPqCxVPHVIlQmsEw2HuhW0VpFofHj/QeTbJx9unU7vJLwn4bLRaZq/JhxqvOPWefaQGpksuL/i+YDhF6O6DFT5vnJvkHBcHKWfu8nS1+oH/++blXkavJQhiRYZkEYELRJSK31AmSnXi269Pa8jBKur+ZZaFCAG0CDMta1rp89KRSQ== 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=U70cc/frmQJDcIUkZaaGMVVqvD8KWjS6aQXkGcSp4WRooaDtJV9q/hWDTs9WF1RUxIqsWZk9oINIl3zvC7h2ouzzfasm7uXPrxFRf2HKuDjsYsv9zPjp+/CAVbf3BHdYSwL7YAqKXLtiUnrR8N/yO2BWozDeyDA/EyMkxUbrMqF+VAO//aQ5cQTyNcc6E/N0t5JgTE92RfNYSrY2U3pjUeyUEJIO2dS4bI6XJrjj9w0JriBhKxzsv9wkJ5gARDxXqeWuZgOETKTIIKs47EXQWmN13UCEBVmxMTcyri6fQlujopv7ngpx0V6zZZdCp2mBDCV9H+eSwVASEVnz6t/d+g== 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: Christian Schoenebeck , Greg Kurz , qemu-devel@nongnu.org Cc: Guohuai Shi Subject: [PATCH v5 05/16] hw/9pfs: Update the local fs driver to support Windows Date: Mon, 20 Feb 2023 18:08:04 +0800 Message-Id: <20230220100815.1624266-6-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230220100815.1624266-1-bin.meng@windriver.com> References: <20230220100815.1624266-1-bin.meng@windriver.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SJ0PR03CA0220.namprd03.prod.outlook.com (2603:10b6:a03:39f::15) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|SA2PR11MB5066:EE_ X-MS-Office365-Filtering-Correlation-Id: e6ebe51e-240b-4248-db71-08db132a7030 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6WIlaI12hOcygns872ZfWX4zWvypKtpp9oPAgGN+z8CP8HwF3g5MZIwzKiqzbghm5p4GlQSmJu/E+nVe5FtFgV9JouJyPF9ZiYxdRyexLSsXsh+byU2HZe7d8PwCDWjAWB7jFLxst/fmPTGo+XoBCbZSdnM5AUI+sxkWHm4idzHKCYqwA+iceSwSVVSiguDy+T3dhj7rTNZIDcerCzoiEqmTXP6bivixyIqK2nribrdaf12y4+1cwhH6sRY3Ge3NLJ/mYQVhO72nfGOKz5CozTphY+c9QfD95v0Oow/+Qx5p3zfyv6gP8KqOCiMGn9Uu2JHS6ieMZPB6T9qCEk5Dd0vCNWJZD786k5UbDspYmzNMnheL3FjA8FBXjyoD0K3bmGNYSr9byIH3KEWVc+Ye7EqIS2MoekufgcNRkoBIA8F2+SXf1p2vMbSv2sBH+OW/mTTy0zQkI2c07EEoPNPbwhK+tZ7eIRgvajVPwJcoiez+Om4COtccCMVD51A6HFH2Ivssj/FKHhv20w1ljvRKqL+afbhreoRuSnGR+CJUumOyGsqn3mHtW5RywMtk/4haHId37hCbbNxgU7blm1S7DNoS4x/sbmAj2LmSdydqX11hwzYy/HKL1QX02ri7u9FwFte3G+PgZIi7+n/tZiJ6ZJvg76QluhtmyKU+mC/AlwORZa8NK9ZSiq5RR9ZysnK3yHtKQEmW4aj+6lO1ex1qqg== 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)(346002)(376002)(366004)(39840400004)(136003)(396003)(451199018)(2616005)(4326008)(66556008)(8676002)(66946007)(83380400001)(66476007)(5660300002)(8936002)(6506007)(6486002)(107886003)(6666004)(1076003)(6512007)(26005)(186003)(52116002)(36756003)(478600001)(110136005)(316002)(41300700001)(38100700002)(44832011)(38350700002)(86362001)(2906002)(15650500001)(30864003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Emgm8abtD28RIGX9CsZGLmeQboJmEWcLGWKdJ6XEQuCq5q869hdgnPM4k8uT?= =?us-ascii?Q?uJIepIDJZC/g5svSVR02HXGF4bJJo37HWDC6wRemcuOn26WGZ70kmPKJVl72?= =?us-ascii?Q?6aXJfJmHP5rsl1jXFc84Cf95mJsHQLtm4MhUql9LLrgKlOqfgU22azjcQhvO?= =?us-ascii?Q?luYIIAc0D0A0rF2k+nioo1pzTc9cXcbAmGQ8WUfxkTIaglxWIHOfIuVEW5dG?= =?us-ascii?Q?RZJVj5CAahY6wbgro/crNwQP9BqQl1azFe89uK/cM+VUj5H2hou9MslWVLvn?= =?us-ascii?Q?UaaXnx9XsNSyeP6MIslzNy1hqq2mmQudcr0ktndiZll5MaEc+Z8hEmmFTL+y?= =?us-ascii?Q?BrjKjIIVfOjAWUG7cXmLnhe4QqUFVQoejgRR7p3MUYBYSW/e9quiAQmeMbN3?= =?us-ascii?Q?K+Nx3q+tQNyTnW9+8c48rI9HwT06OMCvxOKayva8vnr3RuwMwxqGCxNxMqza?= =?us-ascii?Q?k7m368GUYHbXFr8Aoq73GIOtkkQqV48hsl3ES8gsdIyhIfhJK9F3eJfDpqq/?= =?us-ascii?Q?3qAtughVi8rLiBQh3PW3wfZtWUNsftHo/1WeENCnSfKqt6uzhgisa7FwS7wq?= =?us-ascii?Q?mbkue99WSUOuJJ9dl2iWmsRgSmncaHUiEScE51dxlLPd+yavyd5RHB6C+NE5?= =?us-ascii?Q?s5bNTJrLGpvYkkPOE+b0YnYQoJw+P1Mhs7qiWttzL6rAP7YuaWsIbjnPDdxS?= =?us-ascii?Q?CXVEzV7bsfaPk6z0C7uhk3CTFaVEVFgg6Co725p5fCFViGSRuGuBfW/JoAuT?= =?us-ascii?Q?Av5Mgf7W688RxpknkPvlDruKXNRgCXXah04ay21ZvlYUpxTn325O823dK2Yw?= =?us-ascii?Q?JZxVTkc71wExgg2mBoVX8TIzNXKU5WwgF7qXM5ELciZyX5fHiN0ezxRhkjgQ?= =?us-ascii?Q?kxKiYGaCIZA/J1w+tkD8TQVfX2sPohq+rxILhQkLfGgTOe3Lk+fgY33Pn6kW?= =?us-ascii?Q?WtPYzsI3nUH1iYphp7a3SHNUSpsN4yO/IU3nk6Jf8sNHPxMVcMPZ5y1sinsa?= =?us-ascii?Q?4mo/60ljNAtl+p+J009KLugxRgbwU3oJAn7LAHAppEG/f/E0MBSs9uRGpbSq?= =?us-ascii?Q?fT8tM6ZhBeKhL62xfqmvQsBk9pHGR5/yndJLagVTjT6ASpfAaBXRkdWojqbZ?= =?us-ascii?Q?99rXTHFW2GQgweuznjuenT2ctBPEPdn2tnneHZWtZ4x0IfjhN1ZqPvFaTMi0?= =?us-ascii?Q?lA8+klcv3ddCrXsl07vePIUROrbhpCZI37/vQLPcu6mJxDlABaEx9hmyw+2P?= =?us-ascii?Q?vgrrQO8v6RRD9xDPSrLEmxjWk3icr7ToRVzt4bffUddPFSWoWiVFXTuJsOOb?= =?us-ascii?Q?9dsc2VncCfQGHD8MOOh8gh5YKXk/LY3c6hbEQNiLnfyCfygHwSyHdMU/GUlS?= =?us-ascii?Q?3U8zmltXsAbMvXnpTH5I7cdRWPGtX+ohNoWagbNA2u0UQ0odGd3j24gQPnLq?= =?us-ascii?Q?dfXycmtwyLmH1WSMpJ2a2w9CTaG7JQrKqnGXVBFMAneAv4yHFA4RCeD3RabH?= =?us-ascii?Q?NOZyjpmBqmuIpOlKR8DCB5Gd3OHcHLp1kjFwZAQQAO8UbAQyMp1mC1RyXIMq?= =?us-ascii?Q?43/dKzXXJxZ/szXQALSUZpgxF4N72MXSKHopgC3d0B0Qmo59MINiF0vaLpkc?= =?us-ascii?Q?Og=3D=3D?= X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: e6ebe51e-240b-4248-db71-08db132a7030 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2023 10:08:39.9704 (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: Qxq4+VxkF70o+XrXVkEM+f4uUnJA4dm8k7Jq8ntD5nYbHC2paXgXRAH5rqthf5RgTZIJ1zOV20/z6acWGBbJ2g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR11MB5066 X-Proofpoint-ORIG-GUID: _AjFO0WljJWVGgK1fQ46zOeDho7a4q0M X-Proofpoint-GUID: _AjFO0WljJWVGgK1fQ46zOeDho7a4q0M X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-20_08,2023-02-17_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 lowpriorityscore=0 phishscore=0 adultscore=0 suspectscore=0 bulkscore=0 mlxlogscore=999 spamscore=0 priorityscore=1501 malwarescore=0 mlxscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302200091 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=1415163841=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: 1676887765096100005 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 May 2 06:33:10 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=1676888033; cv=pass; d=zohomail.com; s=zohoarc; b=ag0gxT+vaksDPIIYdxNgEZZlZXqrDsK0/15OttfDhCJcjVotU49gERmqvRM1xM/3EYKKkRXT60/p/4J/+byFbJ8ODfHgkJrgIn7Er0Hdl3vTqk6cPfgk0yFnXV1BZjxQ5ot6/ojdcpay7cRyfgCAzhbKOzn69a23lTMrQh41r30= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676888033; 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=q/WvttN3SK8jHbWyKsG3+Ui/gFd/oIOzMhKYDy9ibTc=; b=cUXxhT5iMHIxbXAbs/NchxJi/7nEwU/b4VVhDiLLSkEmEcgMckOFatfM9CNBOb6YiMHis67gO3aDt7pFe4ylQHRuA1x9wvHJB3d+oH2S31hxlp8b9Ii9LMRn+69YgGO7RZoOrq4qkk/JgUt882WeqJyn+eQl5WlIHL3vOqnU97I= 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 1676888033088758.4837693592422; Mon, 20 Feb 2023 02:13:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pU36V-00086D-Be; Mon, 20 Feb 2023 05:09:03 -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 1pU36R-0007z3-3n for qemu-devel@nongnu.org; Mon, 20 Feb 2023 05:08:59 -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 1pU36N-00004r-0Z for qemu-devel@nongnu.org; Mon, 20 Feb 2023 05:08:58 -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 31K8vraG027690; Mon, 20 Feb 2023 02:08:43 -0800 Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3nty2psabv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Feb 2023 02:08:43 -0800 Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by SA2PR11MB5066.namprd11.prod.outlook.com (2603:10b6:806:110::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.19; Mon, 20 Feb 2023 10:08:41 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9%4]) with mapi id 15.20.6111.019; Mon, 20 Feb 2023 10:08:41 +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=q/WvttN3SK8jHbWyKsG3+Ui/gFd/oIOzMhKYDy9ibTc=; b=HHInvt/b+3f7vULU2eDp6/nPYGS4h6XsxR2HFqyWluqofL3G4g0/R55TU9VzYILmSGCY 7i0nuzfK9ySK14H6L+8XQqB2XRsnrMiRt+GjKitKyLjs6T+Yn6bv04ehRLKrxTsVGEcq dUbgmIpcz0YeXL5U0hNozYdWIcdnVWlnDSgvVvCtvVRWVkCaoQcV+yqXdqB3eLD0bQY1 7FAQ+IZ6cIhSm/LMfGhnzBcMOmbuAufhKGM0ksE3xc1vLyJK434SAXrsilrA2IQ2+VLZ Nvj66x+CeR3IEcCnIqi4oMRoRroeQ34OzXMLvxqLR24W7Vai6SzVPancOJBB3hLWrvRG 5Q== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dQHX3/yHFlGUcieygRFwjBXB+dtc/vem6w4GlBfkuIvPYQn7MlMG2Gx0YVvtVBoEKrP1kg3rrPrR+uQbiFYuL8qgpbw16kapUvhdu380A1guYwpgDD5xWs09eGeWqpgJ7+0kWNq9nJenMKYtc7LqmdTGUvpZiOy6m8u7ru3tzHZoGqoroqGqLjZdceITCQCG2RTKQ1Cf0EtiLxpBcL5JNaWIqhd2UAz+2/siRn3usB5MStxMA4hp1SDFto1xD7UPAvymkMXSEW4B6pjFjDEspZGX8RTxzKRcPYl3ByoIV+binEZ9AsI8Bv5okHv2oSQUuE98RghwWq20T7znGtJYnw== 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=q/WvttN3SK8jHbWyKsG3+Ui/gFd/oIOzMhKYDy9ibTc=; b=ilvXxRAS4PyS/ZFm3h3ZGvOEWrVNEC4kZ9hry7M6BiPrgRcm94J1BTdNeVzwPhBlQLYgz/ycQsUE4TbfLr75dN8Hop1NOHHcXkDRE45bYhhfmzm9fohkfQ/Snr609hyvnBGso8leltM/z/jnDL9ewOUcheqoIac9oHdz0LBKPMpoUECQ7LkRhz2DqWx1ADG+dOwcff0VPnimBDLlR781155p/LcJR5b7E45cTmo5DtVsHS+pdKSodrNUgWXU7vBVe7iBtS2G0rBwMKULUSMWOF9R5PQHhZ8ju+ZIWY4rNfg/pH41vtVZtGXE2JGKKGh5dBsAQ4OCv/guxNugqEs1lw== 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: Christian Schoenebeck , Greg Kurz , qemu-devel@nongnu.org Cc: Guohuai Shi Subject: [PATCH v5 06/16] hw/9pfs: Support getting current directory offset for Windows Date: Mon, 20 Feb 2023 18:08:05 +0800 Message-Id: <20230220100815.1624266-7-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230220100815.1624266-1-bin.meng@windriver.com> References: <20230220100815.1624266-1-bin.meng@windriver.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SJ0PR03CA0220.namprd03.prod.outlook.com (2603:10b6:a03:39f::15) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|SA2PR11MB5066:EE_ X-MS-Office365-Filtering-Correlation-Id: c89c0362-c2dd-4a61-bd24-08db132a716b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sZbSbgZzw8FsD2I1CQBZiNVgcNdv4cTEodJ4hngQtqeRXZleZmSP8O4DZakXlb7qDB6j0AbWoS4Ft7ZVNJ2izPgrbK1eITNUcyiDJDhSIAe5gClH27Y7GzRwKpJZR0F21uN+Ggcc9GNat6X5ZgBlwlNg7l4tPl5nzQopfTZgHJVgULjCXN17jSsU10mWHsj28wsk2t46VVAgBRsizoRvXxlvLyzJyJHpDCg5hRDmLzI2oBHRkDzTbuoXuFxdsBsS83tDU47FSVkFnyL/T99ocyMLMLHctaiopqOc51djt8E4qL5pX1VMCrYtQutcKglzrsw8nTxVz4y5kPJ4BCBxXQ7g1Yua1Vsyk1UAhaOMcfgGH8YXwfJuo0xy6tgd4C/T8HrYl/gIyNIRXg1DZdkzZ4hWDc66lZeunwU3lSYO9DUE8iQ2+1WBqRYyRgumhLXEBspGpex5NgIebkvvpWvmJk77nc6sYZA4QAZ34KDaulUS0dTaDUKjTfWM5qt7SizUdFtlrJuuCBWQzXC8QmQ+DiiZiR6sOwPEA4KCtpHjrvVJvKq3B1+Min469tkDDjia4N6kU/9nADBu1hbxAK6RksLz27Y6ZTqLBGlj9gKqyOtvGtdcCWRNB0THvU7APLoSFN4HPQczrdAUfGqSpoh+mycIwuf2XVnspoO4fPa6Llqq2rK/SmvB/w/AuZQraXj3r/Osn0BpLdP0ZddHGXdRZg== 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)(346002)(376002)(366004)(39840400004)(136003)(396003)(451199018)(2616005)(4326008)(66556008)(8676002)(66946007)(83380400001)(66476007)(5660300002)(8936002)(6506007)(6486002)(107886003)(6666004)(1076003)(6512007)(26005)(186003)(52116002)(36756003)(478600001)(110136005)(316002)(41300700001)(38100700002)(44832011)(38350700002)(86362001)(2906002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?X8b5co4oDDZSmHvDTHjFavEr5y3No+wbLl31vIV1tSQIiivYnHTdspFoB38l?= =?us-ascii?Q?u+htfJajNcOHE6YLTn2I8hKp3axVM5qUBsr+973zWOJTiALxq/k7MOwaOODl?= =?us-ascii?Q?UvixDmo4WFdMsN6G6feD70yrvwviIYAh8VTE+yg7hgkjC3DPFzpKNPyFAAdA?= =?us-ascii?Q?CH0o9PSy0tjgHVYTnoRfa8lCi5yzztbjuV1BvlAR96OkAoQTSojgY9QNvcmS?= =?us-ascii?Q?ZIoxawLIDTKFEuwWzxgRZua982z8PCS87APXfrzxxYuu4SzJD2OvZgkUVDmS?= =?us-ascii?Q?XAKaXhUtJ8j3VfMqXCa5yxotQSjKK62u0Y6WnBWIB0S2tzOABA28Ysovpf3x?= =?us-ascii?Q?2NHVo3ee9skrpK2Z+LYWurJxaaUQVUvRUgcpF9854l/iSCfjbdoIrNcajlhE?= =?us-ascii?Q?KcxK01gXyzkq3UkfAih5WxgvO2XZk3WrkRUtNYiBSnl3ghR/bcmsP8qb7AIU?= =?us-ascii?Q?UlHFPn+VDByYn/Pmr0NRLgyuifsaFUalQ4xWtLz84MZlVBCz8LvYxBCTGSqU?= =?us-ascii?Q?ppvBR8B50oEMoEq+f8driWms3/WLhAzfyWyNbIzcyIQv5cebm+g07mhLM6Rr?= =?us-ascii?Q?Lppw+b/fLWfKuVdX3YtRlisXWb72FK7GzqcCOcyCcPgK4UoxZ0+I+zHpD4nU?= =?us-ascii?Q?Q4mbKP7mm4ZPBUsiAhN4qB316DIqFoWkUEnCCiXuesouibPAVkcWz6GKaH0h?= =?us-ascii?Q?DC345Navp2VPpPLlzWaAPVTkSnGTK1BAoxiW79nFWlOFbLPKRfLQZkaGnTu8?= =?us-ascii?Q?JTPgVs9rqmQZhTobRJaitdK8DSZKhnPWlDF49dDQxCzrP+kq3jTsDfUc3wm0?= =?us-ascii?Q?hhlUBuI2gdPLrZ9AeYgZI1CKpRfhBmt1na483TY8aqNwYsQnl2gpN/1NhN+m?= =?us-ascii?Q?2gn8J6lQKjlmGf9pJj7DB7fV9nZ+D2vm8sDOygohghr0lts4hgL51dPbkaKy?= =?us-ascii?Q?uigCpaN+yWv63pVJ4W9w/S9Tuqmda2ubFM1lc1P8qp1CW1gIx/qbhHnGGtrF?= =?us-ascii?Q?c2CjWYDJ9qDovhxHyOXxtQUwGS0cJjEMOQLGtJ/9iLslFP3xHjsDLpNf7wkl?= =?us-ascii?Q?PqKLbnQqEpZbddDGt7FircY6qn/Ys1YvB07f9LMWtwAySx5/suV3wcp8QRRh?= =?us-ascii?Q?FKsVB52CqI/6ENtnAG2HOMZdwuuN8epKJPxHhUQtjWqEWfqBYYuSs+2KjsJl?= =?us-ascii?Q?pdYfqmjNRFRKBx3hhgJ2pL0HeIxk8hPs6HYqCZl9CvhCPm86zN6JDQiG46Y2?= =?us-ascii?Q?LsbOh1FtTxA1JN8X4pr61Zh8b4MhVim+8hm8zkLngrbWuy1SO15UMxTkbr/g?= =?us-ascii?Q?AD+iEjocsy8JbZrZ+cpgkz/sP8LMDyyNLzzDM3USeWUIC/Ocx8WCvbim+dhv?= =?us-ascii?Q?uxiPnhfnidtXPbD8KOvHiziaS7/hW0JuMdNltpgHXNo2wjqCeXMrwPuYg099?= =?us-ascii?Q?mfbGWVCT7D0Lv1Ur65fBLAAuZxvKX+95YDYGN87Pn6et+LJajfWusJRbH73a?= =?us-ascii?Q?3qwJGAWRg2Lt1W6ZMiXvkUaDy+mNZuaNUTFhzygfwoFTsvez3P5UJ3YmfsUQ?= =?us-ascii?Q?Sl2RT5l+NJ758mCSiDgtFQPT/YyuCssToZCCWWh073XAtH+PgS7SkaOkTiZL?= =?us-ascii?Q?xw=3D=3D?= X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: c89c0362-c2dd-4a61-bd24-08db132a716b X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2023 10:08:41.8465 (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: kj328CSc/aoCl0EOZw/ozh0SX7jUS1jvE7KmTGBa8Yt1YJj89gsEjDQAIsIiCx+pFPtfwsZN/+kIMM/wrO91Fg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR11MB5066 X-Proofpoint-ORIG-GUID: p4Z9hNgimmqY58sclvPzq5mSZQmmTDVu X-Proofpoint-GUID: p4Z9hNgimmqY58sclvPzq5mSZQmmTDVu X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-20_08,2023-02-17_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 lowpriorityscore=0 phishscore=0 adultscore=0 suspectscore=0 bulkscore=0 mlxlogscore=999 spamscore=0 priorityscore=1501 malwarescore=0 mlxscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302200091 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=1415163841=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: 1676888034624100001 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 e9408f3c45..37d98a3e63 100644 --- a/hw/9pfs/9p-util-win32.c +++ b/hw/9pfs/9p-util-win32.c @@ -1420,3 +1420,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 9621ec1341..1b252c6eaf 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -2334,7 +2334,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); @@ -2535,7 +2535,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 May 2 06:33:10 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=1676888070; cv=pass; d=zohomail.com; s=zohoarc; b=KpgWJsID7YcIX8/ySj7dRGv4m2c7XWzrZkO7KMIcMg0/t43JkjPZi3Iagp/225E3NxJfEMqQhjyVsmtZ498MvxIwTw5oHFC/j0pfy4Dj9sPQ1Tnda1RaVAfiLEeywsEPo8D0ZhhqRvyll1Od+85Izd70bO8TdV5DJNfufg3eC14= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676888070; 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=VH6OaBhVmVJjWn4ieoJPa+RgwHCs2zhaUQGxo8+i7i4=; b=BGwOqvy5PQF0Hwhb4dJNVaOt4P5h6aAD8C77HrycVkeyNPY/mppchD3ir+BUIqg9CYZ0kCrU/CQEh7Z3p9+hnosKMXuRrYeihrvzr9SbC+cZ5ul+FlT/SjqromkeX1ZA8zYQTNV3tVl6NmnJCSdLwcLDTRICdYMYBvPtLnAMG5Q= 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 1676888070760200.25553192596874; Mon, 20 Feb 2023 02:14:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pU36T-0007zj-6C; Mon, 20 Feb 2023 05:09: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 1pU36P-0007yU-NX for qemu-devel@nongnu.org; Mon, 20 Feb 2023 05:08:57 -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 1pU36L-0008UM-1B for qemu-devel@nongnu.org; Mon, 20 Feb 2023 05:08:57 -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 31K9wFQp005915; Mon, 20 Feb 2023 02:08:45 -0800 Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2174.outbound.protection.outlook.com [104.47.59.174]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3nttu6sfs7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Feb 2023 02:08:45 -0800 Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by SA2PR11MB5066.namprd11.prod.outlook.com (2603:10b6:806:110::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.19; Mon, 20 Feb 2023 10:08:43 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9%4]) with mapi id 15.20.6111.019; Mon, 20 Feb 2023 10:08:43 +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=VH6OaBhVmVJjWn4ieoJPa+RgwHCs2zhaUQGxo8+i7i4=; b=Bz8B4XxrZ4Z8NE5/nOZKYE1KbBy/duKhCJ4DDbpIC3vSO82SYfOjbYyvLnDcRxJQj2V3 TcW3CCrqj7vvCTRpsCbA/ii89ZXZERvajSj1BoRcWyuH0eW4NkB+b26QDoYPOA8ehM4N 3xYMLSlz5h3V20kU9qdVMoi3kKVRULZPw3kHStraZ+ziUgfcPxbzgg8IkaPA7LesqZyc Ie+e9RqmErBYban2/W68gfKpl/iv1Fc3ch+kOsHt+pf09rr6/CanikCIXllHfsLkI9wz vZXpMFfHU5OHTp1dG2T7lodf4dU2zW1rZfF+yiwTQpsyqVL89X50FLUxsX4OczUbaW7w cg== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a9wJ5I9LmlPPP9bXptETbQcPYBy7BCKZtQRYZ6UJE1I3oD+8O2Xp6sDTwiBHyqwESU7Tic2Rn17J6g08sbEHYKyyTRktdfZz53Oucod2LvJ7SRI/PRCG+aiVc7gjmrCnFcI4RzOxWiEfhP0iQWawEkuC5SsPRDTR0TxVpP7tRZwMqzlZN0W/I2rwg21daoHQe5JWkWesyguYelV9ywFhZxLgywV8k3xJyWk7QivxFJhmxxNFeBnmc0NVUdtsWr4w3q4cd7yhBq5rnPTL4bANij7hbeP0CLAUZrklE4lIUwij8N6APDNVb5K5fgT6rSisOGSwY2Ie9bKDYwZpeXYhNw== 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=VH6OaBhVmVJjWn4ieoJPa+RgwHCs2zhaUQGxo8+i7i4=; b=CPTGUxpoz1rDOLLQ7H5ltycSVT5/2rSMEFvkcneqkeKZhOq59MksVN59bmIMTw4e/gNk0PBNNbtStm+k+dmY/rWtn0TMuqwnhiEcUzBHMgzmasSlpEDwqjnEcjYzs0bz/SYcGCHphFF1xBvwo0qMs14UUGDPqf9sYd/MmrJ/m2JCLprI5fkgfaKyjzPNlqQC3l+Y372eNKZmR/W3hyuC4lKjYpiB4dBDupGXtA8mlzDd1ChsOnuQCt46WGqjb+BWpt85cHWPZIBXuZO6lXZcv4a9UKbp3jkdJAmzrU2LWVFMCbPFv66LYjh3avAM+k9NitbdiGwgyXY7nzuCoo9qqw== 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: Christian Schoenebeck , Greg Kurz , qemu-devel@nongnu.org Cc: Guohuai Shi Subject: [PATCH v5 07/16] hw/9pfs: Update helper qemu_stat_rdev() Date: Mon, 20 Feb 2023 18:08:06 +0800 Message-Id: <20230220100815.1624266-8-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230220100815.1624266-1-bin.meng@windriver.com> References: <20230220100815.1624266-1-bin.meng@windriver.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SJ0PR03CA0220.namprd03.prod.outlook.com (2603:10b6:a03:39f::15) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|SA2PR11MB5066:EE_ X-MS-Office365-Filtering-Correlation-Id: 2e217adc-6157-46ec-9843-08db132a7287 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Il4gIIBazTUByI43CT6gKXjEOz2G5YU9GL0BG84WQGYgk9S686K0IJ6mtPySH1iVmGHl+cHyNaC/6LMelWglakADqPy3O+Hw3vhWnr70z0RVpzRd0VHTTqnKjajHC65TI/XsCA9yVrMzj9+qD84VPZb8C6Up/QClFNXkPqo6u5kHOLePkKq95syzc8Ym4t74Ry9IgOZ2sqJ30DcGht7EtFMPOpIizhcnb39q1/PAW3PvvSymKTC4vgjXBPhi/amUfTpW0kElr09sHz7G89D9o44v9Ov/sD2gIvGz8I/yQBS9LXLiuaMwcEOrKNyQNl6YhbC42Yq3SWGhR3/8ff8n/8K/q359dZRmaOb6UaklYZdhouNAKWUFOXd7yabzdK1OV7BGzg4+16OOpD4wXRPQs4IRv7rcaIa3lDtiHa0WFY5C4DRyvwRpwHXc7rxpd5J0f5vfE+gy3vkfchjXaAF6OBINNCuv+lAgLa85wuVH2ct/CgYunUcXzvKBNADmqbjr3c5kEJGvSY4gJ3KsKSBqvRK6aMD4ewa0wjJj9AdjaSvcdqiCO6xGrsWNPBFXZrwLn5RCi04CryEda0WxvD8mla+IlJfQbemwd3IoDQHkMiI8C/HVM5Ihyy3eFVAsqjXE1r5y3/YtCx9wNYvt/uS3sP8taaClUbd4/aJTtp6JjhEFS2P/YtCJvOXaTKOy7w5XXn2RH2BjGj42eRP+4TS1gg== 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)(346002)(376002)(366004)(39840400004)(136003)(396003)(451199018)(2616005)(4326008)(66556008)(8676002)(66946007)(83380400001)(66476007)(5660300002)(8936002)(6506007)(6486002)(107886003)(6666004)(1076003)(6512007)(26005)(186003)(52116002)(36756003)(478600001)(110136005)(316002)(41300700001)(38100700002)(44832011)(38350700002)(86362001)(2906002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?s7U/0nUyrnxGUcUroGJfSlZpe3jX2wncroWMUOPXAzCSNCeJ44u13IBjef6B?= =?us-ascii?Q?uwzxHE/ttGyiK79kLc4ZZ67Ufi+L8yjyTPHtL2f+q1g33WxaJb99w5Wyxl6Q?= =?us-ascii?Q?N4f2XET4Xwp5fzTR1kquxi7xrCnNxD+V/3I2uQx6MJk/fJoaZC1iysLFs5nK?= =?us-ascii?Q?uc1UJwC60APHRl3MYoNXysq3moYNJuIpefxS5NjqrQ0zu7dRz76mKVpl9Fgg?= =?us-ascii?Q?X+32VYXHPCY+KHxgGDQY+1NS+5TOCeiKycSbsVjL3D4F1dGzVkKoY7rsfa2C?= =?us-ascii?Q?q2y0UD/yXBAv/mf0zmzlPXyxR+latL2UuHL1oiH81UbXU5swNKkC41tC2vmD?= =?us-ascii?Q?cwRjv6n6/F3mZ3RCkjXzvfUkD/MpSfJXOVPLZ+Mv1UtUIdlfbG6XzmD1jJu9?= =?us-ascii?Q?zoSYSNxF98tM9aXzyYkjb58utVrpFPk4bTmNis5Zka7lDmbi0O2pvGKrfRxN?= =?us-ascii?Q?AjOit2A/xF09MNawrCje5Iew24Il9zTkyRMGkdICglJyF7LQXmbxpEqXrEo7?= =?us-ascii?Q?PshNztVOUHeVQbSYZvdH/vdThXIPeKl7Kre5E2JIcUa6jY/GhKeZJxpnafZI?= =?us-ascii?Q?7IlHovYKPCqBLFVFTa55j4FaUEv6dqagnJoef6JZdGnz2SJoX63zaba01GPB?= =?us-ascii?Q?KUoOfwDCGASd084auDphRWnPUqA189Af0/++1h2/TwN4ZPiNrXDrtCIDojCO?= =?us-ascii?Q?MhdvKol6mr1nxdLue359l6p/FC7guCn3EoWeLDJ2bPYxGX9dPioTnaO4yaCH?= =?us-ascii?Q?1DJJkZK897tQBLUEx4V/7a2Ar7Z6LllegTcH80F+nGOxzoaYg3JodL51HIbX?= =?us-ascii?Q?36GlpJ09Pq9N7sYj/eY6+b4jc7nEuWBgJWg5BXsSTqfvhRY1SMDXplWjaOMg?= =?us-ascii?Q?YLoSn41lbPrlCxRD61ZAh55ZRoz1j3LtrC8QT8OTZ6c+FLgV0XwWLuvL+HHp?= =?us-ascii?Q?KeForG9Sg5sxbWhCGt1eLx486vaksnm1SZApS8eEiJzZNO2Tmob8cm9QDIja?= =?us-ascii?Q?q++jdD+QhQmzFfRI6heqi48MOXJm7wZpV5DxlRKCyqfN91HHvetkGW+OxI9Q?= =?us-ascii?Q?qx9H9e3C7bAeIFVMutVA9PotutRnV2wjOZywUeIotjJhSOLDdsu0pHz+WDDd?= =?us-ascii?Q?5sK4y8HoocuDxJKIP4av6v/AC3lKMDNHnxUX3uVkRAiRYkFWqIivltBDCyj2?= =?us-ascii?Q?P4kJ+O42VernqTZ4EyQ5UzPKwxPzKvb2XBWCfnJo2MYlLByI5OSmubkGKzPO?= =?us-ascii?Q?A9ZdNqBzBd0FxPA8isyVl90T/jTuS0dbqw9wsLvjAd5Y51MRs2n7QbjtFOdx?= =?us-ascii?Q?UKrUQ+4TchuEYLogqO9SMLkz28p8DeXi3I5X5PNecXo4RKzjPyRwFLG35Say?= =?us-ascii?Q?pWWSz978MJdKuEcHn8Q9HXHfVjEP83ejvZWLBLnYQPsBqrB9gMdV9UY6vLcE?= =?us-ascii?Q?fMDLIhQYYJZA/FFBYXpqHerL299t29WsfPIMemS2vulq1DQhkRXWUj/BRBUG?= =?us-ascii?Q?Ru731vYxwmMhndqUy0/KbIOBI3FAcWQW3sWK3LQQSl+YwG1DpwdAwAQH+DR8?= =?us-ascii?Q?mKvnYIBrYOePnqr293JacdB2n3KthpdxEKszs1vcPHWX1/dknNfKRtFHCAyz?= =?us-ascii?Q?Bw=3D=3D?= X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2e217adc-6157-46ec-9843-08db132a7287 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2023 10:08:43.7053 (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: yDKBGie7W9kP9xAya1KSYtMJ92I3Q6Oppi+F8Vrz7MbE46fXYo9VlO638lHq0P/uJkAE5QeOVJjVVqUn5MeVIQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR11MB5066 X-Proofpoint-ORIG-GUID: W3BFgxI0L12Ri_hpqNz-9EwqjyF3oWXe X-Proofpoint-GUID: W3BFgxI0L12Ri_hpqNz-9EwqjyF3oWXe X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-20_08,2023-02-17_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 impostorscore=0 clxscore=1015 mlxlogscore=999 mlxscore=0 lowpriorityscore=0 priorityscore=1501 spamscore=0 malwarescore=0 adultscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302200091 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=1415163841=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: 1676888072987100003 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 37d98a3e63..61bb572261 100644 --- a/hw/9pfs/9p-util-win32.c +++ b/hw/9pfs/9p-util-win32.c @@ -1425,3 +1425,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 1b252c6eaf..ead727a12b 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -1264,7 +1264,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); @@ -1344,7 +1345,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 May 2 06:33:10 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=1676887794; cv=pass; d=zohomail.com; s=zohoarc; b=P5Q5boFiXAfcYaPQNs7GtJUdLWyFPx8xBF4yjY4LzPLUmle1T6RbAXBPuD0B5QhXjeg8rR0IKT+UtXtlcdIGj6YZGjghNHtT0TZATFFN2u3JtVgu8SCy+QKOwT96vuq2SDktYsTryVgRscN4fZTTgwaTpMRt+1cUus/bpgSoDjQ= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676887794; 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=4eBRErfMpVmQYhZhJHRvDDAEFBlnCDAod94L+/LmaTE=; b=Wgu0pSe7Dhfdh4ciP4k7cmBx6aAYuGALx5SqwJcWAYL9dtsq60N3c+rlrYChHL7JVg25nJLNtn3BpgSZtC3x2/4I1m/ItMq0Yc2VhdvSCo3fMK0KVoiCDTyBKGm416qO32+ex8gU+TJNkFgOnFqZpRdrf+Z/WDqM+LM7udI6ySs= 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 1676887794658129.7861997532774; Mon, 20 Feb 2023 02:09:54 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pU36V-00086S-EE; Mon, 20 Feb 2023 05:09:03 -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 1pU36T-0007zk-6R for qemu-devel@nongnu.org; Mon, 20 Feb 2023 05:09: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 1pU36R-00007k-Ee for qemu-devel@nongnu.org; Mon, 20 Feb 2023 05:09:00 -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 31K9CRZs026793; Mon, 20 Feb 2023 02:08:47 -0800 Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2176.outbound.protection.outlook.com [104.47.59.176]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3nty2psabx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Feb 2023 02:08:47 -0800 Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by SA2PR11MB5066.namprd11.prod.outlook.com (2603:10b6:806:110::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.19; Mon, 20 Feb 2023 10:08:45 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9%4]) with mapi id 15.20.6111.019; Mon, 20 Feb 2023 10:08:45 +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=4eBRErfMpVmQYhZhJHRvDDAEFBlnCDAod94L+/LmaTE=; b=F7gkNXn1jqCMna797rv77PKq9n8HW8DZhHExJ7BBIOZ5s8yRNUV1wSK1n9+dpmJh0RM/ Q3MxuKiC7JuSwlRQGrUBenT04Tz4WeYFNu/WK2ZFxIHC2sg+HKQpTg/0meAMG4tC1tyA 6cEdxDuyUGLa8JqSborYDX3yqa1EX8zPx90rxrihgIIGLhn2CqRHiVbWQYz/l4i3dKhf xrFCfSzJod0bnhcCkrDw2z4/Ng6K1v2ZQFF1mHPlMXLELCK16ZLfFaF7wbxNBUOpFCrd F43M8NA4ywgm3y5mf7RlCk38IPQgoXEPJrIdHzNjtauHI375TXWJBQ3H6zTNrfHrn9RW Iw== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kZjbxvmDj/YuOYk5Bs31zZ1HWeemmp3M2W8LacqFVoNZhlrkAuiwC0T/o4Jfc1MgX3dQ3GmyartP/0g6C4QHjb7oAl8Spb7cJQvOx2ZYohfucIOq9QL0+Uk9wdE0KiuM28NXkPikr28NFwRY0i+Cc7lI25K44rbutmhqVLn/a9uZnpSzCtCRZG6iYj3foor94PGebYsyIoUqH3K5z0AsSKH/6w6NO335tPvLClOqKQ/rRB/okCyxX+KfAuUU6vbXmwYLOZXZMUOLT5nkNGVv5ZLamWrSVGPzZ947N9/Ila4OlSVWSpKx27MpmSnQFSRRryjjU7VydWPirGaIKZvAXQ== 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=4eBRErfMpVmQYhZhJHRvDDAEFBlnCDAod94L+/LmaTE=; b=XOr6hHtq8H0L5EQoV97Rn1F237iF0k36hOKd+G/ZqniZzA0bnRA1sGHrPkNNMOdHn9BV/Ia6BuzDzI5RrLpv1+g0ftphORDi58UbTn7weV1MvZp7sGOYrtcpbKeKQRXFTZDX/vD0jqv7g0uf/ZUOmrcF/q35+Hcd3NfB4wt7n2cBTXnu9Absl3idKV5+3BVp/hWxCDAo1H/7kOSVXnfShlH7SfjtCvRyEM8izDIeNhySXcLawTCIi6WzVyvhPC16ZMKACxGbeWL+vC0vIr1dkrsl0S0kFtaBkwEOk9y8nC24Qtt7acSwppCoAuvvizURvXQGXTZG6QCvHWlhoWMZ9w== 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: Christian Schoenebeck , Greg Kurz , qemu-devel@nongnu.org Cc: Guohuai Shi Subject: [PATCH v5 08/16] hw/9pfs: Add a helper qemu_stat_blksize() Date: Mon, 20 Feb 2023 18:08:07 +0800 Message-Id: <20230220100815.1624266-9-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230220100815.1624266-1-bin.meng@windriver.com> References: <20230220100815.1624266-1-bin.meng@windriver.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SJ0PR03CA0220.namprd03.prod.outlook.com (2603:10b6:a03:39f::15) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|SA2PR11MB5066:EE_ X-MS-Office365-Filtering-Correlation-Id: 90d00833-314f-4556-2ce4-08db132a73a6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xzHGhtgDb04zUjHIVqkX0GJR/j7goHtA8/PGrrIT7+VKsYb9pQXuIn92KMuZNz8ShhRTZCHyqjzUyuWz9W2pVOeTZa5LZhnRw4LugyN1fCDEo5wbKNChsrVKON1pvfBYFpcTufRJFPxXXeUu98rKz3iWh8vLYA+2uW552yP8qxulVsMGIb2ZVF6B0CKKrRLMpo8ht+UJeJTiCHWQBGoE0up6EgP+M2W543swR74nr8rdxhslz+nSVBqRtQOfcvHUNvEpKtzaXJToVptMBqUdkI1w06Jx8SDaDaJWfO37kB0SIE7vibAcm7Xk374FM0ts818cULIpwxH1jr/U4b5F80t9p8LGxKc8LGeKFTiaqdTijpKgUYq97JkpQ0HWjoVOb0h1e94lh1XA5EjcuwN+Di6IAr+BZxMon9vFiSgOtw1/NOXFuCDxtGTfz1w/ysZeA5o2Acq2xPf9F9myimwfWeLi8oE+u5xDKmkhDwecmDAt+nZVnNv5z4oTSI+MpJb/CGuAMxe015+kJk3XAt/x0BFTcN01ym0SQRlU7zGlYlepTr+MDaAYT3MdpIh9sie591haXUVYX65QdeOAA1sRuGjzyKM/FOtOQRG8mlPfjI4Jfnmyq/8Rq5AiYvm/nuuBLFTb0pjoHeudsw+H1ACQPyEEFHl+3jnJ1GrGDMsrZcX+23te2MrwbkOVjMP5gFEMuej3iTuM9fr51iln+WDBag== 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)(346002)(376002)(366004)(39840400004)(136003)(396003)(451199018)(2616005)(4326008)(66556008)(8676002)(66946007)(83380400001)(66476007)(5660300002)(8936002)(6506007)(6486002)(107886003)(6666004)(1076003)(6512007)(26005)(186003)(52116002)(36756003)(478600001)(110136005)(316002)(41300700001)(38100700002)(44832011)(38350700002)(86362001)(2906002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?+Mg6J2RtP09+ar/iXdWnyZk3jNS5BxRmxokPFTp/an30bgW+wQtIBVy/fiUp?= =?us-ascii?Q?KUhPX3W4mjKAdLZX66JewpT9NN3CMBFNj75hThW7NXXmqyQiO+bHvw93v68d?= =?us-ascii?Q?qgw3O7Khlu70l2U26VlcOYZ+q1f1oDiOKNyQvI2O6nzDwryoKQznQBBRi1eG?= =?us-ascii?Q?2oEke+IZn+/pbEZLKcNOXcmgOVT3pdLAIhD7yoavBxLZ8E1HBcoElBKtJmZK?= =?us-ascii?Q?NQiLceELVjR0UWONH+cBX9WBV4tTi8dJUsaVGKNRoV1tE9jjX/SPsKGDInv0?= =?us-ascii?Q?ox82DmkKg4hZWGuBQs5qOMYKnL2MIBq28RUR1j741F+U2PqdRGnlgZQbrH/3?= =?us-ascii?Q?9QYgbDYC4S+iyt5ZSljBT9CyyZsG+s7s+ar1iyx8EErZ/nJGKnrWbZD7FrWi?= =?us-ascii?Q?lVn/J7GqpRGLz6SKhvtYSr0XXorTmYSX5Lw7/9YlIRPwsnunSoSMsdgug+lj?= =?us-ascii?Q?Co5tkKWhpo1lSd2cZP8HpxQkM5SAfhuRBtq2jLxzbiagEQ3UkkAjaOEyLNAH?= =?us-ascii?Q?W4uqeYreRxHXUlJwv6Daa3go4dbEaY2qL0sRSn5G6M6hkQ3nPYmFNKNKsATW?= =?us-ascii?Q?+bFvl+PLrEVL2kqpDAJfMlhN04Sy6+cLYjZ0xD/5jdGVZJfpcAqHwBee0LlP?= =?us-ascii?Q?fQAFhFsB8ACfmCIZzZPja7bR5TS3kFj+nVSNG/d/8ziU7gXTz7a2uHRUrVal?= =?us-ascii?Q?GJnQ9llbEQAshdUmgYV3ZbiDeTklduGdvzdlyPxAYgqx/EMdKB+1QBkt0rze?= =?us-ascii?Q?RFZ/AT7aWmkKs48nNdXlCf1yzgzwd99XkrnsB4snXXMMFwB/bASlC6Wis047?= =?us-ascii?Q?HylUZGaswX6lYIcSut3Gwy3e7zIXLlp3IPtaOoc7nxT636U3X7A8YnAqZZbM?= =?us-ascii?Q?mnV/46iRgJV/BFeHqu4NuaArsAgvr6gf89sc0OJubKG9dNS68w66hZYI11PK?= =?us-ascii?Q?fJbxAEwSuY2PqukiXNpndWGaMRHG4io0Bc2B0aLCt72InrQLNx8v6zy1+k0e?= =?us-ascii?Q?NHQEgOSHtgcMDJd20HiPnmmFPKq6rS3I3fAJM0LLloHrFlX0QOgKw+Cm2g0Q?= =?us-ascii?Q?i7tsD6vklJk4cFgtQp+r9ZnNm4vAn0zbsc+stw+oGowpDdxYjlGnj+pkMZKr?= =?us-ascii?Q?Icz1RJGJGbH48YQD7v5kwqGuppiYIB3YSqpbbuOdggWpmWmBM0kaqBNPnGbj?= =?us-ascii?Q?thY+PuSb8rlDmLSxe34iGGUsIlEcbiQ6A/c2oEe+UibKRHt1ThvvQbg1Xtkv?= =?us-ascii?Q?kWARuCBa8Z6A3OfOsrK1R+MsGIuXRRBrovKScw2PlAVT8htgBr1aHsBoLq4w?= =?us-ascii?Q?GvMfoph0wjIMK8UOpq3VCD+N+ckTvNBjm/sXNkhbOjaxpHBN+9DDZPVIgdnH?= =?us-ascii?Q?/rDFXgCTtH0suRXNVNIBVmblnnpIGYcgPX543Rp5vSzukGUC+uoOYuzT1RmB?= =?us-ascii?Q?sycc7iTWTPzb4K30rs+00Mv8fMOO1dPikBsucBGZqFdFeq006nzUETi9dGOH?= =?us-ascii?Q?RUQsvd9S341A6zwgJUixjJXv+5xxv215uqPr8id78JSqTW3wSGrQx/cqkSww?= =?us-ascii?Q?b8sFVsrEc3yjxZVWKH4AHHv9XRxCmcnOI6yYKYZZ3M+N8sr7oBdlIDgjWR+k?= =?us-ascii?Q?yQ=3D=3D?= X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 90d00833-314f-4556-2ce4-08db132a73a6 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2023 10:08:45.5694 (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: Z8rhvgUOIMH5/5jzO2el+3hdh/wSCbn3M8Uo7NQ7BOUikn6Vdsfh/J4/zo+kuLrlXL/gJOs8cIJzwHJsX6u84Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR11MB5066 X-Proofpoint-ORIG-GUID: TWavJn1kNRuuLPcEw8S4o1KiQvCg7hmY X-Proofpoint-GUID: TWavJn1kNRuuLPcEw8S4o1KiQvCg7hmY X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-20_08,2023-02-17_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 lowpriorityscore=0 phishscore=0 adultscore=0 suspectscore=0 bulkscore=0 mlxlogscore=999 spamscore=0 priorityscore=1501 malwarescore=0 mlxscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302200091 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=1415163841=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: 1676887794983100005 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 61bb572261..ce7c5f7847 100644 --- a/hw/9pfs/9p-util-win32.c +++ b/hw/9pfs/9p-util-win32.c @@ -1443,3 +1443,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 ead727a12b..8858d7574c 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -1333,12 +1333,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; @@ -1348,7 +1350,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 May 2 06:33:10 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=1676887778; cv=pass; d=zohomail.com; s=zohoarc; b=GFyOsUh51Ia+l7SZK2qfQBVJu/5Utz1zoiAhrOGQheq17H7R3ccEZxjiUriIr/85jHEzTNNhU4ygCQBjUjzpUBYd9oH82cZsdnuIJiwtBbyvfsv0SlUXSD50Pt1jc81NqR9LG03g+FF/yVOIFZJ5hsJVWlydVSQ4YUegAurA+GU= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676887778; 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=XCThB6U8JgGE3cSTEWUPuwhj2vNuXnFN9C7046coD7M=; b=VjKhl+VNomZ1Npu4ZdRexGBiHKzKUeKFTNs1TSRN/LMLlX98FLryQg2jUg2hAx0Debi0lkZNKwgxxAnmTR/Oml2izUp9s8ynkm//T/RRmlH5M/iHk6YRJUpOqjJFkZb7gGlLHvvCN4wmmr3ynCnoJHuM8Xs8CiRgJFlQ32lBDyw= 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 16768877781501014.5873110701626; Mon, 20 Feb 2023 02:09:38 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pU36a-00088z-8R; Mon, 20 Feb 2023 05:09:08 -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 1pU36Y-00088X-VH for qemu-devel@nongnu.org; Mon, 20 Feb 2023 05:09:06 -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 1pU36W-00009G-Ud for qemu-devel@nongnu.org; Mon, 20 Feb 2023 05:09:06 -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 31K9f821020143; Mon, 20 Feb 2023 02:08:53 -0800 Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2170.outbound.protection.outlook.com [104.47.59.170]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3nty2psac0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Feb 2023 02:08:52 -0800 Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by IA0PR11MB7912.namprd11.prod.outlook.com (2603:10b6:208:3dd::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.20; Mon, 20 Feb 2023 10:08:47 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9%4]) with mapi id 15.20.6111.019; Mon, 20 Feb 2023 10:08:47 +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=XCThB6U8JgGE3cSTEWUPuwhj2vNuXnFN9C7046coD7M=; b=czL5JLo8zqosfuYaqv3uwCRhPOR0HREo3Oh3nbm29wcizHhzAffPzLrzSO0kdzIAfCXL DLBcIz6e7SCMuXOYI+dVB9o9jkna713OFlKx+7hkSKNi/xd8R4c8LGmDYmS7gYeATNLP MFW4zjH53xY0JLWKR7A2bqG2HC6vyb/BEDbLgZpBuNl/K6q3ti3DieodQzLWj0upBdSv z4It3WJ6NFLgugfcTgoHOEjpj/rMk+5+nU2Z7OAaOEv+lpsUta5WdsCOS/q1lIfR7L+S 4MVmT235YGv+U9r3QSKIL4xiwYB2QOmcIzPEORIk1iV5ep3nRAHQNI0x3OL9eCnml25r BA== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X9xL+TxWsAFEGcnk0u0kd2oHlsaspKBU9Yv1A5reaUF4cPNLet75UcYXGjf5lRs4Gce4iP5mukElpY4fcPfeBf11yM76jcNXwuTxROTsexyBCZuk3pL5Sx+gtLBCRBi/V16KQ9sDzxiR0JYIbKwhjv3KDIcH8JZydBIFHWM7L7OHUbOgqNbrJWTH4BfS13X3OGZ1Ckb+Tgx2P7sMdl6yIhwE2pRNhy84pNPr1iaMYY2M36EOojY/SJmxoMVpdRJg3cAHSE4Myk3qBJuv5Y9P/L0b9OYk2/UpKEqTRpybGrpnk3dLJVcy7z5bJ/ZGTn1WHdtj1XYt8N7as2cM5E+SXg== 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=XCThB6U8JgGE3cSTEWUPuwhj2vNuXnFN9C7046coD7M=; b=n6Wi7hGuatK0M4S9ZQtg1Ldtvi04Ds9HAR0rUqK+Vl+7rQjIfHniDLBDyfmNB5/2pkXGS8/WMrYF6HTrW8loGmoWkd+Twuo4V5C6EAwmGenfNBB4rBqfJP4j8Iv4YfXaB7L6OhK/pQl3NeYK2zEjccNzvKXx+ymF8YtPXPFw2fcW9ih4RbdJJbiy1KH6d9gBxuydvCVYoHkAfSfoAeJKT/47naKgaJRzNu/Yl9GArB4qmZlEYK4xxMDh/jP+b4ycLrEC9Sp+3BQ8yxVL7MU/VcuiVaT3GqNowQlNf9IZ6Rb8xQB7hBGT6k7X81snZkeVmRMm0gXLLxX0yEbirSMS1w== 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: Christian Schoenebeck , Greg Kurz , qemu-devel@nongnu.org Cc: Guohuai Shi Subject: [PATCH v5 09/16] hw/9pfs: Disable unsupported flags and features for Windows Date: Mon, 20 Feb 2023 18:08:08 +0800 Message-Id: <20230220100815.1624266-10-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230220100815.1624266-1-bin.meng@windriver.com> References: <20230220100815.1624266-1-bin.meng@windriver.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SJ0PR03CA0220.namprd03.prod.outlook.com (2603:10b6:a03:39f::15) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|IA0PR11MB7912:EE_ X-MS-Office365-Filtering-Correlation-Id: d9e12991-8e07-4528-6ced-08db132a74c4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gAezlPa0IR3yx1aUNbQoOaMh+1UEqccJtkhQe0P/z2e6ngX+XP91VWAKax8fglxmovLGx6x1PkFXnhlwGGIwZYaXs/6GvhZOpya1NYFDe4NS75ALLWNQh8HSdegYiZ3UdJgOU1H3GpkEAnAc+A+HFb9w3ngN9x6mz41gD9xhmmHUP0Za9XmY91JnOCtUjR/9V2i7cvtgd1ZGpuJSspmxAEuwMViYxQuQ6ygy/7+099UI8ipgZIqLJKAqeM3ilU8YXwl+bgAdgn4QiSzV7ekHpXff7Ae2JMN5tAdQjf3WzvUGn94fPRH4u7s8hvYMo7kA10ITqZL36aK7sSu8H7uf3DdPed7xHodAs6XPHOrkeOCf2Wwge6XCKLx3QOGVX4FuORKLgonEdVgP1flBb0OxlG8kmM24VS0N+XyVd/U0AwvhKkjJHUQgr4GdFoVrnY0ERz4hnImXckhRT3wY86mnyx4UiEJ5gsFuWYlygFVdpalOSzGXJciHjBVWfhz0AAQrRfq0u/FiX/kbCCLGGHt2dnsSNZoJARw7CRytrA93AW5s251EICCuY1GuIVL4wEzyEcPOolY3UBM/fl9DgOaHCS66gmvvMjD9ZlOYZig1wUwEH72vShcBdubJdIiyvBKKTfgT+H61G0jl5c+ZaJLcoU9O/1CRh6/Bz7jswqdLbNQELTeQ/6g/gnG2cL9d8bRfJ9O4ALaigc4MsHjaGKV0Jg== 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)(346002)(376002)(396003)(39850400004)(366004)(136003)(451199018)(8936002)(83380400001)(5660300002)(41300700001)(86362001)(44832011)(2906002)(4326008)(52116002)(6486002)(6666004)(186003)(26005)(6512007)(1076003)(107886003)(66556008)(8676002)(66946007)(66476007)(316002)(478600001)(2616005)(110136005)(38350700002)(36756003)(38100700002)(6506007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?YGMgAmWTUrpvfeQrGNwKt3Ariv7A7ZvhezVQz5+NqsqBY0AXmvuv8zX1GIOY?= =?us-ascii?Q?+6ZPgZdsxXU4OVHOKasW/Dn7kouj7mATw8P2599KyWF92hCVyGYm+VCpsqo/?= =?us-ascii?Q?5sfV3FvSgheZ1dS2jeLKMUcBCPQlH0di2FSS0gobyGRn72p1EmVLgnGa1Rtu?= =?us-ascii?Q?Cj8JK5guT5cMqC6uxU+CKSZhxVSrOkWPwwq80NqSiN58ZNSmVt2I63OFjRVP?= =?us-ascii?Q?iGHkiSi49rh8OUbjAQwKV5c4/JHG0c+9U8i7zS/cyHr/LhpaFiFfVDtD9eD3?= =?us-ascii?Q?KwsxYthLKa6ws+nMQN2vHi0G+ndrxt/8+Tk0QTNKkAnr+seg4zw1+qfXIxOx?= =?us-ascii?Q?5teERszK/ZIJnefkMKNPtW2Z3P3JJAOCVzSP8/bGfsdAu90gFC1OZuw/oy4x?= =?us-ascii?Q?hvrZRHod7l0YCWFW53x82X81FL9FyosO4oYw5I0bXmO1KuKvexpgiY5EKlvK?= =?us-ascii?Q?ENuftMutF3jG+Hp3ExTTdMnBh8Cc1VeJjbgnu6PCyxRwchypmaTIJY4+ZFs7?= =?us-ascii?Q?984M9qiLwHuushjw/yU1bxhYxwjttby1DBPR/o+D+kZwuG65h8i9TJSt7jAg?= =?us-ascii?Q?yaDOgpGhD2qYbOmhTVSHURkoPucq3kxixq6RpKZRKlvrDx6yj0RhXCteD0lD?= =?us-ascii?Q?LH8Nif3tiqgMmiiHLIO7aSNr7md/any9oAcdA/dCFdlfOLoEU6fWYKopzADE?= =?us-ascii?Q?idczgW88I95KVNShImo6y9/1Apuo3Lcau/4gkQJmj/WlLwRjgHxXjHGeN+h+?= =?us-ascii?Q?6mAWRcyQg+tZq5wyzpAy2XO3oCo7+T2aFz5bg+4LWfotVsJMJHyiuisMesRK?= =?us-ascii?Q?GQvZQuFXFB7QG4wzwfPEBrl41hPe3a9NjeebrrE9xM+kykQWYlXjr7iMxL3L?= =?us-ascii?Q?zxvrjBubMjCKjk9jVPgP31peoKKdlnfi5bYeA5DYsRhCVEaytB9Lo9fLUvdA?= =?us-ascii?Q?TB+NXUrLDsysFuuQYrORP2iZVkElgWx6dmuA3oBkKBZ7hd0EhHNuQhLWxNn9?= =?us-ascii?Q?FaCTHfC1hNGJDmFrEcIhSROy+8wyzlObiD7OduJ0KYvzdE1gwcQih1mls/0X?= =?us-ascii?Q?ln4e4ZmL92hKFJTczjkLENZS5d5ZRMWZ5iGzkoVwaM/diTeFjoHNBmzWet2s?= =?us-ascii?Q?8Muv/vC0eb+e15sYRYUjc6O2Cob/aZhh9E3GCx0Ok4ZcKb1ElMHmR08BIQef?= =?us-ascii?Q?95/kZuRd9X/VAeWDsKkurnYV9jR5BrjpuOcEL7hlqv9z/lTIPTFMrtiZgk0S?= =?us-ascii?Q?QD13fwnbnvGVL7GL4IunQ80wsK+CoPEx0wdcR32zGnhYIeXKCrFSBVTe0n6D?= =?us-ascii?Q?OeKeJOX3HxfTOt3BnMUvaT3q3eOppo6D6kJv3Obnrc19vP9XvU9N/Hh87opc?= =?us-ascii?Q?SkYQrAyIbQkBwEY92pH+LEZK1uXnNriait5eeUMh2nX/KmjGPWE7fPCr5ueR?= =?us-ascii?Q?6dmsUWO4QRRXMXmvz+l5lDlat1Auc5Lu1w3Q1cX7L/dMMVbhtUzLOAhy5nAG?= =?us-ascii?Q?MfPVRX86Now/GDMBvmfUy6T3oNT0gHRKAfHSDWJ3qa/i6rIxolPzaopG01Te?= =?us-ascii?Q?YVv4MMArUhxvW9fHa45YpipysNeHVvN9OOhkK427But+0pQK/5RpcKxrqi5j?= =?us-ascii?Q?dQ=3D=3D?= X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: d9e12991-8e07-4528-6ced-08db132a74c4 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2023 10:08:47.4297 (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: Y2upy5PC3OqohFlptVFDGHa+kNvaT9gnevUuQm4ljkX/GJh3dtBGDKJeUOx6LVId48pemassrMkHVvE1Qz5+rA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR11MB7912 X-Proofpoint-ORIG-GUID: wxLf5SjRhSERXdcduJhwjXYoEiuPIeGU X-Proofpoint-GUID: wxLf5SjRhSERXdcduJhwjXYoEiuPIeGU X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-20_08,2023-02-17_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1011 lowpriorityscore=0 phishscore=0 adultscore=0 suspectscore=0 bulkscore=0 mlxlogscore=999 spamscore=0 priorityscore=1501 malwarescore=0 mlxscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302200091 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=1415163841=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: 1676887778917100007 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 8858d7574c..768f20f2ac 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -37,6 +37,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; @@ -130,13 +135,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 @@ -149,8 +158,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++) { @@ -177,8 +188,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. */ @@ -1115,12 +1129,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; @@ -1201,6 +1217,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; } @@ -1208,6 +1225,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; @@ -1367,7 +1385,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; @@ -2490,6 +2509,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 @@ -2551,10 +2571,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 @@ -2910,8 +2933,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; } @@ -3981,7 +4008,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. @@ -3998,6 +4025,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; @@ -4006,7 +4035,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); @@ -4059,6 +4087,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 May 2 06:33:10 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=1676887776; cv=pass; d=zohomail.com; s=zohoarc; b=SQw8xKzeyXYSrb8XXUerX+278xfTjbFsK4MAEo7apyas5XExAxkuP1DjRVls9Uco/93N7vZAQm2ngcx/KUcCt2bOLHkN3+C/omEJCj11ehi/FiSCfMw5g5MLlcknZBvJBLHzP+uEhs2XC/kLs49XJKpGu1XvoKlTDi5Z6HpsCzQ= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676887776; 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=6HWeoVpOMG9q1+I4TbjLKgFJbW2Ar0pkOMatkPjkfsU=; b=KFWiK9fXfGbALQUWBH6SLTxz9LuJ/3Byr+9MPplPfHBh0U+hWH8tt360o3+PvHjYkl7IJHLhfHvEZNLvayxG8O+/+y/X4u0ggV+nisBO3vYyPY/IuukqSuJ+EvI9+OUHGSC1HBrQEz2jcQiSQUuC2KNhrYSBMlf++JY0lfKcJvs= 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 1676887776722493.8416355400668; Mon, 20 Feb 2023 02:09:36 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pU36b-00089m-QH; Mon, 20 Feb 2023 05:09:09 -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 1pU36a-00088p-2o for qemu-devel@nongnu.org; Mon, 20 Feb 2023 05:09:08 -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 1pU36X-00009L-4T for qemu-devel@nongnu.org; Mon, 20 Feb 2023 05:09:07 -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 31K9f822020143; Mon, 20 Feb 2023 02:08:53 -0800 Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2170.outbound.protection.outlook.com [104.47.59.170]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3nty2psac0-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Feb 2023 02:08:53 -0800 Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by IA0PR11MB7912.namprd11.prod.outlook.com (2603:10b6:208:3dd::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.20; Mon, 20 Feb 2023 10:08:49 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9%4]) with mapi id 15.20.6111.019; Mon, 20 Feb 2023 10:08:49 +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=6HWeoVpOMG9q1+I4TbjLKgFJbW2Ar0pkOMatkPjkfsU=; b=V3TGqk4EktLjI0BRPDsnn2oT5oU2FSIxbGRNjTRLW+Ei63zMxP866m/pVsU2qbE2EaM8 QuiBqfOD79u8MUBqYMk5gkYEsLcVEHyOREJ9KiMEKq/jeuPlFYAoyUi06A9GnEglYevg 7IVlp+qEo4sh57x2wyAAsepKPnssQMPalkYnTtjlMY0eZE+2QFBFIwrKjfQLMcjtmpA0 KnDgy9K7E19WEjooIFbwxmhtYy9Ib/tZpZ1fMdJNxKm5FZUDgyDWzi31tCg35MImJp47 Vk7fjAXghl7W+T3MiW+ytYWgWFMOf/9+aFMaqn0cbyF84PYiJkgiRBkB1F0SV64jm7QB fQ== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Mj7JzmJdUumY7xvYA2re5XJnaQMbC0CLqeRXFx7PnIPoBLFhFKGh60zUqFfXBUz9ZQd4++ZT8jN0PPBwC6LcYVw/j3Mpsx5lZVh65GT6oKNLPpPpTHpPalUShe0Lao4x63IL0Bj1Mfmsm9hv/h0XSvQkhLNeD+JIQNYtiTs7Mgl0sZfa7XLSfkUhQ974djcJKyBP2K/qjOk0byjEMuL4Q6h3MS8qK3O12KrSbV+JTxld3SYvq3G533RNzw76XLAabn+uYvuv4oduSkJeoXivT2j02mCsoe7OLAntmDz5sy6YBV4AIR/IbPiyQ8XgWwEYVeuuxF91ZT0BLV7IPsMY1w== 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=6HWeoVpOMG9q1+I4TbjLKgFJbW2Ar0pkOMatkPjkfsU=; b=Zq0NyqrByUYer0Op6g5r31pwMj0w2WuF1oc3aL/Yu2OiHIvOsfeSIP3VPSDojkZlZ9nZO8huar2lsA1qApGpCGnRVFmpo0RJXB3s1p6G8HhD5qzzQMszT5CjN/S4hxZAQPvXNGHiNGxqNVIFao5PoLeBmygC07wjOWc8Bh0DUdIqDJl+HpBq9ewgGNqjjbDBQ3czW1slRpWhYR1/3NgaaVUhckihH7C5Ae6ihl3RGhCT18AT6aqmWfEHE+kpIsrymiCPgMiO31kVXgqYCiQy1Yl74l9Uqpt/TO2CmSdxJvQxgxLzYMVKjBZuUeuwGxd2B7GerZ0+ct36Rs92+h0O6w== 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: Christian Schoenebeck , Greg Kurz , qemu-devel@nongnu.org Cc: Guohuai Shi Subject: [PATCH v5 10/16] hw/9pfs: Update v9fs_set_fd_limit() for Windows Date: Mon, 20 Feb 2023 18:08:09 +0800 Message-Id: <20230220100815.1624266-11-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230220100815.1624266-1-bin.meng@windriver.com> References: <20230220100815.1624266-1-bin.meng@windriver.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SJ0PR03CA0220.namprd03.prod.outlook.com (2603:10b6:a03:39f::15) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|IA0PR11MB7912:EE_ X-MS-Office365-Filtering-Correlation-Id: b4dfcb4e-b6b5-4fdd-f070-08db132a75dd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TGhNY7aHIMPlSyM5wFjwh8Iq7PXSuPtlHNY5yEaFq5cOnnz2MXYCnYzeYS0pjbc+IyUQ6ZsYlwtFRyQZ/mbPAoLNv/k8y5GfPbFLtTUKVo3bk2pY3Jp8eXmUeBJk+G/j1ER2vkyjFhTvWhoHdteukMRCvQ3gOFUTDcklxAjLSNhQY068WITAVi8ToB9cg9YzXb063BgpYqctPZbz3BLZ8rm1aP9qW5373aqUki+9JPqmokg9Y1BTtacKgfJ6ZWm5LAl1w3UI5VmfdTdsRRwBPkMoLI8Mg6wxyDsiMLygUr0kqQVfvIWlHQAvNOvLnTohUZRvlf8sdd06OpqEtpKivFs9mNVO5ti2F+pyKBG/SVpjLeyYzqRKGLvMDvHkEvGX8j51dLtsUT13j2aAzbW+KtO9b1fAtgc5l+T48/+Gqf8pgrs7LBqt+kpN+5bUy0st8BDtCV0gQl+hGV23j0qZ/Oa1uqJC/wvHfRonwdo1NvGf9+QcZaT3aRy+5i7oMZRz7jOiMxUkMkzNY3xXZMV/Chh6gbnpd376zgSlMznCbe0WGg4H34oO1XqpJZfaSH6cvX5fbJ+ZXW/ooAs+LLpU6SrvFEcrzEmQsb25Jinip3jwyPCyVK76Co9Lg1trrXF0IGN5aV2kEQdPDth0JicF8dn9hS3FQ4rBgwjCv3lmGsDSxuEB9aNnG/afRLWL0E+FDdJu9hINag6U6NOBTIJwLw== 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)(346002)(376002)(396003)(39850400004)(366004)(136003)(451199018)(8936002)(83380400001)(5660300002)(41300700001)(86362001)(44832011)(2906002)(4326008)(52116002)(6486002)(6666004)(186003)(26005)(6512007)(1076003)(107886003)(66556008)(8676002)(66946007)(66476007)(316002)(478600001)(2616005)(110136005)(38350700002)(36756003)(38100700002)(6506007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?URH4uKLieMCigidfCAgmsxJCqSnF5Zi5IiNO/Q7OvZPSL0V/1gMRhLH97qgy?= =?us-ascii?Q?Mvi0/J7GgWttWjBWr28OgP7k6Y8bFmffgJw/TTGjvk6FVGwnXHXLtoHn0V3s?= =?us-ascii?Q?aLuWjSeXcja4tdkzrscB6DHjgzCtwAoXnmcBEhQL8eAyQKAIpfmHWHCslCoJ?= =?us-ascii?Q?c9cIN6ww8OYlyzLB5/ujsjs7hZfb/SIhhq+bW9fegtvX96HZeMn8x2kRGBMz?= =?us-ascii?Q?tg16tX8yFxVXPsXdhfhAVHOClfV7JUZRmdU9KA9mOw4cZKeI7CNvNPGSfxyz?= =?us-ascii?Q?hFWMZ8mK8aNAV2mRXsI8SwerJ0LF6KHJtH4isgkWlGW6Wus7OV7nyBqveXFy?= =?us-ascii?Q?dwuT7+/GGTnU1U8XGekcTjB8yC9bpRjBPE6jcWg85Re2L0WEdfHxjVokdtpS?= =?us-ascii?Q?hZ4Fv6D6FhUsaXdk1GLA2GcPfVIi5b/9Y5/TVv1aAEgPr4knvlVnk5KjhEt2?= =?us-ascii?Q?57FCoGns1T4vPJ4Gi3q6Yh9xtQW27ArxDmr6haKSpVdQd4/s9V7swZ9EtrLh?= =?us-ascii?Q?RP5VdCYkIElDfgPBeLJmMZiuu9zpP3s7J+YZ+QSeJDuwvK6jC5HJfQTTyqD5?= =?us-ascii?Q?CEokmnhNnBJ4Ypwd9pYQHlYjvj5BdI5up0ZGVzPJxZ9tg9olgZOY4JKcjHlL?= =?us-ascii?Q?ryOPHUEGxDKBj0rLDpgNR/Tzad3meVP7ykHwMQiAbl9lW+GRMTGo+0SqhAPG?= =?us-ascii?Q?TzJr7PcC6XT0M/TBthpL/Sx6zVSgwOKDc7+0yYQokN9/Q4nyRdUMEyjTV7Ne?= =?us-ascii?Q?DDdm5TL6wkAGZ71al0WiRQSlR3c45QpBxo73VSpe4cZirToOXZ7iwCetDlAu?= =?us-ascii?Q?neQG9sdc+s/6P9Z0DBUXt71IioNeUxhak0jUFlieNaLdvUyLnwL36Pb38NHd?= =?us-ascii?Q?o/uTSPZEbfRZ0r6RwRvN+mqQqXnTXrhzsUYtaE133OcWW5bHrJqYKyT94Uwu?= =?us-ascii?Q?FQSmFJPjsW6bTnQ5aTQ/viFE/kpbisV697UXWiWfBV3rtJj6zO8bvB7sssVz?= =?us-ascii?Q?FoZfFp7uB4070OblJX5KkmEBTpzQLrYwiE0EnSu73dtCdAlV0lBrmLwpBZ1j?= =?us-ascii?Q?9jZPcfsXAC2iRNElki0r5JPWCiDZiNymXULEQihrlkc1hm1gMpSsAFglJuvn?= =?us-ascii?Q?0/M2d37+NxLz/CivChvc/znhj32Gm40/l0szswFCdmxoSIu+nVlWV5XO5dGu?= =?us-ascii?Q?GnNla3bHeBaPuFDuwlGwAQ6CrWRKmzIcFS98zP8kyARKPD4gJFd1ciHRdSAl?= =?us-ascii?Q?LxFk5IXh/Rqjus3nDKX1j5LxItD9sh3TE5o8Q84mgfW+OchFZkS0ux38EOaA?= =?us-ascii?Q?4HcK3gcv9+BQVb+WIlPd4nJATMUp+Zc7mIyHFPpB0VrWVegBqgGJN8nq00tn?= =?us-ascii?Q?EnGuC0REVrjo6EQdu9CwkerJIcFdJlYj5YfHHGLLRhbSWkcBp6iTjejRYglK?= =?us-ascii?Q?eyEWooeh25SOtYO+GyZOrP7V4B2XIS6Lt5bkDyWa5hg7KkoZS9x/IT7DiIsQ?= =?us-ascii?Q?AxwKIdNVx/ICYlizhBURL2z+VOtEXopSh9Ssd6sWo4f05NvGzH0EsOdTwx/l?= =?us-ascii?Q?WAuHEv0atzdur/t86ouSCC2IXJZJKymyQVn6mHiFkMYMOp+kQazqD8Fzn8SB?= =?us-ascii?Q?VA=3D=3D?= X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: b4dfcb4e-b6b5-4fdd-f070-08db132a75dd X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2023 10:08:49.2903 (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: U8sqMlIfLKG+jPvfOPrR30lziMz4DoSE4+EvN2ki0G1dU3kmqvPh+eOoS2Z0UtUKu7b3/OQRuxlSUhZ6nAeZUQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR11MB7912 X-Proofpoint-ORIG-GUID: ySZiCw_Nue8Jlf-PX3JfQT1QEzBSI-aP X-Proofpoint-GUID: ySZiCw_Nue8Jlf-PX3JfQT1QEzBSI-aP X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-20_08,2023-02-17_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 lowpriorityscore=0 phishscore=0 adultscore=0 suspectscore=0 bulkscore=0 mlxlogscore=999 spamscore=0 priorityscore=1501 malwarescore=0 mlxscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302200091 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=1415163841=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: 1676887778895100005 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 768f20f2ac..6b2977f637 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -4394,11 +4394,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 May 2 06:33:10 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=1676887791; cv=pass; d=zohomail.com; s=zohoarc; b=MTDPArMOL16E/PbojFxNxiPYAoV3EjanwG7WVTPOhPHw6/fSH68IQSi1VqUmSXmouvFezE3tdL4/jJ4YxIl5jKU96RFtBjXlL42DJ8hgGTaYr1Ni0Sw4x/sN0QGd2nPnV+ZVVcJul0+nZQOW4sqPr6R0GfZ3o1+g+aR+QVvVN0Y= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676887791; 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=TpOk1gRZcRFoReagUdIr/nT6Q/9OwdobJNDa+DuEUVapHjqSF8tx6l2pJQBShIaHArV0B4jcBJZfbTDkwbfwkYIuTBAfqCN4bAIeWSqt/LScIcE1HiKtnwK2wXieBMFpRt/AXbPN8Yp9FAibXH6GbCiS/vZUkke3S2cXw8qBScQ= 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 1676887790991199.60098798119395; Mon, 20 Feb 2023 02:09:50 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pU36c-0008Af-PU; Mon, 20 Feb 2023 05:09:10 -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 1pU36a-00089M-TJ for qemu-devel@nongnu.org; Mon, 20 Feb 2023 05:09:08 -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 1pU36X-00009T-PJ for qemu-devel@nongnu.org; Mon, 20 Feb 2023 05:09:08 -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 31K9f823020143; Mon, 20 Feb 2023 02:08:54 -0800 Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2170.outbound.protection.outlook.com [104.47.59.170]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3nty2psac0-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Feb 2023 02:08:53 -0800 Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by IA0PR11MB7912.namprd11.prod.outlook.com (2603:10b6:208:3dd::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.20; Mon, 20 Feb 2023 10:08: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%4]) with mapi id 15.20.6111.019; Mon, 20 Feb 2023 10:08: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=iDJXqj4XOxb/nnwKqkF3Hh2hAAii9wCHHUvqDsYvMv8=; b=Mug4TykZWyiMfhGvHrcxIzpeGR+sfm1YWlofTjtXgBU8ZNA3lgPO39PWW4s/2EcA6BEq lxaSvrsPsfGZZvn171BiLJeap54mLUldjwEdNf/10duuRVDG2tUqmKDTcUiy3JLcFHLF jHGlGlmXNFzPgISgrkU6lMLNMT3jtIxsMl5gA1t3ZZ8GItrDlMwpB7sf77Zp1NA6ZXuy 76jBb7zvm2nAgf+lF8FWu8LFQs80Yzmn0gwzlI4sQdSuvYYloJ86cFx37cqig+svjsSJ U3V2CmRgp+1TtqMIkpdx5SBPNzz853XlMq6Jm79HGJrkvshz6Kqnu+tKl3P/yCdmOcjV aA== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V+02+tTH+bmzZ2BRlnYDjZVTfHWfQKb+5geWBhLO5bvZDf5Em3GbUnpoKuGl5790ypz1nXPCQvKMbtTdjalA3eSaJHPGKUb22rQ5KXG4TL6LMvJ0lkMnKnuBaisJSAQF2SgBbL7pjxa7gszEIROGlXbQBA/CN6/KHXxNZnZLO4vsUtWXcXiZHVcxM/cv1ew+yIEvQLwRJe9hK2uDYnjKMra0OwIft71fqup1oFQlCqSLtWPGYJr8+HyacW9YKm3IATF0xELwJgXXioHmqGV8Vb4aGEOaYPoKsLFiXtdRGHwze25Og/PV2v+UXoK/VkMGfiIjhA/3rI/7bxdo62GkXw== 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=ARbJHEzs4rW4g+ProQQqZToprxJy4tR5Rg2cHoAomH83m+ZLtX84vGudMHeQ7z+c4rGnb+Yx53LqBZpLZAM1hXoQepQOXVLD/6mxVGPJAkrJ7sjq8pbLUj0BypNMHJHch8dXYHp9KH/xXGeq+oPAchueENRzp9YxxkhDLwbPkAiC90jpPKPWLquR3VvK3s2ElBk6yITp2MVW4OEjtKETsEqUOuXGXXieyEjAGWpSQ/+JiR4nlczlUz3bM/sId4ntNJtli43rLCwMHDONQWWdaA3y7MUvhvhgb1e1+lzfrLBEFisI8GDfTzs79qm3YSa5oGZr5Zx9J/TZW+H/lC6ntA== 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: Christian Schoenebeck , Greg Kurz , qemu-devel@nongnu.org Cc: Guohuai Shi Subject: [PATCH v5 11/16] hw/9pfs: Add Linux error number definition Date: Mon, 20 Feb 2023 18:08:10 +0800 Message-Id: <20230220100815.1624266-12-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230220100815.1624266-1-bin.meng@windriver.com> References: <20230220100815.1624266-1-bin.meng@windriver.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SJ0PR03CA0220.namprd03.prod.outlook.com (2603:10b6:a03:39f::15) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|IA0PR11MB7912:EE_ X-MS-Office365-Filtering-Correlation-Id: 99012594-2b19-4e1f-9e6d-08db132a76f9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0ztzR8sKgA0w0qR0bjVy8nVDafuc1Y3H+NxB9QqknnzxmL0mXJG4VbY1lCEN9qVDPyLP7Ky7jgvvON4lk5BSjskBTGM42fyT+jptxwqK/36p7BDf6Tgff9EENzoCbmAdNwXdQtFbnznsLfcUxJatgTSjpLEnFpvADKeCDlsirxS4AODSG/IZIbPKq7PUX7VU/yFY9kHuhEhy5qsL2TJb5alt5MExGCZeTl+ix2J5ReAP7sRyfNKrYisvWOVw1YsQquM9Pbdef/pfvb17nTnsudRZ3X38QD8gxQbQj+q+JJOrbBGFDiMT98GwZFnuqANoimBKwauWzopbbf9S8b41hms8X2GNmx4oYZmT0otg1xZkybGGAREXfoQcXWeHXO7n4ghQV5yUhEtUl1sMLGUN1WkvqIPQOtEZNEsYneOEuZOKneesLFIj/XxLhcWPq8qCNOAEDsTv1jsq+9Iw+btNZVX9yk73dXL13XenqPApiPKtDODR0QaxCa1FlN5CJ9mW0RINoMzgEfZVcga3VeqNm3TG1Beh1L2bSryir8MBnOiGkE8S35CYqrn9TuEbMefgHftAlkG6YW9RMINHIkVFS8WnJB3HsLANNDD2Cy9r/ZOUvaPO8NDwjz0GiGmfKqky2CvHDhbNjEy1yyLkWepa39srMdDX5Gr5NXPpTxTEhccP6ozvVb568adQpI2I14QE 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)(346002)(376002)(396003)(39850400004)(366004)(136003)(451199018)(8936002)(83380400001)(5660300002)(41300700001)(86362001)(44832011)(2906002)(4326008)(52116002)(6486002)(6666004)(186003)(26005)(6512007)(1076003)(107886003)(66556008)(8676002)(66946007)(66476007)(316002)(478600001)(2616005)(110136005)(38350700002)(36756003)(38100700002)(6506007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?iUS8LsvmILp2XaFwe/N392a1FKtlAClRVHQ8xszxbaJohTayUGeFs+7t8jum?= =?us-ascii?Q?QEcnU21Rufecy4A8b+VHHV8b423NjesrcPKxUB0zAX15TzGhddv2qzoJJFLn?= =?us-ascii?Q?VEkhnTGC3B7hpO4BOXer9OEwcWEfZ6PyaxNiowTUwnHA4bdn4BMRKsvvqfhX?= =?us-ascii?Q?/i1iuVx64qoY8anFy9R/YKKPzkdPEZuSrIgs5p/kmH2NAoWbrKDU2KFSR4m1?= =?us-ascii?Q?mB0r8Rz+AamgWkQcw46hPlp6GlDkGl/Th0b1Pqk9eOEmitdsIIiUrmc97q8M?= =?us-ascii?Q?kDHJxylWFzakRvejTjtluh1Kf/+yD3kylWKxlXSTmVB6FopHos2Bek/2xVkn?= =?us-ascii?Q?SL1StlncDbqkd2s1NrGJWOBK/v2tZ+meW2GTKJxubSfy8i9fXQrNgMzUVmHI?= =?us-ascii?Q?cl4HoZ8sAueudsW8iYgpnwxIqgfUIiA92Ci7GMWRpGolNMZ4F3rWsVTPJXXf?= =?us-ascii?Q?VHq/07JqRwgiXk/NpMUsw2OwIcM1syP8rLepQizdQjsKaWwmQ+LH14mOfSnU?= =?us-ascii?Q?XXtWu5BKxvH32hCTLmwPlbuDmVPlCiRQrRG0uaL8lfU1MZnMXE/V30fZaU2k?= =?us-ascii?Q?OttZ9BSj/k8kemC9yxJM9g7/FaYETHPzRJovtQSUUjYzSXYQQ7S+A71paN73?= =?us-ascii?Q?DDgZpgjLiq6mhrz3jiG88oowvsHfDx8xIwwwnWAx4Cl0MrZu0yCtoEUMjMWc?= =?us-ascii?Q?96jJPDm8Jw2ccP5iEQYF5jfj7D1HqBpyO+5JbpFUWmQwx/BMG5HM+ufkZ0Y5?= =?us-ascii?Q?TuO1H9SsebL0qEJqd8C3J2eAZ2sOvJuor+fI//EQ9tIzDS8pgE9biqrp5atp?= =?us-ascii?Q?1Dry8O2TkoTQfHnzT+nHmoKbIqNyRoyW8y6bCa8BkCA6fsNFqPzrERVLHf/j?= =?us-ascii?Q?CxF28gEs4wRAfmmPpbc3Z9VnZLY7W0LDs82lC3U45AWuLJOztmD2eh+P1cMC?= =?us-ascii?Q?JSazBTJwBkfHXs7CpNhZkv/90qncKa7UGPHCKxeMXLRezmspN49k1btM86D9?= =?us-ascii?Q?8Ywe0sflmBQccGPxglr8nRDE+dWpT8xMhh8Iypk2vUlCRLtfZPMG/fGaLBws?= =?us-ascii?Q?4CZjPU76r4uKfj2CUVMCtzMlRuDsBsBIO3iRWsfvoVLT6O7f42OfD+PU5Dt0?= =?us-ascii?Q?bsTs6Mg7+zJH5TnC/sx3k0RGKu/aCBnGTRGptt/HS9PACOPdpB4I4PrURuFv?= =?us-ascii?Q?TDwcMQpnk2r8Hpq5ODgitJssuxjmccfCD0oLb2adJuDD3KtMscRWcRTcL0aW?= =?us-ascii?Q?ozQf7uOwB09zSvEGiWvyN3fl8L8i2SC5hKRK8OQjQxCBBwKNQCMulz00efO5?= =?us-ascii?Q?rcl37aVnfpqDntiJ+kqXlsuS3phWbTHgR/2S62Wa3El1RdDLRbqRZGWZ+r0R?= =?us-ascii?Q?LAttxZlFOUwjpy/sGMgd+vKAo6rw0uKm72j3jyCHBRYa61k6JjrqfRxJIwTy?= =?us-ascii?Q?gdqwd/QByoPPdlf6BmwDK0/4hYN5482uetpHzptn3yOf5ZXVdD4ZaMWJAqbi?= =?us-ascii?Q?g6Fw32+Jq0JfYOxulJ6TWJ8sAUYEfYtuyTaIZVkuY+lkWOsrF5PrV+Auargs?= =?us-ascii?Q?Ne6a5D743jnGID/G85HKpKPRW65leFdVq9OraicWCwoPJYTYGPuNB+lmBxeJ?= =?us-ascii?Q?Yw=3D=3D?= X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 99012594-2b19-4e1f-9e6d-08db132a76f9 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2023 10:08:51.1507 (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: vLwHcSIIcESCTHqVlJBWq1ImhoenQju2BRhyzI5NOp63mFakcCMiCTSTfuOemehhlEdoLD34r8irBrdKSJKAlg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR11MB7912 X-Proofpoint-ORIG-GUID: DGQB9zG24XLmjTv-I6Wwu6ADfWGanSf- X-Proofpoint-GUID: DGQB9zG24XLmjTv-I6Wwu6ADfWGanSf- X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-20_08,2023-02-17_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 lowpriorityscore=0 phishscore=0 adultscore=0 suspectscore=0 bulkscore=0 mlxlogscore=999 spamscore=0 priorityscore=1501 malwarescore=0 mlxscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302200091 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=1415163841=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: 1676887792957100003 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 May 2 06:33:10 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=1676888146; cv=pass; d=zohomail.com; s=zohoarc; b=SH7n5Q5/9cvX3KB9HeU8xQJIdSUWHv0vy2K9kuIQ9t0Fi94/OeofoeeDeriRv+TXpGntg42GrLY8Lgz8i2tmEhrq/pUg9+I/F1P34aCe6qF7ptIFza7QsPNJ3bVonF9WY0yM8rV5yt5JUi4MrNYrBeyPHjk0Zr8PRZTrR51kshs= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676888146; 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=So0SFwigFYk170X6oGM1UB8N6w8+P/OpQzhTtPe8IK7AGREgPPKd69ZkOTYWZkWC89jzs5cHSvLzefuMZGWPZtiKyJpEzXvOfrnrvZYHYnUwpBIqqZt/DH/S+JmQfrk4IjUz3M1HtSDYR0MpvPIY/e8L+FGnkuMkVqMh8AzhljE= 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 1676888146848951.1163145201236; Mon, 20 Feb 2023 02:15:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pU36d-0008Ar-EJ; Mon, 20 Feb 2023 05:09:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pU36b-00089O-1j for qemu-devel@nongnu.org; Mon, 20 Feb 2023 05:09:09 -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 1pU36Z-00009k-6i for qemu-devel@nongnu.org; Mon, 20 Feb 2023 05:09:08 -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 31K9f824020143; Mon, 20 Feb 2023 02:08:54 -0800 Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2170.outbound.protection.outlook.com [104.47.59.170]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3nty2psac0-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Feb 2023 02:08:54 -0800 Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by IA0PR11MB7912.namprd11.prod.outlook.com (2603:10b6:208:3dd::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.20; Mon, 20 Feb 2023 10:08:53 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9%4]) with mapi id 15.20.6111.019; Mon, 20 Feb 2023 10:08:53 +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=ZTLyq9noDsQ4GyO/7Dr8AkkAnytsAAd2xWWfdLXmD/o8FOHooPOUaf4pKXaqc6z6Lokj Q3iUEr3Lr7vGbT4X2egFoL5qTMZxvAOovwuw4EVj7EiduSD9BO+oHzN1SPzfGNOMh+ZZ NOvXk0BmGnC6/iOqV1fPaqai8T5Fczprr+slOlSJVcGbcw6twAIpno2V8Ujl81UhxrNU /SmVQOq2eB9+HdgeqhixwlVI0NKrsrlXdtcV9naAy0Q6Egi03Itxclcinxhayl+Rfl96 1MKqPvlY5HyMPdQV4AQ7dafUf7oLA4hz22LyleUYJwgvPWyEOy/W2fz2u3jrIVf/mBgO ZA== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=glckciW1n/KL5dBKFAXilh9OvyhOlWKN0DTa2qXop0aWwbOnRFJX9vb7ZF54ybsOXVRsquN7XAJj81EdzVj1kJIc1/WvT3zTQdOmflbVUf1Hx0joZz1VKRSGdsIY46YPVkIcnP0KiDdoscnl7HbNenYj4oolrP++WJTU+e62fPPQj64aZNuUyNYgJwN5BKRaU5Pc2eocgP2bX8FLh9ywuuwXGS7Z3NaZDldZaAuZ2yxbsIzlSFTiSItKGkV/DyTbFIlUhtW1kd1qWuUj2pA3tqI47h6GvXnS3sR3XnbhbdepzCJ879LaQAdIZWZjwPa4NmxzRSOdeiOzbM3MZDCPVQ== 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=X2JvKAdZCfXrDjh48pZYaYBADk2xfyZdfWF2TAONzNDR72ZAHKMZqlFvbDF76gynS7zbT25gdZ2xy4XsWKYE578DR30Rk1GMBPIUeGHfk2axkXUF6lS1ciElEZ2DNIZUBb3uIJdCInDUyUF8hSYR4QJPRmR2F2ssl+xszsoawMe08Rv5+oabToebpe18u2WSXVGA+WTqYzGu0ikA6ASxBHPC9IJ+ihrCJco9UlzZ+DjVuEMhuU/VFK8rek/SWGAC7qsiF6MAwpEPMkko9O+7XvAFzfA2lCdotXU+Psec1RCAMCGcUPPM+zQjf/cR6XsuLnvW5bXuzqgSU6ihsB5SOg== 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: Christian Schoenebeck , Greg Kurz , qemu-devel@nongnu.org Cc: Guohuai Shi Subject: [PATCH v5 12/16] hw/9pfs: Translate Windows errno to Linux value Date: Mon, 20 Feb 2023 18:08:11 +0800 Message-Id: <20230220100815.1624266-13-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230220100815.1624266-1-bin.meng@windriver.com> References: <20230220100815.1624266-1-bin.meng@windriver.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SJ0PR03CA0220.namprd03.prod.outlook.com (2603:10b6:a03:39f::15) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|IA0PR11MB7912:EE_ X-MS-Office365-Filtering-Correlation-Id: b4daa615-844d-4f07-7e16-08db132a7815 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VD56L3e6vwMAQvU/bOhZSOEXrAR5UteoMRLEqBnfwFGRymPA6NTDyPEjCWbwRE7Ub4KimjiDi8oiXqiB53542LP60a1yreI5Bzo/Bce2Ogsi6tj8KifsHF+wViTuIitQPlIyhWzAJjiYwQxW0CoXfkgWYvy7NWUhw67MjtlmVlsWOC2qVzji/RmmfDXBsGYYY3lfrZcBm/AHBf3aQeebwBmadjsO10oRqGbMkhH/CO5osHVUwi3P351KrXi7wRphbKm2YkQO5xdO/Aw6E02HOsFYezNojeOUKbfKOf3eudlMQxhrMd17gb3zew+EbYDO2lKeIsyPBtEru5uY/DgLVEn5BLInYZzYhVU58dXFI9T5+DoSFI/R1A2Ktzx0Onw896jDVxs7yGftAUkypt6Rl4EpVvpGQIarUo+3fM9mNX/3X/4xc4jYXQ6gbpLjSu4wzPpE3jqAMaU318SVSlqOHpVSQwXbmajbjuxMT/ZFQ6O0lFkMu4gmhctWPvmjcOLcvHo9MERShaNZeIwmcO056IqQXBmUCegxL38h0M7m6ORxXczphzVx/QvB9G9VLdKbAnAycrBNPpbJRqsE6OQt3fgZbR6mRkzctq4hhQhOnHwtni6OYw4+CK+MDrykWMqWCpHbasaiskTydYsA5cdNrL90BPgOFVMbInozUpobt69yMeDQrt6JPTuM6zw9hOS5ORU85seXrrtuPEM5WBj7dQ== 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)(346002)(376002)(396003)(39850400004)(366004)(136003)(451199018)(8936002)(83380400001)(5660300002)(41300700001)(86362001)(44832011)(2906002)(4326008)(52116002)(6486002)(6666004)(186003)(26005)(6512007)(1076003)(107886003)(66556008)(8676002)(66946007)(66476007)(316002)(478600001)(2616005)(110136005)(38350700002)(36756003)(38100700002)(6506007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?TGEvX8HophDEkN/ZqXsKTzZBw9VmtzjhBxGWAukpnPhjZHGv0Yu5mob4slA8?= =?us-ascii?Q?laVpnFRJLvlLxUaBo/hxHuoJRVJ0N7oOLvXVbX/2VQ1UNFVlH8780woJUbi8?= =?us-ascii?Q?0DR4qKEk0cs3c+8fuZUFNtT2LYfQ3TeDvndap4uMoTv4Fm4aGiGNaXfoavsA?= =?us-ascii?Q?ie+99gN6qX84QpDO88clRrw1efZdlp33lIQOoo23iXjFOwmix6UUgFnzhLAg?= =?us-ascii?Q?n+RVFp5Nq7ujoS9EvZ5Rh2KiL4FKdQns6HCFDe3sXkj4nhvwlq1D4XcEZV7X?= =?us-ascii?Q?0FaZHZ8Xd4DQRQoZuu0fmDwpFciYKs8y5a0tgrjDnfCHcykiQbLGk9Dbh9Xm?= =?us-ascii?Q?P8Vo+JyVUJ2UL/FQyjzDysTX4PaCFUgQBz7JqpDNavoXOEWshZIAEKQnYXmi?= =?us-ascii?Q?Ek3N06Ib9wL/+SVKrt4LSNH5gnP8w0SxJBuxbHNybgGJ7CXpE9gks9jXq5OW?= =?us-ascii?Q?uj/EqVCslBcTF5sKlf55j0B8pKMj47OfljiDOk2KOsbolmxugqjiQxGwBR2K?= =?us-ascii?Q?zZdu1lyL54huZCfKjzBHG0noUgLZqMJ/FXNGUtvGwDp9OiJzbixPTklcUAYK?= =?us-ascii?Q?f2JhbvNsER4/SFxGBgOzWItPZFkHLg4egrnhnciSb2RZB3TKEohChAxjfdoS?= =?us-ascii?Q?nznxGX9gT3j3CwDKKyW95lY68r6P6hvzmGVp4KFZiSUi5TtL1RtHNMjmzMCC?= =?us-ascii?Q?+fsoesIlgLiTYmfJhDOqA6+kwzzO7pM/b3N2qEb8q0hGtHdDZqv8Nnaro78T?= =?us-ascii?Q?3FGTAcJSZjtDASl3HKW2usIp18WbE+bIXx6umqBSeDdileOsHDQ6ykXX+K3T?= =?us-ascii?Q?sG8vERLHeAgkVdTcjGS1PWLL/9GM2DVCZIgK2GyiwSwFhZ/PnLTlDwQwXXxJ?= =?us-ascii?Q?X/iCuevFpM2Wt7H0De6EvgxlOpFvIi/e1w3WMRWJoAGOl70h7SwrATKMAzuy?= =?us-ascii?Q?LxXFOq0JfXHjr5FI7InUs8UvNECTJRfIydQTJJopWCRPXn1/AAL4sVF4jnd2?= =?us-ascii?Q?pkgh3+SYcFhM5/wgARx36i1H2RK3tMkztjGZr7ovi1mF5epLZv3x/ot6EVcF?= =?us-ascii?Q?rHj3Da9lFYjR9ZqiUblMXugS91FMfl0sNadHLwNPhfZnWqIQpiS6dsQkGg90?= =?us-ascii?Q?93ATLZTe5C5FAo+ElCBdBQvpta8UMJcnXQ3qzoMD9QwrLu99fpQa6IeidPV+?= =?us-ascii?Q?lbh5Aea0xnZmSpNDX0nES547ab/YL03tW/agwitLuOgPyDraeEUxR5jNwdFT?= =?us-ascii?Q?GLJHzNEI/lu3cWD011JA732yh4JmiqoipXxJ4eB8nQxZGEwc8AoVHWh3NIPc?= =?us-ascii?Q?YX8VQaXyIr+X2nISLGGSxXhrjFNe6vGOfhyaNLq/Jg9hlsZfykWGGEBG3Md5?= =?us-ascii?Q?m3OWoVDNlmgSjjK7YFH9Q86/KqEq88k3TsBaYQSnQ3pFUCMHEMWJaSQRm5gI?= =?us-ascii?Q?Mzlq/HsiplowIs3ZDzakktnFq8iPTXCSZquQuYKV+Pzoa6re31mzCSQNa6t1?= =?us-ascii?Q?vrwYp+qirqbKctBRM/6fuqdTn5Zaym/KlVX99UU24ZJDDSs/FlRLWpX549n1?= =?us-ascii?Q?eZZPNYuf9Ud0RDsDXKT/ED5Kk5u6RueN/OCXa1SrS3tN5l+JxxKbFO+hMx5F?= =?us-ascii?Q?jw=3D=3D?= X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: b4daa615-844d-4f07-7e16-08db132a7815 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2023 10:08:53.0109 (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: jhkzLuK10XLYMl1VYoNKSiZlSgzoGWWmXUMIaKg1s4AljZzXixIQ5eF1LAS64Q9h06MQbOp+EHHxI0OLyMCjwg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR11MB7912 X-Proofpoint-ORIG-GUID: DQbSLRGL_i1In3zJTxj9p8vkwVcCB1eP X-Proofpoint-GUID: DQbSLRGL_i1In3zJTxj9p8vkwVcCB1eP X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-20_08,2023-02-17_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 lowpriorityscore=0 phishscore=0 adultscore=0 suspectscore=0 bulkscore=0 mlxlogscore=767 spamscore=0 priorityscore=1501 malwarescore=0 mlxscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302200091 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=1415163841=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: 1676888147260100001 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 May 2 06:33:10 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=1676888026; cv=pass; d=zohomail.com; s=zohoarc; b=AebpO83Yh9Em8LrlbyWp5eNrMiyuY4mcg2IGs6hZNIY6wboxn6fIeBqkf6/LBTMT6BHKL9WgFTiLgW2LaD3z9yuXi1qnjaI7WQir8GztvnVHIbmP/9kvN3j8/vw2WDzAJdIGTsQQffCMcH7tgTeC+Wx1Yc5gGODfR+39LB6CTYc= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676888026; 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=COf/eBd2fpMG7mHXI3+8r+vbPVJdmnI55W7amX67ApCBIrR/G8SZ9+a9LAccRyG5UQ6oomwYtMNE7RlDJ9/Par5EBRa02WgVH2Wx6Y/2n262bpTlMrURbwzXm+xxH5S7ZQbPAPr0Nl1EhLJ/Rs7Sc2uXUtwMcjU6BTM5L8v/QuE= 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 1676888026206573.8959417708675; Mon, 20 Feb 2023 02:13:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pU36e-0008Ax-Dk; Mon, 20 Feb 2023 05:09:12 -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 1pU36c-0008AK-Mq for qemu-devel@nongnu.org; Mon, 20 Feb 2023 05:09:10 -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 1pU36a-0000AG-RK for qemu-devel@nongnu.org; Mon, 20 Feb 2023 05:09:10 -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 31K9CRZt026793; Mon, 20 Feb 2023 02:08:56 -0800 Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2173.outbound.protection.outlook.com [104.47.59.173]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3nty2psac2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Feb 2023 02:08:56 -0800 Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by IA0PR11MB7912.namprd11.prod.outlook.com (2603:10b6:208:3dd::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.20; Mon, 20 Feb 2023 10:08:55 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9%4]) with mapi id 15.20.6111.019; Mon, 20 Feb 2023 10:08:55 +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=GdnLObZMl/eJUJZOrZzu08grlEEnI4nVxfqKOLjKTgjEEW2MXgR1cktOMnaNH3gwUh/h 9K7jrMDdQk314VSh7bZmviXi6ogy6T5Nvwexc/1M69cqh2gn1vUymcP026eG5KbIZDFW Ngc36rtpi0WdPoyl33N6A9D0clLMlrPflrwjbJWGRVMRrz3dYA9ZfJXIzr/68mqUccBP SUGUpzxs/ljBPbqZp9Ky2IXGCGuuIJtyjl5HMtYndh3FxihKzU5Ui0ju43ZdpEmaOUow OkuG7jYR+gGFAISuU5ThX6kdO3scgECcJRhH/JBYoERqzk/OwfZrdzHk/HngmcIvf6vz +w== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Yz/3yfx7lwTUUGLfKbu6IsX9pdVLEsNtXBj5fR7zuiibcQJhLKG2da+9OZC8zzPpU+DmCTahpcLfloHN0uMUUjkcdRYjLnLesuOXc41HhikyZwkmXNB+Q05lPSUhY3dreGApbDJWHOa1iurkbJb4nxg9fMt0iBTgYoJSmPaiNLTg7RrpM3bf4Mm1jY+Q4y06cYu5WlInsjw5ztYlDW6y1FG2o3W7CXbmAkqO6DpPutuYZkHbaU+fxLFuXsBW7UyNuakczgAZua2np/wPHqACxqnakKHfO/QhxmgRFU6l/hR3wQNI1035LWeD5Xc1YXVOBhHnnotvO+0rkpvcV5lkCQ== 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=cA8XBd4mXWREhr00ictr2X0PF7NGQucQ9GrwAcs5B6rINM5Ko/ZrjfTB8IeE14tLIp4hXOF++ZdQxEQqL2kv24QMiqt1vYOlr1XwFmCpK8d1tK/PLOevwas2ce86+0qSuDHgh3KGDWqSZR263LCzLMGa/FCNgb+6hNDjW2IIt8CdLyoAUsdfgdwKQ2wFI8fhovIMD3wJiN1VAT/eInckjZ5/ubqjwcPfK5EsRpr5X+Urq2dMyRuFOttbMWxGMm9TNKhzCT5+nvYpUbFjbQ/EzGCUWcBW9513JWmSxWPxuEN+ZVv6mVU8JSQ6i9WBRUoXNYZFf1Ypebd/ncsJeJVmqw== 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: Christian Schoenebeck , Greg Kurz , qemu-devel@nongnu.org Cc: Guohuai Shi Subject: [PATCH v5 13/16] fsdev: Disable proxy fs driver on Windows Date: Mon, 20 Feb 2023 18:08:12 +0800 Message-Id: <20230220100815.1624266-14-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230220100815.1624266-1-bin.meng@windriver.com> References: <20230220100815.1624266-1-bin.meng@windriver.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SJ0PR03CA0220.namprd03.prod.outlook.com (2603:10b6:a03:39f::15) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|IA0PR11MB7912:EE_ X-MS-Office365-Filtering-Correlation-Id: 328fc7d3-cdbf-4451-2820-08db132a7938 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RsXwVo44tUVfSlm7qppJ9jF/zeCf4vlKCOk5UsEJj0+lFXYKJYt7PFjNE2DERyfwFKPxL7uKBgA9/hLWNiFqrAq1MDR+coROoNnXjwPc892YuneBpsigZnczJe88mqOrs8w4kHM3lXuDhS4epj5uLMQ5wkP//CjVwF63rY/vM4alYZhN7Lqrx+nsU0knq+QWByHplTFv+tD7DOINNSUFrqa5IjNlmSkXAkTIu069Ac751zYMdF166pL2yVM0+dzjTN49Y0Pfsu+AYWSJ7MjotXqSGAspvzJVXbGK6tooIwCdwGQoJGYbD+kDQC2uaH8sfZL6iVEPHsIeJjmb6w9u00KrmHNTzpUNXYxBDmZxBUXJCZkfUKaUeAV4FLOby8oPczQ30zu53rBpJoMYdso4v+vakMSz9mn84zyy2DlyBKK7nrRDPyOXrBqyvS6xhOqiAojwu1dIgOGzH4ODPwz63M5npsSSxpYU2HSaBqII6NPrbqPJwGdFHcDGQmJBWuydI202nLB2OI886BLILPw8JgOfADiMebZthQoc3WE1fFDdG6cQY9Ni37ffsdW/DlTzjmE7fsOAdj8ZSHKdz1VNSmXv+AVulX9AcdLuwJPvfWa1jksXiaAkLsCygoiS5PIPuoRaRo7q0PancohtOK84pLMmSpavli1T92IUyopGt0WInW+Z+OLf1HvM+SHcu0hzK7ggq0pJUzrbIA079cbzRg== 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)(346002)(376002)(396003)(39850400004)(366004)(136003)(451199018)(8936002)(4744005)(83380400001)(5660300002)(41300700001)(86362001)(44832011)(2906002)(4326008)(52116002)(6486002)(6666004)(186003)(26005)(6512007)(1076003)(107886003)(66556008)(8676002)(66946007)(66476007)(316002)(478600001)(2616005)(110136005)(38350700002)(36756003)(38100700002)(6506007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?FA2tdfpz0MjERVsVL9gjRYsevSSrJ8YgcDT8uhKA+E6w81uyBdaiGUxdnftz?= =?us-ascii?Q?4EpQzutHTsFYDKkjcddEUaGBIep4Hs9Tx8W0rkEgbu5IdfreVyKOpXkuGZCH?= =?us-ascii?Q?8AqzF4hxY0i0nrxfM9RZmeJsoEOV7bjali7s0FFgikP74T7pjUVoFlXW1b8J?= =?us-ascii?Q?PuwyArq4s0JpRGwZEnf+hLMZRhJ6YcHcJ4nn8NY5/rPuso/deI3vUnG9HUm7?= =?us-ascii?Q?/Kg8K78N8vytGhbUdrn4/dxnTRt5ZyBfpCTr2+djxUzGepzx5vl2q+3X7nRw?= =?us-ascii?Q?RrglAZfot0qb42rt3vV9VO/WfrtQlNPCm1d2fd5SsHrF/KlFACSKRMeHDcfF?= =?us-ascii?Q?Yy0b7GJTI7/FuvynnX8K4siCq//U3N40oZFfVlFWqxylt3wAl3drBJcRuh3l?= =?us-ascii?Q?59+tN+E/DDkqt6BfYzDplCCoTAf3uyXv9szyvMvK1XEpmrheVXi4zuX69Rx+?= =?us-ascii?Q?ujAaHKaPT+ki+qUPEsXuP6ORcoGzJaXOY4IGRlplVdeNLsAv5qrmkZzrYtRk?= =?us-ascii?Q?NrPz3GCbBCK1MfyveRJFt7Nn/TuxafytF67GDT3It0SOsHoRoAjlWMzhgmMD?= =?us-ascii?Q?dhku2/7IaBNrpj9SrLaLWR3XboeHrdXytpsZQ35WLvOdAj2Wb1LKL1OKGQ6H?= =?us-ascii?Q?bapyotPKK/zwzsKbI6B+EHvpVfsLB/FWH7vTN8NvC0MyCeDhEWGvJPC2emGw?= =?us-ascii?Q?3CXSlFiWuY30HLZrUu1xIPjwGOAocWuE+pyYZ0XbfbhxSGcGSD6ECMcJ6NVK?= =?us-ascii?Q?vO41xPFZdSWHdh1jBHIEFtCHiJW7UAqXxDn0WMNjZtrOjc6BQs0j2jAxBEWr?= =?us-ascii?Q?PQWVEHiPqPgUEtdfUOptwFfyMeMswehT7RKRYiXkjhlwD3QxI4Sfx5HKRHqs?= =?us-ascii?Q?1+/t9KXYT3jRBD8hlU8OFAYsz1HjfJHsdnyV6outXKaRJFApApxmiGtbGDut?= =?us-ascii?Q?yFpWMG+qK4ilAdNBQCd6Av/I3Gnvst1ktGHopI1bhZZ224YxMoZg39bD/v0n?= =?us-ascii?Q?q8G4I6VYY0c2V2e2RHt5nWQx4QFjRSJUlRd270grX9ut9Tb8A/Gyop3oQ4t6?= =?us-ascii?Q?WCGkg5HgisTqoOpK9Yys5IW13cNEZzKEi8cEdH6/JhSu/hZiPx8TJboH1o74?= =?us-ascii?Q?bCLJ08jmv/lrkCWhbw4KZBfdXTO0rlwSSHmFW4eG27Gx/0gtFPnYnMPCDacb?= =?us-ascii?Q?yjwNEVAEZZISbksVPt8NzJDia6C1zCaeNeQgDDU9mGvbNE45L1zudKBk4Pek?= =?us-ascii?Q?x5o+Th2LAwMaZF+tkDwdKea4z8XWTM8+NPUdoBRXAm5r0mhMzYJ6QGFKsJNt?= =?us-ascii?Q?Cw5J66EKt8LAvBZ+9FUldgouLyrBbVpNPueccyjEepZtamUb9tzBou3CQrQE?= =?us-ascii?Q?3g0A9GoPv/2we5SE24fCc7hGtSrvBL9f4z0EAuFQ0NiPaCEb4AWW80e9jY9c?= =?us-ascii?Q?FisyIJx+W2fyamA9Kl5QtcNKMk8c3gnqyWdz4B9BbJbTSJpapMc96ds57bCX?= =?us-ascii?Q?wwbsp/CAdv/ZvK7KyrGwJxHoBDd+ukz4/gKUDkRVf+XB5ZpiasDUso3hTVyd?= =?us-ascii?Q?j8bNaQeoglTWXHGIakOM3c2pGeOoNbpOS2ZZM2eR96z7YsDvOHLiJfqPvKCn?= =?us-ascii?Q?fw=3D=3D?= X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 328fc7d3-cdbf-4451-2820-08db132a7938 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2023 10:08:54.9302 (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: Cn/fQt9+m9VznM57HWooIvlkMq5WNnHpKvwhsbJaYqVEN7MYbeMxm+JJyfusloINPfz4wLBpj1V9kHTpMRTPvQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR11MB7912 X-Proofpoint-ORIG-GUID: ajvYor7aIrR-qKzATBKiAmP8FiwIcT3N X-Proofpoint-GUID: ajvYor7aIrR-qKzATBKiAmP8FiwIcT3N X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-20_08,2023-02-17_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 lowpriorityscore=0 phishscore=0 adultscore=0 suspectscore=0 bulkscore=0 mlxlogscore=788 spamscore=0 priorityscore=1501 malwarescore=0 mlxscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302200091 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=1415163841=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: 1676888026547100001 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 May 2 06:33:11 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=1676887815; cv=pass; d=zohomail.com; s=zohoarc; b=Vpm6HEwa2mjxLuub+sfNCqCQDDQjYXOJEo+FkPsPn4FPe5Xbg/bfR+HZ5FiwGfcGGX5wDIR0BHWLMUZniRFHaEGxbbf6NtiyyG2AbLJtrdyNjNPd+6YQKepN+tlNCBzrPssndjIFBeDHGWNtl9Y6n1T/Tf9lzLRR2Mmd5RWajW8= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676887815; 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=R1Pw5RPzjb5jgzlek9LzIi01R9q6oXgH3wFEAtKG1k0iptcwWywXxItcy8uLdhzXVvNFFQl44CMmEW4/IDAMzGjYOWTlHRgcTjevx2JEad+4QNVN7eyV3jcNEtVrQat/MnRozhBbCIMWdM4TvtsSW63WmGu/K+3t+VLlfVxbadg= 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 1676887815730379.35750259804547; Mon, 20 Feb 2023 02:10:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pU370-0008Os-Vm; Mon, 20 Feb 2023 05:09:35 -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 1pU36r-0008Ji-0b for qemu-devel@nongnu.org; Mon, 20 Feb 2023 05:09:25 -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 1pU36o-0000B0-J4 for qemu-devel@nongnu.org; Mon, 20 Feb 2023 05:09:24 -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 31K9hWqm004096; Mon, 20 Feb 2023 02:08:59 -0800 Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2045.outbound.protection.outlook.com [104.47.56.45]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3nttu6sfsd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Feb 2023 02:08:58 -0800 Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by IA0PR11MB7912.namprd11.prod.outlook.com (2603:10b6:208:3dd::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.20; Mon, 20 Feb 2023 10:08:57 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9%4]) with mapi id 15.20.6111.019; Mon, 20 Feb 2023 10:08:57 +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=I/gs9ywgGC4D5y9RcVVVz8YQqU6SbfSr9qCykkvXLGOqozbWjPQpxFPpsRS47F6r3pEo aY5rGbMrQkJqqZOls5pDB+GcK2XgLY+DgS57qKW9M61a9QrM7EDQGpvOjw+F+C0jT5GZ hh1eNNdDQyXIxiB9BbUcJp2UfVipx+XNlvlehPJoLIpvZLauuXvzCJ4qcphnpRAz6Kgr a8bhgcDrmju+ZjFSfWW4Hq+FkH6zuIyA+9v53OTzVZD53DabKMmAILPYVwqN1a/7k6Nb YzvygKfsV63Vl0b0Uufxhvp1HmLwq7G9r1DN+faGrWbbn+he4GJZH2QsgoNEdY2PJzMm DA== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cpcn58NkoUuYyE7gMCNSx5/JwWEd9gHfAtrTG66GDSC2ZihuWChDR6g7OEVX8/J8gqjUCHhDvzyQuHKxtM+lSHV6WgpVfman/yiYWiGpWQJ/DX17oopFA7wrfWEX9sgCT+iAzA83BPzcnOAZSsD/QM9Q75G2A+0n1Wgdb4wW6Wz9/z9kBs+1p/mZDVzVRMQbte1kFRjlrkzFGTpqVfbogwhv7x8eONC7ejmpWeAIxw+m8cmsjheML9NV2NT3SCX/RmoB1+teI++4tAH28SJx4qlHi18flS7y8HBWXv2Srqe8IrDo7SJjfn4ictlkl1OFz7Q8HH1KwYELz0qi0IijHg== 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=Fk7VlI8uR7OnnWT5JwzhI1dX67DNxvRRPKfomk1G6Io8iXyGh9LxOswiCTvE2geaNr0XUddlSFHmRzfvpNadPz2n/QDBxS98Ka7zq02OVpfUeos1jhxU0hI+fcVb4jkVaF5HyAi18RjkmqomJLs8HZi346MUkhGQXE+LiZoNRVqovEIO1uylVxTTNZwEz8fTEx5+1uyfgx6UevzwojwVOFk+v1R1VY+oq0WSfeUcbg/Yild+pZuOuYOgEH1sCTg+SixCM+skQ6St/toRSVtQzwWTeen26lidKLTtGe53/oQMXcEC1wz5kwjVsYcJ3oeYXn58mAtHYVs8gvWizqaXaQ== 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: Christian Schoenebeck , Greg Kurz , qemu-devel@nongnu.org Cc: Guohuai Shi , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v5 14/16] hw/9pfs: Update synth fs driver for Windows Date: Mon, 20 Feb 2023 18:08:13 +0800 Message-Id: <20230220100815.1624266-15-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230220100815.1624266-1-bin.meng@windriver.com> References: <20230220100815.1624266-1-bin.meng@windriver.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SJ0PR03CA0220.namprd03.prod.outlook.com (2603:10b6:a03:39f::15) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|IA0PR11MB7912:EE_ X-MS-Office365-Filtering-Correlation-Id: 7586213a-b878-4df7-61dd-08db132a7a75 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rIA4+7aDZiER/Z42aFtwQilhoj7oID65tFzp+Q8lHqydNaTC2pfl7/3Tp5IA7qRDo2eJvc1Jo/yNDVt2lnw+uaRKjlOPXfd0QlwHyBOmSVoDwZdBQOJvw8sXIPH93gn1UEATVgCYKjWZVTjruPTFvDwkDKm4uGz7kUFpxvD0HTAwKpy4kSdp4cqjLJZ0cUbaBiTjYzcA4B6r3ZNxP+HT+9/AGe9EjHBRiHGNDEoyyMjCfhURxKK4stFixRb4vmwh1YgJdJ2XEtTUc/Andx8kfiwSJdq7QA8rbMfG7D1WSLDo/HdwETGqFfJGT0iNffyGWtrfCxbegE6V4MBJJjCmt1OuSt/q9kdQK20seWmbhptRrx3Vz7WUhtiR52AmAuD6DL8POoZT/CAqfHGvSxWcFY3C+78XUIiMiXutODoQxNs00ppQLAqBMlbTuunJtWJJXxUKbeg9Kb+bfy6d77dN/T/kopiaymTca2g/GM/lVFgFYvgnKRUsbWy87htQT56jOUdnCkClFEl6XdLGh2poj/NuFXXR7+t03k4yFvYFNvjWKMJpu5PWsEAXTGjCDllMrOvHOm9LnQzd98bTTa2wipSo2xBChC2KOrFFdHG1z3muuwp0eQtttWBkE+QRJzcsppj+wNFgQuN9olIGM9m+0BjysuFUmEon/CX8Xcl7dW6CcVI4YpDTIUHSINgAQZEtXutLVrYAE4Saz5O1Fjr30w== 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)(346002)(376002)(396003)(39850400004)(366004)(136003)(451199018)(8936002)(83380400001)(5660300002)(41300700001)(86362001)(44832011)(2906002)(4326008)(52116002)(6486002)(6666004)(186003)(26005)(6512007)(1076003)(66556008)(8676002)(66946007)(66476007)(316002)(478600001)(2616005)(54906003)(110136005)(38350700002)(36756003)(38100700002)(6506007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Q0lsNXF5bElsYnRUeDNWN2dwaUhaMVA5MFhSY2ZNeGRoRXdYMGdGSTU5R2tS?= =?utf-8?B?aitFaXhTWldWbERuRVI0Y3hYcEcxQ0N0eEJPOXk1bHNpbEd5MThEZ2dtalBB?= =?utf-8?B?ZmhYSHRhN2JYYVo5YTBra21KSTNzRlBhT3FRUE1NTVcrNkNTTmtlVXZMRDAw?= =?utf-8?B?cmV0SW5hbGgycjBheklyRzZXRU5naEdFRmRIMU1oaThnV0lZWFZsY3NZTkVm?= =?utf-8?B?QTFVZXB5MmtVaVN0RU9zc2dVMFBVbUlncTc2Q0s1QkI2TDJXaEF2eWkxbDE0?= =?utf-8?B?cEhYTWZqd0REMjhaaVJudVpuN3hEekFnUVZ2a3MxNkJ4bUx5WWZDaTJGWDls?= =?utf-8?B?c1NndktNeFZWTWZFckNNV0x1T2djNGRBQTFpZXZCaVh0YjNiUTBqakc4Zkhi?= =?utf-8?B?LzViRTJtY0U5dG1SbGw5eTArSDhjbWNvUHRyTGhKYjlZNWg3UGxzdDJ6S2hz?= =?utf-8?B?QzZvR0l6ZFVKZmxUeStxTWZMMlFsSTlKMVl3eEhycFVSVXdwWnR2aENOUlVC?= =?utf-8?B?WFJtZWR3TVBQVWZLd0tqbGxTYmR1aGtKZDNLMlRSeVhXaXAwZ05yYithOGxF?= =?utf-8?B?NnFoWXhvbE9kL2NDcklNdndGb1hGRGRhRXhUMDg5cEkrZ1RxUmtXdHI5UlBS?= =?utf-8?B?aG0vWTYzVkdLRGZhQURRZlRaSHRYMU84UE5XdzlVNWpkZy81VW5vL3BJTHMv?= =?utf-8?B?dXB6cmlLUUM3UWExek9IVy80dld6QjVJODNqM0JXbHdNTDJYK2V2czJCTTd0?= =?utf-8?B?eWRaUHE3SWxpR0R0OEpXNUxtT1dWc0o5M0I1MENoVVkyQmNkaC9TSkhRUFNw?= =?utf-8?B?dkhZckhGRktCcUxhR0U0T3FTZlhOd0dqU0wrOHB2TXpkclVZUGVMR1hJcVJG?= =?utf-8?B?UHBUU0lacFBaMGFpYmdnVGhrMXNFS0RhN2lqQmI3V1JRY1VyOThYbmpaKy9t?= =?utf-8?B?c1htUEFHc2oxN09BZFNBbFQyemNYUGErbHlPS3U1QWo0SW11TjdOdGlBMHVK?= =?utf-8?B?cDJkT1ZMelNWMnFkMi94RkI3VTRBWUM2NWlxSHFzV1RxY0l5WXZHbldsNzVw?= =?utf-8?B?NjdQZG9BZU5hOVB2aG1yKzJRdlNuSU0wNlkyTm9aQWFiUkFaL0dPSEE2c3FP?= =?utf-8?B?UVZ6M1B5TGJMUXc0YWQybW4zK2luY1RXd1hOSXlDWmJlbVhRTXRoWVQzOG1p?= =?utf-8?B?R29uRlVLNGc2QWNSQk90WlZ5Q290cFRabVVKc09CVUEvZ1FvcnllUS9uQjZz?= =?utf-8?B?ZFZmaUZydGdMalpsdzVJQ3pKNmhhdW5IaTkwVW5VcEpNZWtRS0t5YTZ2ekw0?= =?utf-8?B?VTM4bW1OeU5YSEhkcjlaNDJWZlN4akdvbGhxOE5iVStReHNSSGJrTitqdlVP?= =?utf-8?B?ckxiZENmU01IU0cwcmJPQzhWdGJiaUQ0ajdNVGp2Vzg3MFRrdlBJandOczNz?= =?utf-8?B?UVZhM0k2dXk0cUc0Q1BFRUEwN3ZRWDZvRFk4SHY0ZytzVFdWT0l6ZTl3dzQ2?= =?utf-8?B?Q1hzOGc2RFcrVHZpZWRFUlE0MlJyN0xlRk15T0grT0VUQVZrcXAwZy9tbVRa?= =?utf-8?B?TWErUmQ5N1NISWZ2RjRIZXpzSXA0dFdvSlFidzc5NDhIK3JaaDZLeC93bGpj?= =?utf-8?B?M3pESlJIektQbDUwRllodzMwS1RDWks2T2dBQ0hRN1ZhdTdMT0Nkd1F3WEdK?= =?utf-8?B?OWZwaW5RQmVnRDluVHlZTzNVUHdkWDRpWURMYlJBZ0g3L0lhd3MyOCtBd3R3?= =?utf-8?B?NS8vOTFWM29RaXBmNU83VU9IQ0RvRml6MHgyQkVyWDQwN3doRHQvNmIzb1RL?= =?utf-8?B?WXlrOG9YYTZhMHRPaGtoTWJNRzVJeVV6WkZoRlpEbXBlU2NTU0JRRGVuRnJI?= =?utf-8?B?NEw3SEZpUitOSGs0RWo4dkVjaGdMeXNjejRBaGh4bENadllhL21sSWpUekxy?= =?utf-8?B?V1R0Z0VoZFJNcXpUTXZqejZLdGNQU2ZiZXJadk15WjRzMnF6alpuVStvaWcx?= =?utf-8?B?ZXhWUWtOUjhPQ1VVSTZEQmpqSWVxZ0RXRGlkcmdWM1ZacnVmMVE0enhqWVE4?= =?utf-8?B?cGxCMlcrTTFCQTJEc0lxU3dJbURuMmt1RjVDWk1QeWtqVVM2YTRDQW9qUE0v?= =?utf-8?B?U1h5YVlWUjJ3cmx2V2puekZsdmdIZVlCQmU5ekdjYlV3VlVSVG9oc0s1d250?= =?utf-8?B?cVE9PQ==?= X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7586213a-b878-4df7-61dd-08db132a7a75 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2023 10:08:56.9780 (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: gWRkg5hu9PaEvPehdde85lrA6NF7PMgotRl8eoXm+2G1BZO3l8sjSdFCoPfaBDMAspguCwfw/X+YsS0urGrHeA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR11MB7912 X-Proofpoint-ORIG-GUID: 4wHtKcTsaRhf9YGW7mcSPy1FD3CEeO33 X-Proofpoint-GUID: 4wHtKcTsaRhf9YGW7mcSPy1FD3CEeO33 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-20_08,2023-02-17_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 impostorscore=0 clxscore=1015 mlxlogscore=999 mlxscore=0 lowpriorityscore=0 priorityscore=1501 spamscore=0 malwarescore=0 adultscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302200091 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=1415163841=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: 1676887817046100003 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 May 2 06:33:11 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=1676887795; cv=pass; d=zohomail.com; s=zohoarc; b=LSgzYA07fCrhnAZh2hMmtPevlg+pdQ22hMijrf0RN4Irz4i/VVZ6o++PUIOzGB04mGaA8rfSBNeNbcXAjkVaI6CfN3OU05uMlojOWAUpc2MLyDlSEW7Zxdgb43G0cYZY4Th1sHPo+Sn+6KmKXUzyG/tDdUhnfmwzN1UM/YCRFEU= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676887795; 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=LANOMPDUCor+4cjXcN36B3wdEC6UDpRf1gvHWW+01Ofqkyq25owchyk7/eqinsPjPWF4+bVuWyhpz12zDpuvC0AWfSqhCvLVTKxVf8cc5nTgMVgif6rQHSgxgkjStnAIL1BhcPRbYH9RcDAYaB2Ed0JDmwSR3nCkxXr2nLvIWLk= 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 1676887795777629.9723287252262; Mon, 20 Feb 2023 02:09:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pU36h-0008Bd-5B; Mon, 20 Feb 2023 05:09:15 -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 1pU36f-0008BH-Ek for qemu-devel@nongnu.org; Mon, 20 Feb 2023 05:09: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 1pU36d-0000Az-Up for qemu-devel@nongnu.org; Mon, 20 Feb 2023 05:09:13 -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 31K9VRAn027338; Mon, 20 Feb 2023 10:09:01 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2044.outbound.protection.outlook.com [104.47.56.44]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3ntpem1kwu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Feb 2023 10:09:00 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by IA0PR11MB7912.namprd11.prod.outlook.com (2603:10b6:208:3dd::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.20; Mon, 20 Feb 2023 10:08:59 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9%4]) with mapi id 15.20.6111.019; Mon, 20 Feb 2023 10:08:59 +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=TPpag44Mh7aanljEecPrUi2ksRj9lGrAPRn1PvXemrKcGznutWE1QixYptsZLtzSwPQ9 rH/2aOZjOPiVI5/jLzcH7S8H4GXuGk6wha3qoHgsMXrJ2QBx+vFqqm37XYY53SO3YOwO sH6l8kM6Ls66I0otvCprD90P1Cqs3ajs2/cZ9gtPQtTr4hTUaLOMLC2p/D3vymJG1Cqz t4+92ExDwevtBaV4emeaCI2JQRVw/u+XlEUuxoXy/vrjzeaxmkorTE0UDFLSLSnuHQNN xftmwuscXCC2T2JrRoaINjf6vvJe1kzu7bZdRAr6WfH/FJYaPKndRlYnbaS6/XxZijeA 9w== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PdfCIdTVhm1sZJiNJMa2l+CG39bbA5EGL8j482eWgBnYScnIw4DS9I2s4ajGYspjQPOOyVxh3fXUeFcqJMEwKw/R4CSEGR+YB7WUmDXYB83otIis/kqkOQyagHLi+PZYFsBKcCW+t+1695EUAOgrLB27KukMO//d8n4h99TAWl7us2/WF/ofv/BWE2rHhbYC9+qjBXrpMC+eOntQvxp+uv5+v063WKQ6NQYZ5u7pxbIvvsPcHeyrXlTvAvyy+5Cwyt8gHmV7mAVaBKjC4WrzIChAYavkg8OixGUNMzZ1WSx+2vhu8Y6d6SG+D+Pe2Y2rnz27CzI5M4C+S8BrF9riYg== 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=dqTFLs5KezynA1tj4ynCJeRU6Dd/EsviS8yImoKfIQkD6RDR79+EJro/RfgGocAf251ThrGQM0UapyLaL0C8SZZhi5ziUtGQrIPd4drjbjNPyjGyyhBmg5LEIu6mkcSC6T40Cv01G4ebinaTa1ZavKil8CJuXAids6xR1wGfs4oRr2NKdARFefh0VNJ0qTb0WwnhONAKqr3VuaCwVjO/xrrE3HF38s6nwdQJphNIZnEquOkuXAOHYWD44JyLw7JhWhuXWjiwCS4r963a5rwUKX9ifeLfpX02Ls9X+1ChmW3x88RNoxC26hPGkSEEf//sRdKMDVJJU3zdfiksrkcq/Q== 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: Christian Schoenebeck , Greg Kurz , qemu-devel@nongnu.org Cc: Guohuai Shi , Xuzhou Cheng , Thomas Huth Subject: [PATCH v5 15/16] tests/qtest: virtio-9p-test: Adapt the case for win32 Date: Mon, 20 Feb 2023 18:08:14 +0800 Message-Id: <20230220100815.1624266-16-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230220100815.1624266-1-bin.meng@windriver.com> References: <20230220100815.1624266-1-bin.meng@windriver.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SJ0PR03CA0220.namprd03.prod.outlook.com (2603:10b6:a03:39f::15) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|IA0PR11MB7912:EE_ X-MS-Office365-Filtering-Correlation-Id: fa672b89-7bc4-43a0-b048-08db132a7bcc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: l5pF8aNvTOiQXtz1twzE4AZDOQ/lsind1K/L6VIj378nD7wE1uEozbEvRuwZx0lvvxLVgUT3NsJUy0f8iWdsHMlCXkaXB+/7q02nNZM86e1UtmMHIA3G5lv+fTnQloA2l2jau6iw5bt8PESSDlWumePl4YGtHTQ9C9e6/Z8UDeeFuFWsp0kGLITep4XIEUy7vrrLiMgY9UQFKX+aA5rvyOEgQK70dTqKvmsNo3P27FsukXRXQ8ZKdfMK6Ggru1jLB/hq0YlP81cVPl261pZiMnisjvT8/vupOzQmY4Xmr4JsmTFnNzAc/oinrbRIbiYycAi6emvCYMSs1oK632veyrKcXXY89JPAVsPvwmwAdn0c8mJ50DJ1E6LgIw7iFHBP9QvD1+9bmVKAvgHMXtGU8WL4vgQuF7yIAXbSDPs/eTqPnJQDFAompfGRHIMZnHiSzsytJRjo20kbmxBSVgutBTWHaCnjV3AmCOUEJx5iSiMjhFbJ4X/gPAqxYpRsXuBGHUJlBMv0Ah7Q/27K6Tu09j6sSbAQvci5YeFam17gYibgfW4PvP0j4HABAMVqdpdAJTyscFK7z2X5SuC9PBJS7Ppol8UX+X8ahRqospW8kyyN5CIzM7B+1fl24ooiJdM9u4v10TVa0Ge5cco84/scTt78qM9NAvLSp6XOOVBilpmEsNPgMj/mIjrAu8R4S8JnL36FUb5BrbGLqVr1v8vw4Q== 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)(346002)(376002)(396003)(39850400004)(366004)(136003)(451199018)(8936002)(4744005)(5660300002)(41300700001)(86362001)(44832011)(2906002)(4326008)(52116002)(6486002)(6666004)(186003)(26005)(6512007)(1076003)(66556008)(8676002)(66946007)(66476007)(316002)(478600001)(2616005)(54906003)(110136005)(38350700002)(36756003)(38100700002)(6506007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?b6aa22Gboce3tDJnb86FICarjE67bbRLlvw71e0nuQNNvDv2/ikHENhRHDVi?= =?us-ascii?Q?pHi0eb/l3uK4m9A3IE+P1CdluKYH9zYz0wC0TbQaqmxacw2+uZbehojmyDOV?= =?us-ascii?Q?SxtTvYltPSrZVaiX3qXIIv1BnAd00WNcngOU7g++liIncWiPxO0qzCA9AHyu?= =?us-ascii?Q?AFrRxUswI7OSOdFVRMgGlcD7s/ZwFtxy4flWWcFfIIw5Lh5tlmR+elS7XEIc?= =?us-ascii?Q?a2UrLMYEPr4vZiu/W0sgyuT/4KjCMLKbfXDNDQ5T2C6gq5cpz93hdgHSevht?= =?us-ascii?Q?JR1FFbPrjxVo+mVDc9E1Uu1R2ubWw8FZdRNDGvH3IlOuwAQYMeEKw5RIkGLE?= =?us-ascii?Q?Kczh45GkVHALeYvWuwgOdwjI2flKXj6NZEAygiEmQIqHPrEyh07AkGYPk+1F?= =?us-ascii?Q?NVBJnArHc9ScPHYSlrgn9uBXNKuuru4scS9A+TDHxOMm2nfdy0kUN+SM5Bn2?= =?us-ascii?Q?lUqQJtVhQdvlo4EdSc/yhsZ8t08fFg47Ds96utA0+VCKXuuNL6EvNWO7GEnr?= =?us-ascii?Q?jnRCCTk7pJsk9fULvQHu84o0H1Mw8eSet9UJQ4TNl5e7MnY84eeg/bKceS9K?= =?us-ascii?Q?TUky720YLthuG05B3Yu/mhhU0ylicGYRIG8uHhwSdsESp6nNF3yLSHLKdryy?= =?us-ascii?Q?0O15/Fhf54gHOBFbSuDn2SkTYy74laP1oH+LBFtAhkYBjhqOD4i3Q8hj+XQR?= =?us-ascii?Q?zYqNxzkut9rM6F3i7e0tsRx+d1uyIlbSbR1xe3RSdWke1g9YxawdwF57vgcw?= =?us-ascii?Q?u7j2QBM6TFWQ2H0ZjL1zd+Hs7rlI/4+iyK/CgTWTAn58qXzAtxcWdeBpAc2M?= =?us-ascii?Q?+oUTdshve9lMICg7ZIcfQfI8CJ9sNXP6/kk1d35Lh0kZPJqW/VMfCQTGvSpG?= =?us-ascii?Q?ToTi88kMxpPja4cZUraUJvxQhH2wFMoRfTrzrFMUUNMUgJLl42asQaguT6i7?= =?us-ascii?Q?QgKtyMiqn0vrVRSpAzUEu82sblGsiMrSmSEcYscqlLVmNuoFw+tt4q+nQyZv?= =?us-ascii?Q?MVR6S2cWfAj9o1NznH3dAL9roqzqXTXtVeMrXLwba15nVHNHTX0oTT5Sm2rD?= =?us-ascii?Q?2clYtf94mGXeWmZh40jTTZdiBmPbGe0IIZoQyKtpR726RknEfopWrS0FjnWl?= =?us-ascii?Q?gGq5aisoyBVGmPZEnS7aatx/qQUgGHXeUSc6DPrE+intGgx8/V9ZXyEjFBZG?= =?us-ascii?Q?CBTYuvBch6gO6j+td6f6bA36gTHJZFRDJcZVrPynLz6m1JZvpg86pcfeWVCD?= =?us-ascii?Q?iOxlyfgExU2ec1x4fRnLxEg03hDfcFs5XuKs5nbhCjxnmzc5o7zeGO8i0q6I?= =?us-ascii?Q?aJpclvw+0GOyMTrWz5wBcf9zvfbhJXvAcrkH5+Yz+4UUSViN0N/2F08ElQcT?= =?us-ascii?Q?PvJO3mPV/XcnTpPpn46Bq6c9GhaWXI7x4vPOi0jTZiH71EeOmLsHCuxuK1od?= =?us-ascii?Q?9DPok02INU43QPhjFuU0m5wCcqTur55u76b/t0U1XO147VJGTZmxeqZq3js8?= =?us-ascii?Q?PIbqqF2ebDfZWXM7/EfR0OIgtr+UorEJm1T7NFTtgQs5ASWuS9or7hNTl5q7?= =?us-ascii?Q?jYHde9S8s1XblcnRQEeL90mwOT3/wv+NyhKwECudTNEKNLhd8O01X+f3dJpa?= =?us-ascii?Q?sA=3D=3D?= X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: fa672b89-7bc4-43a0-b048-08db132a7bcc X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2023 10:08:59.2605 (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: d3VGu9gdaXaBp5C6Mv/DgIlhSQKgZmVKM45/bmtIWB9luevwccynFForay3IbrMRnFqN+0reT+7vkFj+L8s4Zg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR11MB7912 X-Proofpoint-ORIG-GUID: LdCfv12mULttuyVHjqp4CCaZVCghvoUN X-Proofpoint-GUID: LdCfv12mULttuyVHjqp4CCaZVCghvoUN X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-20_07,2023-02-17_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1011 mlxscore=0 lowpriorityscore=0 priorityscore=1501 suspectscore=0 mlxlogscore=999 bulkscore=0 spamscore=0 malwarescore=0 impostorscore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302200089 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=1415163841=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: 1676887796968100011 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 May 2 06:33:11 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=1676887777; cv=pass; d=zohomail.com; s=zohoarc; b=G/LeX5JRmzXFAuY3ORW0HjmHapDEzDPQeLUKHZkRf3Xmj9dku+YI8K41UUNZiDs3StKx/KRIH+C5IGG1RPMO3ERGYGo7lg4Tv1HGlJiAvfy4S7rY6XW2PGkYcJwhFm33KZBzkDFVi/jqTaxGREScTkXxYyB1dAXK7RzyBOgei5U= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676887777; 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=pj6CpAiOkn0C8N0WeNVo6qDdPxsqZlnzg156xpWuFDU=; b=WQERRCxIK5Vv8Z2mevLkGmR4vJ4oIyfHRMLPv68p/YrA32PwX4/9faytmKqj87O7y//lud4iUjV+lKXLvrlQNPggs9rQ9yBnkPVlxsizaE3dmTPJCa05bc7JqTRcsxCfah2UOz9fF2m6M0DZ8EQlwWY5Q8SFBgpPYWKodaJ4UXQ= 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 1676887777351179.8196388656229; Mon, 20 Feb 2023 02:09:37 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pU36j-0008CR-NH; Mon, 20 Feb 2023 05:09:17 -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 1pU36h-0008Bk-FU for qemu-devel@nongnu.org; Mon, 20 Feb 2023 05:09:15 -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 1pU36f-0000C6-Qf for qemu-devel@nongnu.org; Mon, 20 Feb 2023 05:09:15 -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 31K8ieNr022312; Mon, 20 Feb 2023 10:09:03 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2041.outbound.protection.outlook.com [104.47.56.41]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3ntpem1kww-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Feb 2023 10:09:02 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by IA0PR11MB7912.namprd11.prod.outlook.com (2603:10b6:208:3dd::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.20; Mon, 20 Feb 2023 10:09:01 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9%4]) with mapi id 15.20.6111.019; Mon, 20 Feb 2023 10:09:01 +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=pj6CpAiOkn0C8N0WeNVo6qDdPxsqZlnzg156xpWuFDU=; b=bbQIAb4BwzsgSLgMyxZgHowgRkqFTwbeOFM0IrB8R3aJWvkFzvNOckaczT+wfdd18hBQ wcGci5jXLhqiZ6fkLHdtrAri7U7o9BEdDyvIkDWl+MqU5lMZICiUoilwOt0IV4NA6s5A F738r6PMQ8PhLHiHWLKCnbBhqlmVSORQxCTyoNJ/2wMw+qotnjL8LqbhH3PuqruX+MBL 63tM9I4DvcKHAv/m9NIiuP2v/vLm2HoajdWq7L3qMd/+ESn1+Kawd506u5gTyOvpkDSC j0OxpH/QqS5u71RXVQxr19yfeagMk3y4p+fd75Caj0Bomc+/ZPbIHy9yaf8lnmTlTXrc fQ== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m0pKnxCVg4vATcCIfISMO0L/CvXXLH2IxpDVCPSfp1OeCGZF2F/5QKV0nqyqOxCFdGdN2/hj6POBn8iBs9k97kdMOH7gut5qkGBApS5reUnlqU3+XRra2GFXgfZPr8MQBITpXVGqcKV2HrIYIuRY/nrYsEnN17mntvQ9K+HbqbGKBhunyAG1eo/1dZsuNumHm+SSUOfjkJyA3ppOKr+vneTCPMISv4/g7QKg7wGLEAAnVFKH1tdSyLjO7Vdl4fB8rpKP7Fu25CRTvyBE3tQUp46kEAD0WOf1AUQ736iQw5MKDjFZgsDFVnh0xSXeGEHYbdzoAHTSBxY6+r+/TvOX6g== 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=pj6CpAiOkn0C8N0WeNVo6qDdPxsqZlnzg156xpWuFDU=; b=dvjkFP13B+OSzSxeLpNvVE1xpDQ57aVxpzTK014LU05E4piW8dmold143yLitq2VvlutWHY/ZPfxY20uHL29+LIn9jlBZv0e3L3nwVIcLe/CC7w+cTLooefk5E7wp1d3QrnNduibh51B6AvjpWPQkb6jQCQbWpe9qFzL/Z5ZgGB7V+K9yOZ0gmM0WamabTBly7pYGX5GoCNNebKymNIAV+aiATc769xGWQLt8uRKMmBgx44bLrlhYAs+cBDBIbm/mUFcvbC/ebCmit7IQCqGMJAZte+OLghdNZMaYqIS8Ccv1+7ILCpcW7WMjTsD3L3S3Rmh+G0Akyoxdg1VG7yYGg== 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: Christian Schoenebeck , Greg Kurz , qemu-devel@nongnu.org Cc: Guohuai Shi Subject: [PATCH v5 16/16] meson.build: Turn on virtfs for Windows Date: Mon, 20 Feb 2023 18:08:15 +0800 Message-Id: <20230220100815.1624266-17-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230220100815.1624266-1-bin.meng@windriver.com> References: <20230220100815.1624266-1-bin.meng@windriver.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SJ0PR03CA0220.namprd03.prod.outlook.com (2603:10b6:a03:39f::15) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|IA0PR11MB7912:EE_ X-MS-Office365-Filtering-Correlation-Id: 2d1f00de-53bf-47ec-5a45-08db132a7ced X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jcY0hhbY9V8Meg1oHot4WuUmrP/Zli4KVShJxMl8DAOnkxx3Pt0I7SW5aUF83KIV8QraEu4T3Ik3z0P6ucGs5RrjXeJPOgJD2Q1x1b/ezUtUsGNQlXkXeDJ86BX7GJ1U9EEDa9Ywt4fVkaHaFDQnWadA+Rd9ZFOSQGOxWspVYp6hQ0Ge/w41fgATxYRGgfSACJLaHJqcAkW4AZihYEOvy2/fMlB3vgILUTFDTdvVd5au1FVEaweP8wSbAjwOw5x/G5CPzbj8uuOw/ma0gminlWhyJJ0wMOdwXPw2aDpR3dANCpRMW4miSoS/5/ZkQu6BJNCqnbEBrppeG9qMJlzvsRbAVbXilMBwXHnzBOtFrGI4pwb87HwcDpqfx4vntR3SJHI/AIwXYEEX8mk80SKSurhO4rIj6KyhLpUDuZgDMD89guNSK3Wk+I9NEy1m1KCasCUDChDN/JOv6HGuDlpXo7z6JRbWL5j1aFt5cumFfskYSWuufaReP4BhHwy72wpccKZ6fUIrntj6zVrDy1Up03PbNZpcoSPA8iPHctH/ik+shxmcbLrQvYHeOaBBQJNwFOFJk9dW0nNuPlfgl92WI1oeuo5c0b68OAkuW09SZrmD/T2HHbmxOPu54a5jhPTWNStzlBAlaEf5TL7TmhAvHL3Pmencsx9A1+ohOHy0IZirlakOM5qF8XHFYObZgy9NDZDvL2hnKOh6qSVCYsUKLw== 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)(346002)(376002)(396003)(39850400004)(366004)(136003)(451199018)(8936002)(83380400001)(5660300002)(41300700001)(86362001)(44832011)(2906002)(4326008)(52116002)(6486002)(6666004)(186003)(26005)(6512007)(1076003)(107886003)(66556008)(8676002)(66946007)(66476007)(316002)(478600001)(2616005)(110136005)(38350700002)(36756003)(38100700002)(6506007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?XTVTLAyZw54KovutCqxJY88Jtwr3l0DKGHnJtnAxpqKFfElCEQVMysD10lDg?= =?us-ascii?Q?+z42Je2w602dQw3/lcZZZpc5OZBccas3r5nE6+OgDUUtyWb7i5ptjphi03V7?= =?us-ascii?Q?sVFI/bUU+uVyQmsPlAZKW6aPrCrzdEqo/gc/tY43JEodntXuUa1PWAIBEmQ6?= =?us-ascii?Q?u28tbWxskgfNpJqMn+FVgd7iB9caH0K8cdTWV31Pdf6pK2rE5OWRq0fzJrYh?= =?us-ascii?Q?Eer1hT81KfOrCV7PPvfyNwL1WeKKNdp0f2zGdpaBv7O7bhltcMDSqVJNhI56?= =?us-ascii?Q?l+cRGIs0oG+2BOHrg5vw7p7dOZbboMEJ7+YGXZ+x8dQYV6xhZ20RhqGUVVXr?= =?us-ascii?Q?gYtzf8xhp39FLaGImOAtiE17j6yyPAlFgmQwvmjjy0WfObKnAzIHyXL50MEo?= =?us-ascii?Q?NATYWk13yEoAvX5eFxyXogcxus44Kkdh5ICF2od/yrBkcC+sLSf+gjdl0c3y?= =?us-ascii?Q?0Syuvk0wVMfW793r4o+DkK39XapkHa/Mm4h/FgnW+fFYWTm9FelADl0wINw+?= =?us-ascii?Q?E3yiVs+5K6YTJ/9ej3zJ6o/AvHMBge3Mc6FxJGCCQ8ckmzQy+GuF9oIp20J6?= =?us-ascii?Q?3Ecw36TO1epgE7svWKEqRiYoSprQf1MPhjCR9ifUlxjXfHyXFVe1bXBwYAtd?= =?us-ascii?Q?hqCcKaAJZk3YTtpRY8bYtqDkcfLKKk0Ku1xVmFKLygTmbrS/2v1D5VmK2eMT?= =?us-ascii?Q?gvN3/asv/W1XS9bGrGR9ZRcnPncWM4DHbOPzSQtkiPyBlfPZv0q7UcH/sUSd?= =?us-ascii?Q?E1uXUgb3offwliRCq366e1CozAeFJ7X335Od7P7nWkzaiy1xP3jKcwM0Y7Xa?= =?us-ascii?Q?+8SbE0REYLYAdIIfK/vcnGIdwIU1EwumSHSGmfpIfS3XjHBs2WTB+9WjsvGf?= =?us-ascii?Q?Aa0vmdAGuQlcbCF+KyJqEOL1TOQWmFTwf4NiYC8ZTEhO06wAgRjl/nmA6czx?= =?us-ascii?Q?vK1KrnJr4AZ8+AVmc46Ej/c28j+FTYmMFE+Jidf+AzUM/MRnNqHaf1tw1JHC?= =?us-ascii?Q?sSNcGSAxDuj+tO06Mg39upS5LtcG7hF/sWY05ueT97naO4yDTJ63TXfLttLJ?= =?us-ascii?Q?vO8DnTpLcahajQ9dc9gnrdd2FrZD44cjfqcFaJMdUPuusedfwLTEWmvQufMB?= =?us-ascii?Q?0vpZ3bESmYLNhlZFpHRNmOGA9O7gclkyMKPJ53QgYmtipWDr0BIqLBnLGiot?= =?us-ascii?Q?BmyY1T5uHOqThDDS3OoKv/1ctjRUR5W3uQpDiKTgEU25eY2FuCd9CUtHE91/?= =?us-ascii?Q?M5Vso8taeKZVpQWrQFMKV4aj/sz94UK8rD5+g+p0okBUbXpo2dnYTn9k7kVr?= =?us-ascii?Q?OZCx0jHTE8njD+Dfx0b/VTe/JYdEpsrSvUDWn1kKQv6LePnn92MMWuQ9mPI5?= =?us-ascii?Q?/YCPf3C3vEAjhknKZS3dTeo8+F/l2wChlM/nJ5nZIrj9nsfALxGW7bEZcJpK?= =?us-ascii?Q?6A2SN1o6dPoQdDOxVr/yLyZp4XrC6t9zhsvNAhOo8fGyMshqYmx4peYPKTGJ?= =?us-ascii?Q?A2TDR2oE/okSc4VrstN0naT0SkHbzuOeYOHyYyAhP6mceHiVGA0rRe7gsxWO?= =?us-ascii?Q?Gt6vVVaQ6yC9OnGBcP6hT08DsgpWhPJcp6CWq9zv7560nv+j8fb52xtdwZyz?= =?us-ascii?Q?og=3D=3D?= X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2d1f00de-53bf-47ec-5a45-08db132a7ced X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2023 10:09:01.1208 (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: GDFeV+wkSyrH9pTIgO9x43BxOrqzxYzBz7xyhJ4G6AVuNrBGxj+lgkqYrF8zEds45pGJUbVpN+h/M6JVE7pTNA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR11MB7912 X-Proofpoint-ORIG-GUID: VkG3uUhFA3sWYviGuXm8alQeqFiUZGUj X-Proofpoint-GUID: VkG3uUhFA3sWYviGuXm8alQeqFiUZGUj X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-20_07,2023-02-17_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 mlxscore=0 lowpriorityscore=0 priorityscore=1501 suspectscore=0 mlxlogscore=949 bulkscore=0 spamscore=0 malwarescore=0 impostorscore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302200089 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=1415163841=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: 1676887778901100006 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 a76c855312..9ddf254e78 100644 --- a/meson.build +++ b/meson.build @@ -1755,16 +1755,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