From patchwork Mon Feb 20 10:08:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13146240 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 92E40C6379F for ; Mon, 20 Feb 2023 10:15:48 +0000 (UTC) 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 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== 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 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 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 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> 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: M5scc2bkTxop1sjdm/BelKGLpFJhEHY3Z+pzvG/Qw/FAzURYv5so/OPgZ0XOhn7Sf7ejhk1dgGIRLSMuu5mQUBMb3rD5oOKXiI+kIH09V431uTcQFOd1XY6Nc534fMzOchNhD4wdk1euoS2HjFgLUQieOGgg5YhSU5vguIqfhU8sX1kCBpqyFGtSnrUzosnT0JV/0UskqohhcB6H+MQgzh+unAglvmiuGHY7nXb1iX/d5LKdkVlKZaKZRhNNHvoUWYlYxxTI0fgN414OO8Le4rADjjeneczt2zLkUhuqPZG3DcHid2jYayJJbRhtGBDzgOCUP+EIhUtTquRAMzZTfAGS7FLYKneUYYp0mmst8lqAdzseviPT8voaGD75uo4bNTlMpa9JaRXOd/o/j/Iy/gfplT4v5NqobTSN1ztTyNtlK/O8cUNsK+ncAMcgv1m5ERh25VczGxX4SfFSObiYrKbKyB7M1uYu438a5jtI8QuZAKYdwLKERQSI0Ad/AEWNUyrs0RqLzPKBWtyMfmMmX1n1xmv06Nt2b7I4dmCY0uPOQ2qTpBIDZAIvy0Sx8zQS8x3VUjJlFDD5J/UAJhNDu+eknDl6QWLzhcJS5WEWiNq6A/anPVtQ009TYPgW6UlcM8/uiSEahRsAU2beaYEh/XUpA8O8iRfkIv28QLCb7lpqBOvaZ9UByNGj4g+UsvXmDf6IMdW69vy24Jm4b4zBAF9P5NUK6JX7vdcSjedvyJI/pIIPMy3k7iDyRzKambFtlFw/Y61qO71fNqv52NTRZhx2HH3TRO0uZgmOKE1FrW8FtvScL5cso/1ka2EBmSFF/4SamNRvsJXMGBzSqLtb2861pbFJdytTKqYlOf91RxcWcS0/X2R/5WrvvlpMcHbUBeR1q5SakGdgSxLjD0c5Yei97hrrRw9HLpb+YTmmlDKCq/SaviyqNhPor2AqAsj/U4/y9wLW1rDHjToH2buM6zELZPRijaaJ1cJdYDMdKO0KQq8JtID8mkkXPwyeoiCZJY/RjrcL7zvkfrf0ERo7gLNO1k09zcNItXV3iMcm0Jpi4UDmhzdLjFw/lfsmFil4SCZkWdx66cs49EqxGoNJ61LkDbRT37CStX+0ef8hS4Dg7YX2w4eXsi9CdHGFjLxUrCEnRrohnI2UlLDS1s3P5aDYMuRpC7YJK0kNK4Bwx4D0JtZalS6+6Vb47I0MkiQbeVEbXp7MYIGTQwWoRT9TPD2HUl993SttlzePQMD7KBqHXbinqZUrRHTkW9Y95MezgjIEFXC0fFgrpIiuyV3Kw0Xuf+vP8C0tnuynjCCVbHl08c59urIWiAZX6jYI5qpknTpApBvkK9M7WEDhgWKEIaGv1+Qhe64Hz03gTuKAsKDRAKxQN4g4Y8qK62pvrGsJZszIZbGmDVrGG6iekn00pMTFwpxDPBQGbQfNrUVkvH+aba7aPluPXJQezMHhA5MkaEJ6ZOWMVsWVnUwF9ujU4jrKrnZCz6CwW5qI5CiTn6B8nydJmx7Q+ChFpaDU9ZUzgeoOR9zzcphKIHOuBwAsfS+BJvF9izN3MgdzMoVzAXIECRUdl3lwVJPjjR5TKtX+bArAXhceaSrvWtaQgrWdag== 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Guohuai Shi Some definitions currently used by the 9pfs codes are only available on POSIX platforms. Let's add our own ones in preparation to adding 9pfs support for Windows. Signed-off-by: Guohuai Shi Signed-off-by: Bin Meng --- 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 +#ifdef CONFIG_WIN32 + +/* POSIX structure not defined in Windows */ + +typedef uint32_t uid_t; +typedef uint32_t gid_t; + +/* from http://man7.org/linux/man-pages/man2/statfs.2.html */ +typedef uint32_t __fsword_t; +typedef uint32_t fsblkcnt_t; +typedef uint32_t fsfilcnt_t; + +/* from linux/include/uapi/asm-generic/posix_types.h */ +typedef struct { + long __val[2]; +} fsid_t; + +struct statfs { + __fsword_t f_type; + __fsword_t f_bsize; + fsblkcnt_t f_blocks; + fsblkcnt_t f_bfree; + fsblkcnt_t f_bavail; + fsfilcnt_t f_files; + fsfilcnt_t f_ffree; + fsid_t f_fsid; + __fsword_t f_namelen; + __fsword_t f_frsize; + __fsword_t f_flags; +}; + +#endif /* CONFIG_WIN32 */ + #define SM_LOCAL_MODE_BITS 0600 #define SM_LOCAL_DIR_MODE_BITS 0700 diff --git a/hw/9pfs/9p.h b/hw/9pfs/9p.h index 2fce4140d1..ada9f14ebc 100644 --- a/hw/9pfs/9p.h +++ b/hw/9pfs/9p.h @@ -3,13 +3,56 @@ #include #include +#ifndef CONFIG_WIN32 #include +#endif #include "fsdev/file-op-9p.h" #include "fsdev/9p-iov-marshal.h" #include "qemu/thread.h" #include "qemu/coroutine.h" #include "qemu/qht.h" +#ifdef CONFIG_WIN32 + +/* 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 conflicts. + */ + +#ifndef S_IFLNK +#define S_IFLNK 0xA000 +#define S_ISLNK(mode) ((mode & S_IFMT) == 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 = 6, P9_RLERROR, From patchwork Mon Feb 20 10:08:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13146234 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 93BD3C05027 for ; Mon, 20 Feb 2023 10:13:23 +0000 (UTC) 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 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== 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 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 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 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> 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: n4VyVbERhKeP+X9n6hW0Xw0xU/J6EsPWqYYybols5ov/8ef1fW7ZKhGHxs1pbzMirkbeNKhkIn7lEbEb7UHIeZLdOZXIoDdbm8iyPrSO5q9KE8dHIFVoLptzXYKX4nn00dN/pwsaOcX2u2KWN0WIwBScJ4PE07R4aV7fgzZ0B2O4VEPPThVpDcOMDy4ZXNh1WjppiFuP6EnZUq/TLmmguCKNbT96QintnmeBmlV6dwc44L0XVSDfNRF/uzyYWFBdfxAc65lJFLvxYTKGJrKri/B/dCXXthSifexA65zREbUaaM8kcl+rF0a2olgOnmZaJXYAeSn6ajfMoP7WEZ/5dbasAV5vTB25j8+ICbU43cZ7u67MOolFkKdBwb+Z6SmJIkMqcpo1/my31NpMqE9x6Rh2PNEvDDidlD2km8iLgyKzLk1Kzjfgg7nBim5TzIim0CTBTbvWZ7UBTa4NS1AmxU0AS/YE7lDpqb/YN7cwsmYi9jQbhmXqi9giTk/6jXB8905LVl79jByRobvn+4iKSRRkMEwHrfNfUnnGn3jLV2hp86kmgOUXOWewW5gvsm8vUpM6TZwrHcPsmdsN/QqvmS6E5O62Rsm3OhXYi6mo6G9KAYlZIxXBVostgvVEVAqzJHETXCdlhhAywslxb8i9Do6QteDSuYBNQPTCpzqyT7Nse3tVs1P/SbqzYtmzcMvi6MmfJqL+471+bzsIkK8xFHWKZoKcRyl8abwFpdlk80BHpngIS4otCUyWl9RKwSOxFk27i1P7acDI7ifPWZd76Kl6gQJPPOFfr1pCqivKkKtr5AfV8CuliugIOO8QX1qXsQWGy8O7hnjaFz7hARQ4zasJV3vyrVG0i79qaNhcAGPIone+akO8gc9eUeiP4PQclV8FO/DqLM5/eVbvPCklsFoMqvZ2KrdAWTtEKIS68GCLF2GXQroLRzvZ8Qq1kN+T7uDVTW+BbXQVES6StadO8C3HwSOyDGT0x/Ky3wrscedvTrozwdbcL6V9qlsLZyYr4I6SBWvK13dSgESo0cssPjHvpcVCjdtjty6uStGydzR1UXhiCosG9kGpLr8LU8lbQgMxVjPb0RkP+r3gF5Dt01vAFf1hwPEB9PKb4MUO9bhWajBlsbnfu7Ao17x4U6DIoJif+zn9voPijJOsoxox6cIyeVyVgnMiPr4F6SgfaLB1MYq3zLzKesWKR0KtFcbx1AEHEt4H7Yluo4dCw1qJK2xcMmFkMRwS2ygUOsjb0kTW04FDwjoE+P8cVvrAfOWwXLaTYJjhLUiSiIHkRm2zCS6pZQGjAv+QEawaxqTU7VTdAR6ZPbaRD/oespeYmykJt9283QNXkcQJRfavzGNwFb9lZfPinqOkUzgauhMutRJAn9rFy9RecYkzb9o7jQZiwJnqDfx0k0kpN8c427wAecE4O+kyw6l4wnVyy9cTiTeFYVg/DlIYZTt4pqjtO/9+6hDxEyZk5VFNPina6A/iUMFeHlTng+btc4nmlpFsvDg1sZ0zrgrQPCsDblIE6OU3jU+FB3aFQSTe6azattjtwREDc3T2C+k/vLZltORx2L0azzJsPRLshfS7dsl0aeZX/EIe9FW+w1weYt+3qT26Sg== 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Guohuai Shi Windows POSIX API and MinGW library do not provide the NO_FOLLOW flag, and do not allow opening a directory by POSIX open(). This causes all xxx_at() functions cannot work directly. However, we can provide Windows handle based functions to emulate xxx_at() functions (e.g.: openat_win32, utimensat_win32, etc.). NTFS ADS (Alternate Data Streams) is used to emulate 9pfs extended attributes on Windows. Symbolic link is only supported when security model is "mapped-xattr" or "mapped-file". Signed-off-by: Guohuai Shi Signed-off-by: Bin Meng --- 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 +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; } -#ifdef CONFIG_DARWIN +#if defined(CONFIG_DARWIN) #define qemu_fgetxattr(...) fgetxattr(__VA_ARGS__, 0, 0) +#elif defined(CONFIG_WIN32) +#define qemu_fgetxattr fgetxattr_win32 #else #define qemu_fgetxattr fgetxattr #endif +#ifdef CONFIG_WIN32 +#define qemu_openat openat_win32 +#define qemu_fstatat fstatat_win32 +#define qemu_mkdirat mkdirat_win32 +#define qemu_renameat renameat_win32 +#define qemu_utimensat utimensat_win32 +#define qemu_unlinkat unlinkat_win32 +#else #define qemu_openat openat #define qemu_fstatat fstatat #define qemu_mkdirat mkdirat #define qemu_renameat renameat #define qemu_utimensat utimensat #define qemu_unlinkat unlinkat +#endif + +#ifdef CONFIG_WIN32 +char *get_full_path_win32(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 static inline void close_preserve_errno(int fd) { @@ -108,6 +136,7 @@ static inline void close_preserve_errno(int fd) errno = serrno; } +#ifndef CONFIG_WIN32 static inline int openat_dir(int dirfd, const char *name) { return qemu_openat(dirfd, name, @@ -154,6 +183,7 @@ again: errno = serrno; return fd; } +#endif 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 -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 later. + * See the COPYING file in the top-level directory. + */ + +/* + * This file contains Windows only functions for 9pfs. + * + * For 9pfs Windows host, the following features are different from Linux host: + * + * 1. Windows POSIX API does not provide the NO_FOLLOW flag, that means MinGW + * cannot detect if a path is a symbolic link or not. Also Windows do not + * provide POSIX compatible readlink(). Supporting symbolic link in 9pfs on + * Windows may cause security issues, so symbolic link support is disabled + * completely for security model "none" or "passthrough". + * + * 2. Windows file system does not support extended attributes directly. 9pfs + * for Windows uses NTFS ADS (Alternate Data Streams) to emulate extended + * attributes. + * + * 3. statfs() is not available on Windows. qemu_statfs() is used to emulate it. + * + * 4. On Windows trying to open a directory with the open() API will fail. + * This is because Windows does not allow opening directory in normal usage. + * + * As a result of this, all xxx_at() functions won't work directly on + * Windows, e.g.: openat(), unlinkat(), etc. + * + * As xxx_at() can prevent parent directory to be modified on Linux host, + * to support this and prevent security issue, all xxx_at() APIs are replaced + * by xxx_at_win32(). + * + * 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 = strlen(filename) + strlen(ads_name) + 2; + if (total_size > namebuf_len) { + return -1; + } + + /* + * NTFS ADS (Alternate Data Streams) name format: filename:ads_name + * e.g.: D:\1.txt:my_ads_name + */ + + strcpy(namebuf, filename); + strcat(namebuf, ":"); + strcat(namebuf, ads_name); + + return 0; +} + +/* + * copy_ads_name - copy ADS name from buffer returned by FindNextStreamW() + * + * This function removes string "$DATA" in ADS name string returned by + * FindNextStreamW(), and copies the real ADS name to . + */ +static ssize_t copy_ads_name(char *namebuf, size_t namebuf_len, + char *full_ads_name) +{ + char *p1, *p2; + + /* + * NTFS ADS (Alternate Data Streams) name from enumerate data format: + * :ads_name:$DATA, e.g.: :my_ads_name:$DATA + * + * ADS name from FindNextStreamW() always has ":$DATA" string at the end. + * + * This function copies ADS name to namebuf. + */ + + p1 = strchr(full_ads_name, ':'); + if (p1 == NULL) { + return -1; + } + + p2 = strchr(p1 + 1, ':'); + if (p2 == NULL) { + return -1; + } + + /* skip empty ads name */ + if (p2 - p1 == 1) { + return 0; + } + + if (p2 - p1 + 1 > namebuf_len) { + return -1; + } + + memcpy(namebuf, p1 + 1, p2 - p1 - 1); + namebuf[p2 - p1 - 1] = '\0'; + + return p2 - p1; +} + +/* + * get_full_path_win32 - get full file name base on a handle + * + * This function gets full file name based on a handle specified by to + * a file or directory. + * + * Caller function needs to free the file name string after use. + */ +char *get_full_path_win32(HANDLE hDir, const char *name) +{ + g_autofree char *full_file_name = NULL; + DWORD total_size; + DWORD name_size; + + if (hDir == INVALID_HANDLE_VALUE) { + return NULL; + } + + full_file_name = g_malloc0(NAME_MAX); + + /* get parent directory full file name */ + name_size = GetFinalPathNameByHandle(hDir, full_file_name, + NAME_MAX - 1, FILE_NAME_NORMALIZED); + if (name_size == 0 || name_size > NAME_MAX - 1) { + return NULL; + } + + /* full path returned is the "\\?\" syntax, remove the lead string */ + memmove(full_file_name, full_file_name + 4, NAME_MAX - 4); + + if (name != NULL) { + total_size = strlen(full_file_name) + strlen(name) + 2; + + if (total_size > NAME_MAX) { + return NULL; + } + + /* build sub-directory file name */ + strcat(full_file_name, "\\"); + strcat(full_file_name, name); + } + + return g_steal_pointer(&full_file_name); +} + +/* + * fgetxattr_win32 - get extended attribute by fd + * + * This function gets extened attribute by . will be translated to + * Windows handle. + * + * This function emulates extended attribute by NTFS ADS. + */ +ssize_t fgetxattr_win32(int fd, const char *name, void *value, size_t size) +{ + g_autofree char *full_file_name = NULL; + char ads_file_name[NAME_MAX + 1] = {0}; + DWORD dwBytesRead; + HANDLE hStream; + HANDLE hFile; + + hFile = (HANDLE)_get_osfhandle(fd); + + full_file_name = get_full_path_win32(hFile, NULL); + if (full_file_name == NULL) { + errno = EIO; + return -1; + } + + if (build_ads_name(ads_file_name, NAME_MAX, full_file_name, name) < 0) { + errno = EIO; + return -1; + } + + hStream = CreateFile(ads_file_name, GENERIC_READ, FILE_SHARE_READ, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (hStream == INVALID_HANDLE_VALUE && + GetLastError() == ERROR_FILE_NOT_FOUND) { + errno = ENODATA; + return -1; + } + + if (ReadFile(hStream, value, size, &dwBytesRead, NULL) == FALSE) { + errno = EIO; + CloseHandle(hStream); + return -1; + } + + CloseHandle(hStream); + + return dwBytesRead; +} + +/* + * openat_win32 - emulate openat() + * + * This function emulates openat(). + * + * 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 flag. + * 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 = NULL; + g_autofree char *full_file_name2 = NULL; + HANDLE hFile; + HANDLE hDir = (HANDLE)_get_osfhandle(dirfd); + int fd; + + full_file_name1 = get_full_path_win32(hDir, pathname); + if (full_file_name1 == NULL) { + return -1; + } + + fd = open(full_file_name1, flags, mode); + if (fd > 0) { + DWORD attribute; + hFile = (HANDLE)_get_osfhandle(fd); + + full_file_name2 = get_full_path_win32(hFile, NULL); + attribute = GetFileAttributes(full_file_name2); + + /* check if it is a symbolic link */ + if ((attribute == INVALID_FILE_ATTRIBUTES) + || (attribute & FILE_ATTRIBUTE_REPARSE_POINT) != 0) { + errno = EACCES; + 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 = NULL; + HANDLE hFile = INVALID_HANDLE_VALUE; + HANDLE hDir = (HANDLE)_get_osfhandle(dirfd); + BY_HANDLE_FILE_INFORMATION file_info; + DWORD attribute; + int err = 0; + int ret = -1; + ino_t st_ino; + int is_symlink = 0; + + full_file_name = get_full_path_win32(hDir, pathname); + if (full_file_name == NULL) { + return ret; + } + + /* open file to lock it */ + hFile = CreateFile(full_file_name, GENERIC_READ, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, + NULL, + OPEN_EXISTING, + FILE_FLAG_BACKUP_SEMANTICS + | FILE_FLAG_OPEN_REPARSE_POINT, + NULL); + + if (hFile == INVALID_HANDLE_VALUE) { + err = win32_error_to_posix(GetLastError()); + goto out; + } + + attribute = GetFileAttributes(full_file_name); + + if (attribute == INVALID_FILE_ATTRIBUTES) { + err = EACCES; + goto out; + } + + /* check if it is a symbolic link */ + if ((attribute & FILE_ATTRIBUTE_REPARSE_POINT) != 0) { + is_symlink = 1; + } + + ret = stat(full_file_name, statbuf); + + if (GetFileInformationByHandle(hFile, &file_info) == 0) { + err = 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) == sizeof(uint64_t)) { + st_ino = (ino_t)((uint64_t)file_info.nFileIndexLow + | (((uint64_t)file_info.nFileIndexHigh) << 32)); + } else if (sizeof(st_ino) == sizeof(uint16_t)) { + st_ino = (ino_t)(((uint16_t)file_info.nFileIndexLow) + ^ ((uint16_t)(file_info.nFileIndexLow >> 16))); + } else { + st_ino = (ino_t)file_info.nFileIndexLow; + } + + statbuf->st_ino = st_ino; + + if (is_symlink == 1) { + /* force to set mode to 0, to prevent symlink access */ + statbuf->st_mode = 0; + + /* hide information */ + statbuf->st_atime = 0; + statbuf->st_mtime = 0; + statbuf->st_ctime = 0; + statbuf->st_size = 0; + } + +out: + if (hFile != INVALID_HANDLE_VALUE) { + CloseHandle(hFile); + } + + if (err != 0) { + errno = 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 = NULL; + int ret = -1; + HANDLE hDir = (HANDLE)_get_osfhandle(dirfd); + + full_file_name = get_full_path_win32(hDir, pathname); + if (full_file_name == NULL) { + return ret; + } + + ret = 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 = NULL; + g_autofree char *full_new_name = NULL; + HANDLE hFile; + HANDLE hOldDir = (HANDLE)_get_osfhandle(olddirfd); + HANDLE hNewDir = (HANDLE)_get_osfhandle(newdirfd); + DWORD attribute; + int err = 0; + int ret = -1; + + full_old_name = get_full_path_win32(hOldDir, oldpath); + full_new_name = get_full_path_win32(hNewDir, newpath); + if (full_old_name == NULL || full_new_name == NULL) { + return ret; + } + + /* open file to lock it */ + hFile = CreateFile(full_old_name, GENERIC_READ, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, + NULL, + OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); + + if (hFile == INVALID_HANDLE_VALUE) { + err = win32_error_to_posix(GetLastError()); + goto out; + } + + attribute = GetFileAttributes(full_old_name); + + /* check if it is a symbolic link */ + if ((attribute == INVALID_FILE_ATTRIBUTES) + || (attribute & FILE_ATTRIBUTE_REPARSE_POINT) != 0) { + err = EACCES; + goto out; + } + + CloseHandle(hFile); + + ret = rename(full_old_name, full_new_name); +out: + if (err != 0) { + errno = err; + } + return ret; +} + +/* + * utimensat_win32 - emulate utimensat() + * + * This function emulates utimensat(). + * + * 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 = NULL; + HANDLE hFile = INVALID_HANDLE_VALUE; + HANDLE hDir = (HANDLE)_get_osfhandle(dirfd); + DWORD attribute; + struct utimbuf tm; + int err = 0; + int ret = -1; + + full_file_name = get_full_path_win32(hDir, pathname); + if (full_file_name == NULL) { + return ret; + } + + /* open file to lock it */ + hFile = CreateFile(full_file_name, GENERIC_READ, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, + NULL, + OPEN_EXISTING, + FILE_FLAG_BACKUP_SEMANTICS + | FILE_FLAG_OPEN_REPARSE_POINT, + NULL); + + if (hFile == INVALID_HANDLE_VALUE) { + err = win32_error_to_posix(GetLastError()); + goto out; + } + + attribute = GetFileAttributes(full_file_name); + + /* check if it is a symbolic link */ + if ((attribute == INVALID_FILE_ATTRIBUTES) + || (attribute & FILE_ATTRIBUTE_REPARSE_POINT) != 0) { + errno = EACCES; + goto out; + } + + tm.actime = times[0].tv_sec; + tm.modtime = times[1].tv_sec; + + ret = utime(full_file_name, &tm); + +out: + if (hFile != INVALID_HANDLE_VALUE) { + CloseHandle(hFile); + } + + if (err != 0) { + errno = err; + } + return ret; +} + +/* + * unlinkat_win32 - emulate unlinkat() + * + * This function emulates unlinkat(). + * + * 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 = NULL; + HANDLE hFile; + HANDLE hDir = (HANDLE)_get_osfhandle(dirfd); + DWORD attribute; + int err = 0; + int ret = -1; + + full_file_name = get_full_path_win32(hDir, pathname); + if (full_file_name == 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 = CreateFile(full_file_name, GENERIC_READ, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, + NULL, + OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); + + if (hFile == INVALID_HANDLE_VALUE) { + err = win32_error_to_posix(GetLastError()); + goto out; + } + + attribute = GetFileAttributes(full_file_name); + + /* check if it is a symbolic link */ + if ((attribute == INVALID_FILE_ATTRIBUTES) + || (attribute & FILE_ATTRIBUTE_REPARSE_POINT) != 0) { + err = EACCES; + goto out; + } + + if (flags == AT_REMOVEDIR) { /* remove directory */ + if ((attribute & FILE_ATTRIBUTE_DIRECTORY) == 0) { + err = ENOTDIR; + goto out; + } + ret = rmdir(full_file_name); + } else { /* remove regular file */ + if ((attribute & FILE_ATTRIBUTE_DIRECTORY) != 0) { + err = EISDIR; + goto out; + } + ret = remove(full_file_name); + } + + /* after last handle closed, file will be removed */ + CloseHandle(hFile); + +out: + if (err != 0) { + errno = err; + } + return ret; +} + +/* + * statfs_win32 - statfs() on Windows + * + * This function emulates statfs() on Windows host. + */ +int statfs_win32(const char *path, struct statfs *stbuf) +{ + char RealPath[4] = { 0 }; + unsigned long SectorsPerCluster; + unsigned long BytesPerSector; + unsigned long NumberOfFreeClusters; + unsigned long TotalNumberOfClusters; + + /* only need first 3 bytes, e.g. "C:\ABC", only need "C:\" */ + memcpy(RealPath, path, 3); + + if (GetDiskFreeSpace(RealPath, &SectorsPerCluster, &BytesPerSector, + &NumberOfFreeClusters, &TotalNumberOfClusters) == 0) { + errno = EIO; + return -1; + } + + stbuf->f_type = V9FS_MAGIC; + stbuf->f_bsize = + (__fsword_t)SectorsPerCluster * (__fsword_t)BytesPerSector; + stbuf->f_blocks = (fsblkcnt_t)TotalNumberOfClusters; + stbuf->f_bfree = (fsblkcnt_t)NumberOfFreeClusters; + stbuf->f_bavail = (fsblkcnt_t)NumberOfFreeClusters; + stbuf->f_files = -1; + stbuf->f_ffree = -1; + stbuf->f_namelen = NAME_MAX; + stbuf->f_frsize = 0; + stbuf->f_flags = 0; + + return 0; +} + +/* + * openat_dir - emulate openat_dir() + * + * This function emulates openat_dir(). + * + * 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 = NULL; + HANDLE hSubDir; + HANDLE hDir = (HANDLE)_get_osfhandle(dirfd); + DWORD attribute; + + full_file_name = get_full_path_win32(hDir, name); + if (full_file_name == NULL) { + return -1; + } + + attribute = GetFileAttributes(full_file_name); + if (attribute == INVALID_FILE_ATTRIBUTES) { + return -1; + } + + /* check if it is a directory */ + if ((attribute & FILE_ATTRIBUTE_DIRECTORY) == 0) { + return -1; + } + + /* do not allow opening a symbolic link */ + if ((attribute & FILE_ATTRIBUTE_REPARSE_POINT) != 0) { + return -1; + } + + /* open it */ + hSubDir = CreateFile(full_file_name, GENERIC_READ, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, + NULL, + OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); + return _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 = NULL; + char ads_file_name[NAME_MAX + 1] = { 0 }; + DWORD dwBytesRead; + HANDLE hStream; + HANDLE hDir = (HANDLE)_get_osfhandle(dirfd); + + full_file_name = get_full_path_win32(hDir, path); + if (full_file_name == NULL) { + errno = EIO; + return -1; + } + + if (build_ads_name(ads_file_name, NAME_MAX, full_file_name, name) < 0) { + errno = EIO; + return -1; + } + + hStream = CreateFile(ads_file_name, GENERIC_READ, FILE_SHARE_READ, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (hStream == INVALID_HANDLE_VALUE && + GetLastError() == ERROR_FILE_NOT_FOUND) { + errno = ENODATA; + return -1; + } + + if (ReadFile(hStream, value, size, &dwBytesRead, NULL) == FALSE) { + errno = EIO; + CloseHandle(hStream); + return -1; + } + + CloseHandle(hStream); + + return dwBytesRead; +} + +/* + * fsetxattrat_nofollow - set extended attribute + * + * This function 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 = NULL; + char ads_file_name[NAME_MAX + 1] = { 0 }; + DWORD dwBytesWrite; + HANDLE hStream; + HANDLE hDir = (HANDLE)_get_osfhandle(dirfd); + + full_file_name = get_full_path_win32(hDir, path); + if (full_file_name == NULL) { + errno = EIO; + return -1; + } + + if (build_ads_name(ads_file_name, NAME_MAX, full_file_name, name) < 0) { + errno = EIO; + return -1; + } + + hStream = CreateFile(ads_file_name, GENERIC_WRITE, FILE_SHARE_READ, NULL, + CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + if (hStream == INVALID_HANDLE_VALUE) { + errno = EIO; + return -1; + } + + if (WriteFile(hStream, value, size, &dwBytesWrite, NULL) == FALSE) { + errno = EIO; + CloseHandle(hStream); + return -1; + } + + CloseHandle(hStream); + + return 0; +} + +/* + * flistxattrat_nofollow - list extended attribute + * + * This function gets extended attribute lists from file in the + * directory specified by . Lists returned will be put in . + * + * This function emulates extended attribute by NTFS ADS. + */ +ssize_t flistxattrat_nofollow(int dirfd, const char *filename, + char *list, size_t size) +{ + g_autofree char *full_file_name = NULL; + WCHAR WideCharStr[NAME_MAX + 1] = { 0 }; + char full_ads_name[NAME_MAX + 1]; + WIN32_FIND_STREAM_DATA fsd; + BOOL bFindNext; + char *list_ptr = list; + size_t list_left_size = size; + HANDLE hFind; + HANDLE hDir = (HANDLE)_get_osfhandle(dirfd); + int ret; + + full_file_name = get_full_path_win32(hDir, filename); + if (full_file_name == NULL) { + errno = EIO; + return -1; + } + + /* + * ADS enumerate function only has WCHAR version, so we need to + * covert filename to utf-8 string. + */ + ret = MultiByteToWideChar(CP_UTF8, 0, full_file_name, + strlen(full_file_name), WideCharStr, NAME_MAX); + if (ret == 0) { + errno = EIO; + return -1; + } + + hFind = FindFirstStreamW(WideCharStr, FindStreamInfoStandard, &fsd, 0); + if (hFind == INVALID_HANDLE_VALUE) { + errno = ENODATA; + return -1; + } + + do { + memset(full_ads_name, 0, sizeof(full_ads_name)); + + /* + * ADS enumerate function only has WCHAR version, so we need to + * covert cStreamName to utf-8 string. + */ + ret = WideCharToMultiByte(CP_UTF8, 0, + fsd.cStreamName, wcslen(fsd.cStreamName) + 1, + full_ads_name, sizeof(full_ads_name) - 1, + NULL, NULL); + if (ret == 0) { + if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) { + errno = ERANGE; + } + CloseHandle(hFind); + return -1; + } + + ret = copy_ads_name(list_ptr, list_left_size, full_ads_name); + if (ret < 0) { + errno = ERANGE; + CloseHandle(hFind); + return -1; + } + + list_ptr = list_ptr + ret; + list_left_size = list_left_size - ret; + + bFindNext = FindNextStreamW(hFind, &fsd); + } while (bFindNext); + + CloseHandle(hFind); + + return size - list_left_size; +} + +/* + * fremovexattrat_nofollow - remove extended attribute + * + * This function removes an extended attribute from file in the + * directory specified by . + * + * This function emulates extended attribute by NTFS ADS. + */ +ssize_t fremovexattrat_nofollow(int dirfd, const char *filename, + const char *name) +{ + g_autofree char *full_file_name = NULL; + char ads_file_name[NAME_MAX + 1] = { 0 }; + HANDLE hDir = (HANDLE)_get_osfhandle(dirfd); + + full_file_name = get_full_path_win32(hDir, filename); + if (full_file_name == NULL) { + errno = EIO; + return -1; + } + + if (build_ads_name(ads_file_name, NAME_MAX, filename, name) < 0) { + errno = EIO; + return -1; + } + + if (DeleteFile(ads_file_name) != 0) { + if (GetLastError() == ERROR_FILE_NOT_FOUND) { + errno = ENODATA; + return -1; + } + } + + return 0; +} + +/* + * local_opendir_nofollow - open a Windows directory + * + * This function returns a 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 = NULL; + LocalData *data = fs_ctx->private; + HANDLE hDir; + int dirfd; + + dirfd = openat_dir(data->mountfd, dirpath); + if (dirfd == -1) { + return -1; + } + hDir = (HANDLE)_get_osfhandle(dirfd); + + full_file_name = get_full_path_win32(hDir, NULL); + if (full_file_name == 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)) != 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 = openat_file(dirfd, filename, O_CREAT, mode); + if (fd == -1) { + return -1; + } + close_preserve_errno(fd); + return 0; + } + + error_report_once("Unsupported operation for mknodat"); + errno = ENOTSUP; + return -1; +} From patchwork Mon Feb 20 10:08:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13146224 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A2408C636CC for ; Mon, 20 Feb 2023 10:09:22 +0000 (UTC) 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 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== 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 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 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 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> 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: GXmjM0xmddb/69u8QFRmf94YSbEKd6eqi2073+1rziQIWlR8otzf2pinMCMcMGB4+IlTeBcbduISslAyZqnj408jkQpGR5CiOzkMyPnKipOyosQZ3D0EUNFwds79uU74xowEBF76CXs0mGSQGlB/Sh/6JxypBg1OvdK4zIkjImoLuwMTURm7d5yiHLpw1vVaeorHRKmsilbjmqskqvW7gP5sIqQfKTKtFoc5PdvfbMpXsHrznylQeKGR4pbwXlEbh8xJzOhW4ZUS1MaxEZxSkEMuKgDDdLlhqZlJ91LRRsfs5r3F54gS8MLreB90KSTGLZdpsxyuDCO3Vt+vwp+TPUCJRZ/KKXjnCrud2uyRHek+ypNzsL405UkfGADVEzuOFcOEN5NYt4dTdHbHFHtTiEnHOx1JXyG/uf/zOqE5iVnF3h0vtjHN9RWCJweQQVQboTBJ7D9hBIpw+S/8jvzajg0clb2EZztCwLSgJk5h4/dfpVfBYJDUxICHp90Os1hMNVqkUHc840Z3moNHuWSqlxuvN0uMhYPCo40GHD2duV3SOuUk2Nm4zJZsCsUnpgVQwArcCimHw9TeS48ixfGmVnnDTHClKq515arvmLxa+dKHkGGTraJrfZ7u0amTlya3PwRX20iQGguPlNXClwOp4rM6EInsSySwTyynYbew484hRNRXQkSHlPF4C00VQIBWBaYFlLRRpC7fPyu3e8TGwa2rIyX0o1xEFVnrUFk+ba9Rne7a1P2MBApUECrKCQOXYBy7SMe44zXHIep4RcRwba/ATHmpEkL49neb5tX+rKwO1jaUYbNtQVdwzX5Upa+FisWIiWgZE7il14hpW5zssoo+3fIICPuf0XYTvPMfjvzEUx6aQHXB0jXgw/Kv82EvkRnWIXLdELnBKqugYWbpPb3XKL8DMLkdYn+2okVMigAnN1Xm0Zreu59KGArly7BcLYP9GoLKJ4QmXV5l1Wqdv3RWQo4RC7W282i3H6I0pxO/5p27tRhapzgsIK7XnKelLXYzJ/N5oT+3rowtKK/Myqxc82RwyU9fviV7cijyw8XiTT3KRhmksSma0PAkCXV8xYquCsM6Hm47UAKD4JeC4a+ji6Wtcnqmh5z6pTx0WNnLSZAwXbfkoRXyOz13BJQxzD1J75IE2oKPFsfHwO7ASbZ7clXHK7JPmVOp1Bmhnpjmq/vG/YW83qd3KthSRY18N1ccs/i1v3ExN0uh+U6HYn5ig+UNml7sC91f0G28cw7vi5OP//9PL9vv7+InRaJP8lsX8a1B1LCflUfJiUiVXz20HBZsdwEDDK8Fvbr123t6zrWYi9mCA/mUukmqPxoARU530AsJLdt+2U83/+x9vYO6bPKNHcHZVR4I8N+WRvM0PJ3wELBSP6v3z7waS0ZGsU6z+q7027v8mQGCHMJN7pawuAUpXDYBhAtWgxQIf2FGEHzfXaUlHyknw6SIZRaq/ZHAfJ/0hl2nmhEH4K+rE8ayoC8R1UQOtoOEwhgUTgNPkinjJ3ZcW9tqM/tf15p5WGmTA0qWc9E0EotVVb61QC568ucTtauPw9kSSod+3ZsPnvFNhUi0M5LrXYp3G3evkyn720pKhqUoCxW9O6LOCQ== 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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 #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) static int local_closedir(FsContext *ctx, V9fsFidOpenState *fs) { - return closedir(fs->dir.stream); + return qemu_closedir(fs->dir.stream); } static int local_open(FsContext *ctx, V9fsPath *fs_path, @@ -533,12 +533,12 @@ static int local_opendir(FsContext *ctx, static void local_rewinddir(FsContext *ctx, V9fsFidOpenState *fs) { - rewinddir(fs->dir.stream); + qeme_rewinddir(fs->dir.stream); } static off_t local_telldir(FsContext *ctx, V9fsFidOpenState *fs) { - return telldir(fs->dir.stream); + return qemu_telldir(fs->dir.stream); } static bool local_is_mapped_file_metadata(FsContext *fs_ctx, const char *name) @@ -552,13 +552,13 @@ static struct dirent *local_readdir(FsContext *ctx, V9fsFidOpenState *fs) struct dirent *entry; again: - entry = readdir(fs->dir.stream); + entry = qemu_readdir(fs->dir.stream); if (!entry) { return NULL; } #ifdef CONFIG_DARWIN int off; - off = telldir(fs->dir.stream); + off = qemu_telldir(fs->dir.stream); /* If telldir fails, fail the entire readdir call */ if (off < 0) { return NULL; @@ -581,7 +581,7 @@ again: static void local_seekdir(FsContext *ctx, V9fsFidOpenState *fs, off_t off) { - seekdir(fs->dir.stream, off); + qemu_seekdir(fs->dir.stream, off); } static ssize_t local_preadv(FsContext *ctx, V9fsFidOpenState *fs, From patchwork Mon Feb 20 10:08:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13146238 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A689AC636CC for ; Mon, 20 Feb 2023 10:14:37 +0000 (UTC) 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 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== 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 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 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 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> 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: IqBSAAIVsqHP4BV7JGxB59U+QoCGCSN8d/5ZvJePD9tLbdqSGybkXTJrtvCGcR8rZU6IvWUS//DIH3WH+iA8Z3ATXMFONX9Zx68ujZDziqrE9zPEt6C+w4nZL5XVb21mlIL7+rCIjYHINFLL8kbIIS0x18znXLIfzAwy+34eKR2ofkUujxRzYt5u6oKdhWs3KhcS9I0kXxxPrqlCXq0y5gPOOJakoVAjhaHYR+GpT8y/UOv0Xwe/WxVCEa1uCydi4I0HbPuGaom+b3JXwwl3kZMv8pZLylBWB8pCepw9KhKdjWgot3cH2xb+My5TvavPTLlbUquGT7s+Wy/66opFjZupU7v6TLiLJ/oHViLIDfacPT3HvBLhvpvPiyJU3nTfej4+pS5l6v1Nw85VUHCGXGAzsGQ24z8Odq5YoxE5MUltNzAfqmQV0yb57C0q4JoxtkzgPAWexF1t+8mCFYxiK7kbxeVwpp9XplVcrIXdsoDpQriR++1w9HK6CpLxmXbfcQI3Ob/HAi1b+jFWshikuZmFfVGOrRMXHl1TzlRScg5Fh11bMwxPZMxjW49Qa2v5TPbrsAslhVywVaz32FJq/jLqUqhrfbsFQZGG9s5/RsqWmq1HL4QlqB0GrgYJVJn0zQOrhepP3LbT+sVYkmibPCRyDykO5RXks+BKS5hIH0i5EaIgpYx1vOnBReYM+BT7MrfXYS8DyWpsPbZqW6Mtj/mPxQOZLtoB9svXbO1q+Ly1mZgfwviLOhwG0KIgEwR+vuX+7hC5ujWUlh8LzBAxJtXDwDaDNpBORWHzWL97hqvL9mpdnj6lne5qIOyfMXAMcdJ6A0CrbsijmEXSe4fCIxtBxbDjKsGtl17B8r77JEMFJGByZqYbKuCoyu6Fwik7o14sGyEMhr4yDepB5bmL4MzUK9Mcwds7aZ2EBaBd6bgGi1JkxeM9vnWBRV4svOk+LdAy8VIxwlXatGh4dpb41xdpYhPszEODudgLppaGtUSTHl8vypx7shBrKwd+ABtfD+lL6RNjWyhj6Sx3C3lEDcrFVYcwR3jmLnsddQF/Adb72PJzavktt5tTIQ557P6Ef9lLP2vsS17GATrPQqXZVd/ClMMhhSdDRfbP3cYjV1qkBuoL0ThSi60bUrobdohuwyAc6a8A5VF7aoZE2MIkySL5usR8ZYZ91UEEeYfW/ZUe+ZxZ9kfK264Q88+KcLNdTDQjihTYVMEPN6mzcfgWaS82ReHt4hwdZ9O2fdp70gk9oKV/QOSVfmD0mD5aJuH/kO+Lo8sFIIPXo9HHUgOKdm4HKi3yZWp4f23jkZ7MnNQBiXRaXCwJzzPqGeAuxyHnrvvobXMMVYX7TtVXAclikTqv4SLqayyMqGdbBeixTVslajah20eDaWxz/HU44yrZjsTlYi3ffbvATX+ZO2xknkXQussdUJZlgSTmCSpUvzek2Im3XBJYRXE8swecEnzY/7VX2MlHmwb89ONVho1Qu9Sqih7J9ivPm1a9vKSNopgpKt3nI6vAydYWb/x7oWrYWEAwHI/mR54y35lGtGzWf3szAi6Se59Gi2hH7rpGUjSE7AIt83HQgraUvNioDLfphp+zrdO/dOxAMT9H9mv4Ug== 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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, 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); +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 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 API 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 happens + * with deleted or newly created directories in between, but it guarantees a + * consistent state. */ #include "qemu/osdep.h" @@ -51,6 +61,25 @@ #define V9FS_MAGIC 0x53465039 /* string "9PFS" */ +/* + * MinGW and Windows does not provide a safe way to seek directory while other + * 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, mode_t mode, dev_t dev) errno = ENOTSUP; return -1; } + +static int file_id_compare(const void *id_ptr1, const void *id_ptr2) +{ + uint64_t id[2]; + + id[0] = *(uint64_t *)id_ptr1; + id[1] = *(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 = INVALID_HANDLE_VALUE; + char *entry_name; + char *entry_start; + FILE_ID_DESCRIPTOR fid; + DWORD attribute; + + if (stream->file_id_list[stream->offset] == stream->dot_id) { + strcpy(stream->dd_dir.d_name, "."); + return 0; + } + + if (stream->file_id_list[stream->offset] == stream->dot_dot_id) { + strcpy(stream->dd_dir.d_name, ".."); + return 0; + } + + fid.dwSize = sizeof(fid); + fid.Type = FileIdType; + + fid.FileId.QuadPart = stream->file_id_list[stream->offset]; + + hDirEntry = 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 == INVALID_HANDLE_VALUE) { + /* + * Not open it successfully, it may be deleted. + * Try next id. + */ + return -1; + } + + entry_name = get_full_path_win32(hDirEntry, NULL); + + CloseHandle(hDirEntry); + + if (entry_name == NULL) { + return -1; + } + + attribute = GetFileAttributes(entry_name); + + /* symlink is not allowed */ + if (attribute == INVALID_FILE_ATTRIBUTES + || (attribute & FILE_ATTRIBUTE_REPARSE_POINT) != 0) { + return -1; + } + + if (memcmp(entry_name, stream->dd_name, stream->dir_name_len) != 0) { + /* + * The full entry file name should be a part of parent directory name, + * except dot and dot_dot (is already handled). + * If not, this entry should not be returned. + */ + return -1; + } + + entry_start = entry_name + stream->dir_name_len; + + /* skip slash */ + while (*entry_start == '\\') { + entry_start++; + } + + if (strchr(entry_start, '\\') != NULL) { + return -1; + } + + if (strlen(entry_start) == 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 = INVALID_HANDLE_VALUE; + HANDLE hDirEntry = INVALID_HANDLE_VALUE; + char *full_dir_entry = NULL; + DWORD attribute; + intptr_t dd_handle = -1; + struct _finddata_t dd_data; + uint64_t file_id; + uint64_t *file_id_list = NULL; + BY_HANDLE_FILE_INFORMATION FileInfo; + struct dir_win32 *stream = NULL; + int err = 0; + int find_status; + int sort_first_two_entry = 0; + uint32_t list_count = 16; + uint32_t index = 0; + + /* open directory to prevent it being removed */ + + hDir = CreateFile(full_file_name, GENERIC_READ, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, + NULL, + OPEN_EXISTING, + FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT, + NULL); + + if (hDir == INVALID_HANDLE_VALUE) { + err = win32_error_to_posix(GetLastError()); + goto out; + } + + attribute = GetFileAttributes(full_file_name); + + /* symlink is not allow */ + if (attribute == INVALID_FILE_ATTRIBUTES + || (attribute & FILE_ATTRIBUTE_REPARSE_POINT) != 0) { + err = EACCES; + goto out; + } + + /* check if it is a directory */ + if ((attribute & FILE_ATTRIBUTE_DIRECTORY) == 0) { + err = ENOTDIR; + goto out; + } + + file_id_list = g_malloc0(sizeof(uint64_t) * list_count); + + /* + * findfirst() needs suffix format name like "\dir1\dir2\*", + * allocate more buffer to store suffix. + */ + stream = g_malloc0(sizeof(struct dir_win32) + strlen(full_file_name) + 3); + + strcpy(stream->dd_name, full_file_name); + strcat(stream->dd_name, "\\*"); + + stream->hDir = hDir; + stream->dir_name_len = strlen(full_file_name); + + dd_handle = _findfirst(stream->dd_name, &dd_data); + + if (dd_handle == -1) { + err = errno; + goto out; + } + + /* read all entries to link list */ + do { + full_dir_entry = get_full_path_win32(hDir, dd_data.name); + + if (full_dir_entry == NULL) { + err = ENOMEM; + break; + } + + /* + * Open every entry and get the file informations. + * + * Skip symbolic links during reading directory. + */ + hDirEntry = 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 != INVALID_HANDLE_VALUE) { + if (GetFileInformationByHandle(hDirEntry, + &FileInfo) == TRUE) { + attribute = FileInfo.dwFileAttributes; + + /* only save validate entries */ + if ((attribute & FILE_ATTRIBUTE_REPARSE_POINT) == 0) { + if (index >= list_count) { + list_count = list_count + 16; + file_id_list = g_realloc(file_id_list, + sizeof(uint64_t) + * list_count); + } + file_id = (uint64_t)FileInfo.nFileIndexLow + + (((uint64_t)FileInfo.nFileIndexHigh) << 32); + + + file_id_list[index] = file_id; + + if (strcmp(dd_data.name, ".") == 0) { + stream->dot_id = file_id_list[index]; + if (index != 0) { + sort_first_two_entry = 1; + } + } else if (strcmp(dd_data.name, "..") == 0) { + stream->dot_dot_id = file_id_list[index]; + if (index != 1) { + sort_first_two_entry = 1; + } + } + index++; + } + } + CloseHandle(hDirEntry); + } + g_free(full_dir_entry); + find_status = _findnext(dd_handle, &dd_data); + } while (find_status == 0); + + if (errno == ENOENT) { + /* No more matching files could be found, clean errno */ + errno = 0; + } else { + err = errno; + goto out; + } + + stream->total_entries = index; + stream->file_id_list = file_id_list; + + if (sort_first_two_entry == 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_compare); + } else { + qsort(&file_id_list[0], index, sizeof(file_id), file_id_compare); + } + +out: + if (err != 0) { + errno = err; + if (stream != NULL) { + if (file_id_list != NULL) { + g_free(file_id_list); + } + CloseHandle(hDir); + g_free(stream); + stream = NULL; + } + } + + if (dd_handle != -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 = (struct dir_win32 *)pDir; + + if (stream == NULL) { + errno = 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 = (struct dir_win32 *)pDir; + + if (stream == NULL) { + errno = EBADF; + return NULL; + } + +retry: + + if (stream->offset >= stream->total_entries) { + /* reach to the end, return NULL without set errno */ + return NULL; + } + + if (get_next_entry(stream) != 0) { + stream->offset++; + goto retry; + } + + /* Windows does not provide inode number */ + stream->dd_dir.d_ino = 0; + stream->dd_dir.d_reclen = 0; + stream->dd_dir.d_namlen = 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 = (struct dir_win32 *)pDir; + + if (stream == NULL) { + errno = EBADF; + return; + } + + stream->offset = 0; + + return; +} + +/* + * seekdir_win32 - set the position of the next readdir() call in the directory + * + * This function sets the position of the next readdir() call in the directory + * from which the next readdir() call will start. + */ +void seekdir_win32(DIR *pDir, long pos) +{ + struct dir_win32 *stream = (struct dir_win32 *)pDir; + + if (stream == NULL) { + errno = EBADF; + return; + } + + if (pos < -1) { + errno = EINVAL; + return; + } + + if (pos == -1 || pos >= (long)stream->total_entries) { + /* seek to the end */ + stream->offset = stream->total_entries; + return; + } + + if (pos - (long)stream->offset == 0) { + /* no need to seek */ + return; + } + + stream->offset = 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 = (struct dir_win32 *)pDir; + + if (stream == NULL) { + errno = EBADF; + return -1; + } + + if (stream->offset > stream->total_entries) { + return -1; + } + + return (long)stream->offset; +} From patchwork Mon Feb 20 10:08:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13146225 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A65A9C6379F for ; Mon, 20 Feb 2023 10:09:22 +0000 (UTC) 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 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== 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 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 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 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> 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: Emgm8abtD28RIGX9CsZGLmeQboJmEWcLGWKdJ6XEQuCq5q869hdgnPM4k8uTuJIepIDJZC/g5svSVR02HXGF4bJJo37HWDC6wRemcuOn26WGZ70kmPKJVl726aXJfJmHP5rsl1jXFc84Cf95mJsHQLtm4MhUql9LLrgKlOqfgU22azjcQhvOluYIIAc0D0A0rF2k+nioo1pzTc9cXcbAmGQ8WUfxkTIaglxWIHOfIuVEW5dGRZJVj5CAahY6wbgro/crNwQP9BqQl1azFe89uK/cM+VUj5H2hou9MslWVLvnUaaXnx9XsNSyeP6MIslzNy1hqq2mmQudcr0ktndiZll5MaEc+Z8hEmmFTL+yBrjKjIIVfOjAWUG7cXmLnhe4QqUFVQoejgRR7p3MUYBYSW/e9quiAQmeMbN3K+Nx3q+tQNyTnW9+8c48rI9HwT06OMCvxOKayva8vnr3RuwMwxqGCxNxMqzak7m368GUYHbXFr8Aoq73GIOtkkQqV48hsl3ES8gsdIyhIfhJK9F3eJfDpqq/3qAtughVi8rLiBQh3PW3wfZtWUNsftHo/1WeENCnSfKqt6uzhgisa7FwS7wqmbkue99WSUOuJJ9dl2iWmsRgSmncaHUiEScE51dxlLPd+yavyd5RHB6C+NE5s5bNTJrLGpvYkkPOE+b0YnYQoJw+P1Mhs7qiWttzL6rAP7YuaWsIbjnPDdxSCXVEzV7bsfaPk6z0C7uhk3CTFaVEVFgg6Co725p5fCFViGSRuGuBfW/JoAuTAv5Mgf7W688RxpknkPvlDruKXNRgCXXah04ay21ZvlYUpxTn325O823dK2YwJZxVTkc71wExgg2mBoVX8TIzNXKU5WwgF7qXM5ELciZyX5fHiN0ezxRhkjgQkxKiYGaCIZA/J1w+tkD8TQVfX2sPohq+rxILhQkLfGgTOe3Lk+fgY33Pn6kWWtPYzsI3nUH1iYphp7a3SHNUSpsN4yO/IU3nk6Jf8sNHPxMVcMPZ5y1sinsa4mo/60ljNAtl+p+J009KLugxRgbwU3oJAn7LAHAppEG/f/E0MBSs9uRGpbSqfT8tM6ZhBeKhL62xfqmvQsBk9pHGR5/yndJLagVTjT6ASpfAaBXRkdWojqbZ99rXTHFW2GQgweuznjuenT2ctBPEPdn2tnneHZWtZ4x0IfjhN1ZqPvFaTMi0lA8+klcv3ddCrXsl07vePIUROrbhpCZI37/vQLPcu6mJxDlABaEx9hmyw+2PvgrrQO8v6RRD9xDPSrLEmxjWk3icr7ToRVzt4bffUddPFSWoWiVFXTuJsOOb9dsc2VncCfQGHD8MOOh8gh5YKXk/LY3c6hbEQNiLnfyCfygHwSyHdMU/GUlS3U8zmltXsAbMvXnpTH5I7cdRWPGtX+ohNoWagbNA2u0UQ0odGd3j24gQPnLqdfXycmtwyLmH1WSMpJ2a2w9CTaG7JQrKqnGXVBFMAneAv4yHFA4RCeD3RabHNOZyjpmBqmuIpOlKR8DCB5Gd3OHcHLp1kjFwZAQQAO8UbAQyMp1mC1RyXIMq43/dKzXXJxZ/szXQALSUZpgxF4N72MXSKHopgC3d0B0Qmo59MINiF0vaLpkcOg== 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Guohuai Shi Update the 9p 'local' file system driver to support Windows, including open, read, write, close, rename, remove, etc. All security models are supported. The mapped (mapped-xattr) security model is implemented using NTFS Alternate Data Stream (ADS) so the 9p export path shall be on an NTFS partition. Symbolic link and hard link are not supported when security model is "passthrough" or "none", because Windows NTFS does not fully support them with POSIX compatibility. Symbolic link is enabled when security model is "mapped-file" or "mapped-xattr". inode remap is always enabled because Windows file system does not provide a compatible inode number. mknod() is not supported because Windows does not support it. chown() and chmod() are not supported when 9pfs is configured with security mode to 'none' or 'passthrough' because Windows host does not support such type request. Signed-off-by: Guohuai Shi Signed-off-by: Bin Meng --- 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; 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 #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; } +#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 static void renameat_preserve_errno(int odirfd, const char *opath, int ndirfd, const char *npath) @@ -236,7 +242,7 @@ static int local_set_mapped_file_attrat(int dirfd, const char *name, int ret; char buf[ATTR_MAX]; int uid = -1, gid = -1, mode = -1, rdev = -1; - int map_dirfd = -1, map_fd; + int map_dirfd = -1; bool is_root = !strcmp(name, "."); if (is_root) { @@ -300,10 +306,12 @@ update_map_file: return -1; } - map_fd = fileno(fp); +#ifndef CONFIG_WIN32 + int map_fd = fileno(fp); assert(map_fd != -1); ret = fchmod(map_fd, 0600); assert(ret == 0); +#endif if (credp->fc_uid != -1) { uid = credp->fc_uid; @@ -335,6 +343,7 @@ update_map_file: return 0; } +#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 *name, mode_t mode) close_preserve_errno(fd); return ret; } +#endif 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 *path, FsCred *credp) return 0; } +#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, return fchmodat_nofollow(dirfd, name, credp->fc_mode & 07777); } +#endif static ssize_t local_readlink(FsContext *fs_ctx, V9fsPath *fs_path, char *buf, size_t bufsz) @@ -470,6 +482,12 @@ static ssize_t local_readlink(FsContext *fs_ctx, V9fsPath *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 = ENOTSUP; + error_report_once("readlink is not available on Windows host when" + "security_model is \"none\" or \"passthrough\""); + tsize = -1; +#else char *dirpath = g_path_get_dirname(fs_path->data); char *name = g_path_get_basename(fs_path->data); int dirfd; @@ -484,6 +502,7 @@ static ssize_t local_readlink(FsContext *fs_ctx, V9fsPath *fs_path, out: g_free(name); g_free(dirpath); +#endif } return tsize; } @@ -522,9 +541,31 @@ static int local_opendir(FsContext *ctx, return -1; } +#ifdef CONFIG_WIN32 + char *full_file_name; + + HANDLE hDir = (HANDLE)_get_osfhandle(dirfd); + + full_file_name = get_full_path_win32(hDir, NULL); + + close(dirfd); + + if (full_file_name == NULL) { + return -1; + } + stream = qemu_opendir(full_file_name); + g_free(full_file_name); +#else stream = fdopendir(dirfd); +#endif + if (!stream) { +#ifndef CONFIG_WIN32 + /* + * dirfd is closed always in above code, so no need to close it here. + */ close(dirfd); +#endif return -1; } fs->dir.stream = stream; @@ -567,13 +608,17 @@ again: #endif if (ctx->export_flags & V9FS_SM_MAPPED) { +#ifndef CONFIG_WIN32 entry->d_type = DT_UNKNOWN; +#endif } else if (ctx->export_flags & V9FS_SM_MAPPED_FILE) { if (local_is_mapped_file_metadata(ctx, entry->d_name)) { /* skip the meta data */ goto again; } +#ifndef CONFIG_WIN32 entry->d_type = DT_UNKNOWN; +#endif } return entry; @@ -647,7 +692,14 @@ static int local_chmod(FsContext *fs_ctx, V9fsPath *fs_path, FsCred *credp) ret = local_set_mapped_file_attrat(dirfd, name, credp); } else if (fs_ctx->export_flags & V9FS_SM_PASSTHROUGH || fs_ctx->export_flags & V9FS_SM_NONE) { +#ifdef CONFIG_WIN32 + errno = ENOTSUP; + error_report_once("chmod is not available on Windows host when" + "security_model is \"none\" or \"passthrough\""); + ret = -1; +#else ret = fchmodat_nofollow(dirfd, name, credp->fc_mode); +#endif } close_preserve_errno(dirfd); @@ -691,6 +743,12 @@ static int local_mknod(FsContext *fs_ctx, V9fsPath *dir_path, } } else if (fs_ctx->export_flags & V9FS_SM_PASSTHROUGH || fs_ctx->export_flags & V9FS_SM_NONE) { +#ifdef CONFIG_WIN32 + errno = ENOTSUP; + error_report_once("mknod is not available on Windows host when" + "security_model is \"none\" or \"passthrough\""); + goto out; +#else err = qemu_mknodat(dirfd, name, credp->fc_mode, credp->fc_rdev); if (err == -1) { goto out; @@ -699,6 +757,7 @@ static int local_mknod(FsContext *fs_ctx, V9fsPath *dir_path, if (err == -1) { goto err_end; } +#endif } goto out; @@ -748,10 +807,12 @@ static int local_mkdir(FsContext *fs_ctx, V9fsPath *dir_path, if (err == -1) { goto out; } +#ifndef CONFIG_WIN32 err = local_set_cred_passthrough(fs_ctx, dirfd, name, credp); if (err == -1) { goto err_end; } +#endif } goto out; @@ -768,7 +829,12 @@ static int local_fstat(FsContext *fs_ctx, int fid_type, int err, fd; if (fid_type == P9_FID_DIR) { +#ifdef CONFIG_WIN32 + errno = ENOTSUP; + return -1; /* Windows do not allow opening a directory by open() */ +#else fd = dirfd(fs->dir.stream); +#endif } else { fd = fs->fd; } @@ -820,10 +886,10 @@ static int local_open2(FsContext *fs_ctx, V9fsPath *dir_path, const char *name, return -1; } - /* - * Mark all the open to not follow symlinks - */ +#ifndef CONFIG_WIN32 + /* Mark all the open to not follow symlinks */ flags |= O_NOFOLLOW; +#endif dirfd = local_opendir_nofollow(fs_ctx, dir_path->data); if (dirfd == -1) { @@ -853,10 +919,12 @@ static int local_open2(FsContext *fs_ctx, V9fsPath *dir_path, const char *name, if (fd == -1) { goto out; } +#ifndef CONFIG_WIN32 err = local_set_cred_passthrough(fs_ctx, dirfd, name, credp); if (err == -1) { goto err_end; } +#endif } err = fd; fs->fd = 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 = ENOTSUP; + error_report_once("symlink is not available on Windows host when" + "security_model is \"none\" or \"passthrough\""); + goto out; +#else err = symlinkat(oldpath, dirfd, name); if (err) { goto out; @@ -938,6 +1021,7 @@ static int local_symlink(FsContext *fs_ctx, const char *oldpath, err = 0; } } +#endif } goto out; @@ -951,6 +1035,11 @@ out: static int local_link(FsContext *ctx, V9fsPath *oldpath, V9fsPath *dirpath, const char *name) { +#ifdef CONFIG_WIN32 + errno = ENOTSUP; + error_report_once("link is not available on Windows host"); + return -1; +#else char *odirpath = g_path_get_dirname(oldpath->data); char *oname = g_path_get_basename(oldpath->data); int ret = -1; @@ -1020,6 +1109,7 @@ out: g_free(oname); g_free(odirpath); return ret; +#endif } 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 == -1 && credp->fc_gid == -1) || (fs_ctx->export_flags & V9FS_SM_PASSTHROUGH) || (fs_ctx->export_flags & V9FS_SM_NONE)) { +#ifdef CONFIG_WIN32 + errno = ENOTSUP; + error_report_once("chown is not available on Windows host when" + "security_model is \"none\" or \"passthrough\""); + ret = -1; +#else ret = fchownat(dirfd, name, credp->fc_uid, credp->fc_gid, AT_SYMLINK_NOFOLLOW); +#endif } else if (fs_ctx->export_flags & V9FS_SM_MAPPED) { ret = local_set_xattrat(dirfd, name, credp); } else if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) { @@ -1163,6 +1260,12 @@ out: static int local_fsync(FsContext *ctx, int fid_type, V9fsFidOpenState *fs, int datasync) { +#ifdef CONFIG_WIN32 + if (fid_type != P9_FID_DIR) { + return _commit(fs->fd); + } + return 0; +#else int fd; if (fid_type == P9_FID_DIR) { @@ -1176,11 +1279,14 @@ static int local_fsync(FsContext *ctx, int fid_type, } else { return fsync(fd); } +#endif } static int local_statfs(FsContext *s, V9fsPath *fs_path, struct statfs *stbuf) { - int fd, ret; + int ret; +#ifndef CONFIG_WIN32 + int fd; fd = local_open_nofollow(s, fs_path->data, O_RDONLY, 0); if (fd == -1) { @@ -1188,39 +1294,65 @@ static int local_statfs(FsContext *s, V9fsPath *fs_path, struct statfs *stbuf) } ret = fstatfs(fd, stbuf); close_preserve_errno(fd); +#else + LocalData *data = (LocalData *)s->private; + + ret = statfs_win32(data->root_path, stbuf); + if (ret == 0) { + /* use context address as fsid */ + memcpy(&stbuf->f_fsid, s, sizeof(intptr_t)); + } +#endif + return ret; } static ssize_t local_lgetxattr(FsContext *ctx, V9fsPath *fs_path, const char *name, void *value, size_t size) { +#ifdef CONFIG_WIN32 + return -1; +#else char *path = fs_path->data; return v9fs_get_xattr(ctx, path, name, value, size); +#endif } static ssize_t local_llistxattr(FsContext *ctx, V9fsPath *fs_path, void *value, size_t size) { +#ifdef CONFIG_WIN32 + return -1; +#else char *path = fs_path->data; return v9fs_list_xattr(ctx, path, value, size); +#endif } static int local_lsetxattr(FsContext *ctx, V9fsPath *fs_path, const char *name, void *value, size_t size, int flags) { +#ifdef CONFIG_WIN32 + return -1; +#else char *path = fs_path->data; return v9fs_set_xattr(ctx, path, name, value, size, flags); +#endif } static int local_lremovexattr(FsContext *ctx, V9fsPath *fs_path, const char *name) { +#ifdef CONFIG_WIN32 + return -1; +#else char *path = fs_path->data; return v9fs_remove_xattr(ctx, path, name); +#endif } static int local_name_to_path(FsContext *ctx, V9fsPath *dir_path, @@ -1383,6 +1515,7 @@ static int local_unlinkat(FsContext *ctx, V9fsPath *dir, return ret; } +#ifndef CONFIG_WIN32 #ifdef FS_IOC_GETVERSION static int local_ioc_getversion(FsContext *ctx, V9fsPath *path, mode_t st_mode, uint64_t *st_gen) @@ -1432,11 +1565,90 @@ static int local_ioc_getversion_init(FsContext *ctx, LocalData *data, Error **er #endif return 0; } +#endif -static int local_init(FsContext *ctx, Error **errp) +#ifdef CONFIG_WIN32 +static int init_win32_root_directory(FsContext *ctx, LocalData *data, + Error **errp) { - LocalData *data = g_malloc(sizeof(*data)); + HANDLE hRoot; + char *root_path; + DWORD SectorsPerCluster; + DWORD BytesPerSector; + DWORD NumberOfFreeClusters; + DWORD TotalNumberOfClusters; + char disk_root[4] = { 0 }; + + hRoot = CreateFile(ctx->fs_root, GENERIC_READ, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, + NULL, + OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); + if (hRoot == INVALID_HANDLE_VALUE) { + error_setg_errno(errp, EINVAL, "cannot open %s", ctx->fs_root); + return -1; + } + + if ((ctx->export_flags & V9FS_SM_MAPPED) != 0) { + wchar_t fs_name[MAX_PATH + 1] = {0}; + wchar_t ntfs_name[5] = {'N', 'T', 'F', 'S'}; + + /* Get file system type name */ + if (GetVolumeInformationByHandleW(hRoot, NULL, 0, NULL, NULL, NULL, + fs_name, MAX_PATH + 1) == 0) { + error_setg_errno(errp, EINVAL, + "cannot get file system information"); + CloseHandle(hRoot); + return -1; + } + + /* + * security_model=mapped(-xattr) requires a fileystem on Windows that + * supports Alternate Data Stream (ADS). NTFS is one of them, and is + * probably most popular on Windows. It is fair enough to assume + * Windows users to use NTFS for the mapped security model. + */ + if (wcscmp(fs_name, ntfs_name) != 0) { + CloseHandle(hRoot); + error_setg_errno(errp, EINVAL, "require NTFS file system"); + return -1; + } + } + + root_path = get_full_path_win32(hRoot, NULL); + if (root_path == 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); + if (GetDiskFreeSpace(disk_root, &SectorsPerCluster, &BytesPerSector, + &NumberOfFreeClusters, &TotalNumberOfClusters) == 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 = _open_osfhandle((intptr_t)hRoot, _O_RDONLY); + data->root_path = root_path; + data->block_size = SectorsPerCluster * BytesPerSector; + + return 0; +} + +#endif + +static int local_init(FsContext *ctx, Error **errp) +{ + LocalData *data = g_malloc0(sizeof(*data)); +#ifndef CONFIG_WIN32 data->mountfd = open(ctx->fs_root, O_DIRECTORY | O_RDONLY); if (data->mountfd == -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) != 0) { + goto err; + } + /* + * Always enable inode remap since Windows file system does not + * have inode number. + */ + ctx->export_flags |= V9FS_REMAP_INODES; +#endif if (ctx->export_flags & V9FS_SM_PASSTHROUGH) { ctx->xops = passthrough_xattr_ops; } else if (ctx->export_flags & V9FS_SM_MAPPED) { @@ -1467,6 +1689,16 @@ static int local_init(FsContext *ctx, Error **errp) return 0; err: +#ifdef CONFIG_WIN32 + if (data->root_path != NULL) { + g_free(data->root_path); + } +#endif + + if (data->mountfd != -1) { + close(data->mountfd); + } + g_free(data); return -1; } @@ -1479,6 +1711,11 @@ static void local_cleanup(FsContext *ctx) return; } +#ifdef CONFIG_WIN32 + if (data->root_path != NULL) { + g_free(data->root_path); + } +#endif close(data->mountfd); g_free(data); } From patchwork Mon Feb 20 10:08:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13146236 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EB217C6379F for ; Mon, 20 Feb 2023 10:13:52 +0000 (UTC) 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 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== 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 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 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 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> 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: X8b5co4oDDZSmHvDTHjFavEr5y3No+wbLl31vIV1tSQIiivYnHTdspFoB38lu+htfJajNcOHE6YLTn2I8hKp3axVM5qUBsr+973zWOJTiALxq/k7MOwaOODlUvixDmo4WFdMsN6G6feD70yrvwviIYAh8VTE+yg7hgkjC3DPFzpKNPyFAAdACH0o9PSy0tjgHVYTnoRfa8lCi5yzztbjuV1BvlAR96OkAoQTSojgY9QNvcmSZIoxawLIDTKFEuwWzxgRZua982z8PCS87APXfrzxxYuu4SzJD2OvZgkUVDmSXAKaXhUtJ8j3VfMqXCa5yxotQSjKK62u0Y6WnBWIB0S2tzOABA28Ysovpf3x2NHVo3ee9skrpK2Z+LYWurJxaaUQVUvRUgcpF9854l/iSCfjbdoIrNcajlhEKcxK01gXyzkq3UkfAih5WxgvO2XZk3WrkRUtNYiBSnl3ghR/bcmsP8qb7AIUUlHFPn+VDByYn/Pmr0NRLgyuifsaFUalQ4xWtLz84MZlVBCz8LvYxBCTGSqUppvBR8B50oEMoEq+f8driWms3/WLhAzfyWyNbIzcyIQv5cebm+g07mhLM6RrLppw+b/fLWfKuVdX3YtRlisXWb72FK7GzqcCOcyCcPgK4UoxZ0+I+zHpD4nUQ4mbKP7mm4ZPBUsiAhN4qB316DIqFoWkUEnCCiXuesouibPAVkcWz6GKaH0hDC345Navp2VPpPLlzWaAPVTkSnGTK1BAoxiW79nFWlOFbLPKRfLQZkaGnTu8JTPgVs9rqmQZhTobRJaitdK8DSZKhnPWlDF49dDQxCzrP+kq3jTsDfUc3wm0hhlUBuI2gdPLrZ9AeYgZI1CKpRfhBmt1na483TY8aqNwYsQnl2gpN/1NhN+m2gn8J6lQKjlmGf9pJj7DB7fV9nZ+D2vm8sDOygohghr0lts4hgL51dPbkaKyuigCpaN+yWv63pVJ4W9w/S9Tuqmda2ubFM1lc1P8qp1CW1gIx/qbhHnGGtrFc2CjWYDJ9qDovhxHyOXxtQUwGS0cJjEMOQLGtJ/9iLslFP3xHjsDLpNf7wklPqKLbnQqEpZbddDGt7FircY6qn/Ys1YvB07f9LMWtwAySx5/suV3wcp8QRRhFKsVB52CqI/6ENtnAG2HOMZdwuuN8epKJPxHhUQtjWqEWfqBYYuSs+2KjsJlpdYfqmjNRFRKBx3hhgJ2pL0HeIxk8hPs6HYqCZl9CvhCPm86zN6JDQiG46Y2LsbOh1FtTxA1JN8X4pr61Zh8b4MhVim+8hm8zkLngrbWuy1SO15UMxTkbr/gAD+iEjocsy8JbZrZ+cpgkz/sP8LMDyyNLzzDM3USeWUIC/Ocx8WCvbim+dhvuxiPnhfnidtXPbD8KOvHiziaS7/hW0JuMdNltpgHXNo2wjqCeXMrwPuYg099mfbGWVCT7D0Lv1Ur65fBLAAuZxvKX+95YDYGN87Pn6et+LJajfWusJRbH73a3qwJGAWRg2Lt1W6ZMiXvkUaDy+mNZuaNUTFhzygfwoFTsvez3P5UJ3YmfsUQSl2RT5l+NJ758mCSiDgtFQPT/YyuCssToZCCWWh073XAtH+PgS7SkaOkTiZLxw== 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Guohuai Shi On Windows 'struct dirent' does not have current directory offset. Update qemu_dirent_off() to support Windows. While we are here, add a build time check to error out if a new host does not implement this helper. Signed-off-by: Guohuai Shi Signed-off-by: Bin Meng --- 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 +/* forward declaration */ +union V9fsFidOpenState; +struct V9fsState; + #if !defined(CONFIG_LINUX) /* @@ -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 *fs); #endif 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 } 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) return (long)stream->offset; } + +off_t qemu_dirent_off_win32(struct V9fsState *s, union V9fsFidOpenState *fs) +{ + 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(V9fsPDU *pdu, count += len; v9fs_stat_free(&v9stat); v9fs_path_free(&path); - saved_dir_pos = qemu_dirent_off(dent); + saved_dir_pos = qemu_dirent_off(dent, pdu->s, &fidp->fs); } v9fs_readdir_unlock(&fidp->fs.dir); @@ -2535,7 +2535,7 @@ static int coroutine_fn v9fs_do_readdir(V9fsPDU *pdu, V9fsFidState *fidp, qid.version = 0; } - off = qemu_dirent_off(dent); + off = qemu_dirent_off(dent, pdu->s, &fidp->fs); v9fs_string_init(&name); v9fs_string_sprintf(&name, "%s", dent->d_name); diff --git a/hw/9pfs/codir.c b/hw/9pfs/codir.c index 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, } size += len; - saved_dir_pos = qemu_dirent_off(dent); + saved_dir_pos = qemu_dirent_off(dent, s, &fidp->fs); } /* restore (last) saved position */ From patchwork Mon Feb 20 10:08:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13146237 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9ABDAC636CC for ; Mon, 20 Feb 2023 10:14:30 +0000 (UTC) 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 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== 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 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 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 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> 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: s7U/0nUyrnxGUcUroGJfSlZpe3jX2wncroWMUOPXAzCSNCeJ44u13IBjef6BuwzxHE/ttGyiK79kLc4ZZ67Ufi+L8yjyTPHtL2f+q1g33WxaJb99w5Wyxl6QN4f2XET4Xwp5fzTR1kquxi7xrCnNxD+V/3I2uQx6MJk/fJoaZC1iysLFs5nKuc1UJwC60APHRl3MYoNXysq3moYNJuIpefxS5NjqrQ0zu7dRz76mKVpl9FggX+32VYXHPCY+KHxgGDQY+1NS+5TOCeiKycSbsVjL3D4F1dGzVkKoY7rsfa2Cq2y0UD/yXBAv/mf0zmzlPXyxR+latL2UuHL1oiH81UbXU5swNKkC41tC2vmDcwRjv6n6/F3mZ3RCkjXzvfUkD/MpSfJXOVPLZ+Mv1UtUIdlfbG6XzmD1jJu9zoSYSNxF98tM9aXzyYkjb58utVrpFPk4bTmNis5Zka7lDmbi0O2pvGKrfRxNAjOit2A/xF09MNawrCje5Iew24Il9zTkyRMGkdICglJyF7LQXmbxpEqXrEo7PshNztVOUHeVQbSYZvdH/vdThXIPeKl7Kre5E2JIcUa6jY/GhKeZJxpnafZI7IlHovYKPCqBLFVFTa55j4FaUEv6dqagnJoef6JZdGnz2SJoX63zaba01GPBKUoOfwDCGASd084auDphRWnPUqA189Af0/++1h2/TwN4ZPiNrXDrtCIDojCOMhdvKol6mr1nxdLue359l6p/FC7guCn3EoWeLDJ2bPYxGX9dPioTnaO4yaCH1DJJkZK897tQBLUEx4V/7a2Ar7Z6LllegTcH80F+nGOxzoaYg3JodL51HIbX36GlpJ09Pq9N7sYj/eY6+b4jc7nEuWBgJWg5BXsSTqfvhRY1SMDXplWjaOMgYLoSn41lbPrlCxRD61ZAh55ZRoz1j3LtrC8QT8OTZ6c+FLgV0XwWLuvL+HHpKeForG9Sg5sxbWhCGt1eLx486vaksnm1SZApS8eEiJzZNO2Tmob8cm9QDIjaq++jdD+QhQmzFfRI6heqi48MOXJm7wZpV5DxlRKCyqfN91HHvetkGW+OxI9Qqx9H9e3C7bAeIFVMutVA9PotutRnV2wjOZywUeIotjJhSOLDdsu0pHz+WDDd5sK4y8HoocuDxJKIP4av6v/AC3lKMDNHnxUX3uVkRAiRYkFWqIivltBDCyj2P4kJ+O42VernqTZ4EyQ5UzPKwxPzKvb2XBWCfnJo2MYlLByI5OSmubkGKzPOA9ZdNqBzBd0FxPA8isyVl90T/jTuS0dbqw9wsLvjAd5Y51MRs2n7QbjtFOdxUKrUQ+4TchuEYLogqO9SMLkz28p8DeXi3I5X5PNecXo4RKzjPyRwFLG35SaypWWSz978MJdKuEcHn8Q9HXHfVjEP83ejvZWLBLnYQPsBqrB9gMdV9UY6vLcEfMDLIhQYYJZA/FFBYXpqHerL299t29WsfPIMemS2vulq1DQhkRXWUj/BRBUGRu731vYxwmMhndqUy0/KbIOBI3FAcWQW3sWK3LQQSl+YwG1DpwdAwAQH+DR8mKvnYIBrYOePnqr293JacdB2n3KthpdxEKszs1vcPHWX1/dknNfKRtFHCAyzBw== 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org As Windows host does not have stat->st_rdev field, we use the first 3 characters of the root path to build a device id. 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; -#if !defined(CONFIG_LINUX) +#ifdef CONFIG_DARWIN /* * 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 } @@ -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 *fs); +uint64_t qemu_stat_rdev_win32(struct FsContext *fs_ctx); #endif static inline void close_preserve_errno(int fd) @@ -269,6 +273,18 @@ static inline struct dirent *qemu_dirent_dup(struct dirent *dent) return g_memdup(dent, sz); } +static inline uint64_t qemu_stat_rdev(const struct stat *stbuf, + 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, union V9fsFidOpenState *fs) { return s->ops->telldir(&s->ctx, fs); } + +uint64_t qemu_stat_rdev_win32(struct FsContext *fs_ctx) +{ + uint64_t rdev = 0; + LocalData *data = 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 struct stat *stbuf, v9lstat->st_nlink = stbuf->st_nlink; v9lstat->st_uid = stbuf->st_uid; v9lstat->st_gid = stbuf->st_gid; - v9lstat->st_rdev = host_dev_to_dotl_dev(stbuf->st_rdev); + v9lstat->st_rdev = host_dev_to_dotl_dev(rdev); v9lstat->st_size = stbuf->st_size; v9lstat->st_blksize = stat_to_iounit(pdu, stbuf); v9lstat->st_blocks = stbuf->st_blocks; From patchwork Mon Feb 20 10:08:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13146231 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 86198C6379F for ; Mon, 20 Feb 2023 10:09:54 +0000 (UTC) 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 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== 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 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 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 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> 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: +Mg6J2RtP09+ar/iXdWnyZk3jNS5BxRmxokPFTp/an30bgW+wQtIBVy/fiUpKUhPX3W4mjKAdLZX66JewpT9NN3CMBFNj75hThW7NXXmqyQiO+bHvw93v68dqgw3O7Khlu70l2U26VlcOYZ+q1f1oDiOKNyQvI2O6nzDwryoKQznQBBRi1eG2oEke+IZn+/pbEZLKcNOXcmgOVT3pdLAIhD7yoavBxLZ8E1HBcoElBKtJmZKNQiLceELVjR0UWONH+cBX9WBV4tTi8dJUsaVGKNRoV1tE9jjX/SPsKGDInv0ox82DmkKg4hZWGuBQs5qOMYKnL2MIBq28RUR1j741F+U2PqdRGnlgZQbrH/39QYgbDYC4S+iyt5ZSljBT9CyyZsG+s7s+ar1iyx8EErZ/nJGKnrWbZD7FrWilVn/J7GqpRGLz6SKhvtYSr0XXorTmYSX5Lw7/9YlIRPwsnunSoSMsdgug+ljCo5tkKWhpo1lSd2cZP8HpxQkM5SAfhuRBtq2jLxzbiagEQ3UkkAjaOEyLNAHW4uqeYreRxHXUlJwv6Daa3go4dbEaY2qL0sRSn5G6M6hkQ3nPYmFNKNKsATW+bFvl+PLrEVL2kqpDAJfMlhN04Sy6+cLYjZ0xD/5jdGVZJfpcAqHwBee0LlPfQAFhFsB8ACfmCIZzZPja7bR5TS3kFj+nVSNG/d/8ziU7gXTz7a2uHRUrValGJnQ9llbEQAshdUmgYV3ZbiDeTklduGdvzdlyPxAYgqx/EMdKB+1QBkt0rzeRFZ/AT7aWmkKs48nNdXlCf1yzgzwd99XkrnsB4snXXMMFwB/bASlC6Wis047HylUZGaswX6lYIcSut3Gwy3e7zIXLlp3IPtaOoc7nxT636U3X7A8YnAqZZbMmnV/46iRgJV/BFeHqu4NuaArsAgvr6gf89sc0OJubKG9dNS68w66hZYI11PKfJbxAEwSuY2PqukiXNpndWGaMRHG4io0Bc2B0aLCt72InrQLNx8v6zy1+k0eNHQEgOSHtgcMDJd20HiPnmmFPKq6rS3I3fAJM0LLloHrFlX0QOgKw+Cm2g0Qi7tsD6vklJk4cFgtQp+r9ZnNm4vAn0zbsc+stw+oGowpDdxYjlGnj+pkMZKrIcz1RJGJGbH48YQD7v5kwqGuppiYIB3YSqpbbuOdggWpmWmBM0kaqBNPnGbjthY+PuSb8rlDmLSxe34iGGUsIlEcbiQ6A/c2oEe+UibKRHt1ThvvQbg1XtkvkWARuCBa8Z6A3OfOsrK1R+MsGIuXRRBrovKScw2PlAVT8htgBr1aHsBoLq4wGvMfoph0wjIMK8UOpq3VCD+N+ckTvNBjm/sXNkhbOjaxpHBN+9DDZPVIgdnH/rDFXgCTtH0suRXNVNIBVmblnnpIGYcgPX543Rp5vSzukGUC+uoOYuzT1RmBsycc7iTWTPzb4K30rs+00Mv8fMOO1dPikBsucBGZqFdFeq006nzUETi9dGOHRUQsvd9S341A6zwgJUixjJXv+5xxv215uqPr8id78JSqTW3wSGrQx/cqkSwwb8sFVsrEc3yjxZVWKH4AHHv9XRxCmcnOI6yYKYZZ3M+N8sr7oBdlIDgjWR+kyQ== 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org As Windows host does not have stat->st_blksize field, we use the one we calculated in init_win32_root_directory(). Add a helper qemu_stat_blksize() and use it to avoid direct access to stat->st_blksize. Co-developed-by: Guohuai Shi Signed-off-by: Bin Meng --- 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 *fs); uint64_t qemu_stat_rdev_win32(struct FsContext *fs_ctx); +uint64_t qemu_stat_blksize_win32(struct FsContext *fs_ctx); #endif static inline void close_preserve_errno(int fd) @@ -285,6 +286,18 @@ static inline uint64_t qemu_stat_rdev(const struct stat *stbuf, #endif } +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_ctx) return rdev; } + +uint64_t qemu_stat_blksize_win32(struct FsContext *fs_ctx) +{ + LocalData *data = 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) static int32_t stat_to_iounit(const V9fsPDU *pdu, const struct stat *stbuf) { - return blksize_to_iounit(pdu, stbuf->st_blksize); + return blksize_to_iounit(pdu, qemu_stat_blksize(stbuf, &pdu->s->ctx)); } static int stat_to_v9stat_dotl(V9fsPDU *pdu, const struct stat *stbuf, V9fsStatDotl *v9lstat) { + dev_t rdev = qemu_stat_rdev(stbuf, &pdu->s->ctx); + memset(v9lstat, 0, sizeof(*v9lstat)); v9lstat->st_mode = stbuf->st_mode; @@ -1348,7 +1350,16 @@ static int stat_to_v9stat_dotl(V9fsPDU *pdu, const struct stat *stbuf, v9lstat->st_rdev = host_dev_to_dotl_dev(rdev); v9lstat->st_size = stbuf->st_size; v9lstat->st_blksize = stat_to_iounit(pdu, stbuf); +#if defined(CONFIG_LINUX) || defined(CONFIG_DARWIN) v9lstat->st_blocks = stbuf->st_blocks; +#elif defined(CONFIG_WIN32) + if (v9lstat->st_blksize == 0) { + v9lstat->st_blocks = 0; + } else { + v9lstat->st_blocks = ROUND_UP(v9lstat->st_size / v9lstat->st_blksize, + v9lstat->st_blksize); + } +#endif v9lstat->st_atime_sec = stbuf->st_atime; v9lstat->st_mtime_sec = stbuf->st_mtime; v9lstat->st_ctime_sec = stbuf->st_ctime; From patchwork Mon Feb 20 10:08:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13146228 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1043EC6379F for ; Mon, 20 Feb 2023 10:09:37 +0000 (UTC) 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 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== 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 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 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 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> 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: YGMgAmWTUrpvfeQrGNwKt3Ariv7A7ZvhezVQz5+NqsqBY0AXmvuv8zX1GIOY+6ZPgZdsxXU4OVHOKasW/Dn7kouj7mATw8P2599KyWF92hCVyGYm+VCpsqo/5sfV3FvSgheZ1dS2jeLKMUcBCPQlH0di2FSS0gobyGRn72p1EmVLgnGa1RtuCj8JK5guT5cMqC6uxU+CKSZhxVSrOkWPwwq80NqSiN58ZNSmVt2I63OFjRVPiGHkiSi49rh8OUbjAQwKV5c4/JHG0c+9U8i7zS/cyHr/LhpaFiFfVDtD9eD3KwsxYthLKa6ws+nMQN2vHi0G+ndrxt/8+Tk0QTNKkAnr+seg4zw1+qfXIxOx5teERszK/ZIJnefkMKNPtW2Z3P3JJAOCVzSP8/bGfsdAu90gFC1OZuw/oy4xhvrZRHod7l0YCWFW53x82X81FL9FyosO4oYw5I0bXmO1KuKvexpgiY5EKlvKENuftMutF3jG+Hp3ExTTdMnBh8Cc1VeJjbgnu6PCyxRwchypmaTIJY4+ZFs7984M9qiLwHuushjw/yU1bxhYxwjttby1DBPR/o+D+kZwuG65h8i9TJSt7jAgyaDOgpGhD2qYbOmhTVSHURkoPucq3kxixq6RpKZRKlvrDx6yj0RhXCteD0lDLH8Nif3tiqgMmiiHLIO7aSNr7md/any9oAcdA/dCFdlfOLoEU6fWYKopzADEidczgW88I95KVNShImo6y9/1Apuo3Lcau/4gkQJmj/WlLwRjgHxXjHGeN+h+6mAWRcyQg+tZq5wyzpAy2XO3oCo7+T2aFz5bg+4LWfotVsJMJHyiuisMesRKGQvZQuFXFB7QG4wzwfPEBrl41hPe3a9NjeebrrE9xM+kykQWYlXjr7iMxL3LzxvrjBubMjCKjk9jVPgP31peoKKdlnfi5bYeA5DYsRhCVEaytB9Lo9fLUvdATB+NXUrLDsysFuuQYrORP2iZVkElgWx6dmuA3oBkKBZ7hd0EhHNuQhLWxNn9FaCTHfC1hNGJDmFrEcIhSROy+8wyzlObiD7OduJ0KYvzdE1gwcQih1mls/0Xln4e4ZmL92hKFJTczjkLENZS5d5ZRMWZ5iGzkoVwaM/diTeFjoHNBmzWet2s8Muv/vC0eb+e15sYRYUjc6O2Cob/aZhh9E3GCx0Ok4ZcKb1ElMHmR08BIQef95/kZuRd9X/VAeWDsKkurnYV9jR5BrjpuOcEL7hlqv9z/lTIPTFMrtiZgk0SQD13fwnbnvGVL7GL4IunQ80wsK+CoPEx0wdcR32zGnhYIeXKCrFSBVTe0n6DOeKeJOX3HxfTOt3BnMUvaT3q3eOppo6D6kJv3Obnrc19vP9XvU9N/Hh87opcSkYQrAyIbQkBwEY92pH+LEZK1uXnNriait5eeUMh2nX/KmjGPWE7fPCr5ueR6dmsUWO4QRRXMXmvz+l5lDlat1Auc5Lu1w3Q1cX7L/dMMVbhtUzLOAhy5nAGMfPVRX86Now/GDMBvmfUy6T3oNT0gHRKAfHSDWJ3qa/i6rIxolPzaopG01TeYVv4MMArUhxvW9fHa45YpipysNeHVvN9OOhkK427But+0pQK/5RpcKxrqi5jdQ== 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Guohuai Shi Some flags and features are not supported on Windows, like mknod, readlink, file mode, etc. Update the codes for Windows. Signed-off-by: Guohuai Shi Signed-off-by: Bin Meng --- 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 +#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[] = { { 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 }; for (i = 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 = dotl_to_open_flags(oflags); - flags &= ~(O_NOCTTY | O_ASYNC | O_CREAT); -#ifndef CONFIG_DARWIN + flags &= ~(O_CREAT); +#ifndef CONFIG_WIN32 + flags &= ~(O_NOCTTY | O_ASYNC); +#endif +#if !defined(CONFIG_DARWIN) && !defined(CONFIG_WIN32) /* * Ignore direct disk access hint until the server supports it. */ @@ -1115,12 +1129,14 @@ static mode_t v9mode_to_mode(uint32_t mode, V9fsString *extension) if (mode & P9_STAT_MODE_SYMLINK) { ret |= S_IFLNK; } +#ifndef CONFIG_WIN32 if (mode & P9_STAT_MODE_SOCKET) { ret |= S_IFSOCK; } if (mode & P9_STAT_MODE_NAMED_PIPE) { ret |= S_IFIFO; } +#endif if (mode & P9_STAT_MODE_DEVICE) { if (extension->size && extension->data[0] == 'c') { ret |= S_IFCHR; @@ -1201,6 +1217,7 @@ static uint32_t stat_to_v9mode(const struct stat *stbuf) mode |= P9_STAT_MODE_SYMLINK; } +#ifndef CONFIG_WIN32 if (S_ISSOCK(stbuf->st_mode)) { mode |= P9_STAT_MODE_SOCKET; } @@ -1208,6 +1225,7 @@ static uint32_t stat_to_v9mode(const struct stat *stbuf) if (S_ISFIFO(stbuf->st_mode)) { mode |= P9_STAT_MODE_NAMED_PIPE; } +#endif if (S_ISBLK(stbuf->st_mode) || S_ISCHR(stbuf->st_mode)) { mode |= P9_STAT_MODE_DEVICE; @@ -1367,7 +1385,8 @@ static int stat_to_v9stat_dotl(V9fsPDU *pdu, const struct stat *stbuf, v9lstat->st_atime_nsec = stbuf->st_atimespec.tv_nsec; v9lstat->st_mtime_nsec = stbuf->st_mtimespec.tv_nsec; v9lstat->st_ctime_nsec = stbuf->st_ctimespec.tv_nsec; -#else +#endif +#ifdef CONFIG_LINUX v9lstat->st_atime_nsec = stbuf->st_atim.tv_nsec; v9lstat->st_mtime_nsec = stbuf->st_mtim.tv_nsec; v9lstat->st_ctime_nsec = stbuf->st_ctim.tv_nsec; @@ -2490,6 +2509,7 @@ static int coroutine_fn v9fs_do_readdir(V9fsPDU *pdu, V9fsFidState *fidp, struct dirent *dent; struct stat *st; struct V9fsDirEnt *entries = NULL; + unsigned char d_type = 0; /* * inode remapping requires the device id, which in turn might be @@ -2551,10 +2571,13 @@ static int coroutine_fn v9fs_do_readdir(V9fsPDU *pdu, V9fsFidState *fidp, v9fs_string_init(&name); v9fs_string_sprintf(&name, "%s", dent->d_name); +#ifndef CONFIG_WIN32 + d_type = dent->d_type; +#endif /* 11 = 7 + 4 (7 = start offset, 4 = space for storing count) */ len = pdu_marshal(pdu, 11 + count, "Qqbs", &qid, off, - dent->d_type, &name); + d_type, &name); v9fs_string_free(&name); @@ -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 = v9fs_co_mknod(pdu, fidp, &name, fidp->uid, -1, 0, S_IFSOCK | (perm & 0777), &stbuf); +#else + err = -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: static void coroutine_fn v9fs_xattrcreate(void *opaque) { + V9fsPDU *pdu = opaque; +#ifndef CONFIG_WIN32 int flags, rflags = 0; int32_t fid; uint64_t size; @@ -4006,7 +4035,6 @@ static void coroutine_fn v9fs_xattrcreate(void *opaque) size_t offset = 7; V9fsFidState *file_fidp; V9fsFidState *xattr_fidp; - V9fsPDU *pdu = opaque; v9fs_string_init(&name); err = pdu_unmarshal(pdu, offset, "dsqd", &fid, &name, &size, &flags); @@ -4059,6 +4087,9 @@ out_put_fid: out_nofid: pdu_complete(pdu, err); v9fs_string_free(&name); +#else + pdu_complete(pdu, -1); +#endif } static void coroutine_fn v9fs_readlink(void *opaque) From patchwork Mon Feb 20 10:08:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13146226 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9B914C636CC for ; Mon, 20 Feb 2023 10:09:36 +0000 (UTC) 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 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== 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 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 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 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> 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: URH4uKLieMCigidfCAgmsxJCqSnF5Zi5IiNO/Q7OvZPSL0V/1gMRhLH97qgyMvi0/J7GgWttWjBWr28OgP7k6Y8bFmffgJw/TTGjvk6FVGwnXHXLtoHn0V3saLuWjSeXcja4tdkzrscB6DHjgzCtwAoXnmcBEhQL8eAyQKAIpfmHWHCslCoJc9cIN6ww8OYlyzLB5/ujsjs7hZfb/SIhhq+bW9fegtvX96HZeMn8x2kRGBMztg16tX8yFxVXPsXdhfhAVHOClfV7JUZRmdU9KA9mOw4cZKeI7CNvNPGSfxyzhFWMZ8mK8aNAV2mRXsI8SwerJ0LF6KHJtH4isgkWlGW6Wus7OV7nyBqveXFydwuT7+/GGTnU1U8XGekcTjB8yC9bpRjBPE6jcWg85Re2L0WEdfHxjVokdtpShZ4Fv6D6FhUsaXdk1GLA2GcPfVIi5b/9Y5/TVv1aAEgPr4knvlVnk5KjhEt257FCoGns1T4vPJ4Gi3q6Yh9xtQW27ArxDmr6haKSpVdQd4/s9V7swZ9EtrLhRP5VdCYkIElDfgPBeLJmMZiuu9zpP3s7J+YZ+QSeJDuwvK6jC5HJfQTTyqD5CEokmnhNnBJ4Ypwd9pYQHlYjvj5BdI5up0ZGVzPJxZ9tg9olgZOY4JKcjHlLryOPHUEGxDKBj0rLDpgNR/Tzad3meVP7ykHwMQiAbl9lW+GRMTGo+0SqhAPGTzJr7PcC6XT0M/TBthpL/Sx6zVSgwOKDc7+0yYQokN9/Q4nyRdUMEyjTV7NeDDdm5TL6wkAGZ71al0WiRQSlR3c45QpBxo73VSpe4cZirToOXZ7iwCetDlAuneQG9sdc+s/6P9Z0DBUXt71IioNeUxhak0jUFlieNaLdvUyLnwL36Pb38NHdo/uTSPZEbfRZ0r6RwRvN+mqQqXnTXrhzsUYtaE133OcWW5bHrJqYKyT94UwuFQSmFJPjsW6bTnQ5aTQ/viFE/kpbisV697UXWiWfBV3rtJj6zO8bvB7sssVzFoZfFp7uB4070OblJX5KkmEBTpzQLrYwiE0EnSu73dtCdAlV0lBrmLwpBZ1j9jZPcfsXAC2iRNElki0r5JPWCiDZiNymXULEQihrlkc1hm1gMpSsAFglJuvn0/M2d37+NxLz/CivChvc/znhj32Gm40/l0szswFCdmxoSIu+nVlWV5XO5dGuGnNla3bHeBaPuFDuwlGwAQ6CrWRKmzIcFS98zP8kyARKPD4gJFd1ciHRdSAlLxFk5IXh/Rqjus3nDKX1j5LxItD9sh3TE5o8Q84mgfW+OchFZkS0ux38EOaA4HcK3gcv9+BQVb+WIlPd4nJATMUp+Zc7mIyHFPpB0VrWVegBqgGJN8nq00tnEnGuC0REVrjo6EQdu9CwkerJIcFdJlYj5YfHHGLLRhbSWkcBp6iTjejRYglKeyEWooeh25SOtYO+GyZOrP7V4B2XIS6Lt5bkDyWa5hg7KkoZS9x/IT7DiIsQAxwKIdNVx/ICYlizhBURL2z+VOtEXopSh9Ssd6sWo4f05NvGzH0EsOdTwx/lWAuHEv0atzdur/t86ouSCC2IXJZJKymyQVn6mHiFkMYMOp+kQazqD8Fzn8SBVA== 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Guohuai Shi Use _getmaxstdio() to set the fd limit on Windows. Signed-off-by: Guohuai Shi Signed-off-by: Bin Meng --- 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) static void __attribute__((__constructor__)) v9fs_set_fd_limit(void) { + int rlim_cur; + int ret; + +#ifndef CONFIG_WIN32 struct rlimit rlim; - if (getrlimit(RLIMIT_NOFILE, &rlim) < 0) { + ret = getrlimit(RLIMIT_NOFILE, &rlim); + rlim_cur = rlim.rlim_cur; +#else + /* + * On Windows host, _getmaxstdio() actually returns the number of max + * open files at the stdio level. It *may* be smaller than the number + * of open files by open() or CreateFile(). + */ + ret = _getmaxstdio(); + rlim_cur = ret; +#endif + + if (ret < 0) { error_report("Failed to get the resource limit"); exit(1); } - open_fd_hw = rlim.rlim_cur - MIN(400, rlim.rlim_cur / 3); - open_fd_rc = rlim.rlim_cur / 2; + + open_fd_hw = rlim_cur - MIN(400, rlim_cur / 3); + open_fd_rc = rlim_cur / 2; } From patchwork Mon Feb 20 10:08:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13146229 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E1E0BC05027 for ; Mon, 20 Feb 2023 10:09:50 +0000 (UTC) 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 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== 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 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 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 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> 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: iUS8LsvmILp2XaFwe/N392a1FKtlAClRVHQ8xszxbaJohTayUGeFs+7t8jumQEcnU21Rufecy4A8b+VHHV8b423NjesrcPKxUB0zAX15TzGhddv2qzoJJFLnVEkhnTGC3B7hpO4BOXer9OEwcWEfZ6PyaxNiowTUwnHA4bdn4BMRKsvvqfhX/i1iuVx64qoY8anFy9R/YKKPzkdPEZuSrIgs5p/kmH2NAoWbrKDU2KFSR4m1mB0r8Rz+AamgWkQcw46hPlp6GlDkGl/Th0b1Pqk9eOEmitdsIIiUrmc97q8MkDHJxylWFzakRvejTjtluh1Kf/+yD3kylWKxlXSTmVB6FopHos2Bek/2xVknSL1StlncDbqkd2s1NrGJWOBK/v2tZ+meW2GTKJxubSfy8i9fXQrNgMzUVmHIcl4HoZ8sAueudsW8iYgpnwxIqgfUIiA92Ci7GMWRpGolNMZ4F3rWsVTPJXXfVHq/07JqRwgiXk/NpMUsw2OwIcM1syP8rLepQizdQjsKaWwmQ+LH14mOfSnUXXtWu5BKxvH32hCTLmwPlbuDmVPlCiRQrRG0uaL8lfU1MZnMXE/V30fZaU2kOttZ9BSj/k8kemC9yxJM9g7/FaYETHPzRJovtQSUUjYzSXYQQ7S+A71paN73DDgZpgjLiq6mhrz3jiG88oowvsHfDx8xIwwwnWAx4Cl0MrZu0yCtoEUMjMWc96jJPDm8Jw2ccP5iEQYF5jfj7D1HqBpyO+5JbpFUWmQwx/BMG5HM+ufkZ0Y5TuO1H9SsebL0qEJqd8C3J2eAZ2sOvJuor+fI//EQ9tIzDS8pgE9biqrp5atp1Dry8O2TkoTQfHnzT+nHmoKbIqNyRoyW8y6bCa8BkCA6fsNFqPzrERVLHf/jCxF28gEs4wRAfmmPpbc3Z9VnZLY7W0LDs82lC3U45AWuLJOztmD2eh+P1cMCJSazBTJwBkfHXs7CpNhZkv/90qncKa7UGPHCKxeMXLRezmspN49k1btM86D98Ywe0sflmBQccGPxglr8nRDE+dWpT8xMhh8Iypk2vUlCRLtfZPMG/fGaLBws4CZjPU76r4uKfj2CUVMCtzMlRuDsBsBIO3iRWsfvoVLT6O7f42OfD+PU5Dt0bsTs6Mg7+zJH5TnC/sx3k0RGKu/aCBnGTRGptt/HS9PACOPdpB4I4PrURuFvTDwcMQpnk2r8Hpq5ODgitJssuxjmccfCD0oLb2adJuDD3KtMscRWcRTcL0aWozQf7uOwB09zSvEGiWvyN3fl8L8i2SC5hKRK8OQjQxCBBwKNQCMulz00efO5rcl37aVnfpqDntiJ+kqXlsuS3phWbTHgR/2S62Wa3El1RdDLRbqRZGWZ+r0RLAttxZlFOUwjpy/sGMgd+vKAo6rw0uKm72j3jyCHBRYa61k6JjrqfRxJIwTygdqwd/QByoPPdlf6BmwDK0/4hYN5482uetpHzptn3yOf5ZXVdD4ZaMWJAqbig6Fw32+Jq0JfYOxulJ6TWJ8sAUYEfYtuyTaIZVkuY+lkWOsrF5PrV+AuargsNe6a5D743jnGID/G85HKpKPRW65leFdVq9OraicWCwoPJYTYGPuNB+lmBxeJYw== 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Guohuai Shi When using 9p2000.L protocol, the errno should use the Linux errno. Currently magic numbers with comments are used. Replace these with macros for future expansion. Signed-off-by: Guohuai Shi Signed-off-by: Bin Meng --- 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 later. + * See the COPYING file in the top-level directory. + */ + +#include + +#ifndef QEMU_9P_LINUX_ERRNO_H +#define QEMU_9P_LINUX_ERRNO_H + +/* + * This file contains the Linux errno definitions to translate errnos set by + * the 9P server (running on non-Linux hosts) to a corresponding errno value. + * + * This list should be periodically reviewed and updated; particularly for + * errnos that might be set as a result of a file system operation. + */ + +#define L_EPERM 1 /* Operation not permitted */ +#define L_ENOENT 2 /* No such file or directory */ +#define L_ESRCH 3 /* No such process */ +#define L_EINTR 4 /* Interrupted system call */ +#define L_EIO 5 /* I/O error */ +#define L_ENXIO 6 /* No such device or address */ +#define L_E2BIG 7 /* Argument list too long */ +#define L_ENOEXEC 8 /* Exec format error */ +#define L_EBADF 9 /* Bad file number */ +#define L_ECHILD 10 /* No child processes */ +#define L_EAGAIN 11 /* Try again */ +#define L_ENOMEM 12 /* Out of memory */ +#define L_EACCES 13 /* Permission denied */ +#define L_EFAULT 14 /* Bad address */ +#define L_ENOTBLK 15 /* Block device required */ +#define L_EBUSY 16 /* Device or resource busy */ +#define L_EEXIST 17 /* File exists */ +#define L_EXDEV 18 /* Cross-device link */ +#define L_ENODEV 19 /* No such device */ +#define L_ENOTDIR 20 /* Not a directory */ +#define L_EISDIR 21 /* Is a directory */ +#define L_EINVAL 22 /* Invalid argument */ +#define L_ENFILE 23 /* File table overflow */ +#define L_EMFILE 24 /* Too many open files */ +#define L_ENOTTY 25 /* Not a typewriter */ +#define L_ETXTBSY 26 /* Text file busy */ +#define L_EFBIG 27 /* File too large */ +#define L_ENOSPC 28 /* No space left on device */ +#define L_ESPIPE 29 /* Illegal seek */ +#define L_EROFS 30 /* Read-only file system */ +#define L_EMLINK 31 /* Too many links */ +#define L_EPIPE 32 /* Broken pipe */ +#define L_EDOM 33 /* Math argument out of domain of func */ +#define L_ERANGE 34 /* Math result not representable */ +#define L_EDEADLK 35 /* Resource deadlock would occur */ +#define L_ENAMETOOLONG 36 /* File name too long */ +#define L_ENOLCK 37 /* No record locks available */ +#define L_ENOSYS 38 /* Function not implemented */ +#define L_ENOTEMPTY 39 /* Directory not empty */ +#define L_ELOOP 40 /* Too many symbolic links encountered */ +#define L_ENOMSG 42 /* No message of desired type */ +#define L_EIDRM 43 /* Identifier removed */ +#define L_ECHRNG 44 /* Channel number out of range */ +#define L_EL2NSYNC 45 /* Level 2 not synchronized */ +#define L_EL3HLT 46 /* Level 3 halted */ +#define L_EL3RST 47 /* Level 3 reset */ +#define L_ELNRNG 48 /* Link number out of range */ +#define L_EUNATCH 49 /* Protocol driver not attached */ +#define L_ENOCSI 50 /* No CSI structure available */ +#define L_EL2HLT 51 /* Level 2 halted */ +#define L_EBADE 52 /* Invalid exchange */ +#define L_EBADR 53 /* Invalid request descriptor */ +#define L_EXFULL 54 /* Exchange full */ +#define L_ENOANO 55 /* No anode */ +#define L_EBADRQC 56 /* Invalid request code */ +#define L_EBADSLT 57 /* Invalid slot */ +#define L_EBFONT 58 /* Bad font file format */ +#define L_ENOSTR 59 /* Device not a stream */ +#define L_ENODATA 61 /* No data available */ +#define L_ETIME 62 /* Timer expired */ +#define L_ENOSR 63 /* Out of streams resources */ +#define L_ENONET 64 /* Machine is not on the network */ +#define L_ENOPKG 65 /* Package not installed */ +#define L_EREMOTE 66 /* Object is remote */ +#define L_ENOLINK 67 /* Link has been severed */ +#define L_EADV 68 /* Advertise error */ +#define L_ESRMNT 69 /* Srmount error */ +#define L_ECOMM 70 /* Communication error on send */ +#define L_EPROTO 71 /* Protocol error */ +#define L_EMULTIHOP 72 /* Multihop attempted */ +#define L_EDOTDOT 73 /* RFS specific error */ +#define L_EBADMSG 74 /* Not a data message */ +#define L_EOVERFLOW 75 /* Value too large for defined data type */ +#define L_ENOTUNIQ 76 /* Name not unique on network */ +#define L_EBADFD 77 /* File descriptor in bad state */ +#define L_EREMCHG 78 /* Remote address changed */ +#define L_ELIBACC 79 /* Can not access a needed shared library */ +#define L_ELIBBAD 80 /* Accessing a corrupted shared library */ +#define L_ELIBSCN 81 /* .lib section in a.out corrupted */ +#define L_ELIBMAX 82 /* Attempting to link in too many shared libs */ +#define L_ELIBEXEC 83 /* Cannot exec a shared library directly */ +#define L_EILSEQ 84 /* Illegal byte sequence */ +#define L_ERESTART 85 /* Interrupted system call should be restarted */ +#define L_ESTRPIPE 86 /* Streams pipe error */ +#define L_EUSERS 87 /* Too many users */ +#define L_ENOTSOCK 88 /* Socket operation on non-socket */ +#define L_EDESTADDRREQ 89 /* Destination address required */ +#define L_EMSGSIZE 90 /* Message too long */ +#define L_EPROTOTYPE 91 /* Protocol wrong type for socket */ +#define L_ENOPROTOOPT 92 /* Protocol not available */ +#define L_EPROTONOSUPPORT 93 /* Protocol not supported */ +#define L_ESOCKTNOSUPPORT 94 /* Socket type not supported */ +#define L_EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ +#define L_EPFNOSUPPORT 96 /* Protocol family not supported */ +#define L_EAFNOSUPPORT 97 /* Address family not supported by protocol */ +#define L_EADDRINUSE 98 /* Address already in use */ +#define L_EADDRNOTAVAIL 99 /* Cannot assign requested address */ +#define L_ENETDOWN 100 /* Network is down */ +#define L_ENETUNREACH 101 /* Network is unreachable */ +#define L_ENETRESET 102 /* Network dropped connection because of reset */ +#define L_ECONNABORTED 103 /* Software caused connection abort */ +#define L_ECONNRESET 104 /* Connection reset by peer */ +#define L_ENOBUFS 105 /* No buffer space available */ +#define L_EISCONN 106 /* Transport endpoint is already connected */ +#define L_ENOTCONN 107 /* Transport endpoint is not connected */ +#define L_ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ +#define L_ETOOMANYREFS 109 /* Too many references: cannot splice */ +#define L_ETIMEDOUT 110 /* Connection timed out */ +#define L_ECONNREFUSED 111 /* Connection refused */ +#define L_EHOSTDOWN 112 /* Host is down */ +#define L_EHOSTUNREACH 113 /* No route to host */ +#define L_EALREADY 114 /* Operation already in progress */ +#define L_EINPROGRESS 115 /* Operation now in progress */ +#define L_ESTALE 116 /* Stale NFS file handle */ +#define L_EUCLEAN 117 /* Structure needs cleaning */ +#define L_ENOTNAM 118 /* Not a XENIX named type file */ +#define L_ENAVAIL 119 /* No XENIX semaphores available */ +#define L_EISNAM 120 /* Is a named type file */ +#define L_EREMOTEIO 121 /* Remote I/O error */ +#define L_EDQUOT 122 /* Quota exceeded */ +#define L_ENOMEDIUM 123 /* No medium found */ +#define L_EMEDIUMTYPE 124 /* Wrong medium type */ +#define L_ECANCELED 125 /* Operation Canceled */ +#define L_ENOKEY 126 /* Required key not available */ +#define L_EKEYEXPIRED 127 /* Key has expired */ +#define L_EKEYREVOKED 128 /* Key has been revoked */ +#define L_EKEYREJECTED 129 /* Key was rejected by service */ +#define L_EOWNERDEAD 130 /* Owner died */ +#define L_ENOTRECOVERABLE 131 /* State not recoverable */ + +#endif /* QEMU_9P_LINUX_ERRNO_H */ diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index 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 } +#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 == ENAMETOOLONG) { - err = 36; /* ==ENAMETOOLONG on Linux */ - } else if (err == ENOTEMPTY) { - err = 39; /* ==ENOTEMPTY on Linux */ - } else if (err == ELOOP) { - err = 40; /* ==ELOOP on Linux */ - } else if (err == ENOATTR) { - err = 61; /* ==ENODATA on Linux */ - } else if (err == ENOTSUP) { - err = 95; /* ==EOPNOTSUPP on Linux */ - } else if (err == EOPNOTSUPP) { - err = 95; /* ==EOPNOTSUPP on Linux */ + switch (err) { + case ENAMETOOLONG: return L_ENAMETOOLONG; + case ENOTEMPTY: return L_ENOTEMPTY; + case ELOOP: return L_ELOOP; + case ENOATTR: return L_ENODATA; + case ENOTSUP return L_EOPNOTSUPP; + case EOPNOTSUPP: return L_EOPNOTSUPP; } #else #error Missing errno translation to Linux for this host system From patchwork Mon Feb 20 10:08:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13146239 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A219AC05027 for ; Mon, 20 Feb 2023 10:15:46 +0000 (UTC) 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 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== 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 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 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 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> 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: TGEvX8HophDEkN/ZqXsKTzZBw9VmtzjhBxGWAukpnPhjZHGv0Yu5mob4slA8laVpnFRJLvlLxUaBo/hxHuoJRVJ0N7oOLvXVbX/2VQ1UNFVlH8780woJUbi80DR4qKEk0cs3c+8fuZUFNtT2LYfQ3TeDvndap4uMoTv4Fm4aGiGNaXfoavsAie+99gN6qX84QpDO88clRrw1efZdlp33lIQOoo23iXjFOwmix6UUgFnzhLAgn+RVFp5Nq7ujoS9EvZ5Rh2KiL4FKdQns6HCFDe3sXkj4nhvwlq1D4XcEZV7X0FaZHZ8Xd4DQRQoZuu0fmDwpFciYKs8y5a0tgrjDnfCHcykiQbLGk9Dbh9XmP8Vo+JyVUJ2UL/FQyjzDysTX4PaCFUgQBz7JqpDNavoXOEWshZIAEKQnYXmiEk3N06Ib9wL/+SVKrt4LSNH5gnP8w0SxJBuxbHNybgGJ7CXpE9gks9jXq5OWuj/EqVCslBcTF5sKlf55j0B8pKMj47OfljiDOk2KOsbolmxugqjiQxGwBR2KzZdu1lyL54huZCfKjzBHG0noUgLZqMJ/FXNGUtvGwDp9OiJzbixPTklcUAYKf2JhbvNsER4/SFxGBgOzWItPZFkHLg4egrnhnciSb2RZB3TKEohChAxjfdoSnznxGX9gT3j3CwDKKyW95lY68r6P6hvzmGVp4KFZiSUi5TtL1RtHNMjmzMCC+fsoesIlgLiTYmfJhDOqA6+kwzzO7pM/b3N2qEb8q0hGtHdDZqv8Nnaro78T3FGTAcJSZjtDASl3HKW2usIp18WbE+bIXx6umqBSeDdileOsHDQ6ykXX+K3TsG8vERLHeAgkVdTcjGS1PWLL/9GM2DVCZIgK2GyiwSwFhZ/PnLTlDwQwXXxJX/iCuevFpM2Wt7H0De6EvgxlOpFvIi/e1w3WMRWJoAGOl70h7SwrATKMAzuyLxXFOq0JfXHjr5FI7InUs8UvNECTJRfIydQTJJopWCRPXn1/AAL4sVF4jnd2pkgh3+SYcFhM5/wgARx36i1H2RK3tMkztjGZr7ovi1mF5epLZv3x/ot6EVcFrHj3Da9lFYjR9ZqiUblMXugS91FMfl0sNadHLwNPhfZnWqIQpiS6dsQkGg9093ATLZTe5C5FAo+ElCBdBQvpta8UMJcnXQ3qzoMD9QwrLu99fpQa6IeidPV+lbh5Aea0xnZmSpNDX0nES547ab/YL03tW/agwitLuOgPyDraeEUxR5jNwdFTGLJHzNEI/lu3cWD011JA732yh4JmiqoipXxJ4eB8nQxZGEwc8AoVHWh3NIPcYX8VQaXyIr+X2nISLGGSxXhrjFNe6vGOfhyaNLq/Jg9hlsZfykWGGEBG3Md5m3OWoVDNlmgSjjK7YFH9Q86/KqEq88k3TsBaYQSnQ3pFUCMHEMWJaSQRm5gIMzlq/HsiplowIs3ZDzakktnFq8iPTXCSZquQuYKV+Pzoa6re31mzCSQNa6t1vrwYp+qirqbKctBRM/6fuqdTn5Zaym/KlVX99UU24ZJDDSs/FlRLWpX549n1eZZPNYuf9Ud0RDsDXKT/ED5Kk5u6RueN/OCXa1SrS3tN5l+JxxKbFO+hMx5Fjw== 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Guohuai Shi Some of Windows error numbers have different value from Linux ones. For example, ENOTEMPTY is defined to 39 in Linux, but is defined to 41 in Windows. So deleting a directory from a Linux guest on top of QEMU from a Windows host complains: # rmdir tmp rmdir: 'tmp': Unknown error 41 This commit provides error number translation from Windows to Linux. It can make Linux guest OS happy with the error number when running on top of QEMU from a Windows host. Signed-off-by: Guohuai Shi Signed-off-by: Bin Meng --- 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 From patchwork Mon Feb 20 10:08:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13146235 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A8D0EC05027 for ; Mon, 20 Feb 2023 10:13:45 +0000 (UTC) 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 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== 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 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 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 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> 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: FA2tdfpz0MjERVsVL9gjRYsevSSrJ8YgcDT8uhKA+E6w81uyBdaiGUxdnftz4EpQzutHTsFYDKkjcddEUaGBIep4Hs9Tx8W0rkEgbu5IdfreVyKOpXkuGZCH8AqzF4hxY0i0nrxfM9RZmeJsoEOV7bjali7s0FFgikP74T7pjUVoFlXW1b8JPuwyArq4s0JpRGwZEnf+hLMZRhJ6YcHcJ4nn8NY5/rPuso/deI3vUnG9HUm7/Kg8K78N8vytGhbUdrn4/dxnTRt5ZyBfpCTr2+djxUzGepzx5vl2q+3X7nRwRrglAZfot0qb42rt3vV9VO/WfrtQlNPCm1d2fd5SsHrF/KlFACSKRMeHDcfFYy0b7GJTI7/FuvynnX8K4siCq//U3N40oZFfVlFWqxylt3wAl3drBJcRuh3l59+tN+E/DDkqt6BfYzDplCCoTAf3uyXv9szyvMvK1XEpmrheVXi4zuX69Rx+ujAaHKaPT+ki+qUPEsXuP6ORcoGzJaXOY4IGRlplVdeNLsAv5qrmkZzrYtRkNrPz3GCbBCK1MfyveRJFt7Nn/TuxafytF67GDT3It0SOsHoRoAjlWMzhgmMDdhku2/7IaBNrpj9SrLaLWR3XboeHrdXytpsZQ35WLvOdAj2Wb1LKL1OKGQ6HbapyotPKK/zwzsKbI6B+EHvpVfsLB/FWH7vTN8NvC0MyCeDhEWGvJPC2emGw3CXSlFiWuY30HLZrUu1xIPjwGOAocWuE+pyYZ0XbfbhxSGcGSD6ECMcJ6NVKvO41xPFZdSWHdh1jBHIEFtCHiJW7UAqXxDn0WMNjZtrOjc6BQs0j2jAxBEWrPQWVEHiPqPgUEtdfUOptwFfyMeMswehT7RKRYiXkjhlwD3QxI4Sfx5HKRHqs1+/t9KXYT3jRBD8hlU8OFAYsz1HjfJHsdnyV6outXKaRJFApApxmiGtbGDutyFpWMG+qK4ilAdNBQCd6Av/I3Gnvst1ktGHopI1bhZZ224YxMoZg39bD/v0nq8G4I6VYY0c2V2e2RHt5nWQx4QFjRSJUlRd270grX9ut9Tb8A/Gyop3oQ4t6WCGkg5HgisTqoOpK9Yys5IW13cNEZzKEi8cEdH6/JhSu/hZiPx8TJboH1o74bCLJ08jmv/lrkCWhbw4KZBfdXTO0rlwSSHmFW4eG27Gx/0gtFPnYnMPCDacbyjwNEVAEZZISbksVPt8NzJDia6C1zCaeNeQgDDU9mGvbNE45L1zudKBk4Pekx5o+Th2LAwMaZF+tkDwdKea4z8XWTM8+NPUdoBRXAm5r0mhMzYJ6QGFKsJNtCw5J66EKt8LAvBZ+9FUldgouLyrBbVpNPueccyjEepZtamUb9tzBou3CQrQE3g0A9GoPv/2we5SE24fCc7hGtSrvBL9f4z0EAuFQ0NiPaCEb4AWW80e9jY9cFisyIJx+W2fyamA9Kl5QtcNKMk8c3gnqyWdz4B9BbJbTSJpapMc96ds57bCXwwbsp/CAdv/ZvK7KyrGwJxHoBDd+ukz4/gKUDkRVf+XB5ZpiasDUso3hTVydj8bNaQeoglTWXHGIakOM3c2pGeOoNbpOS2ZZM2eR96z7YsDvOHLiJfqPvKCnfw== 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Guohuai Shi We don't plan to support 'proxy' file system driver for 9pfs on Windows. Disable it for Windows build. Signed-off-by: Guohuai Shi Signed-off-by: Bin Meng --- fsdev/qemu-fsdev.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fsdev/qemu-fsdev.c b/fsdev/qemu-fsdev.c index 3da64e9f72..58e0710fbb 100644 --- a/fsdev/qemu-fsdev.c +++ b/fsdev/qemu-fsdev.c @@ -89,6 +89,7 @@ static FsDriverTable FsDrivers[] = { NULL }, }, +#ifndef CONFIG_WIN32 { .name = "proxy", .ops = &proxy_ops, @@ -100,6 +101,7 @@ static FsDriverTable FsDrivers[] = { NULL }, }, +#endif }; static int validate_opt(void *opaque, const char *name, const char *value, From patchwork Mon Feb 20 10:08:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13146232 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9B27BC05027 for ; Mon, 20 Feb 2023 10:10:15 +0000 (UTC) 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 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== 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 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 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 From: Bin Meng To: Christian Schoenebeck , Greg Kurz , qemu-devel@nongnu.org Cc: Guohuai Shi , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=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> 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?q?CIl5qylIlbtTx3V7gpiHZ1P90XRc?= =?utf-8?q?fMxdhEwX0gFI59GkRj+EixSZWVlDnER4cxXpG1CCtxBO9y5lsilGy18DggmjPAfhX?= =?utf-8?q?Hta7bXaZ9a0kkmJI3sFPaOqQPMMMW+6CSNkeUvLD00retInalh2r0azIrG6WENghG?= =?utf-8?q?EFdH1Mhi8gWIYXVlcsYNEfA1Uepy2kUiStEOssgU0PUmIgq76CK5BB6L2WhAvyi1l?= =?utf-8?q?14pHXMfjwDD28ZiRnuZn7xDzAgQVvks16BxmLyYfCi2FX9lsSgvKMxVVMfErCMWLu?= =?utf-8?q?Ogc4dAA1ievBiXtb3bQ0jjG8fHb/5bE2mcE9tmRll9y0+H8cmcoPtrLhJb9Y5h7Pl?= =?utf-8?q?st2zKhsC6oGIzdUJflTy+qMfL2QlI9J1YwxHrpURUwpZtvhCNRUBXRmedwMPPUfKw?= =?utf-8?q?KjllSbduhkJd3K2TRyXWip0gNrb+a8lE6qhYxolOd/cCrIMvwFoXFDdaExT089pI+?= =?utf-8?q?gTqRkWtr9RPRhm/Y63VGKDfaADQfTZHtX1O8PNWw9U5jdg/5Uno/pILs/upzriKQC?= =?utf-8?q?7Qa1zOHW/4vWzB5I83j3BWlwML2X+evs2BM7tydZPq7IliGDt8JW5LmOWVsJ93B50?= =?utf-8?q?ChUY2Bcdh/SJHQPSpvHYrHFFKBqLaGE4OqSfXNwGjSL+8pvMzdrUYPeLGXIqRFPpT?= =?utf-8?q?SIZpPZ0aibggThk1sEKDa7ijBb7WRQcUr98XnjZ+/msXmPAGsj17OAdSAlT2zcXPa?= =?utf-8?q?+lyOKu5Aj4ImuN7NtiA0uJp2dOVLzSV2qd2/xFB7U4AYC65iqHqsWTqcIyYvGnWl7?= =?utf-8?q?5p67PdoAeNa9Pvhmr+2QvSnIM06Y2NoZAabRAZ/GOHA6sqOQVz3PyLbLQw4ad2mn3?= =?utf-8?q?+incTWwXNIyCZbemXQMthYT38miGonFUK4g6AcRBOtZVyCotpTZmUJsOBUA/gQory?= =?utf-8?q?eQ/nB6sdVfiFrtgLjZlw5ICzJ6haunHi90UnUpJMekQKKya6vzL4U38mmNyNXHHdr?= =?utf-8?q?9Z42VfSxjGolhq8NbU+QxsRHbkN+jvUOrLbdCfSMHSG0rbOC8VtbbiD4j7MTjvW87?= =?utf-8?q?0TkvPIjwNs3sQVa3I6uy4qG4CPEEA07vQX6oDY8Hv4g+sTWVOIze9ww46CXs8g6DW?= =?utf-8?q?+TviedERQ42Rr7LeFMyOH+OETAVkqp0g/mmTZMa+Rd97SHIfvF4HezsIp4tWoJQbw?= =?utf-8?q?7948H+rZh6Kx/wljc3zDJRHzKPl50FYhw30KTCZK6OgACHQ7Vau7LOCdwQwXGJ9fp?= =?utf-8?q?inQBegD9nTyYO3UPwdX4iYDLbRAgH7/Iaws28+Awtw5//91V3oQipf5O7UOHCDoFi?= =?utf-8?q?z0x2BErX407whDt/6b3oTKYyk8oXa6a0tOhkhMbMG5IyUzZFhFZDmpeScSSBQDenF?= =?utf-8?q?rH4L7HFiR+NHk4Ej8vEchgLyscz4AhhxlCZvYa/mlIjTzLrWTtgEhdRMqzTMvjz6K?= =?utf-8?q?tcPSfberZvMyZ4s2qzjZnU+oig1exVQkNR8OCUUI6DBjjIeqgDWDidrgV3VZruf1Q?= =?utf-8?q?4zxjYQ8plB2W+M1BA2DsIqSwImDn2kuF5CZMPykjUS6a4CAojPM/SXyaYVR2wrlvW?= =?utf-8?q?jnzFlvgHeYBBe9zGcbUwVURTohsK5wntqQ=3D=3D?= 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Guohuai Shi Adapt synth fs driver for Windows in preparation to running qtest 9p testing on Windows. Signed-off-by: Guohuai Shi Signed-off-by: Bin Meng Reviewed-by: Philippe Mathieu-Daudé --- 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, struct stat *stbuf) stbuf->st_gid = 0; stbuf->st_rdev = 0; stbuf->st_size = 0; +#ifndef CONFIG_WIN32 stbuf->st_blksize = 0; stbuf->st_blocks = 0; +#endif stbuf->st_atime = 0; stbuf->st_mtime = 0; stbuf->st_ctime = 0; @@ -230,7 +232,8 @@ static void synth_direntry(V9fsSynthNode *node, entry->d_ino = node->attr->inode; #ifdef CONFIG_DARWIN entry->d_seekoff = off + 1; -#else +#endif +#ifdef CONFIG_LINUX entry->d_off = off + 1; #endif } From patchwork Mon Feb 20 10:08:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13146230 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 860F7C636CC for ; Mon, 20 Feb 2023 10:09:54 +0000 (UTC) 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 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== 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 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 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 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> 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: b6aa22Gboce3tDJnb86FICarjE67bbRLlvw71e0nuQNNvDv2/ikHENhRHDVipHi0eb/l3uK4m9A3IE+P1CdluKYH9zYz0wC0TbQaqmxacw2+uZbehojmyDOVSxtTvYltPSrZVaiX3qXIIv1BnAd00WNcngOU7g++liIncWiPxO0qzCA9AHyuAFrRxUswI7OSOdFVRMgGlcD7s/ZwFtxy4flWWcFfIIw5Lh5tlmR+elS7XEIca2UrLMYEPr4vZiu/W0sgyuT/4KjCMLKbfXDNDQ5T2C6gq5cpz93hdgHSevhtJR1FFbPrjxVo+mVDc9E1Uu1R2ubWw8FZdRNDGvH3IlOuwAQYMeEKw5RIkGLEKczh45GkVHALeYvWuwgOdwjI2flKXj6NZEAygiEmQIqHPrEyh07AkGYPk+1FNVBJnArHc9ScPHYSlrgn9uBXNKuuru4scS9A+TDHxOMm2nfdy0kUN+SM5Bn2lUqQJtVhQdvlo4EdSc/yhsZ8t08fFg47Ds96utA0+VCKXuuNL6EvNWO7GEnrjnRCCTk7pJsk9fULvQHu84o0H1Mw8eSet9UJQ4TNl5e7MnY84eeg/bKceS9KTUky720YLthuG05B3Yu/mhhU0ylicGYRIG8uHhwSdsESp6nNF3yLSHLKdryy0O15/Fhf54gHOBFbSuDn2SkTYy74laP1oH+LBFtAhkYBjhqOD4i3Q8hj+XQRzYqNxzkut9rM6F3i7e0tsRx+d1uyIlbSbR1xe3RSdWke1g9YxawdwF57vgcwu7j2QBM6TFWQ2H0ZjL1zd+Hs7rlI/4+iyK/CgTWTAn58qXzAtxcWdeBpAc2M+oUTdshve9lMICg7ZIcfQfI8CJ9sNXP6/kk1d35Lh0kZPJqW/VMfCQTGvSpGToTi88kMxpPja4cZUraUJvxQhH2wFMoRfTrzrFMUUNMUgJLl42asQaguT6i7QgKtyMiqn0vrVRSpAzUEu82sblGsiMrSmSEcYscqlLVmNuoFw+tt4q+nQyZvMVR6S2cWfAj9o1NznH3dAL9roqzqXTXtVeMrXLwba15nVHNHTX0oTT5Sm2rD2clYtf94mGXeWmZh40jTTZdiBmPbGe0IIZoQyKtpR726RknEfopWrS0FjnWlgGq5aisoyBVGmPZEnS7aatx/qQUgGHXeUSc6DPrE+intGgx8/V9ZXyEjFBZGCBTYuvBch6gO6j+td6f6bA36gTHJZFRDJcZVrPynLz6m1JZvpg86pcfeWVCDiOxlyfgExU2ec1x4fRnLxEg03hDfcFs5XuKs5nbhCjxnmzc5o7zeGO8i0q6IaJpclvw+0GOyMTrWz5wBcf9zvfbhJXvAcrkH5+Yz+4UUSViN0N/2F08ElQcTPvJO3mPV/XcnTpPpn46Bq6c9GhaWXI7x4vPOi0jTZiH71EeOmLsHCuxuK1od9DPok02INU43QPhjFuU0m5wCcqTur55u76b/t0U1XO147VJGTZmxeqZq3js8PIbqqF2ebDfZWXM7/EfR0OIgtr+UorEJm1T7NFTtgQs5ASWuS9or7hNTl5q7jYHde9S8s1XblcnRQEeL90mwOT3/wv+NyhKwECudTNEKNLhd8O01X+f3dJpasA== 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Guohuai Shi Windows does not provide the getuid() API. Let's create a local one and return a fixed value 0 as the uid for testing. Co-developed-by: Xuzhou Cheng Signed-off-by: Guohuai Shi Signed-off-by: Bin Meng Reviewed-by: Thomas Huth --- tests/qtest/libqos/virtio-9p-client.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/qtest/libqos/virtio-9p-client.h b/tests/qtest/libqos/virtio-9p-client.h index 78228eb97d..a5c0107580 100644 --- a/tests/qtest/libqos/virtio-9p-client.h +++ b/tests/qtest/libqos/virtio-9p-client.h @@ -491,4 +491,11 @@ void v9fs_rlink(P9Req *req); TunlinkatRes v9fs_tunlinkat(TunlinkatOpt); void v9fs_runlinkat(P9Req *req); +#ifdef CONFIG_WIN32 +static inline uint32_t getuid(void) +{ + return 0; +} +#endif + #endif From patchwork Mon Feb 20 10:08:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13146227 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 21CA0C05027 for ; Mon, 20 Feb 2023 10:09:37 +0000 (UTC) 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 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== 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 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 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 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> 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: XTVTLAyZw54KovutCqxJY88Jtwr3l0DKGHnJtnAxpqKFfElCEQVMysD10lDg+z42Je2w602dQw3/lcZZZpc5OZBccas3r5nE6+OgDUUtyWb7i5ptjphi03V7sVFI/bUU+uVyQmsPlAZKW6aPrCrzdEqo/gc/tY43JEodntXuUa1PWAIBEmQ6u28tbWxskgfNpJqMn+FVgd7iB9caH0K8cdTWV31Pdf6pK2rE5OWRq0fzJrYhEer1hT81KfOrCV7PPvfyNwL1WeKKNdp0f2zGdpaBv7O7bhltcMDSqVJNhI56l+cRGIs0oG+2BOHrg5vw7p7dOZbboMEJ7+YGXZ+x8dQYV6xhZ20RhqGUVVXrgYtzf8xhp39FLaGImOAtiE17j6yyPAlFgmQwvmjjy0WfObKnAzIHyXL50MEoNATYWk13yEoAvX5eFxyXogcxus44Kkdh5ICF2od/yrBkcC+sLSf+gjdl0c3y0Syuvk0wVMfW793r4o+DkK39XapkHa/Mm4h/FgnW+fFYWTm9FelADl0wINw+E3yiVs+5K6YTJ/9ej3zJ6o/AvHMBge3Mc6FxJGCCQ8ckmzQy+GuF9oIp20J63Ecw36TO1epgE7svWKEqRiYoSprQf1MPhjCR9ifUlxjXfHyXFVe1bXBwYAtdhqCcKaAJZk3YTtpRY8bYtqDkcfLKKk0Ku1xVmFKLygTmbrS/2v1D5VmK2eMTgvN3/asv/W1XS9bGrGR9ZRcnPncWM4DHbOPzSQtkiPyBlfPZv0q7UcH/sUSdE1uXUgb3offwliRCq366e1CozAeFJ7X335Od7P7nWkzaiy1xP3jKcwM0Y7Xa+8SbE0REYLYAdIIfK/vcnGIdwIU1EwumSHSGmfpIfS3XjHBs2WTB+9WjsvGfAa0vmdAGuQlcbCF+KyJqEOL1TOQWmFTwf4NiYC8ZTEhO06wAgRjl/nmA6czxvK1KrnJr4AZ8+AVmc46Ej/c28j+FTYmMFE+Jidf+AzUM/MRnNqHaf1tw1JHCsSNcGSAxDuj+tO06Mg39upS5LtcG7hF/sWY05ueT97naO4yDTJ63TXfLttLJvO8DnTpLcahajQ9dc9gnrdd2FrZD44cjfqcFaJMdUPuusedfwLTEWmvQufMB0vpZ3bESmYLNhlZFpHRNmOGA9O7gclkyMKPJ53QgYmtipWDr0BIqLBnLGiotBmyY1T5uHOqThDDS3OoKv/1ctjRUR5W3uQpDiKTgEU25eY2FuCd9CUtHE91/M5Vso8taeKZVpQWrQFMKV4aj/sz94UK8rD5+g+p0okBUbXpo2dnYTn9k7kVrOZCx0jHTE8njD+Dfx0b/VTe/JYdEpsrSvUDWn1kKQv6LePnn92MMWuQ9mPI5/YCPf3C3vEAjhknKZS3dTeo8+F/l2wChlM/nJ5nZIrj9nsfALxGW7bEZcJpK6A2SN1o6dPoQdDOxVr/yLyZp4XrC6t9zhsvNAhOo8fGyMshqYmx4peYPKTGJA2TDR2oE/okSc4VrstN0naT0SkHbzuOeYOHyYyAhP6mceHiVGA0rRe7gsxWOGt6vVVaQ6yC9OnGBcP6hT08DsgpWhPJcp6CWq9zv7560nv+j8fb52xtdwZyzog== 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Guohuai Shi Enable virtfs configuration option for Windows host. Signed-off-by: Guohuai Shi Signed-off-by: Bin Meng --- 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 = get_option('dbus_display') \ .allowed() have_virtfs = get_option('virtfs') \ - .require(targetos == 'linux' or targetos == 'darwin', - error_message: 'virtio-9p (virtfs) requires Linux or macOS') \ - .require(targetos == 'linux' or cc.has_function('pthread_fchdir_np'), + .require(targetos == 'linux' or targetos == 'darwin' or targetos == 'windows', + error_message: 'virtio-9p (virtfs) requires Linux or macOS or Windows') \ + .require(targetos == 'linux' or targetos == 'windows' or cc.has_function('pthread_fchdir_np'), error_message: 'virtio-9p (virtfs) on macOS requires the presence of pthread_fchdir_np') \ - .require(targetos == 'darwin' or (libattr.found() and libcap_ng.found()), + .require(targetos == 'darwin' or targetos == 'windows' or (libattr.found() and libcap_ng.found()), error_message: 'virtio-9p (virtfs) on Linux requires libcap-ng-devel and libattr-devel') \ .disable_auto_if(not have_tools and not have_system) \ .allowed() -have_virtfs_proxy_helper = targetos != 'darwin' and have_virtfs and have_tools +have_virtfs_proxy_helper = targetos != 'darwin' and targetos != 'windows' and have_virtfs and have_tools if get_option('block_drv_ro_whitelist') == '' config_host_data.set('CONFIG_BDRV_RO_WHITELIST', '') diff --git a/fsdev/meson.build b/fsdev/meson.build index b632b66348..2aad081aef 100644 --- a/fsdev/meson.build +++ b/fsdev/meson.build @@ -8,6 +8,7 @@ fsdev_ss.add(when: ['CONFIG_FSDEV_9P'], if_true: files( ), if_false: files('qemu-fsdev-dummy.c')) softmmu_ss.add_all(when: 'CONFIG_LINUX', if_true: fsdev_ss) softmmu_ss.add_all(when: 'CONFIG_DARWIN', if_true: fsdev_ss) +softmmu_ss.add_all(when: 'CONFIG_WIN32', if_true: fsdev_ss) if have_virtfs_proxy_helper executable('virtfs-proxy-helper', diff --git a/hw/9pfs/meson.build b/hw/9pfs/meson.build index 12443b6ad5..aaa50e71f7 100644 --- a/hw/9pfs/meson.build +++ b/hw/9pfs/meson.build @@ -2,7 +2,6 @@ fs_ss = ss.source_set() fs_ss.add(files( '9p-local.c', '9p-posix-acl.c', - '9p-proxy.c', '9p-synth.c', '9p-xattr-user.c', '9p-xattr.c', @@ -13,8 +12,11 @@ fs_ss.add(files( 'coth.c', 'coxattr.c', )) -fs_ss.add(when: 'CONFIG_LINUX', if_true: files('9p-util-linux.c')) -fs_ss.add(when: 'CONFIG_DARWIN', if_true: files('9p-util-darwin.c')) +fs_ss.add(when: 'CONFIG_LINUX', if_true: files('9p-proxy.c', + '9p-util-linux.c')) +fs_ss.add(when: 'CONFIG_DARWIN', if_true: files('9p-proxy.c', + '9p-util-darwin.c')) +fs_ss.add(when: 'CONFIG_WIN32', if_true: files('9p-util-win32.c')) fs_ss.add(when: 'CONFIG_XEN', if_true: files('xen-9p-backend.c')) softmmu_ss.add_all(when: 'CONFIG_FSDEV_9P', if_true: fs_ss)