From patchwork Mon Jan 30 09:51:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13120830 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 66190C54EED for ; Mon, 30 Jan 2023 09:54:40 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMQqD-0002xY-7G; Mon, 30 Jan 2023 04:52:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMQqA-0002wo-Oc for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:52:42 -0500 Received: from mx0a-0064b401.pphosted.com ([205.220.166.238]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMQq7-0001zl-GN for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:52:42 -0500 Received: from pps.filterd (m0250809.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30U9hjuC015618; Mon, 30 Jan 2023 01:52:24 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=Xy/0/TnZzqrfJjp7JG4s8BGGuRiy5TjlmKMjhpcBLTA=; b=H75mkmO0gmaJdkIwRGH2iBhwRHwocM9nUJx6+gBaj6tlCYtGWZQkZA5zyJS2Yjyhgtx6 e6sO0CdpWpK2LS9cAgkuVwJOGezHmVOH0FFb92WfVYCIr8nLZGO525xw7d1fwXCjzmBA 06+MnB0g2DBOu0U/+EtxJY3Abgxir0Bg0y3gDbqryafWxXYVToztu8N3g+VROxxhrfVh QrdUgYCGCfvTjXuNOsECxIUgRN1krccGIu+wwcuRiIhIghxheQ82f0ECBCCbJKliBWGx K9SBqEbp6+N6RvreQsNWWXrzZYGxklRhD00nxBBOVJcrl+2ZI/Oxr6LNT9xE+e/grSFz IA== Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam04lp2046.outbound.protection.outlook.com [104.47.74.46]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3nd43rhj5h-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Jan 2023 01:52:23 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hX7tQeOpmAbFUwUJhMg8Y+4yzXlqWx9ctxH1ck0eJNrziIrzQQ7sJ+kLfqOXDEg9VJ/YjkwU9v+EKjABxv5b/pQu3oL06g3Z5JXTxwg0IEP8cAcjh+X9Sm8ZUUI07Kom1UQRcSdolIsQiWzSaz3S/0wYXSM07yiMGl9lK2yqEmrhfzo8kLNHwX7NoPptcyACsRWTQa9h73XanAZrYpyjT03fg4ZdpvgWTUErlVz6Bg5t5r0UvEjZwJ9hclpTmltNZkyCSbtrWLC36JkzYxP71ZQr4pggJU27k3pUA4sUzgQj65pnbjGtQVJV6F7PpIAW+idGMb9zbwNk/lWFYtlk8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Xy/0/TnZzqrfJjp7JG4s8BGGuRiy5TjlmKMjhpcBLTA=; b=JtpV5BbtNdsKyEaQ4Fi7rpcCzm8/e2rBboj/+0/QRP4qoHhGc0H8LUaneqV4s6kDR0Z8XWsCVHCJ+nodfBnlXmq2FlteIdxUQ++BQaF1+tU96E5OtaO1uiMB+nWN1hkoeKB8B7E/kWELoLyY8zEDFT1Abg2WlLlVkg9VIWlHKmsvyzodOYKKsVtNZ9XPj4Dkc0IXzkotXZziOXg7OXLbwgeoLVzXdy/7JRNs6u1YBsHgCePAsfjprL4PBGIFk1eQ18uXRjKv2bT4xeRFXF4McSgY9AxO1p/7QTHH5S6dg57ly+p5BcNvcMB81z+wjk8L/STSkqUzHnUNHzWkA9MyxA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by SJ0PR11MB6573.namprd11.prod.outlook.com (2603:10b6:a03:44d::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36; Mon, 30 Jan 2023 09:52:21 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9%2]) with mapi id 15.20.6043.036; Mon, 30 Jan 2023 09:52:21 +0000 From: Bin Meng To: Greg Kurz , Christian Schoenebeck , qemu-devel@nongnu.org Cc: Guohuai Shi Subject: [PATCH v4 01/16] hw/9pfs: Add missing definitions for Windows Date: Mon, 30 Jan 2023 17:51:47 +0800 Message-Id: <20230130095202.2773186-2-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230130095202.2773186-1-bin.meng@windriver.com> References: <20230130095202.2773186-1-bin.meng@windriver.com> X-ClientProxiedBy: BYAPR02CA0061.namprd02.prod.outlook.com (2603:10b6:a03:54::38) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|SJ0PR11MB6573:EE_ X-MS-Office365-Filtering-Correlation-Id: 19d35270-791a-4c00-c27a-08db02a7ae5e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2sPP+oKCynG+jhp8oRJ8ZCQ50boIhZkPB4DYFKf2gCleKWnCAGbnwErhz5GIw2o2sTLAVCD21fZ4p0z1TOq6eRc5yJKs3aM4haNBLs1XqQDckR267IYWajVqi76rAkNddnqmGSgSwjQGW219PauieB++7l30wb4IJ/xCi4ZiTRoRGP9tKzFhyJkLbk83uNw4FTKqO3tYbeVyvVbr/gW/DpomGQIxNTOFKCem/2tcNz+egxmcY87Swn950g1jbG5aRh8AxhsCK8F5XxxQAqWp1cvbIYKH/AoOEypUQmsTAxp7b2ZT/zDFeQtTwgKWk9IZqVcelwNJLPrVzPJzDC3ECxzqy9yX4h1MUbwE2bY2gWGmY3YxOj5TeVG0iSuu2lrPR0TunkAESm0ibcvlSNuMxQT3CHoNisCWgJc1oj5VOJy2a4DrY1mquXdsAcymqkgXFYH0smmCAx3WmWtQHC8ISVKSU98gGTG6fmjbZOVu5HIOQsQYJwzGODGIz6fkcCMhbeZ/Vjtre2SQzbzAJdpYQ9CxuFydikigLbJAXhFSda/+A6GDMDOLsFszIkPZJ1seGj6FxcqyLMc1b5QdWPICsJElAYYDioL1fx4JZcstE2tYcVvsPH5wSd9OjyWNBj+C0JanlX8EPRrV3EM9WGjIk4QFNdPo2KQtzHF4XpEBo29l8d6VFTU6I0fTz933ipE1sEhIZ0hCMVXxkhSusYOj1QYyGFv143XWdM1J0La2IGM= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5358.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(4636009)(366004)(396003)(376002)(136003)(39850400004)(346002)(451199018)(86362001)(38100700002)(38350700002)(478600001)(36756003)(2906002)(110136005)(107886003)(6666004)(52116002)(6486002)(966005)(41300700001)(26005)(8936002)(5660300002)(44832011)(66946007)(316002)(8676002)(4326008)(83380400001)(66556008)(66476007)(6512007)(186003)(1076003)(6506007)(2616005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2ineZShIdvHGjIovamP0qTIwbjGxB1L+eWl1UX6IX7F7lr4vZkDPxrXxFgGPEtmkeaPB6OmH5yZSJ/74rfzQ01AUjE0ClY88ZkTZJqCWxxGptwqlwKyamwref0XCXupO04HUgG7U6aLe7ZyPsWgMK8ts1gRPWkm0QagF2UZV+dzjtlyUY1SMj4yTDkIWAJDKIpDWl1yHtilbj2URxwhxoQ2oUaTYAUlU4yCIWCTcHrrx5IcIZHs/pSxYovF7H2kp/mGSZSY0pssWjGo+3FZ7deDFDh46IjSBoPOI3li8aHo0nLtGu1k8PUYRUP0QLFq6LXH42kT6t2KohqtfQjlZAslWsSxmgtWEVPNQzzvW7C08Y8ajR95ZU+jQlgp/ejR9XfzcgB2DR2LQIpwTu2wR3Ttfz7XOZP1iOjx6IgEu08Z7raDMmbS1PUAXSCt2xoKar2Qi367KV3tqXdprsmZCKdbLjasMZ3smjqgLqrwe8sx+WnJBHnS4Q7dMgwshXGyR8UahVLq4k6vaAFr3Sifs8S+ifkC1n2YBxLsj4i58iN3Ce4B4U7z3B9Al4+S36FAT9ZM2uta/ri0jrcetKHtZ6504iXvioSdn0fHRAHI2Xrq+BcQLypYSzBHFTGmVdgpo9cB8xtTzXIAWcLBT4gXzds1eUIe4id2bKHqMQDRXYpORDf6bwcuJtY0DjWOymcRI4T2aVNnSQ9AgCXoYwYPqRl6FeICZ02Si2T1a6AsckbiyFsGaugBGI+7gYsgGDBrLQaah150ZJgkFYAmzI7huePzVcsAScUlr9zF5dxkF3TS7LoPuU7O/V3PR9M2PYQ8W2o+hpTZm7uMUiiOybbJ7xMRdbjw5q+aCMaEfmeVmtgtEFLpJz7T9AU0r3+/o8DhY8u/4jjIHAzwLnnMOd1XxIqlOQ6zf+TFU0QuYV+vne0u3+O0UiRc4aLScvdDs1R4kkNqCEi/8Wm8w0TANCI9Xf8+mSQiiPsdmE8VJx7rno2c/AsHXBNvGl329T/a+w5LlQqln4SsWt15a1ArpzmxleSnIxTrUHjK+1425SA8X0wKxM6FBnRNrSbIdXk0op/p8/aDBpZMnZtgcSyDLGZRBbRfIbXRRTrFWV+0K6frSzzs1/IutNK00hCYgCfAwswa1eYMoiUzLH6Nj1119jmK5dktpnNtbxQmiKMY7KaOjq3xSwTFKiU8i8ozg1EwQxmefVB1Dh2CC+FTrAFw4PunWsL0SsgY66XPFwZ8L52OUjayTjuxNFzlw2kgUAqyNkV7QtFAK1ImRESA12Y4vDHXOcDa5HieLcEplsfGjQ25ks3z8zPGFLYpJLVRmTezZCwgFpPhhBTIWfos+DrIpWs1d5byWp+StS+paM6YlCDuHLWh7r8/3QaFLCgaRL61r0PjkOzJZNjAqGP/rJDi9LZ0mRlVOTlmrthpI+DP8504Mlun/qUPtUVnP7etwBf6qnYqv+w7PaTlDD2jDQ1oEJhn/NkklNNatRTHtqhw/h6E5Wi0DQnEs0yK1ZnBNkxxKQQIkpiDrsnS2epV+9Hhr1ltDblPbcwIJg+AUqUpJR21NdDJ8QonnvlJIaaQxoRpOdSmj9vHeWTdpQoPAczb8iBeTNQ== X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 19d35270-791a-4c00-c27a-08db02a7ae5e X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2023 09:52:21.4746 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: J692MswqOVHd3tBUTQJMf2bccq4MOfFyTE9tQYfZZbCqhk7pZTwcIt2pDOWMJ74QxU3EYCslQQFry6gjnC3haQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB6573 X-Proofpoint-ORIG-GUID: 1ybrlnIfEigmWLG7rkGvIsin7zyMc9Y2 X-Proofpoint-GUID: 1ybrlnIfEigmWLG7rkGvIsin7zyMc9Y2 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-30_09,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxscore=0 suspectscore=0 clxscore=1015 malwarescore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 bulkscore=0 spamscore=0 mlxlogscore=748 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301300094 Received-SPF: pass client-ip=205.220.166.238; envelope-from=prvs=13943e2a21=bin.meng@windriver.com; helo=mx0a-0064b401.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+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 Jan 30 09:51:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13120828 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 ADD90C54EED for ; Mon, 30 Jan 2023 09:54:24 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMQqJ-0002zk-8R; Mon, 30 Jan 2023 04:52:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMQqG-0002yd-KO for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:52:48 -0500 Received: from mx0a-0064b401.pphosted.com ([205.220.166.238]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMQqC-00020T-WE for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:52:48 -0500 Received: from pps.filterd (m0250809.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30U96eHX000968; Mon, 30 Jan 2023 01:52:31 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=Q51gWYJ+HXclbGSZ9Zlgv6+QfQYRST3Ok+cRzQ1RAzU=; b=Wi95UR7dl1x7I+0mclcCv9Mf3SiyOKFY2qGGasRL0gQ0s/p1MnIboWqcbm1ASEG8yd0w jcxg9Ai/yjb99s04sDG9CsxX4cy/NIE6Nt5rTvfwpDCZE0rPUcz/Jp8WjkM585aZ0Jy7 GT0i+R11UVIVYzFEqTrrtguVUmjFNh4rElLRHpqTSAPOzJquyIMuYdAZzul1hA5px+ki nzfbk5xlNXnHN5ZgFiAOUMMuZoKiAU0t0ZA6osZv7aJeNrSugVz7nmC7REo1PsbJwHV8 rZisPYrF3I/q5/nRQ8tPPvDs1JIetayZc3ANFG4ctPksy42e8AokD48Tnt0RNxqL54fX cg== Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2174.outbound.protection.outlook.com [104.47.57.174]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3nd43rhj5k-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Jan 2023 01:52:30 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=adyR5r5mrgLuhO5KlprkrwgrMVMQYHRjHhr0Sy55xxpiVKNfHBQKDxO9lVwShzQiejiem6sHPv7ogtQEwXuWcxgCyiDZsrAs7z7iA5NU2W3rUjJ7YwD4ytUCPMLcw+LdkNWMtp5BhU/mmJlAi1xLaO2f8ldBnebvG6as7utFoaHoFL0//qa3tVBKmBKXO4P5UAebaH+Ev4cbDTian485vZXHI9DQ+pIM7s78nXkLv5ZDLrVm1MguKPdXG36Wy/tH7gVRvSnpvaA2ihML4QEBEMuwniN3HDOLtld2sdFcOAn27oq6g3XstqMxzWWP+xmnxQfjOeM/nMO8fpnMqhzDgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Q51gWYJ+HXclbGSZ9Zlgv6+QfQYRST3Ok+cRzQ1RAzU=; b=BvNZVLM3zaYbs6AF4qG7T5UtYfW3BUfWZJIBbmTLZBO4LHHFtynrzrwXjC34c0AtLgd2plZsGINAqJD0CmjS9UCM8QpPtgswOM2mIMIxamWiXPPwWyS7mDFwhfUUNVbWJ/aCy/qkbBzpI1bM0JB195G7DrMlGbk4V8dxuh8dBc1Pl91GMt6WRRkeD8SelsRVuev130KVnPqhmcRbEfz3hty37ij5vhu/VoM7QwTuQLfBfcewpnAudTHzXNOP2H11DQuyBy8P02bNcYLy0Rp+F8kMxhWAY0HMuJDnHb4FE8fbI+IJLGowJNb1eP3rTLMIGadOXtE+PcF7nNjwwaA7bw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by BL1PR11MB6025.namprd11.prod.outlook.com (2603:10b6:208:390::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36; Mon, 30 Jan 2023 09:52:24 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9%2]) with mapi id 15.20.6043.036; Mon, 30 Jan 2023 09:52:23 +0000 From: Bin Meng To: Greg Kurz , Christian Schoenebeck , qemu-devel@nongnu.org Cc: Guohuai Shi Subject: [PATCH v4 02/16] hw/9pfs: Implement Windows specific utilities functions for 9pfs Date: Mon, 30 Jan 2023 17:51:48 +0800 Message-Id: <20230130095202.2773186-3-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230130095202.2773186-1-bin.meng@windriver.com> References: <20230130095202.2773186-1-bin.meng@windriver.com> X-ClientProxiedBy: BYAPR02CA0061.namprd02.prod.outlook.com (2603:10b6:a03:54::38) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|BL1PR11MB6025:EE_ X-MS-Office365-Filtering-Correlation-Id: 3b6d3d70-b91b-45bc-4731-08db02a7af99 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RuS7Vs5N93txuSw0V5zzXFfD6RiGhCgKqvpnZeoY6iw7TEUoq2Bt8SwexCEjua3pbZrPE1sGmXpYKJsZZuAtxWC3QXuBa6vSLrTEbOKkexoK3aakR1GeHW8nbatsWvZB30acsKk/a/a7zE4M7oOlen3unKERx/TAJFG3ANcTFsPQxXGsNQCL4F1FLWMD/yfF+LaHcS4+nPg86LCOvh/xzpcar6/Z3Q7z0P3VSsDoWq0dAyMS5WgkNRTAH1337BxqHEuNLdZ7EhhetSwt7jfXwghGAkkdNsPBpYFf1COuwF2w8Xv84UGySjp5KrKQz9LvlmWLtDQ2qnz2jQC7ofIvsnJpuym0A1rTuW4noJzbK6oyzrZPgsP5hSpmzPGmU7ysUtO9iFcjly6RFi2/H39dpVA5uTUUd3NGxF89ahCyx0AEJbhWcW9+FygJM0epj7UJZeT+i+ZzenEqQnLGlCI7LJJihIMpnwBgnCBCO09MAZmWNlR8JkL7P9TKN181FY0LGrlZCm9N7AUeGoJDODTOrGDN6fgZ6tHwX/J3t7gSDxZm9Nml0gYGdxAnB998jLKyQb+MWPiuI5CadlqN4FMQR1rAmpEEHRNkwGtVwTIl77PqvWInoF1ebx2CXnpzF6Wa7JDcD5OKpRNTCEtiQFiZw5sCTekGMig+OK5MVrVD0d6SfXPaQ6hTGd7ofD6TI6FJyNxp7a5wFMd1Q3p4q97KUDbaLk4w/FZp+k9s26GTZn4= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5358.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(4636009)(396003)(136003)(346002)(366004)(376002)(39850400004)(451199018)(2906002)(26005)(6512007)(186003)(478600001)(6666004)(107886003)(6486002)(316002)(110136005)(36756003)(86362001)(38100700002)(38350700002)(41300700001)(8936002)(2616005)(4326008)(66556008)(66476007)(66946007)(8676002)(52116002)(6506007)(1076003)(5660300002)(44832011)(30864003)(83380400001)(21314003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YHRCjO9FUEKfJY85CPeh/wmM9svKfILpCkY4PKSwPteYCzzoWh+Ifem4tVp1vdqKcgvodg2uH2Hihz36uVyB8Pp6JArRdHhkH89PSmFUYfQwAh6atpqwbp8HzLd9y871Hx8XgPUAWswiDa439R4yey8BoxkBTvaS9I+5Xo/5vNrRgRIuLLMjTnxI9l/jXyQzMBvnUKEu57NHGftgX6Izv28oDi+Ajcr+1OaP/0LlAZ/fU2G9DMUYiavMRgdOtLCxr+kejwMkPHD3QnXlV8PeXo9MEk8JiiIZ2nvjKg51xiqWkHz/fijhWMvCxfN+73Vk+acD/hfo6YaLhxZymwCWHsyj8lCoeSMpDZy71rYjvj+oDzeaF8fhi7+GAFIovo0sDgASW10bRrcsfso27DNsl4zseVV6Q4vafiXWjWRGykTHxITDq1lf20rhFHnWhEg0NXvKT77ko/GAjatrEfryWIc5cXNOEaBUBnhdJw9rEUDygPmLpa7pmM1q/4S9Ue9Mi5qHiXHuAw1d1K8duYv8xch/gPFuxN08sN4uNoTlZg8eyLfW0Rc6xbyjUi7kXmwZjRcRBA+X/e1OTMzp5ol93mSsB8aLFcvDzEzVlffwrWgxTAHv6NfQd3E9pK8Fg34g9nyg+TuE+NVnvRamuggiCrlaOLHfc73tq6vtDzO5YiGYA28ylgeVZaqkLF1UOSjqppq6AAOm2YTsllAmQNJZOgwgzqouKgmQy3UqAvf1PDcz0SppATjXQ6Zsfrp62L2kzcA0AMPMeRIXW+KiDtRuNqb7yWuSObNG478qPoV3YWuLu1zu44K0HahZ8/DeZPVF7+SbdVEgwRV9b3QfzTkqWyLCumpXpD0UPycP+lO1sXU773d7HWU55ly0tM++tWvsa0btwXjVviTdcFrjZf+zSUviYp6ZVjMuAZgRKmN+/TnxqoDD/C+0BBWKUzylpkSUEx42I9qnoTNmczEL7KNhnyVXDEpqFXvHGYY7sH93cJQ3iMWIrKHpdLDbBjhXEdTEhQ94zd0a7PCZoNBneU1olBV8wJYxwDxAdIdOKgH19mEPDqR+40BGbHsb4HgPm9zbYdi4f4sXp+vTI4WdkoEh5aymLlITQB2A0mVm/gF80bhdPj/bEyrfSwkiXi2f4CImvnlEZZXM2Pyi7RtMyX9nm5o18pKqsm9GpmlpVcUlNlvL2UfsMJQ2qPshJsLzFlqOSWsiWVehiMM6NrxPPej3tL4PzV9f2W6huKPCeBoNfTnmaKnE5i4V66+zWwPWkyW/a+333tK2xnbEDTDn50jF5v1bRHlv7AiZBsKLzNhT4pz6ppviZLw910cZo+r0ZOEtYaybnV6NDiyC9lTMN2/O4jZ02YiEhpTb7F0K23tbVLGtIFy/pq/wVT15aG4+Zz36WzUdE3tgqA7F0n1w30wez9gJ4q+LXZm8MMrZEln74ol96VBA2r9fWgNxV/dr4FO7lBttSfEjmokup5n5/wUDE7Hxfl+1XYaNXdb4zDz3az8k0MlovXqZvzR5CWnLQDTroEICc6r0+vPzRlvmbMwC2vQ8szq6EmZAC2C7HL/HEG5bkRi2OWZTL+ufW5SQJwbWkxevjx1zbxYtxRmDxwlxOg== X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3b6d3d70-b91b-45bc-4731-08db02a7af99 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2023 09:52:23.7234 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: x6E4c2/sNXZhPNomea6hzeVpjSJM1T1tIXCjaDAXHXFEgVxD4zUDuGWpqQ8HK9Y0rs5R+a/KWHhTbD9b1kdnWA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR11MB6025 X-Proofpoint-ORIG-GUID: 4rsPNIKJrfB3YFQskcEdvcGgow25ye0h X-Proofpoint-GUID: 4rsPNIKJrfB3YFQskcEdvcGgow25ye0h X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-30_09,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxscore=0 suspectscore=0 clxscore=1015 malwarescore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301300094 Received-SPF: pass client-ip=205.220.166.238; envelope-from=prvs=13943e2a21=bin.meng@windriver.com; helo=mx0a-0064b401.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+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 Jan 30 09:51:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13120833 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 598FFC636CC for ; Mon, 30 Jan 2023 09:54:48 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMQqE-0002xt-30; Mon, 30 Jan 2023 04:52:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMQqC-0002xK-95 for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:52:44 -0500 Received: from mx0a-0064b401.pphosted.com ([205.220.166.238]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMQqA-000202-Dk for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:52:44 -0500 Received: from pps.filterd (m0250809.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30U96eHV000968; Mon, 30 Jan 2023 01:52:30 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=AcLONJBR7YZJY6HYwvAhDEo4k4DfdL0PC/dq/i6N/SI=; b=L7bONpMZn+b+VKUgxSB2I16/WsovA0LuoUUMkQmFUMNgJS6/tLrQ4H6I3lxA7430MFjK 8Ap9y4eI4GEKUxT2yM3RFDM3KLphUREcauD5KGBvfPxT//UPnJbNOzSS+U7nRwJrPtBP F3qngI0xRT9nM6Sk5l33M2hawp6Xk1DqqtfHvRQjZhfk78NH6DSdJ+r1a121b2PqvOKT hnVALqH9X3HpPqBKO5nS6u55fYVnfO3needkassvyTdkhLZU/55s9FnruertlnzS5CMo sCCPD9HCUJfOOHXAjSQpFCB0AWZS6PLNZ8J0YoM5yUV/jKDncNR0u0SCVAA9rBG9Hw2j mQ== Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2174.outbound.protection.outlook.com [104.47.57.174]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3nd43rhj5k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Jan 2023 01:52:29 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M3EWO66G04tLkQJ1rWfPcbv5QAEGV+EVpAOFt1oWz4RlawpWRgBDepAQeSQf7S/7Wy93/ZaYQnmSSjM6aoxyEw8IJaTC7k36caa1weX40k9HCnYRI8HsXACWcF+xMVTTGWn8RuFx177w68cOEEbVbSgWgfkocy2VojbL2Xo9X0gfN9GeOJ2dqlRMBvdoApN2PS19LHZmsXWgv+ip+eDcS19vZsTdbjayXbAOp8ug/6VUJ9VoqQcD5p33IwSmUjASK0dIcBYLyw7oO+H5J63etT4Cwv1Pb7Zm8+Bu2o0sAFGoC63jX4G+2eJEY7yk8lke2fjErGdxWiW8v6CnNqgkbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=AcLONJBR7YZJY6HYwvAhDEo4k4DfdL0PC/dq/i6N/SI=; b=PkqlQKfQlq/yvh68OnwNQhmiy5bE8GCcVuqDzruMMEkjHhisj4L/HFx1pdCniVun8XFa2hmURSkZeWxKw1Og1zVmWKCX7n3wZndmni30TGrPiKOI/Md0KBAKMMOqNaq9zj3MLvF8xwKRWKxaaVTNJEKAmQSygjQWjBZXLjmEVcvXXt0wDIJav0Z4skwFdaOGu8CZ+8YJvyCH4+WI93YkIZWP/6mVanB+FVt/0PZEl1/Oor6f9l2pwfUkJNujXT8ANkmCrOwfRmY7ychhfAIEcD2z8Le4O2lNzogZ61dRwSfHvGeBLRTU5O/fAuAM7Prjb6YTwgUVaDc5ItlfqK4KFw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by BL1PR11MB6025.namprd11.prod.outlook.com (2603:10b6:208:390::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36; Mon, 30 Jan 2023 09:52:26 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9%2]) with mapi id 15.20.6043.036; Mon, 30 Jan 2023 09:52:25 +0000 From: Bin Meng To: Greg Kurz , Christian Schoenebeck , qemu-devel@nongnu.org Cc: Guohuai Shi Subject: [PATCH v4 03/16] hw/9pfs: Replace the direct call to xxxdir() APIs with a wrapper Date: Mon, 30 Jan 2023 17:51:49 +0800 Message-Id: <20230130095202.2773186-4-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230130095202.2773186-1-bin.meng@windriver.com> References: <20230130095202.2773186-1-bin.meng@windriver.com> X-ClientProxiedBy: BYAPR02CA0061.namprd02.prod.outlook.com (2603:10b6:a03:54::38) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|BL1PR11MB6025:EE_ X-MS-Office365-Filtering-Correlation-Id: 39c7772f-e5ce-4d4e-8ceb-08db02a7b0f3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GTNcykkF3fHx5/texJ+5vtbeFLN3N3Kcyrk//jnpIFTTJxlC39HL56g79AUJytiGxZ/xsT4uBWszFDz0vlIlvlaVpBpkxoxqwYTPSCllvoVAVu9UtWDaIxMTOozXyeG12A3gW7aMu/QG2ZDsmg6kPoyVzm52KLwnoykdfB4mpbs1k23HO95jiFXcVrAHHt65qhOYmn7YAyUoVf9VOv3yLkkgFbYJpzPXigGqIvQ+6iGQcfLKxvNMH2XGPyRzzkG3w36TEG0Ui9H9E3AvxGcWbTgN0Gzwoa1UbCYEW/oLq+lizBsZ/kRe3nY7VBuKPvIxY/isD5IYAwxOXPRwR90X9ly4WkhHZ5uxXBX2Zb4yLEpRrpnpAM1557WXt3mNlMsLJLsfsBWZr8igRP7zEFR5zem0zj1Ge4bxNuqlMG7hGd2P1JbTRh/IfKk3S2PyhdT7KIHpRRd2OmjQaowmzTbZitpVyXljWdntFoSyaqAkd0RiOu53KBfHT/QktS0vndLcjyDuhMz1dda2KNwBZ0z958X5aPJwaLGxDbinjNuOKRmF+8YtHYI1SQ8UcVtPap1sv3lghT1sGUTxTTreBdci7JqARkLWMmStH8zlOUg4UGR7s+i6p0tcLrucC6Oo67PybY7UxuNl7BqBcdNxYbsfbRflpn5btlvXDnMf+9RxW+W9MS4lD7nUCi0NV4+ys4zI1ttYNu/T2vaT8+6cOv41sQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5358.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(4636009)(396003)(136003)(346002)(366004)(376002)(39850400004)(451199018)(2906002)(26005)(6512007)(186003)(478600001)(6666004)(107886003)(6486002)(316002)(110136005)(36756003)(86362001)(38100700002)(38350700002)(41300700001)(8936002)(2616005)(4326008)(66556008)(66476007)(66946007)(8676002)(52116002)(6506007)(1076003)(5660300002)(44832011)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LSpRPatdMlpvdmdDb/qp0Kogic1+el8tvfFbVQ3DehIWuo6YEXtpXxU65ovNuCV7pXGvYuN0DpfyAW7vTEnRGd52hDJaORYxQ2g7LKBrqGLM327pDfMBUVJREciMxsIgGH1trt/y7Y8vEhqk3kKUCYZlu/zNt7mNGQEQT9/7iyjToUGnucTIlYoly7UKX5SG4GV408NdJrezfiWbECjy7iRJSvkVrzpltJd3NRuHCfiEWb2uk8AcvV3WAzzEXtYXaN5F561EXSdYNPIu0DqMmixlLYdXfCMKtg+7uC+Kl+o8vaTsyz+7Yxk/PkLWV1ZcSqtv3KwRKjsqNipBNawXAHC7FCwyFxtUiL6RXSA4rklsp6yl/X5oPMkuHLtSOIisMTwKqXWqsfKAu43fjsUzLy6py5Ho9zynq9ulXM+2V8wRySosmcMkLIDP6RpNN4OoCylFCi7PtSVU+Viu3pABQk37CC+8cxFlmBXlwxhJkV/zgHC/EFuwdfCENw04tY0bckBJ5aTLqht2+PMWP1EhDLDtUygS5NObOSqxYGWS6wVc+QIXUfXMDpWhRFgnDvoE1Z/5YNWzQdw8JWAaMK7UnyrcJXhudO/b1aHtXtE0OYreeKUzfb2ZlJziryKRltY/E3OVIrGRyvd8DyZWSZLk7GRCjSuwASAjH89yA0BoFazvUV7dUOQXMxYSVFb1AVodk/WJiw5SO0PO2Wv5DjldGbL/T1hkbvg8M6rqXwlbL16gRS+CuDMnPXv4lQGWJNu/TSEEC4BCFa6ykiy7uT39XcN+N/XAgf+FKhHwnn89wfcjew1/gAjZxovyMi2wgFJllvG/DMh595Oef7JSgh0Lv51OpqKtcxt7O1Q2dmVEjqj/zSYNn5DKo5NxMWWM00vy6z71fLK+2vGr/Lz85vJZ5XJD2zGy+d3NdhpSNu4C6o4EZSApzIkNbtazKtmWsO3PeCFlr3JD+cukr+mtMPyyZv0TGdBSOvbAadZiZKRYM0sJFFI+1h/O5t7r5m9ZYHlQWOSoGToutL3LYr9tn7WeUACCaMbSXPyUGKlwqs41730It/n9bYi0g5k2lPU0hx5oRzAOjgbuLFHrJnOD5w1PDc5BiDruHSQtcSJzX7UL6LVB11nDMXjM3XsgNvcxnFDCM3kO4KUlVh1dsVug4BnoaHTZNp6qVd8aVN4nsZbDgv5jAyxnrkODk1/oWtdmR5STr02TPaUfGyretnYtWq4u4srP13KxMM8jgKQxxKsrI+8lLQvO5iXWUQb8ss5vlXVRCRoUA6zBBX59rcdovN0ZgUJhnzw/feBR8HrIUQl0Euk7hnjEGA8JJ1qJ+uiF7ao45QcGgTBXqeHOu/v6Tdkqbd38wQfLTnOQTQbny4pciVNT+dnZdhpizVl+s0zjLwIHvmbJ7QQ2/guyVHdGHe+hFXaBWTwkitWq/BWLljHjAGxeGG8uZ5NaViD3mTD/Wn1VvAEs/1/+Z2kiYSrfuZ+AuHZaSQnK3sP7xNov+ehFsC0oGFEHhOz30xhEerfTZuxD49/xDmnSt4WY4IbheY8V0U4SED9SAo1cZbidKDdurxN68o8Tu63sRGkNb/lD7OoOS8qlgPfIEEPuCnEtmq342Q== X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 39c7772f-e5ce-4d4e-8ceb-08db02a7b0f3 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2023 09:52:25.7570 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: lKg9SYM+JP6pdIxZUPhcQj+CNHtbnXuJesdd4T90Bk7RwYitSKxxGtxqH2j80lFibUXCrOnS73L1CzcunWDNmg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR11MB6025 X-Proofpoint-ORIG-GUID: SZ5_Lwr2OZD9gaczTvRElF-rdyeSLLoF X-Proofpoint-GUID: SZ5_Lwr2OZD9gaczTvRElF-rdyeSLLoF X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-30_09,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxscore=0 suspectscore=0 clxscore=1015 malwarescore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 bulkscore=0 spamscore=0 mlxlogscore=705 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301300094 Received-SPF: pass client-ip=205.220.166.238; envelope-from=prvs=13943e2a21=bin.meng@windriver.com; helo=mx0a-0064b401.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+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 Jan 30 09:51:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13120820 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 D0A06C54EED for ; Mon, 30 Jan 2023 09:53:30 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMQqF-0002y9-25; Mon, 30 Jan 2023 04:52:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMQqD-0002xk-99 for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:52:45 -0500 Received: from mx0a-0064b401.pphosted.com ([205.220.166.238]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMQqB-000209-1M for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:52:44 -0500 Received: from pps.filterd (m0250809.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30U96eHW000968; Mon, 30 Jan 2023 01:52:30 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=BQCA7lysoYViR5t3M8lScVMY2+PANKI1hG53nyjiWU0=; b=bGoIuyKzU7W6e+xm4m3xj1Iul3PLeKRd1i2mBP79WYLdOnERqq6op2FrSzcEkBFI+yYo JpY2FN4gbWkcSXRV/uOvHvu58VHJuJspY66SP/dHUFi/0VdQLgOaNlIf+wbWiT5AKsbs R5v5uKnegazbPM9svEZNcUJ7ElXrcO3knsqgb7Yz/3lGFKxKPOLHhjH+r6ndddHXXAmi tj5ZGgaGt798qHuvhYPDk7CrFTidIGncAtpoCUA/u00xFKaOLKvL6CrN/j94xXxC+Fs7 IYk6i33B7SOpxABCK+X+Bbk5haVCOgTX2uiX4lo8n9PI3EA3VszXFR0vG23JC/2GdY7r jg== Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2174.outbound.protection.outlook.com [104.47.57.174]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3nd43rhj5k-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Jan 2023 01:52:30 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SPxSnABIxgwRrVNGNrnF3YhYwXnpJxRYPgTfYLJOeouWZ9lnmvcNi2ZiN9lgt9PGxdi+ts3G5slRyVcu328sY1b6ThIvFoAAKoWCKxw9vPglB28vtZTvwBgroyqM/vnikcl4UVNi/EvQZeEQxMErh+enPaQkZIb0Gb5Af8f5oMDhYFpz+Rskc751ou1dijtXKBkV0VGVzhUvV5gWcF92FsWGXT4z1pnu6oDa7CdNPTf/5NKGCgC9wg5ynve+zm4DYlNOH+zz3emnAP89TI7IIIRRnZTxeloJAndBsnF6sbK77uPbER7DeESc8f8zU9ah0c4DynTkhl0rHvYWVJ6Avg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=BQCA7lysoYViR5t3M8lScVMY2+PANKI1hG53nyjiWU0=; b=HvLRSqu4a7bQIcJ6WlcrhDyzBCxj3gh/RKSVxsc5/M7ICfGKg1mZlAL8iPZhDoE+2aymRmKmnuj8SfQ/8pLtlVpmjvqvkX25s9xW0A+yI/jhaV6KVzvGzqJ9A6WwUyKk2TmTnfLbqtE/9Sis8+CDlRXlKJWB7wygogompxexsGp/TZ/F/80WgZK66ON23+/iMQ5dZpP7ckNFvZ3PKKIknZFF5ZdFpDq5NKdQXtNAypttjzxKF/m5lI5oN9jQ/uJOSGpeUOlpmeW7wEaVALugvHzdJmRzJtj6fylud3mF4U1H0a5/VXmDqCvrf5uDmfCchMxDMxqjjnM/olj/eE2fFw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by BL1PR11MB6025.namprd11.prod.outlook.com (2603:10b6:208:390::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36; Mon, 30 Jan 2023 09:52:27 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9%2]) with mapi id 15.20.6043.036; Mon, 30 Jan 2023 09:52:27 +0000 From: Bin Meng To: Greg Kurz , Christian Schoenebeck , qemu-devel@nongnu.org Cc: Guohuai Shi Subject: [PATCH v4 04/16] hw/9pfs: Implement Windows specific xxxdir() APIs Date: Mon, 30 Jan 2023 17:51:50 +0800 Message-Id: <20230130095202.2773186-5-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230130095202.2773186-1-bin.meng@windriver.com> References: <20230130095202.2773186-1-bin.meng@windriver.com> X-ClientProxiedBy: BYAPR02CA0061.namprd02.prod.outlook.com (2603:10b6:a03:54::38) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|BL1PR11MB6025:EE_ X-MS-Office365-Filtering-Correlation-Id: affedad9-7421-4fe2-a360-08db02a7b229 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VoInPnDgXc+A5mqrKlDgYY/eoymPLgkFuaFe9rsAK9hnxNo1YHVocclLKxLWjU85g7QBxHsK1Lp4gujI4Ja45QFxanl1AimCcOVA4sbsqRe7FC8+wNxROCeBeM+almWlUgGcCMnmynRuPo5sN0Z7ER9/KfI9ae8vTU4mwmgDtEY1anCSTGoZoeV4biht51SD+i+dkFPSh6Y3f6/ealp3hBDiOfyYIo9eFCHcBDbnr5IpXKeKjO9OrkyXwGB9IlFTo4xiuzg1i1dxhAPlfRMfV2mqJwDFGpgK8iRjBot8oG2w4KN43c9YDXJ938ByxlwU6WsnyZRo1Umi0PGODVVtyFlCx+Tz1LmiLrK9X1qhp90cHsdrWZE+r9ahDjFDSB4HtO+h9G9ea+XyWBb2B6UCdyfyZ1M/F3jxD5qACScR4jclG+uEyY1QN0gzuJ3ApFZvk0PftmR1OtUXOOGyEE2ptGjkx+dSfvbDvjfANqOv5H0KuAmSj4+ItgUMBEGB0izMBAwZSC1B2PZ6rae/v5UvlOAKy+eOqF0CWcCX5efTw253mjJ0KajpT5ed0YqjXkFfcyz916bBAtUf9p2UNuTnl82O4tgTaHzOkuFRtOHF4/13j7MwSeoen4ffksHoKFHvg5O1WmqWaGA+mOmefJVTiAcB9woveF/x1gPK18FkN/laZ+oqmLiCxB0QR9ILNO0wxqU9Rf5ZjGXhioiFliPmmA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5358.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(4636009)(396003)(136003)(346002)(366004)(376002)(39850400004)(451199018)(2906002)(26005)(6512007)(186003)(478600001)(6666004)(107886003)(6486002)(316002)(110136005)(36756003)(86362001)(38100700002)(38350700002)(41300700001)(8936002)(2616005)(4326008)(66556008)(66476007)(66946007)(8676002)(52116002)(6506007)(1076003)(5660300002)(44832011)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PRmrThh7eXvhPUH5DImMSnX8Wi+w3IzKPGjQuz2NMiESNo6FHc13SEAiB2uhNvmibvgI1f0SZ9FMx6Ye4MGKNQOWqjtmret28zUYcX1G5GIuL7NKsFHY3VdbvW7z7ipnREZ6nKdsXb2FKHa2VuAgJILS4QV1vhABMuZnh78fQAy65Jx8GY91jJeHbiViXe0vT+nG5LJDtkm7CY0j7I7mzK9sd1obTSACwb0tq1KR5pKEC2igcpa7JjDQXty6VFKeryxfTSVeGV/lV6IYb89aZK7Rwdlo3dPiBBx6z78BXeTAvd1Br4s+j0Qbo+1YKEV5PQgX6MPsRNp6xKYPUu6oq8G2o6Ctj3hN1kCCOLpsjRlZX8vmB/dD1sDRK2opqAmX0ZHhX3c82rEiYX3Gp8e3RrNwqY0oKioLMqN69+FjMveec+afYilPtrzz+nYVs3FO4t+Z5nPnFepfXzMu2B78ixF9w86nWaFVlGu4MFukEykZNpyz5GFFmtukE+8kcGapSF4sgcn6kW2Gs/LAB/renzR3rEVqJZLMRqORoP9GgOSoLxTc1l6ncDcjx9GYxZnJfKx6mHzpfPxsYfNWpr+34urKC6obTUH5adNJWoHt1kbNBVtKdj2sHBac7RIWt44OwsMXvundyTqRao7p1EXxm+BFXaohsAzeupI0eONU9psoMbHFs5j70hZeKbwOx8WcvnPVP9iflOUrnxOv/fwhIJoOMbKgPs1MnjguG6CU01Vuj9BrjgeKAZEt6uY5M28Lyd64QIrSCcjXc26EGVKMBnLKVSavJQE2lQ5njWRhMvuJmaB4Di0na6JiD+Mg0ICOfFcMGqL+3oUbkTXRLAlF8uMrNpaOGyritsc/CP7h5XXVFACQ7LlErpIm+598282rJ9Gc7gEtOGIKR5BHLu3HjcHhWqrrt0pr9uf8hO7Rqnl+oXxnTiMnMh4Ox0Lf8/0DtJw+mgiB0ZxvsXKaNDHdKsvrk2WVLRxI4SnLFWputlSc9fmY1EU82pcQKCyByeMZRTz+vzNvs6h3+KWSry1zEzMQ8/cPV+Hyuz9zKXJHUuhSk7mt0cgc/24M/KLZstVCLrWEwjXEcFJlyw9P6jyuuZqNH29Q3B99h0FFmjDj3pya2MreE2DrvWgigrJOcXYKAnWODji3lmTwuOiSr0iHINt0A0T1O1l0C7+QKvkuVDBiXM2aLvH453Ee1oxMHecYUtHpiNQJBWRaKxri7FTsE33drUx+BV7sxaFWlmF4G5Gfz82hLppCLOPQ0XFXhzXhcFU1nqju75qVXp33S6ueoqjZG4699rbTeaDxseUCvMr5I/zel9Xc8tqXxNbn77UYas0FoA3mph9jlJgqEmAfq1GwGqdfvClGNZD1A+wHYj0oWElq1qJHjteFpIj/8P2D3Ly1ekS7c8RIQcFtno6RxxivFQs+BCcGFe/1EcWpxAe9Sc2HZEd+HCgr3XiWl320zxS7x/LzgLpTfFif8F3KKMoKdVfifErZZO0bI1np7oJ9JIEEXjmdvf6+Zp5dQqNHzTLPnrFuLEXHbDNn5GJ6ETM5fTI49WkbpgeSsBFyVcYu5vM0GWkY7BrPn8QBQ+KGyVExMKccWKZ02NFP4YYHQg== X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: affedad9-7421-4fe2-a360-08db02a7b229 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2023 09:52:27.7891 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: tci8n11+VfalVahG8CJA9yaL6YZhpH9QUWVbvHyYWeNlfcfbCB5Ao6MRHyz1LdwoEVZtoSQssjrZNs5dh8+BXQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR11MB6025 X-Proofpoint-ORIG-GUID: tYRGw5gleuFVfkAqk2RuM02CigX0_Rkl X-Proofpoint-GUID: tYRGw5gleuFVfkAqk2RuM02CigX0_Rkl X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-30_09,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxscore=0 suspectscore=0 clxscore=1015 malwarescore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 bulkscore=0 spamscore=0 mlxlogscore=608 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301300094 Received-SPF: pass client-ip=205.220.166.238; envelope-from=prvs=13943e2a21=bin.meng@windriver.com; helo=mx0a-0064b401.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+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 | 296 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 302 insertions(+) diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index 0f159fb4ce..c1c251fbd1 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -141,6 +141,12 @@ int unlinkat_win32(int dirfd, const char *pathname, 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..5503199300 100644 --- a/hw/9pfs/9p-util-win32.c +++ b/hw/9pfs/9p-util-win32.c @@ -37,6 +37,13 @@ * Windows does not support opendir, the directory fd is created by * CreateFile and convert to fd by _open_osfhandle(). Keep the fd open will * lock and protect the directory (can not be modified or replaced) + * + * 5. Windows and MinGW does not provide safety directory accessing functions. + * readdir(), seekdir() and telldir() may get or set wrong value because + * directory entry data is not protected. + * + * This file re-write POSIX directory accessing functions and cache all + * directory entries during opening. */ #include "qemu/osdep.h" @@ -51,6 +58,27 @@ #define V9FS_MAGIC 0x53465039 /* string "9PFS" */ +/* + * MinGW and Windows does not provide safety way to seek directory while other + * thread is modifying same directory. + * + * The two structures are used to cache all directory entries when opening it. + * Cached entries are always returned for read or seek. + */ +struct dir_win32_entry { + QSLIST_ENTRY(dir_win32_entry) node; + struct _finddata_t dd_data; +}; + +struct dir_win32 { + struct dirent dd_dir; + uint32_t offset; + uint32_t total_entries; + QSLIST_HEAD(, dir_win32_entry) head; + struct dir_win32_entry *current; + char dd_name[1]; +}; + /* * win32_error_to_posix - convert Win32 error to POSIX error number * @@ -977,3 +1005,271 @@ int qemu_mknodat(int dirfd, const char *filename, mode_t mode, dev_t dev) errno = ENOTSUP; return -1; } + +/* + * opendir_win32 - open a directory + * + * This function opens a directory and caches all directory entries. + */ +DIR *opendir_win32(const char *full_file_name) +{ + HANDLE hDir = INVALID_HANDLE_VALUE; + DWORD attribute; + intptr_t dd_handle = -1; + struct _finddata_t dd_data; + + struct dir_win32 *stream = NULL; + struct dir_win32_entry *dir_entry; + struct dir_win32_entry *prev; + struct dir_win32_entry *next; + + int err = 0; + int find_status; + uint32_t index; + + /* 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, 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; + } + + /* + * findfirst() need suffix format name like "\dir1\dir2\*", allocate more + * buffer to store suffix. + */ + stream = g_malloc0(sizeof(struct dir_win32) + strlen(full_file_name) + 3); + QSLIST_INIT(&stream->head); + + strcpy(stream->dd_name, full_file_name); + strcat(stream->dd_name, "\\*"); + + dd_handle = _findfirst(stream->dd_name, &dd_data); + + if (dd_handle == -1) { + err = errno; + goto out; + } + + index = 0; + + /* read all entries to link list */ + do { + dir_entry = g_malloc0(sizeof(struct dir_win32_entry)); + memcpy(&dir_entry->dd_data, &dd_data, sizeof(dd_data)); + if (index == 0) { + QSLIST_INSERT_HEAD(&stream->head, dir_entry, node); + } else { + QSLIST_INSERT_AFTER(prev, dir_entry, node); + } + + prev = dir_entry; + find_status = _findnext(dd_handle, &dd_data); + + index++; + } 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->current = QSLIST_FIRST(&stream->head); + +out: + if (err != 0) { + errno = err; + /* free whole list */ + if (stream != NULL) { + QSLIST_FOREACH_SAFE(dir_entry, &stream->head, node, next) { + QSLIST_REMOVE(&stream->head, dir_entry, dir_win32_entry, node); + g_free(dir_entry); + } + g_free(stream); + stream = NULL; + } + } + + /* after cached all entries, this handle is useless */ + if (dd_handle != -1) { + _findclose(dd_handle); + } + + if (hDir != INVALID_HANDLE_VALUE) { + CloseHandle(hDir); + } + + return (DIR *)stream; +} + +/* + * closedir_win32 - close a directory + * + * This function closes directory and free all cached resources. + */ +int closedir_win32(DIR *pDir) +{ + struct dir_win32 *stream = (struct dir_win32 *)pDir; + struct dir_win32_entry *dir_entry; + struct dir_win32_entry *next; + + if (stream == NULL) { + errno = EBADF; + return -1; + } + + /* free all resources */ + + QSLIST_FOREACH_SAFE(dir_entry, &stream->head, node, next) { + QSLIST_REMOVE(&stream->head, dir_entry, dir_win32_entry, node); + g_free(dir_entry); + } + + g_free(stream); + + return 0; +} + +/* + * readdir_win32 - read a directory + * + * This function reads a directory entry from cached entry list. + */ +struct dirent *readdir_win32(DIR *pDir) +{ + struct dir_win32 *stream = (struct dir_win32 *)pDir; + + if (stream == NULL) { + errno = EBADF; + return NULL; + } + + if (stream->offset >= stream->total_entries) { + /* reach to the end, return NULL without set errno */ + return NULL; + } + + memcpy(stream->dd_dir.d_name, + stream->current->dd_data.name, + sizeof(stream->dd_dir.d_name)); + + /* Windows does not provide inode number */ + stream->dd_dir.d_ino = 0; + stream->dd_dir.d_reclen = 0; + stream->dd_dir.d_namlen = strlen(stream->dd_dir.d_name); + + stream->offset++; + stream->current = QSLIST_NEXT(stream->current, node); + + return &stream->dd_dir; +} + +/* + * rewinddir_win32 - reset directory stream + * + * This function resets the position of the directory stream to the + * beginning of the directory. + */ +void rewinddir_win32(DIR *pDir) +{ + struct dir_win32 *stream = (struct dir_win32 *)pDir; + + if (stream == NULL) { + errno = EBADF; + return; + } + + stream->offset = 0; + stream->current = QSLIST_FIRST(&stream->head); + + 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; + uint32_t index; + + 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; + } + + /* seek position from list head */ + + stream->current = QSLIST_FIRST(&stream->head); + + for (index = 0; index < (uint32_t)pos; index++) { + stream->current = QSLIST_NEXT(stream->current, node); + } + stream->offset = index; + + return; +} + +/* + * telldir_win32 - return current location in directory + * + * This function returns current location in directory. + */ +long telldir_win32(DIR *pDir) +{ + struct dir_win32 *stream = (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 Jan 30 09:51:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13120834 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 47CB5C61DA4 for ; Mon, 30 Jan 2023 09:54:48 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMQqH-0002ym-2Z; Mon, 30 Jan 2023 04:52:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMQqF-0002yG-AI for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:52:47 -0500 Received: from mx0a-0064b401.pphosted.com ([205.220.166.238]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMQqC-00020R-KL for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:52:47 -0500 Received: from pps.filterd (m0250809.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30U96eHY000968; Mon, 30 Jan 2023 01:52:31 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=Sm74XzxaRiYXzO1G+YfdbqAZ795gmZJiLP55ipP9+Fw=; b=PidhLCNlokkPOpAVlwcBfjmPwKmL1Yea2Oedqq9Cqy3DcNaCHhZEN7aOPgCojeH7bZf3 X4yV3HDVYQMzKx6PSBfjxMc3yeQ3rABs/L9Pxv2FxmDq7JTNqJ9Ozyp6tY5kI+STxdzE AsuCtmpTh08lvS+g2Dt8LvAzWPNJDWdah57rCeo7m2LFgBoMmXH5XAFv38StqQb4AeS1 YQHsoI3dBZDdUwyqtJaqAfxLaFZYRyvglPzqdWQshy3dvwTJju9pKKxRhW4n/6W4a0T2 L5pN2oi3/30/B8RVOlCdxsLxoSgIdm5eXNmwFxzFmSoQPloVEi5i3qo1noH0hLy0nkmu HA== Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2174.outbound.protection.outlook.com [104.47.57.174]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3nd43rhj5k-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Jan 2023 01:52:31 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OaZTFcrk+Y8YCmCRL3rQsoEEocDffOMIwY5FKoCi3bjAWhC9aeg0mu4N5jGKgOhlTYAoKVHUoJ0+aWsOkWOQPkFV17b8BaCO6xTJwOp6z3W5JmGjre9AY762hjKNkHYpEsbPOp8zBOwf/kShOmpLQ3Lno831dPmu+5LH6GVSTJ0wrfqLZQ97mnmo3d2vg8q8b0OvQO6Zzxv7BlPk4e6O5CoAfIyYcdpB2uxh4ZSa0POvcdM61kAlWG2aKxB+/4ZikpOiZJRg+T8UwHP+7XoHbxBxC1So1/bJUnwJj7lVptygh209/iKb1Ex9+q8w6zbXbpu4jtDaU5cUZJ09xiD/uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Sm74XzxaRiYXzO1G+YfdbqAZ795gmZJiLP55ipP9+Fw=; b=hP5vJ5S3HUx9qnzW51Z3K62wjgHuf/TdwbG5iXVodZ197Kq3Jv1nuIea7LeJVNepvGvUZqGK+whbRDxMkNLz4Dq/TNNtwAblZM6JTFiOM1+1gfYUfo4iOFtrseLMqol96CSplrNdXvwziLY3w0sbDTYBX152CfP50yWn4Ac8GWi+DavzeZAB+SxFHskEzOosjrlWH/leoYZ5wY5y28nNCcy6DU9FdfMT/C0mpFziSr6srdin3mPmXWjjrhKAuoSIx2o80SFzG4sRw3XMWLWahHQ601fG1Xdh51XnQNZHdLTs6zl79WjmA7PYna+Dvo07b5axw9T8ZYmGoBrxa1Hf9g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by BL1PR11MB6025.namprd11.prod.outlook.com (2603:10b6:208:390::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36; Mon, 30 Jan 2023 09:52:30 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9%2]) with mapi id 15.20.6043.036; Mon, 30 Jan 2023 09:52:29 +0000 From: Bin Meng To: Greg Kurz , Christian Schoenebeck , qemu-devel@nongnu.org Cc: Guohuai Shi Subject: [PATCH v4 05/16] hw/9pfs: Update the local fs driver to support Windows Date: Mon, 30 Jan 2023 17:51:51 +0800 Message-Id: <20230130095202.2773186-6-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230130095202.2773186-1-bin.meng@windriver.com> References: <20230130095202.2773186-1-bin.meng@windriver.com> X-ClientProxiedBy: BYAPR02CA0061.namprd02.prod.outlook.com (2603:10b6:a03:54::38) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|BL1PR11MB6025:EE_ X-MS-Office365-Filtering-Correlation-Id: 9611c38e-ca5f-4972-6836-08db02a7b35f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: u9FeBpLZlAOzyN++OWPPp6pkqBLTKY79T+BMe6ejtEhttShv57oCJmObLjR5vraKn+E6TYcED5WMux6bVnK/jP75wviGxw18RRfOS4CmzRy3LV5UdCSl+1jhlwVaA1berRiUII8K1LflSmKxlc/UUAYYPDJkCzQQAzj2fq3jl7bI6GPaT+ka1XUhmyS/He6ZWCvSn402KdHtuWusR2hGycSaa5D1w76tAKqG4hRThsRMJjp3ecAcTFbbWeLxH3MQMDIcgqpfHhF4el+Qyz5OadTVfKUePSu0HvirAdqlygxsCaZ6IB3vxqrGWPGEQudnYsQm5d8YNydl5aOnOVscWCWiGoLXOt757Moj9eWMG1Nub+ZP//s76BtJVSOgBS/MHgV6rVkXye05gPhid/Uqdc9J6P3DOCdqKuqiA+BOPu3A0ok9SoapyeAfwB65515z41jGxgo+Naikz0RAMOTYzCOk2kGJPnwATX+4/StOthRGwSFNiD61j5yBfhslTxoTPgxlPJae7Cxoe8PXXSz/si91Wo5Sm8NpgmOeZ7DxTm1SYJ6Y/o/Oht1aczylmkBDDEte8NdJZgefSZcOG+mvBJLS65506lSdX7otfASKqLCqrn4XPZRojq3DlMK3je3ki4shbrzjcvX9EaaraXSUxfIr67sW1UDjhsCiascyUwN8OoAeQbIUO8OHK4B+iKY/vngFIs8AiJ4dcCJ2iFvNeg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5358.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(4636009)(396003)(136003)(346002)(366004)(376002)(39850400004)(451199018)(15650500001)(2906002)(26005)(6512007)(186003)(478600001)(6666004)(107886003)(6486002)(316002)(110136005)(36756003)(86362001)(38100700002)(38350700002)(41300700001)(8936002)(2616005)(4326008)(66556008)(66476007)(66946007)(8676002)(52116002)(6506007)(1076003)(5660300002)(44832011)(30864003)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: guDbWtjmQv9Oia1NYH+COtiWQzIyrKBN+4yNTJM9k7G++3FK2tW65job6kQ+t2YlnXmbv98xBaJsrasI+AY1TJNIMYWExxNk1FK7c0LAWR7A6d1EhjJKnk0qI2agrmN1BkU76iRn9z2YpxGChqeISdvu9hVMhGH6ywawYXsDI3R7wMx2bDCVvWE3HN3hFO1lKANjgYQrLjSsKKSVl8d2jEwqrN9/Y0t46EY27L+ykQg23YzSKGSApEtAzM4Ue4QkFJE4dSVbwWYsV2srkr38QxhLvYQQWBym38iAfC4cSAJvYU1Uivjg4nJnxCV/iFfi/F77M8sXl6QH4DdY21VO5wOtUmBdFf3AY/psHJuGBCxCuWc87zpmBPZNdL799Am3w2I0kG/n88tei/O7t2ve5T7Bqa2uYPibKamwj4wSwq3kqcC1eIghJbTmCXS41dmQjJ/16+7uY2a1P8A3RAwkk/nVipeJubt+xMLO6fa2O810NeXai1e6+SrmDyulKP4UhZWQxVi1eoPjN7hKEbbCzOEm8u/uHtJSm9nAlhxLBwwvUiZbH4u9hpSt0/C1jks8InEXTs4he65t2ZNWPjharcEZxBZo/Dxm/OtotPwILSwzEbW3n1BfwaSC3JV3GouTqr16uNWmIfcpWAGp0YDXSAzAuT7YEjP0XuKNyVSswJRdg8/V00+t2yivIQ0XWH6+4UXcmYqxenvwf1utmtVpIuWOQ2UfUwTPNqywezJjqThakI3dU1rN/i+ipuBRKKH592+iz7KqJjr6+f2CRZXmjTu28fsr6tw21oGGQ+9hYBugKYRYklCtgnao3VgcDtffQK7F1ogEK//Ajr94PIEZX0+krjKg5iwkYJsN3cyvTqn4YEgh19++8uud/+HbY/8EoW1FYrgYXm10v1KNvMz8Y2Cmz/O+c+cD8OcxAk/EjeXAm/STJg1oHhr5D47i2xReXEVrmxrUkRBrWkV/yD5qMOEnoBe6P6/xfjCw+bimb/RuslXzGQTFHIRD6PK+cFm4DEmyUjOSZ67uCkdt0jzhCXxRofPmeWMIobndI1nRq951jSjiYHU6bHY/OASDa2O+gzvMHP3skU01AyL/eeKCbEMA8XFRMk6MvC/mPkPpv2Oomr3MUzRCF1w07XAzw72WV71TcI4nxiL4NAatqqpONyMGQauxx6+Dw4is786GGOLeAdBDn/JBk3zhjssr6ortzrmswXQNLGJ1pkwWLOVZ3QL581/fFRwzII1nu6TAlWNTjt/FyRe+7TOegkhej8FLO7b4GrPMqSkdI+/derg8oftj3WBrBgA3LHMAXy+WXNHIeCId5FHIbWtNfEwhDcZJRGWpefeGYa6WI9j+T10dfCf8kozPd9XuihKoQN6kn5BP6/GTDMdmhEAmLhYMnRgatd00wWF1jvWF/SaCpxRlT5IZk39D06x3GH4bQjouZG6AjHjA+u+ne6vVhnJsPIrMWfyGzWFx1O4sandMwfjGBHErDYzmB8RJbqIAUTFfVsDClK/2pdZ3vOdaeiFmUECZfGnOrm4OKRddSC9SKKiG7XQ7F/wUgy00rHxFly3Bc+kkKQeSIgWidhNdL60457ly3xcq62eGWE7Y/bkLGQ/GTA== X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9611c38e-ca5f-4972-6836-08db02a7b35f X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2023 09:52:29.8974 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: dQzaZ5DlOS34mrj9otRba2VW00GsFpXLGPyudJT0UPwRGEXXb69MshvQC213A3Mcom+NIeSjHFviek/R9wK2BQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR11MB6025 X-Proofpoint-ORIG-GUID: BLBOe1nisKsh4kmnXpgYnjKPaVCo8PtA X-Proofpoint-GUID: BLBOe1nisKsh4kmnXpgYnjKPaVCo8PtA X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-30_09,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxscore=0 suspectscore=0 clxscore=1015 malwarescore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301300094 Received-SPF: pass client-ip=205.220.166.238; envelope-from=prvs=13943e2a21=bin.meng@windriver.com; helo=mx0a-0064b401.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_PDS_OTHER_BAD_TLD=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+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 Jan 30 09:51:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13120831 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 A6538C61DA4 for ; Mon, 30 Jan 2023 09:54:42 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMQqJ-000304-JT; Mon, 30 Jan 2023 04:52:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMQqG-0002yf-SA for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:52:48 -0500 Received: from mx0b-0064b401.pphosted.com ([205.220.178.238]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMQqD-00020Y-5b for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:52:48 -0500 Received: from pps.filterd (m0250811.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30U7qdkm025000; Mon, 30 Jan 2023 09:52:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=Ajqch1/tMp3Hvy9konbpmH0yUatw6197ofO1LywoORM=; b=RAX1h5mh68ZwcNFPlN9OdyyavFLbvVXyWmv3pJ4AnkKCxfIuYYJNQ5KmBNtZLBogl+XL kMnHoFRkz/CazKx+tLRzly+N4xmIKQW110sM5M1p42Z3Z3V5xnfjS5l24/Jm5N4CZeRm n5ADLvdGmvS7I75z1R9by2EAzcEg7pPpI8CkoWi0RZ+s+HIZ8op/oxXm2rMeJMSnQO3f 3RuPgxYyXScfXQPVphSZA3NYgCOVhTKkyp0WNUnAqfPfWvpycCXutHmk2q0T13qeO+3r 57HTAfQfHTTSQBp8UQ1OvADO5hfr9cdwRbndqkl1l9/sh2Zm7VyXC1cQ4J04mr1PkUTn Jw== Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2168.outbound.protection.outlook.com [104.47.57.168]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3ncrx3a45a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Jan 2023 09:52:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cvNKRqHTrbrDk940nYpPHBDTG+q0bUTQXbnAV02vZStHZX0chGfsHHXpT+mwIwywND3qjFgGnr1GbDY0qtD4SquWpP34OoEZYpFP6lN6dHKiY3DIfsKHJwy7cE773akPzE5/yi3jap2PIo9LXYerqp65wFhp90jxy5eshzX2NzQMYsSLpYueXWRldrAp+RFKziY13n+RQOF+r63eQRoyom/e/vY3/jDfwRH4l7Jgi29RMIN63VLpAiaaNpkX0F7vKe4kXt4cWVjp6eIBNl8oTi5QiAodA8QM7nj7FdogPTflTDJ0PngUNTkIMIlVyCyQ4mkbjauhs+4lL3CDe0Biew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Ajqch1/tMp3Hvy9konbpmH0yUatw6197ofO1LywoORM=; b=INSCroOAsR3Iujt7+8Nrom0P65nvYGoy7mnwrdybYLefgxI2Ms6wusloK90A+6vCVzP1KgRKJyOPjVYaoo8GfYFeWD0BUUccQfX1/1RVA6kubU/VKLCa8KttMp1IG5GwaZWAyqQAECwZz/t/YlJoYBh/3UPwp7CkbrFsZAJi9bkWZifOrhh1HlhxRVc2YXBMNs8KY3331XGSQ7V8sp2ibzcDSBBdcEwkVG3TON7/9JYQCh7C+y9NFQ4J6VYXI3CT2gUdPOB46rEDBIs37gXm9kTyJ2VIt1Fvg7k8zZC2VTrgZjJHIaubLly/alPG2mtN5Hv6FViSzHV9MBuINVaWLg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by BL1PR11MB6025.namprd11.prod.outlook.com (2603:10b6:208:390::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36; Mon, 30 Jan 2023 09:52:32 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9%2]) with mapi id 15.20.6043.036; Mon, 30 Jan 2023 09:52:31 +0000 From: Bin Meng To: Greg Kurz , Christian Schoenebeck , qemu-devel@nongnu.org Cc: Guohuai Shi Subject: [PATCH v4 06/16] hw/9pfs: Support getting current directory offset for Windows Date: Mon, 30 Jan 2023 17:51:52 +0800 Message-Id: <20230130095202.2773186-7-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230130095202.2773186-1-bin.meng@windriver.com> References: <20230130095202.2773186-1-bin.meng@windriver.com> X-ClientProxiedBy: BYAPR02CA0061.namprd02.prod.outlook.com (2603:10b6:a03:54::38) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|BL1PR11MB6025:EE_ X-MS-Office365-Filtering-Correlation-Id: e6ab5f9c-dadd-48d7-a321-08db02a7b49c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Yin8cNGeCXPYkRWko7rSArrK3fdfYzDKdMguafuoo2HMreH+yce+hKJLgm7RRSlZtT083VraGy+Rx7DBy95SD9V0h5vCpmcclqn6N2gAgluzO+sDLxZ1MaPo3q4Sq3OUZ2rDmJ/5CLqH5E1fpHbHoYPRr4FSgPisY8y3HIjV7PZ8Bj5k5evKjHMrrTpSe2xvWEtU6D+qfOPqSNVhd5IYZsx/8s1bHqWa1sgyD0l29aT7r3+5tOmw+JsQErCUHvmTQ1DR/JqKplVf7eERwfliPkgMdCbWOpAfAZX7rPfFLvW9yR89TVrhvGyA6QqkMe+OSgcFai5RsVx0aEOVPGJqTEanTTD4hzhQOJzz7aVoR4Sj2eXnPMintbbBIhDQZbrEOm92Fzp6Hw9++irDGwFkAtnTSoS/2nntwBajHjCZDNOcuMDF6B55Ax3W6rI7XSbsUMSEONFawHxpCckld5qU9U1enQagvawihv4kthN+T7DJlXNSDQE2QEs6ucuDFU0Kcs5y4e84B5ZVSVhWhdfCle3cPF2RMIN9MSslI+t4FicyN0MlZ0Q6t4lJzA2+0QlXjO7RZ4IOQZ6FU4mSqr90vG+rx+Vxp8NuhwoR50ym4km1sSu4dJnOwFCYcj453Zt58ArKOtePrWowJV0TNWG9ad0UlLNn8gsybySRfubg0FnqCcvGPf4K4sAc8q+asksbF0s9/fNC617d6h060EQ+fg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5358.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(4636009)(396003)(136003)(346002)(366004)(376002)(39850400004)(451199018)(2906002)(26005)(6512007)(186003)(478600001)(6666004)(107886003)(6486002)(316002)(110136005)(36756003)(86362001)(38100700002)(38350700002)(41300700001)(8936002)(2616005)(4326008)(66556008)(66476007)(66946007)(8676002)(52116002)(6506007)(1076003)(5660300002)(44832011)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /f5NW7XC2+XK2BUfRrKJhLlMe7JtOr9ZfRJ+i/LZNOla71xGJIvcLP8MR1psDCY+QCWZF85mlFSLAYDBFAul7JZ8EgARj5BsBDBz+EmXYRQ6Kg9X2cIT4+WPFfcUor3zQKuyouRN0J1i4ruQ3ffSMDBiA90N+M1aHBdt7pVE/fI/1eo458ol0gm4idQBRMe8xOwauXw9uxIRz/TuIywjrQFW4QU8Wf8BixJRgRgDPMJkAoW9rP3/UOdPCB+p0J54OTx8ylEuFFoE64ewCo3lYYQRNylKPZv3jrNexNJN7l7+VbwqbabUFQUARHCBCKJliW4m80c1hagSWqQTCkNBhrKwo0idTJh2QAIFQgHxo/4kHnrMgbu8fJH6egAlwPsUorHDT8Zb5JPbWKilV1M8FEbfruV60lairBrXxUCTppEBBiLUvtFcLDJew0X5GqL95oqaiUhqjNI27unChYXDEaN1TUSimpdhYbW63zC/r8vXyEBVJFKtVsuopeTc3Z0Ugc9cacDVhvjcNFV6b+5lrwgOIh+T/pWO8VTi3XUrEvzaaXgg56es0/jHZNJueOUIdJYO6zA4rEzuoKL0hT/K/FkGEb73hrpI1YLxnIBaPkS4YO96wX7dlXxg2GHOCr2cTGbhUCNToOs0XetoU0nrSvqYSk+uEXCnOLgJ0QMbjOV69wWJR5GYhOkxVnO4AfdYj3QOiDq45k99VgZHSR0XcVKcLCvQ5ggM2P+n+M+UkFMKs0XLFmZwtE0eL2ZkgUL7iq0vazHcDR5S9FUmXGh7PSUwzthkS2M2qDHZm6Obyk7ZVjfJLIZp2TaY4E6j16NfD+EoHpg3xbXlPXM0yQf3VB4FULVSbO2pFfz6IJ2TURscuhFutfn42AGt1VHWHQvcJ5m2RR2k5gz8gF0Kh+tl6HGQtUASKn7MoR6kkY0PTdC7fdrgJUywRBUO+KgOpBmMNC/lG2nMHr5MkmDXh5a13DeG6LxaF5uAxP490oNgKF8EIj8AqwXvmCrfxwPIZhwWC1s+GvKPZsS7qBAjmk7BmKqqNkAE6vnTILnlHacKv1BrZpgo5ND0RLyU/wrmW6P85njFD1fZxt8CS0iA9bF0QMIDkcVMYDSi/SSmIE+woyprIY9iLkfO/ft1TJcdANqGX/lCsXVdaVRgGRuwcB54/yyZ7IfXV3qoU4ZZJiHM+sZgdayLeR0Fne1pLCobX+Gz7kakX8GialQ+7gJPF9DXXPiioTDQ0+KmOV/cm7HcPMzekBUQOqM2Dj1/IpTcsNWI3aGSClBXpj08vpFD44NKZZRK6iWwICPLxcc9aT/gdsCzftpl3tDD61eT4FF3yDzRpUHJIV3JYnoLOP71cwnE5zXUo7VVwmjaBmxn7GTZEj+wQc/yoEX1DSsSUbUX9wDhsv9JiWmZT8rAXHa/JxMUsFhF2iXxIO/ZPSJkun97Zpk/QtapwkIdQvfRIVmRh9Sx16NBfVP5V3xCEpywDIdioHOXv81ZGOawc2xoz6LYTC+fDOa7WC7op3JcDfKYM1iesZvUBxaF3AjkIgqncXVBDeOxVO9kaAiOtq9oDJzauuaaQemFe6yaRX/W7OjAsgzffx9GygL2hlveWEPuueGe/Q== X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: e6ab5f9c-dadd-48d7-a321-08db02a7b49c X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2023 09:52:31.8983 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: oOIJbnV7XeUDfk2nBj1KEazdmfu1KeLUJ67iD58NJvEhyzPYY/81JzIN1omo7+5AnnERV1CJUfKTveXDDQMUPA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR11MB6025 X-Proofpoint-GUID: NitqZcDEcVqyVu157G339zvIkds4YKmn X-Proofpoint-ORIG-GUID: NitqZcDEcVqyVu157G339zvIkds4YKmn X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-30_09,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxscore=0 lowpriorityscore=0 suspectscore=0 phishscore=0 impostorscore=0 adultscore=0 malwarescore=0 clxscore=1015 mlxlogscore=999 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301300094 Received-SPF: pass client-ip=205.220.178.238; envelope-from=prvs=13943e2a21=bin.meng@windriver.com; helo=mx0b-0064b401.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+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 5503199300..050c177d0c 100644 --- a/hw/9pfs/9p-util-win32.c +++ b/hw/9pfs/9p-util-win32.c @@ -1273,3 +1273,8 @@ long telldir_win32(DIR *pDir) 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 072cf67956..be247eeb30 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -2336,7 +2336,7 @@ static int coroutine_fn v9fs_do_readdir_with_stat(V9fsPDU *pdu, count += len; v9fs_stat_free(&v9stat); v9fs_path_free(&path); - saved_dir_pos = qemu_dirent_off(dent); + saved_dir_pos = qemu_dirent_off(dent, pdu->s, &fidp->fs); } v9fs_readdir_unlock(&fidp->fs.dir); @@ -2537,7 +2537,7 @@ static int coroutine_fn v9fs_do_readdir(V9fsPDU *pdu, V9fsFidState *fidp, qid.version = 0; } - off = qemu_dirent_off(dent); + off = qemu_dirent_off(dent, pdu->s, &fidp->fs); v9fs_string_init(&name); v9fs_string_sprintf(&name, "%s", dent->d_name); diff --git a/hw/9pfs/codir.c b/hw/9pfs/codir.c index 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 Jan 30 09:51:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13120824 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 AF593C54EAA for ; Mon, 30 Jan 2023 09:54:06 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMQqK-00030U-2K; Mon, 30 Jan 2023 04:52:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMQqG-0002yg-Sm for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:52:48 -0500 Received: from mx0b-0064b401.pphosted.com ([205.220.178.238]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMQqE-00020q-Sq for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:52:48 -0500 Received: from pps.filterd (m0250811.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30U9qYwE013139; Mon, 30 Jan 2023 09:52:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=eID1K2fGtFaSsEv6+j+egSlY1Ky1o6R09v+FidCa4Is=; b=NmwcwkSCbCXBH7YdBHjDD8AbeXnxoz3yhRJGYjb6q1FMUexBX/9CxpMH99tT7qwAJhQR Q/crT8pfUFnqJ+Pfym+NGO4G7asU0MBr52oD7luUerzVQzECgfbpa91DW1IIe2T+paeB 52BbgkELWkOqsI2NiaN9Kf+AbQ/55GQdw9kWJyOc32enkqImk2MEHdvZjH46bF4v8ZB3 0KAvXyt2gaAxF2bjnRAzvYOl75fTAYb/ROWXfMX4ug07riDJ1ZB4sqNuUTwir8byET2I gma3Z4ZPCBLmZxXyj+FNhN+G0EkBvX5dkOaijPkWRaDPwUDzoyOFPYSP0SxvXu4m6Nfi zw== Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2169.outbound.protection.outlook.com [104.47.57.169]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3ncrx3a45d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Jan 2023 09:52:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZgqKD4lb8RDotS2xpOWFqZrDMHRA1MrVP0kjlakew/wXP/son0jYHV5+FKaSMDVpRuttjZTsIuPW5WVKtRgzLidGaEEZXTz02SNSQQ7nIb5ZQgApFWFYnNudYoypnD62i7fT2a7jJAqXx9Z8l3rorfZ7cpOd2dgXcKbDgLlnDG4irM9jHxvYYmmxm2jIgftisZeW+94FHThUattw6J10hnYDgTt4nlRiPx9ijgcpTMXrQGRvaLrqyQhZl1KCUm5hjgqr9dmz41iTWKgzG64RhkWfjH4xpAub9HiTJi/41hj/W8ehbdWmvs8E/ofAQvGZSw51oQVRKuTdtJJAxTPdYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=eID1K2fGtFaSsEv6+j+egSlY1Ky1o6R09v+FidCa4Is=; b=kw/VrfJpy/9n7fJSviRosxr0gk1UFgLkAzMTcQAXmvs+AuLmmlPNro1hfaMsn0xoCzjq6XjVYrpi6Yd0wpQFA2yvwN3Y0q8Mb0Ck+ad7dieY8qxVIhNL6QzDWmkXG6Nn16kVLsN1voi4Sw1a7/1ecp0ilfRDiN9daAlfOvYAqtc98iOlxjM0IrDWfSRn7anSChAwj51YcYhkrwXuou0n3DllwvTEZ2svJxc+hx9afZnutZ0Un38MQgNn6Lsz+JQncQrDGTXBJ+JOmECS6KhzgHhu9TpHckGFJJftI9J3PmSicJv0EoWOOSR1DMW9vi14YATq6joVGp6X6gin23jkKw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by BL1PR11MB6025.namprd11.prod.outlook.com (2603:10b6:208:390::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36; Mon, 30 Jan 2023 09:52:34 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9%2]) with mapi id 15.20.6043.036; Mon, 30 Jan 2023 09:52:34 +0000 From: Bin Meng To: Greg Kurz , Christian Schoenebeck , qemu-devel@nongnu.org Cc: Guohuai Shi Subject: [PATCH v4 07/16] hw/9pfs: Update helper qemu_stat_rdev() Date: Mon, 30 Jan 2023 17:51:53 +0800 Message-Id: <20230130095202.2773186-8-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230130095202.2773186-1-bin.meng@windriver.com> References: <20230130095202.2773186-1-bin.meng@windriver.com> X-ClientProxiedBy: BYAPR02CA0061.namprd02.prod.outlook.com (2603:10b6:a03:54::38) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|BL1PR11MB6025:EE_ X-MS-Office365-Filtering-Correlation-Id: bcc51f99-b417-43dc-c79d-08db02a7b5d4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dOOehaQ7j8XLw/PqmdDUqcbmYYwI+OWPJ8ThHuX1WgpMpaXczcr0VlVHO/htQ6AdRh6cmRkQVTyFSTrI3l/e1OLD0+zAZBAaA84bURf1/QzSpZZMiPSNU8+pPZDCV6Gj/IurrGgBYKGCQoA5mSxsLXJ8UGWo192WKFhqgfitlieR4Z4/yB7cwA6L64B5/A7f1w7P1+mt8cfRfL8KqP9Z2nobPRgO2Jh2n517wahHNkD+Io6Je7LpIyWefst2cIFkGXTZ/r00sQR4AmXpalCZN28b/mdFHGzMH/E8HaMyLDBSEeMODVqYA/NnvqWa1Tc/EtiW3eGrSYEeFS+bCaIOuDJquvT1OO8gSOVYPfflLtKF9KtnEnijzz2PT6h2fsqZg8gjOehRwStz2qmKIMpGhDIWK/l9jJP6Aulf8icUkjjPRGcfVuhNu9iJmjm7vttk32nfZKCnG9uXY9cuBXSoB8UAzfPHNYMJ+64Vagr2MD0YqVpQsGyMOK/gcY7O85Cx9s8rfPkZj7B/J+L0k/wtHlLjJq7RkE09DbAyQOdnbHVPTr/E44nl0e0h9Kvy0eoC/6pEb14Ih84Z4uvw38WDoXiXcPYTyUAEz1a4yC14jzNlJpwlIGPnxbXk3+7Ty+ZT2SeUfuedpFG6mtyE/9gyn+P6AfkdFCGahM2CvY++xD5F33xgqvPm2UXxB/VhoV08I0K7YVyYM9ubcBS+v825Mw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5358.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(4636009)(396003)(136003)(346002)(366004)(376002)(39850400004)(451199018)(2906002)(26005)(6512007)(186003)(478600001)(6666004)(107886003)(6486002)(316002)(110136005)(36756003)(86362001)(38100700002)(38350700002)(41300700001)(8936002)(2616005)(4326008)(66556008)(66476007)(66946007)(8676002)(52116002)(6506007)(1076003)(5660300002)(44832011)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4FHavViznTQ8MeQvUHwMTo9MBKPCu2I2tCENlnFNAFfMFMA2d1YP3OaIeyTS4vPzyK4vBduKbPGYy80ecKnr6m1yOhCouVKrBWG8uSRZU9KuMcXrhpcbXpHsPvQuwTIWBmovT1U/Bm1H5Y82ENzpNGK6c4aDYIqW6T+LolsDXtB7TgjsqiiLdGumsOGRaX0OJUd1I+hRQx93511Gdao00wikCK+TS2tI0fLJ1NaaVbe5Z/2ICL0Xh5AXnS3BOXsStr6UXvigQ61W/7zd+R149I/cCx8YwHsP8i/EolX6D2EycriunpMaDJmo/2Y9mfPEf5U4wzncsD3RL58owhd0WNJEodugWN0h/iCCYc+BSfm1mL0c2G152FQFWIsFSyRxZfOjqVQfsTjw5TljtdjGd03rPWJ7rztShIt16jkUg1Sm9XfPwMWaQscWXDUloV72WsEqRn5yqK857gmtTL0Me275Ak0BrPD9PAlDSNe/TTiK69jXqvO/LLCzHNF1/qtYto5BvVeEW/WRn2tsOQpysSrUF4S3WNL7pq85E3jG6iv0MJxrTy/DzgLMOhifUO0zA4Ru9zY0CpbrVOvGa7YHO48UgoyzHY/Vr3GgfUK0FDtGZafC6R7Zu/jFIzLgBLlfRXNPmVk8gN8NY2MHQ8k9zIa8EuUwLoe1hR0mUXIqJQdKnQEJ8R3V+0Y5deCsL2KZGlNDrGND8020tGCDMQNV+1KbswTWJJ91NW503J/0a/UG0MdXzstmyr+kL+TqMn2I8/IUvEul7UmH/RDrmm+mjeI/+mXNHP8l7Zu/ee6sZtYRNTTk+5AIBRR+2GcTDnXKjDZT/vsWK/R6gB9n4QAJk9qLCVlFNc7bXxNmwpn5nWUlOPR3ILyTWUhZOmLhWGsIVPisyvKi40tVSUKFqugBH6qoBYmnwA9TQTb7hOPHmPpGdnmlhayi8dwYMxglMnitQuIuvpVnbnww/c1tr0a/yyhoNhPKgDQCeN0AU1oADsfn3M0yq8xe4vhtZ3selVrotugsVuKEWVZIWKgPG4kptq3u9mU8UB82GAl43ZsAJ7NMG1pVsB1W6PM5TGURZJmjzeMUUUDpvYiUijPRs6rKuuj1Mb6rv5/Vo5cgc+612UzvWQSu0/Zejhm4cmh+2THQEVkqPNlhTZDTvvsbkESa/5l+aF8A639q1DewrZEvGMItA9PqNO5c4WRo5TqMPXWFXqnEAtPahKBdS7+924SOTr8L8AYthNTxngJE9QJz+Y42A4f5Kj4HKw54wpvdBs9M22kWm4E9+puTMRdjROR7g7Op6AjVUTRUm/tfat2anlyHYMPXyiiEQLZ2lrl8U0lvfxSMnMgnaeFwv0HKAR0LxHaMv5LtfJ1xasy8zoUMhu4zqYUV+oJaiSTO0XIufyWduXWKqPyfZ3TqnHFU7zWzhOVMTjBff/1NGcdk3J6jGg1fTNsIrbXXq1Li42vSAR9E+fKrnL5Zlf9YCBNEvdPA4EGLf+bl7YBPJUYeIhe2A/0tTb43CWjjda0QRSI7CZY6plt+BVfFJOHrXX527L+JDXLBJZAGjO4Xg9dzBqq6jDuRrqEl9R6EfE1Vii/7HHMNEZF4p3nMDTz4vdnCoPXSjQ== X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: bcc51f99-b417-43dc-c79d-08db02a7b5d4 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2023 09:52:33.9595 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 2+ktV4laJPx16UpgqoPVFFXey9Ku+XPx9eMODxkjGFV/dbXNUChbUj515RWEyWh6Z84uxCxs8xjDOar/GaThzQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR11MB6025 X-Proofpoint-GUID: L267bUFytw2q0ycZd7-4OyqZqBROfD5c X-Proofpoint-ORIG-GUID: L267bUFytw2q0ycZd7-4OyqZqBROfD5c X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-30_09,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxscore=0 lowpriorityscore=0 suspectscore=0 phishscore=0 impostorscore=0 adultscore=0 malwarescore=0 clxscore=1015 mlxlogscore=999 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301300094 Received-SPF: pass client-ip=205.220.178.238; envelope-from=prvs=13943e2a21=bin.meng@windriver.com; helo=mx0b-0064b401.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+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 050c177d0c..5f6d43b62c 100644 --- a/hw/9pfs/9p-util-win32.c +++ b/hw/9pfs/9p-util-win32.c @@ -1278,3 +1278,21 @@ off_t qemu_dirent_off_win32(struct V9fsState *s, 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 be247eeb30..36916fe581 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -1266,7 +1266,8 @@ static int coroutine_fn stat_to_v9stat(V9fsPDU *pdu, V9fsPath *path, } else if (v9stat->mode & P9_STAT_MODE_DEVICE) { v9fs_string_sprintf(&v9stat->extension, "%c %u %u", S_ISCHR(stbuf->st_mode) ? 'c' : 'b', - major(stbuf->st_rdev), minor(stbuf->st_rdev)); + major(qemu_stat_rdev(stbuf, &pdu->s->ctx)), + minor(qemu_stat_rdev(stbuf, &pdu->s->ctx))); } else if (S_ISDIR(stbuf->st_mode) || S_ISREG(stbuf->st_mode)) { v9fs_string_sprintf(&v9stat->extension, "%s %lu", "HARDLINKCOUNT", (unsigned long)stbuf->st_nlink); @@ -1346,7 +1347,7 @@ static int stat_to_v9stat_dotl(V9fsPDU *pdu, const 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 Jan 30 09:51:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13120826 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 62522C54EAA for ; Mon, 30 Jan 2023 09:54:14 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMQqI-0002zg-JI; Mon, 30 Jan 2023 04:52:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMQqH-0002yo-2K for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:52:49 -0500 Received: from mx0b-0064b401.pphosted.com ([205.220.178.238]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMQqE-00020r-VC for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:52:48 -0500 Received: from pps.filterd (m0250811.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30U7ovuD022584; Mon, 30 Jan 2023 09:52:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=PkUIwXcPmGDDh7XO6a8+bxOq5aULYYoUZNE5Gf50AF8=; b=BmWEcPi55uUm6ZAfe3tEK0oBx9MSW2HOIyNhnAHRVLBjfl7Ctaz8bOVVU5Rw39pj61Mg LcPNzVYXSg3KzdBRJxYCXKxXgxRl0IMyHtvV+mddkWnqkylWEcDmW3ROrFBDmcHlBWlM 0eXMnKc6Wk4s12umUi0eI3VlP6wMQ3PPUDxCxXWnXFaJ/avhILUoIqEI8ZZsbssNNX+v x+RMBD+6AfmHTf5ZjGJwp3jb89nJoEGj7sSRnJ9khKOZLPDUuZch1jw47DJlLoy1YUPS NYAjhzgebfaABqarWVEbLEEvKVTq7MbRUt+altsyqMTFjAdrUx5aGpEugN2RBJoE3ein RQ== Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2175.outbound.protection.outlook.com [104.47.57.175]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3ncrx3a45e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Jan 2023 09:52:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YPgoa7wumEAJ6QkqifYT1bP8zS2mJpW54xbfr/dOz5uCGvFZYzjt3sNamtewQBXQadue1Ro/wMCKjdVT0i0EB2dh2+up9ZMdjb+Fh8/IwCL9uyNzqrmF80rnIy0fZk+5jWA4UjHRuijt6HCLy70ldmn+kl/UWenl6ppgXieWWNj6PtTQc5XAQzHaT8/LMsLyf3EriyU0HRA9gzfJ/Wih5mHdnZ/Zjf0osEYjr0LaaWd4okTB8h31pNI/BbtfOu2rttE0+jX0Pbs/fEzOF8XD5TUjOauq3FX2mlfKegr6tN6iMiCMpsAj2HbuUXc7hbXk68CefwZ/CixjjPNWVl3gTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=PkUIwXcPmGDDh7XO6a8+bxOq5aULYYoUZNE5Gf50AF8=; b=Kytiygs7t5d7YVYU4MXnZ8vIysI7tzq7Z1LqgbBKDwMzrXdM2YhY6VgocJmmuiV4z4FIEukHuKAQ7Crjx3jZ9Eqfq2OkOtgpf0sXWLh2YfMXkBo3L1YUCL1Fa9iD5Ye7dAV6pHGvC/v8REi1zqXmzDpcxDihBj0WFIYhdXmZE0g9KPwcs8OX9AhaSQDIftg9hmju18Ab6hNsz5Bx7GU6KJoMpsKcpqcVpJCBvONdFfBl5u6Ug8kZ07VWA5dNWyxnHLzkb2sXLbPTGRwFA8jLu9J4dOzCcFvex6HBGYnLNNcWlJO9VAEGmpSa8zB7PMtnQfqR4v1YQk67x5TSrgbtgg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by BL1PR11MB6025.namprd11.prod.outlook.com (2603:10b6:208:390::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36; Mon, 30 Jan 2023 09:52:36 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9%2]) with mapi id 15.20.6043.036; Mon, 30 Jan 2023 09:52:36 +0000 From: Bin Meng To: Greg Kurz , Christian Schoenebeck , qemu-devel@nongnu.org Cc: Guohuai Shi Subject: [PATCH v4 08/16] hw/9pfs: Add a helper qemu_stat_blksize() Date: Mon, 30 Jan 2023 17:51:54 +0800 Message-Id: <20230130095202.2773186-9-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230130095202.2773186-1-bin.meng@windriver.com> References: <20230130095202.2773186-1-bin.meng@windriver.com> X-ClientProxiedBy: BYAPR02CA0061.namprd02.prod.outlook.com (2603:10b6:a03:54::38) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|BL1PR11MB6025:EE_ X-MS-Office365-Filtering-Correlation-Id: d8d086af-92a7-46a1-9677-08db02a7b70d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: p1kV7PJBC5i27NYqDPWgWdbEGZgMRoFACgyjxCAxYeAceAsvd+e32omz/NeCOOi8CINpRY7njHeUpFBk6f45RMund10VNF7NJ4V7RwodXHy5cYlmD9HLFEyMhD2zxu2TlL9Win3Ju6adjmxMqxZPYbEzxai4ph5i6lvex5azXzA+eeISedfhCGMwmM0xSBpyJy+hvQAbwF/G1m6e/kEbgKIX5fRWSyTMRE/GLNrde6zytOAotNMrf9zPSSnSMDisbAYYNZWSxzYofDCQOzOSPHnonjhnsYN9x/RiUXigFU94cYmZxPymn/nv/ESrabmHwRYXYuLibK3i9/WZ5WKMQfuhmP5CLIa2Zx7C1CpAPZXCifYqSn/h9on47fjQhdAqmf1litoItrRhwmf9GZ034xmixdAfjAnIwjmqmMJkwcrQK8wL5CIjJ3LAuEIh/M6pUv7q+49p8+3gFMd5d+yNc6NqX21iuhQnuWfIhOXZ0uWkkyH/fo2E4w7a31lEAVSwLIQP9pbYRT90az5TEtJ92h+xqKQ0v/bC/OMwq68qn5gVmJE+sr89Hz+n41PMpYvQvwF5XJ82PzABAYX/F4l2w7SXzxOHoxw8KyS7DWdp9pitYLAlmH6BCFLXW0My6PWMD26m4BvX7FZWF8BGH3ICKz5HT27r8TW+nuI1LgDkWhZcdtBcLQqUl420LHuQPsZegrUNf8OMwZqSQBicvivXgw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5358.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(4636009)(396003)(136003)(346002)(366004)(376002)(39850400004)(451199018)(2906002)(26005)(6512007)(186003)(478600001)(6666004)(107886003)(6486002)(316002)(110136005)(36756003)(86362001)(38100700002)(38350700002)(41300700001)(8936002)(2616005)(4326008)(66556008)(66476007)(66946007)(8676002)(52116002)(6506007)(1076003)(5660300002)(44832011)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pOlvmteUV7ci7kQJpFUSG9zTPM7hXCKx8XIVNIqoL0d0cqEc3LtXncVLbpFFCLGy1vSxYeM3KLOAaJHkxqEbNkA3rXpnPNUmO7lwRY+KHw+6a5/IJRJzbCnZZL9hyson7j0etdHcUTYHLK2uNCh0ZWAalsbHv7jzISvhAfREVTqHnij746kLC9iCyhQW3/4QQU+w6ZZAxuIOVZUF/Vkx56BzHLRS0srg/nVzzyOXhBzRXtrNCVnIhJOI9D0y1CQ94fOYi/uzecn2k8QaKI42OVj3knrR49TIIlv++7AYkgdV/VH1qOGMfisCgjpX+HuRC3Oy/hN37BOnaymWoV2QPt+gi6ironsQ4oa6cA48BqSQnDgYw0Gu2TQd/7lPE/aIPBY5rRVg/t3xZlr6mS5N8nnYwoTg1n/0Z00VwIGry+LOPF/rJEXs+iAPGnRPPRhpuV665Zpx8p+WKpRwHLZnw152IUzWw3V1VjwxtQPeBXIZasYuE8xE67+/O+S0dGOm78wpUhM9rDcyQL0uupqnFpNh4J8zMg8XgOZjcIDqrDk3FCp5FoVUPBpuxmxQ3I00Ld9KqHqAt5AYSNYgJMKfFUT4Ixu1E2YwMKcMWiZPjnoFf30khkyESCT2I00QTtsmphNgFQNacXwig/6jsB9HiM3V9FI8k1H86p8HLBKGNej0NJOHDcTwAExIkkMeqSbHw8quMEgkKIdO8Qu5u5LQ760rzBwu7/1Xw13aXYwdQ6d6qfgtUE0rGWZqByLoyj20cp5/k44eGpYTUgmN/fi2vHGoI8HrqUvyZ1APu5JTJkklmroSxHlxrfv0sWINXYrsIoY1uJueHqIiVLQ9M49ISv000JaoygHmN8laOrxT8xjTwnFPjFMNS37V392lYgpqOZN2qNaMUQnneDGF8JIrSoVlJSFFmDRztczX3k/+ijGjnfZrRn2uruubbzGojRBWHitJoxnP46qM1Jqu3tMYq2RK2pgK98EslnE0KjdpxB5NfBMxH80FcqkNBR+OIaOItKuUNWirzqs7RH8oH2wzVJDFPuEZD85+wiMPobWQOqrSTJNQlgWjq2i6f/rqSh4X1WXgCkq2WdKOywEMW/dSyd7vVGmVVhnfJ86jUeR7bIbV8UXWG31TqdDbRbN5+YRdO/c+AyGz/EYRq/5SLXva5TlsivIwtC/Shqkf0b/oGDA67D/23phzNhA1xA82aUHDcB+6VKlSvmUrr4lnWNIcBLQyTbVD1+B4X0tKPya3cpGJivXxks2A4p1YNbz41Eg8iE+1JLthct3vkvkOrvdjAINUSIO89FY9LXTMtBiAwHRjoDlUFdQiZdmXyCLHHQ+UkEutqfKoPulzMF/UMLYnig3jqXQqXGYH+dCj+ot15zrx4JUKnsCkExd4jwVyOGvfFUYyNdNl6G9MwmC9VcaLPZN9GmmT5BrAuzh3+6+EUuMdHfgVf9cr6YZQgp9yIQrX7w/E74sU6JO8Q3yQC8Ogiy6UHzrBbTYb0e5+BwgAuEAIEpws0Ah0FusmbQbMu9RUnxfsu6GHepEtVDYHfLkzJAT3ox1y7N9AQ6zMJzIPL5bBZ78I+3kuP1PXiKqqK4TTwvrSmWNviZjUBNidjLOqvA== X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: d8d086af-92a7-46a1-9677-08db02a7b70d X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2023 09:52:35.9784 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 3zMoEnRd7KlZiJ9IoAOXi/29THNQnGPTxPJZH8yWL37f66hZx6/FEwHxVgtdzoYMW94/aVIUo8IQj2mVbVfinA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR11MB6025 X-Proofpoint-GUID: cqhlAtBoy9gwQ7IkqNGMvBUQpg6rTDfY X-Proofpoint-ORIG-GUID: cqhlAtBoy9gwQ7IkqNGMvBUQpg6rTDfY X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-30_09,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxscore=0 lowpriorityscore=0 suspectscore=0 phishscore=0 impostorscore=0 adultscore=0 malwarescore=0 clxscore=1015 mlxlogscore=999 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301300094 Received-SPF: pass client-ip=205.220.178.238; envelope-from=prvs=13943e2a21=bin.meng@windriver.com; helo=mx0b-0064b401.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+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 5f6d43b62c..5ece1db7aa 100644 --- a/hw/9pfs/9p-util-win32.c +++ b/hw/9pfs/9p-util-win32.c @@ -1296,3 +1296,10 @@ uint64_t qemu_stat_rdev_win32(struct FsContext *fs_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 36916fe581..def85a57fa 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -1335,12 +1335,14 @@ static int32_t blksize_to_iounit(const V9fsPDU *pdu, int32_t blksize) 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; @@ -1350,7 +1352,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 Jan 30 09:51:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13120819 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 D0A51C61DA4 for ; Mon, 30 Jan 2023 09:53:30 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMQqM-00032W-0o; Mon, 30 Jan 2023 04:52:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMQqK-00030z-NT for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:52:52 -0500 Received: from mx0b-0064b401.pphosted.com ([205.220.178.238]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMQqI-00021i-Qg for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:52:52 -0500 Received: from pps.filterd (m0250811.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30U7wgu9004336; Mon, 30 Jan 2023 09:52:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=jquWjOk/2bQifIb1iccPzCgXb9Qy8aYd7A+unbyQWmY=; b=d0ru7RA8OeFEhfoxd9fGkUK0JhWt7aEB5Hfr+af5IseNU1z6EQfSt2L5giaFzPFqYaoV /e0g4kV2rmHTlQAOc/3IHzeeD7LRfo4CF15+DvC0YaZ9Zr4pQ3IsQ3Dv56vP+tc+KFR0 +rurggc/KBr4mzmlZSGAZDA6C/yWr+y1rzNAqgC/axkpVFKrWAMZPKVeDmpN7XMxRJrL TuyMYYQ1Bgp+KT/5x6S4y+6nY5ddtW7cEXtHZXR3wTD5eQr4m9PpO+5u25xAFSWLbu4I Cq/0i7b8aG5AE9SA78PgITBa/BiNbOvC9uoXtVwUkJKd/p2vEtn6+Q5fA2ngIXv9LpJU Xg== Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2175.outbound.protection.outlook.com [104.47.57.175]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3ncrx3a45g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Jan 2023 09:52:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k5UsWgzCExT5Vf3FfDXQI4X37LOsMw4jTxlTLYYvPJnz2VscTuHzIKUsLpKdP1zKmBKlxFazrczT5oV6VMegl80QmUgx1IZ7J8ofmoVumznwpBM8+nnItqsG7BhzNBF6MyWIkoCfIIq6CnTulik088bEaKoP8wLFC7m/7xWD94b3p7Bqey2ZzomUOq9kcAubbna1wlfoMlMEjbN+58ravyl7eyR7/lqeEZtwDoJSbqlB0D4lxgUMFNRSgMKVh8tSGcDjoodhoUpNLubc6yVi+3QZpDG+ss0SSqm3PNhceStel8G4c9mlc+E/KJuxDMfGfq5pBwcUJo/JT9uX7I8hAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jquWjOk/2bQifIb1iccPzCgXb9Qy8aYd7A+unbyQWmY=; b=M7ByR1u7FLqyw1pZYzc1PQCRZgWSyBRSWML6wgfi4jvDhEDnVaWj9FzIvvh2t2UZuXqaqn2xFBdPmM13Z4vOsXFCvld0/dNscMYABq0Ij0kK++9mJTJ9l8gOvIsCqKIxuxgY70Y8yXfSVnh7ttlUCmc64LwhWJoLIu0cxZsvcUlMxi4mtZlDl42OEwIn39quPO6qVkM1QN6p0t1jCE1e/7E5UYIv6AxVPneTv5TjDLcOHPUe6gfh0yD7/y5txh7oBy8cZqLmUzCC76yycu7G4fCixo2X0Z1utqK+4/wamJ3tYwLcFkoYzVjjEIpln4uZWfuhpKsobJK4zFSXPcvjxw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by BL1PR11MB6025.namprd11.prod.outlook.com (2603:10b6:208:390::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36; Mon, 30 Jan 2023 09:52:38 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9%2]) with mapi id 15.20.6043.036; Mon, 30 Jan 2023 09:52:38 +0000 From: Bin Meng To: Greg Kurz , Christian Schoenebeck , qemu-devel@nongnu.org Cc: Guohuai Shi Subject: [PATCH v4 09/16] hw/9pfs: Disable unsupported flags and features for Windows Date: Mon, 30 Jan 2023 17:51:55 +0800 Message-Id: <20230130095202.2773186-10-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230130095202.2773186-1-bin.meng@windriver.com> References: <20230130095202.2773186-1-bin.meng@windriver.com> X-ClientProxiedBy: BYAPR02CA0061.namprd02.prod.outlook.com (2603:10b6:a03:54::38) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|BL1PR11MB6025:EE_ X-MS-Office365-Filtering-Correlation-Id: 8268ed78-b6f5-4871-aea7-08db02a7b843 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9FwD9m+i3gDmB852P6jqc6dftgdIq9+Yj/svVb0fk9tvg1BUsYLjOdqTZB/ybdSBn42BMYOuoRHFaOwwmaF8dYlH5+DBjPcZpIK7DIR6CVhN+ksGWkey0VeqFkV3KQlv4sk88pUp2GMu0wuJHeiKdlO88YDQ9iwjKs9oSo2xjF+xTRYxuNmzxItJ/ekfKw8gnTpOT/6oh3DleFd+XKFxlLOKqdVMe4k/M7soNeHaaIEZPnMDPJfhU+I2ZSlKu/sPeg4ahQRtmH7VE1HNvyNpViEUC/JfpnODIm7/W/4OmYBjEVrqPW1wiJGubEt0gPV+fFgVSTKyKVgGrP/JYJcIsctMbu43ST9S6RDdNSv19DKfSY+CrYQNOB9rTKXpL7aCDYkW0hCzIOGAtuwZlLtT3ID5n5Z91Dx6zOozRUAM0kfczf8OJPA27BFaYqw/he2JanQ7GU3380EJqjXO8+aV14P3spzia+oKoFdgfG1+pS+YLYGb2EzfpGi5Grh0IYXvVqNcstWOKyIYFaoKG0u7r2spcVZlGtK98mc+wiO7VgLwQfvMSXZyXjY39/OwHSqvQ5wuvzYmoqcUlhMDx6RYZd1R/FRPIEpsbI1R/d7sI9+YOfqUcfKhlW44/C2vkHCfwKbZ2BII2FD5oO2mC2bgpFa1l5ctznM866gpYf1lxM29Mhfj8d7pftG8xsjxQx1IXV9lczt9QXMRVkxaGa3VxQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5358.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(4636009)(396003)(136003)(346002)(366004)(376002)(39850400004)(451199018)(2906002)(26005)(6512007)(186003)(478600001)(6666004)(107886003)(6486002)(316002)(110136005)(36756003)(86362001)(38100700002)(38350700002)(41300700001)(8936002)(2616005)(4326008)(66556008)(66476007)(66946007)(8676002)(52116002)(6506007)(1076003)(5660300002)(44832011)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: d0rd3MuLvK7nta4ven3WxKwnCtGlvSNpAvCfx5KTUJUheZ0y8f3p2O42dPcvOCIGsEEYYo5VDPjS8ErkVGRrRm3en/6ndeJnPIVV1g9rqPYNHpIbKOJ9nLxhVj0NxzC0nS+ZsxdWxdWGbW8qH/yPaIrHgijRJaHfzq2FO1RKBDvYBCmAci+2P3ia4adtmvVfgsySf4g+pl4hXHqr9RsRMAwJ43BJsz0NwO06UCy+S6qQJyVk2V5qfNm/+3lDp3RI9BibxJj4WuYlBl/5Fm4krnqbTvxFD7vKiz3SR/rskVsxlwbM58nTbyDDh6HIMb2zTctU+KFugDIBVYjpZBvUmgcIAXRISi47lnOPEuopkicWPDKHjVXYKjlCFUTN53Z24MrSiJ7bdJ617XdKXgM0tO52OWEBdtu0g59mUr5kC50ZXk85TSZoQzvU1QPNoT65GcDgYLuioSOFFiACU1pwSsCMocd2kLkfidtAN2tq0Ezn7EnnWXdjQq5nVYLloujYNYI61Zy3r7AfcGive44cNDryDF4r7PhMFe62u1hdY8eeRiEeMnXbX6+afM9j860Qp+oBf9oGFq/W6bkXJEegziRQKhSf+ZpiMsyEEfBRKu+8ZV0tkgu9UQinSLLWXRlQFTOTymTlhpH5COJpc/oZqXOti9pWSQfSuWuPV3h2Ka4IaFN2aNNv6+C/LTQZCs65qdyyX2Bt8YNiecHJzb4PIxNl+zvKn5NHQYsQULrysctrfP9STRgIb9QAlzlDSUqKZs/3gKZ6/o/hcyBvAY2pIPyTcjqjVI495BVIWwbu559/9mAC0PmXdR+5iJJh1lTXQtRBoyA+8jCSlByTCk5NNEbJC+kER7vCTzAaKXqHgzzSu+1LH6UJa515O5UaCDn8ZYQ70AVgtY51yMAKzZOzCtsxcTmz0P4OjeVbHoXBJ1ToWJMlq5hS7ZjM4FAAFO8Ds9jyBB94lHSjYxHTcH7e1F667vt0MlfjU2LpJAQxBf/1gRFRFzia2e+yBowt34G43V9Hz8SRGvFXZcyLUS+/0WmDQYodVMmtcFQWu1gELDu1a+JfXC37E9nEuPfEc94VkjIlbpn2wBUhc2l2v3l9VHv9i1xocfch+DUg0VuCBcqZjGDYkf/nljAq5a8/doDvrlzthOmv3Jiy/W1Ak+Ii1/En01eAqQN1qViyC4xpWbURASvIukdcAO+c+Z9MIY62mp39JRpqsO4aJ0KmFzpbmWtQ041AzVznJfBHCbXuG2V2+VA8S8hAsB5cSgOhstXGWjnpSeFF1ER71eA9K9Rm2D0eEcBgDi3YE642HMeEhv6fwM8PWHj3AykWVmcrB4YAwJSO/Sztp5ec1+gz0w0tFyfzhyCtry4wWT0oZrkwjOq9ZRbLVIlHr+DC7k++OXWh/caeqQPbuedBe6PiC3mibcju5xO9HYTwYz+cz/kBSCgTr+SBSHQfuYrUaPg2UdFk3kBsKzoSlxV6LSqc9t+SUD4GTDo2t0rSXPUZtcCKlFDlC1gk11yVjEHvtdPTNulV/uHKwDrC1kcbX6fpPZ1V6sMqlPTEGCVB2kSEEVG5zeT2ehM7VDM++Br+hFfTwX0TlcObs7bs8bpK5+5Bd9xrow== X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8268ed78-b6f5-4871-aea7-08db02a7b843 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2023 09:52:38.2275 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: vx/KTqeWVAyM/nnTGfLyS3pj8gYAElq7c4gWaQFDxq4bjnv7ic5HVXcSz7a1H63EhBOjF3a4Jj9yEvYwnGhzng== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR11MB6025 X-Proofpoint-GUID: 2Rb3cs8tQPYnRWFhRnfCBnhdluKZDKDa X-Proofpoint-ORIG-GUID: 2Rb3cs8tQPYnRWFhRnfCBnhdluKZDKDa X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-30_09,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxscore=0 lowpriorityscore=0 suspectscore=0 phishscore=0 impostorscore=0 adultscore=0 malwarescore=0 clxscore=1015 mlxlogscore=999 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301300094 Received-SPF: pass client-ip=205.220.178.238; envelope-from=prvs=13943e2a21=bin.meng@windriver.com; helo=mx0b-0064b401.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+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 def85a57fa..2497a06f43 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -39,6 +39,11 @@ #include "qemu/xxhash.h" #include +#ifdef CONFIG_WIN32 +#define UTIME_NOW ((1l << 30) - 1l) +#define UTIME_OMIT ((1l << 30) - 2l) +#endif + int open_fd_hw; int total_open_fd; static int open_fd_rc; @@ -132,13 +137,17 @@ static int dotl_to_open_flags(int flags) DotlOpenflagMap dotl_oflag_map[] = { { P9_DOTL_CREATE, O_CREAT }, { P9_DOTL_EXCL, O_EXCL }, +#ifndef CONFIG_WIN32 { P9_DOTL_NOCTTY , O_NOCTTY }, +#endif { P9_DOTL_TRUNC, O_TRUNC }, { P9_DOTL_APPEND, O_APPEND }, +#ifndef CONFIG_WIN32 { P9_DOTL_NONBLOCK, O_NONBLOCK } , { P9_DOTL_DSYNC, O_DSYNC }, { P9_DOTL_FASYNC, FASYNC }, -#ifndef CONFIG_DARWIN +#endif +#if !defined(CONFIG_DARWIN) && !defined(CONFIG_WIN32) { P9_DOTL_NOATIME, O_NOATIME }, /* * On Darwin, we could map to F_NOCACHE, which is @@ -151,8 +160,10 @@ static int dotl_to_open_flags(int flags) #endif { P9_DOTL_LARGEFILE, O_LARGEFILE }, { P9_DOTL_DIRECTORY, O_DIRECTORY }, +#ifndef CONFIG_WIN32 { P9_DOTL_NOFOLLOW, O_NOFOLLOW }, { P9_DOTL_SYNC, O_SYNC }, +#endif }; for (i = 0; i < ARRAY_SIZE(dotl_oflag_map); i++) { @@ -179,8 +190,11 @@ static int get_dotl_openflags(V9fsState *s, int oflags) * Filter the client open flags */ flags = dotl_to_open_flags(oflags); - flags &= ~(O_NOCTTY | O_ASYNC | O_CREAT); -#ifndef CONFIG_DARWIN + flags &= ~(O_CREAT); +#ifndef CONFIG_WIN32 + flags &= ~(O_NOCTTY | O_ASYNC); +#endif +#if !defined(CONFIG_DARWIN) && !defined(CONFIG_WIN32) /* * Ignore direct disk access hint until the server supports it. */ @@ -1117,12 +1131,14 @@ static mode_t v9mode_to_mode(uint32_t mode, V9fsString *extension) if (mode & P9_STAT_MODE_SYMLINK) { ret |= S_IFLNK; } +#ifndef CONFIG_WIN32 if (mode & P9_STAT_MODE_SOCKET) { ret |= S_IFSOCK; } if (mode & P9_STAT_MODE_NAMED_PIPE) { ret |= S_IFIFO; } +#endif if (mode & P9_STAT_MODE_DEVICE) { if (extension->size && extension->data[0] == 'c') { ret |= S_IFCHR; @@ -1203,6 +1219,7 @@ static uint32_t stat_to_v9mode(const struct stat *stbuf) mode |= P9_STAT_MODE_SYMLINK; } +#ifndef CONFIG_WIN32 if (S_ISSOCK(stbuf->st_mode)) { mode |= P9_STAT_MODE_SOCKET; } @@ -1210,6 +1227,7 @@ static uint32_t stat_to_v9mode(const struct stat *stbuf) if (S_ISFIFO(stbuf->st_mode)) { mode |= P9_STAT_MODE_NAMED_PIPE; } +#endif if (S_ISBLK(stbuf->st_mode) || S_ISCHR(stbuf->st_mode)) { mode |= P9_STAT_MODE_DEVICE; @@ -1369,7 +1387,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; @@ -2492,6 +2511,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 @@ -2553,10 +2573,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); @@ -2912,8 +2935,12 @@ static void coroutine_fn v9fs_create(void *opaque) v9fs_path_copy(&fidp->path, &path); v9fs_path_unlock(s); } else if (perm & P9_STAT_MODE_SOCKET) { +#ifndef CONFIG_WIN32 err = v9fs_co_mknod(pdu, fidp, &name, fidp->uid, -1, 0, S_IFSOCK | (perm & 0777), &stbuf); +#else + err = -ENOTSUP; +#endif if (err < 0) { goto out; } @@ -3983,7 +4010,7 @@ out_nofid: #if defined(CONFIG_LINUX) /* Currently, only Linux has XATTR_SIZE_MAX */ #define P9_XATTR_SIZE_MAX XATTR_SIZE_MAX -#elif defined(CONFIG_DARWIN) +#elif defined(CONFIG_DARWIN) || defined(CONFIG_WIN32) /* * Darwin doesn't seem to define a maximum xattr size in its user * space header, so manually configure it across platforms as 64k. @@ -4000,6 +4027,8 @@ out_nofid: static void coroutine_fn v9fs_xattrcreate(void *opaque) { + V9fsPDU *pdu = opaque; +#ifndef CONFIG_WIN32 int flags, rflags = 0; int32_t fid; uint64_t size; @@ -4008,7 +4037,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); @@ -4061,6 +4089,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 Jan 30 09:51:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13120827 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 4BC4FC54EAA for ; Mon, 30 Jan 2023 09:54:22 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMQqK-000314-TT; Mon, 30 Jan 2023 04:52:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMQqJ-0002zo-BS for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:52:51 -0500 Received: from mx0a-0064b401.pphosted.com ([205.220.166.238]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMQqH-00021P-NJ for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:52:51 -0500 Received: from pps.filterd (m0250809.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30U99Kg7008133; Mon, 30 Jan 2023 01:52:44 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=4A1e6sHVcoUouSxEStJohMBnC1urIIH6KVBurlDY0lw=; b=ffM7GSXkQij7+jZkwhSw+DpgeEjxnP8QlApBMRkETptrCTag0F/SvrpBI+n8fsZYX/Bi Nm9WcF1vsdvFgoR+nmD4oqhedEMVnL/Ns7eUB0NEwQMPIT0K98XJAvo4Enueu9Hi0v1w cAk1Cq/9HrTSfHv5JKqLaZRkluYcnAEsbjbHwoa8yXH2rSBNWQKuS47sWtRa8MLVaK2W e+kYW0TOndB49r1Y5xoWZs97Dmtwmz1ayQI+woBhS9xiP3ZEO8tEp42XTAnvVvZEG4xX 78F3LdmUEzKXZ3O3CaWUOaC4wLq0t7G7/3+AvaYc6sD3GV5EAU9FyDfSreTRKg5nQZjh QA== Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2171.outbound.protection.outlook.com [104.47.56.171]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3nd43rhj5t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Jan 2023 01:52:44 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h26c3vAFm3TLEcVKMw6PRT683hew7M7Dn5sYRvdT1w55BGfn58AVbXpOGhFwBbY7/NHB/lqhOJkRk2rvIR//Y5Q9byOf9UZixCvS57RYrFjyUciyu8NxzmQreT7BvRoIlX1Kw/3L9WrYgwuT5agF9Ljs/Q9Du/pK90nrbpuwEzLE6V1UoBsfVdziNnAcH0TzUNUNqFJlIAvtLsA0BgaABdEziZiu4KfjRW7mr/IrfkAHxPJsG36Sa67lfSDsDzc/c0CW4kcqCLCWf550HU8KvMUi4sA9J04jgxqli4ft0ibpe+bLwqrH7xF+bCrSEJc3pP+K11m8CgrrtMKMqz0rHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4A1e6sHVcoUouSxEStJohMBnC1urIIH6KVBurlDY0lw=; b=Y93lxhrTHMHxDJvpSspVPcV6+ftaJVrEjWm5y5YTMvkYoUS19V0KF4dII6UoiHAPEUqGuL0qSX0iZTelc4sPy90jczbkygJrJk+atJd0mUX77N86dLVc/vddRVOSx0Ugf4OqBSDLBYl7B9ruXClK3ShVVMKf1ujf9LMJ68prBe7Yul8DAk+ApPpYvemMCkZo9t1bbZRnxBQKXdILtOMJe0yAfKCuNfezRrx1t+xnYqEzvVXcvuXS7/zCh5I5+uLIJuRBJnGCorQBNuhNCBfoauzUSUWXTOT8Q/fwamfcHEAUV1joBy+JTXw7uY24DYRAA8BL2oAH/xDMzStvrby5eg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by SJ0PR11MB4992.namprd11.prod.outlook.com (2603:10b6:a03:2d4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36; Mon, 30 Jan 2023 09:52:40 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9%2]) with mapi id 15.20.6043.036; Mon, 30 Jan 2023 09:52:40 +0000 From: Bin Meng To: Greg Kurz , Christian Schoenebeck , qemu-devel@nongnu.org Cc: Guohuai Shi Subject: [PATCH v4 10/16] hw/9pfs: Update v9fs_set_fd_limit() for Windows Date: Mon, 30 Jan 2023 17:51:56 +0800 Message-Id: <20230130095202.2773186-11-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230130095202.2773186-1-bin.meng@windriver.com> References: <20230130095202.2773186-1-bin.meng@windriver.com> X-ClientProxiedBy: BYAPR02CA0061.namprd02.prod.outlook.com (2603:10b6:a03:54::38) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|SJ0PR11MB4992:EE_ X-MS-Office365-Filtering-Correlation-Id: 18824923-328f-4ddf-b850-08db02a7b993 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pcDQReDa8ocJvtKi4O0/kPALl15AxfFPQve7wAghu4NDp5QHpgLQBA734efl76nLYXr7Bts0E1VVqyOIkmj4EneeqFE7R1XKMYQ3ltTfi8iJPgnGuZsKMYSmqFneKbTj0MRU6m+LHRlOgiLmhUppQt0jP/g3R5w3VUS57+gk5U8AOMsAliCbCU6Cs1PYSRDJjpI8ny6cw1O8zlOruS2Yddty3V4gxb7GYFsVecrkTYEqTAjNJu9Sz+7fYVMenaMoIe1ZWRpVPq1cT3A7Ae/8whYiTVIGNLDqr1mE1LY5iCGgG5xFxK6X1YBRPQ0vFl4TJZsQZ3wXPPZ4LygdDQwkesmb4qul3GTKREBQYWsnx2OX3lhjUbJdLq4UQt36IVb6DfotBy6pO1dAn95Tod62o2D9ovvAxH/BcA38iCr0BGYCtn9ewCFh4Pv5swoGoOjByZbcWbLKvZnbSEj6OV+oLrJnPZ6R7VpROEg/3F0FPXdclPmUu5vNapkpZpXbsteBLUalUWlBDC48HKICkaJMiNBlQDadjc89SZHnTecXB7bKdPCZ0ZPhuy1dl2G+YgFV9GSOt1CGhGj3KZS94tP5n5nNCOPuFkO5fUWA5kC/OgdjQYHfiQH6Q47s70Y18k328Pc6Wyx9hISm4bHduIcdou69hDohx1JrsYqAcGxhSNSyG75wqmcfThjaKwCbWZkTIcmpBqxAJbcgZbje4PIN7A== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5358.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(4636009)(396003)(376002)(39850400004)(366004)(346002)(136003)(451199018)(2906002)(83380400001)(66556008)(41300700001)(8936002)(44832011)(6512007)(26005)(107886003)(6506007)(6666004)(1076003)(2616005)(186003)(5660300002)(86362001)(38100700002)(38350700002)(66476007)(4326008)(66946007)(316002)(478600001)(110136005)(8676002)(52116002)(36756003)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CjXESg/o2/N7SPEvzkmgrDBYIQM05+G6mEyXucHf972PpDwmpkUxtqfraJrn/93avBhEtUgZZpRIpUmMTqrucmxrUZuOQFvpPKzJ4PGVCnmNMy9rUIxRBRkpjAhoe800R1CQuff8jWIsWkl3YY7S5StCEKYg74YPncLTenTgpgz0GX8OpqzJc33pNoIc0Qts/G0OqUnKq9UWqtQ/IWi94YVUV7hlXYp4T2pX5aTRr0xPSl8HtZaGABOaUdphJ1gkTZDlvl1XWHlFthJMKJoaxV8aPyu0TpTPOrvwahVHaZW6nqpFQFrWrtzcbqelzoxhirEA3d8z6zT/WdkmS/Drk6HpQBob+3yIIv+SRyXa+dZK/WPEOyRzILad5ixLdh3IkRS29U8GBJAx8vs4jTBqw29yW8OcZLGEqSpFxIeG9GdamgE8J8r1BiCYnaQOWd/FO4ixDbTRLOMpzgP553cNpGEmS/1JadGLzgr7LG25xcxRW7c++iRV3ixML25DQBsggQBsfm4AYZIGXVTE2kyKLVmvtZYPTgTuk9WI48kBpJFfu0vemjYBIx4quAEV+lrFRKIY/lYKf3qpDt1Z3OnXEXZZaQzuerS2O7x8q27jeO5mT/78xPEglG+Etbmyp/3NGfng3nXCpFdP0t3cMUs12GLWKgVOAcG+uIYfSCoG99rYZJ1omQO88WQfB0LAbPO85iFg71GGhZY1LZ4kzmttc6pbtxj8ZvHJlfnzqPgoY5qPlObPUc1uUtSMtrw+5iDZWmR1OLMoG+GCMZOvkLzuedNBUnd7lg+841oAbS4UhCihtx58N39eCtcHT4SkDADmDP3aF54gVi5zua3WhN0/p7wF1aI3axUEShjT5qS/mzkav31n0hiQpQ2IjDszQ0ZTlketRf++C94yC0c/UuQ/iIBVYiB9C9PvK+MeTHOJkT6IABKFFqpomQoYf0BYW7+1VknTkftc4CYRKwCG6bO9MftY0IC3673RHKZuUre9yXvVuHOAXfF+dUMqxCKMWjqyC93Hl4KowCViU4Crxir0PAa0mcGRnQhuORsqbVIH9woARaYVUgFUDPGA56g7oSVWe2bPx3B5IhAsKvbBqbDYr2R/3g9kGeKoBqobLopa1mF1r0iX/5xgagpzCGMbAbGMOf6hDRuRaeVAkhK5F53U3n8AJxZKIMeLK1sL+/Q+SwL+xkYoSjdbLRLLkDuSGIStzQv4wrR15/ZlCpbrhp1jCSDk3CE8BP7fZMx02+2IiSNM/6rnIPjih/cX1U6lMzlVMfchxe9oqH58bQgcQflKANouBKY1vBEWkfXhU3Ykp5uLbx8kz5gsB7I5f/m5PSlYReQTnNSWe7Ze1ZbsVkmnfxmaR6FyYq3F+kuUtWyLdGREpNHJ7ZWPaYQDzhqiH0KMYa17/pVT1wD/GV5OIEvOI2209jEMqVvDVpNQhz3xdjXf53Ll8kDxxtZG0+u8eT+mnQSCWAWL1um4c0rpe7iWV3pqZuVgoRa/aV+SlB9HxmHxmoGD4j3Ei/5UJdLB9haHMxKYj9XeFFkT6bzISPW2c7112os2E9nwuk95KQG/Do04TBMmdHeQqOpdgvpky2xy9b/r54P+b/orHHOUiYnLoA== X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 18824923-328f-4ddf-b850-08db02a7b993 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2023 09:52:40.2284 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: j0COJKFxAY3MkCFAOcmjle0ACpNeDN2msj5xhoeZwUsdpnxuZzHAn3ZX/6zxk4FMl+091QgqVCl1Gs7heG2U8Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB4992 X-Proofpoint-ORIG-GUID: Kw1z-u4MwuW9zm6tn4mY74p5V3ChgZzZ X-Proofpoint-GUID: Kw1z-u4MwuW9zm6tn4mY74p5V3ChgZzZ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-30_09,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxscore=0 suspectscore=0 clxscore=1015 malwarescore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 bulkscore=0 spamscore=0 mlxlogscore=995 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301300094 Received-SPF: pass client-ip=205.220.166.238; envelope-from=prvs=13943e2a21=bin.meng@windriver.com; helo=mx0a-0064b401.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+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 2497a06f43..b55d0bc400 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -4396,11 +4396,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 Jan 30 09:51:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13120832 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 A2F0FC54EED for ; Mon, 30 Jan 2023 09:54:44 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMQqT-00038t-Dl; Mon, 30 Jan 2023 04:53:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMQqR-000388-H7 for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:52:59 -0500 Received: from mx0b-0064b401.pphosted.com ([205.220.178.238]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMQqP-00023T-BA for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:52:59 -0500 Received: from pps.filterd (m0250812.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30U8OtRH025559; Mon, 30 Jan 2023 09:52:46 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=iDJXqj4XOxb/nnwKqkF3Hh2hAAii9wCHHUvqDsYvMv8=; b=PopFLyGiJl+77ex8Eo4MkYql5nV8S/BI9G75TjiP7Xk1N+xdZ31UvbXtsAwXCP/ii92T xpa3XFC+L8ZORiQnyVqZTb2iQfC8Df5Y/ecmYoc1DIIkIBxWif5eWRICoB9VUHH7OHUF R1F9tH3//4i/nskt7vomNwMsaDqzz1bZccaWL6KRHMIEPLT2ASyDHXHsLFBg8mska/Ms 9MxiEcAN+TzP9jNHY7Jgjqs8AIvc5mU0D0NygmbjLBROZ3y3USD03oIMQ2LMZyyccDkV /X446n3H6t72aXvUiUqQnc6an/Xb6ljblprlwbTrSNGJMtbCcMVSor57IISQ6TLAfmX3 +w== Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2042.outbound.protection.outlook.com [104.47.66.42]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3nctpat10m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Jan 2023 09:52:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BCYWGZOcUgp5y2noO7P9LBwPshn+Tbr+KdESo3xoQQyBM4uZGNWJmT+pKAg4izSp7W22aSOvSB/+FlJ3MMOi5oLe5HLOzq/FNzXH+YPnxh6JtIjWC/PJVKOjvB2q9AH0hRvYAjjW6/JcCyo0OpGxMJohgQZuRe95b1JHip1XZ3hX6iJWuT0HkSC24k8AEann/xAkSGrLrN74w7pWgUSM6uag/qwhAn4Rp1Ru545+06bjh1n7J8cTgR2/WAyMTtGQeli11Y3ge01AbDb0m2eXP/IEwDkoTZem7eNYus0+6Gdw+hWuICD3zUFMt9XfAuOuMGPVmi9df0/upFQZJrQfrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=iDJXqj4XOxb/nnwKqkF3Hh2hAAii9wCHHUvqDsYvMv8=; b=dr9TF6frCexJ5u8GSEnSl0IqbQnwh71MAtAiMVQrCGyJc2lQLnpFzAYBiLslAQkktV9IDxqjL47qD68kr72QxEp+J4S+9LQU5eYh96uPw4uQmEC99fcxbmOMN3ilkld3W72B6GHd1BdhPOfpTYpoBjJm0lH0Wx62BPt4BkPAETNvKmyXqSapQ0Zex9TIiaKVH4rjw85kBqQrujGcba9R2nV2ozfrvgruoxam8pgfCEzacuSdO3dTawo+YDRpv07rLQBKRsdIXqG8YBnxf8MWsxrHN2I1Xdjaq6dpIRqOHJDLUcqYt3zNnb5uwHh5qBTRJJgLQGBU2jstYt7Usjtprg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by SJ0PR11MB4992.namprd11.prod.outlook.com (2603:10b6:a03:2d4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36; Mon, 30 Jan 2023 09:52:42 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9%2]) with mapi id 15.20.6043.036; Mon, 30 Jan 2023 09:52:42 +0000 From: Bin Meng To: Greg Kurz , Christian Schoenebeck , qemu-devel@nongnu.org Cc: Guohuai Shi Subject: [PATCH v4 11/16] hw/9pfs: Add Linux error number definition Date: Mon, 30 Jan 2023 17:51:57 +0800 Message-Id: <20230130095202.2773186-12-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230130095202.2773186-1-bin.meng@windriver.com> References: <20230130095202.2773186-1-bin.meng@windriver.com> X-ClientProxiedBy: BYAPR02CA0061.namprd02.prod.outlook.com (2603:10b6:a03:54::38) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|SJ0PR11MB4992:EE_ X-MS-Office365-Filtering-Correlation-Id: 01ccb3b3-6f05-408f-781e-08db02a7bada X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GTi5w1H2QZHAt6QDRk1gDjUESgQEkeezFIqkeBvLijIVNsMNBuiV2h4z9yrHA8Ap657D5FLAr4NGvJv0udHqkixkFuipeZDjpqn/v+sRqoy1wE3/pzecC4ngL8aifkm6YE8uHUQBcmjisghvpedcPEUmsuXERTKKUnLfBjrtxaUtbwORd5ILEGjbB61FpD2KWaOrGBjRgQuwodnRUhHXkm5dPUn0ZBkpPQn8qbYSheMsUrRFlicSszt38T4i4kiMX2ryBOtZ75RN9TJh6ybZR5ymadmDIL225k85dwFFsAM2olxsI3IRc07IYOnV1W6NJVi1sNHijuktjm2LaD57wDIMjgWz2jrhcVhaP9zYknKlfyYol9vdjxHOhX90ASh8Uaswi71vnsZnKT+IVazkp/gAC7X9mxsOIIcO2+W0Z4SKTgs72m2I+B+Kmu8nNhsNSyfqaxIL7Ua9Fy4qVwodW/uoG69XUWB71WFf3RYy8zLQbOsYgIKMQR/4baXvSvkOJqnO1e5J7gStNQhNLGFywfvjRZPeoC7sNTtM3kqlD7949Gudn5X3K/PXB26R5+7kY1naI3a9S8sTz4QychX0ktFtEb4KJJy+RRF00lYZR4q05H7YpMQtz65q3EDNVgqyYU2Zu3JfNBlLFWcStLzytSasN6d3PHyXhkkkbHAOZOQkAx5V0Gmg82yFmYw+b9uu X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5358.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(4636009)(396003)(376002)(39850400004)(366004)(346002)(136003)(451199018)(2906002)(83380400001)(66556008)(41300700001)(8936002)(44832011)(6512007)(26005)(107886003)(6506007)(6666004)(1076003)(2616005)(186003)(5660300002)(86362001)(38100700002)(38350700002)(66476007)(4326008)(66946007)(316002)(478600001)(110136005)(8676002)(52116002)(36756003)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Db0Z0Hur6iknY6ja4hM9Fjb4WgXAhlFr+3kGqEBlVAm951kBRJeYfPWca7yMF99kTxePpEY6bB5OYMsWVvNGbwZfAVEL+Cv8eoGywVsmzMkIaiYAY53WTWqrTSA6/nyMf4TjRiHeG1zvGAn0rqsCuQjirfHyI3AzpUPqXiia9txMVq7QXY7+ahlbp3oW66ZkAesy3ip2MWC/1e+J+KcPkhf+OaABgvaicP2uv0xC9sssHpzPsvo2WpGpdEEEKkiZCLdd6WLOi+au25UKTXOOEoJXQjb+lSHA6My5K47hgtF+UwMWqqhNwMuDwOFqWDn76llUo8PHW64lCpbogqqWaUlmQSTFh+nWKvXM2MkHZQhkrDyxFuEOhjGo5RtGova+ZIB3B63FY/Qxoq6iak8GtxIeCpTk6d6KssyPWwVNjkOZKYlgAflBgUqXGgKESb/LA1m7ceAyqaff+9zzt13zzkCehk+CV3+7OBtDkNds8cTuf5NURJ0fO4Fnli8UWpuTK/edT7VVJyeNnsO39xpb2Y9krndkiZ2bk5U18PnOrmbke9aky1kKXOaWj8JKMhB2RVqbwBd8Fb2+jGpOphBhKSNoofcG+5A2gtF0StM80Mn2Qe0d3x3tLJpSyM2qWHtQuhe24DIDWJfI/b9t7jE7EN/5b2MQR1Z9xEKy4QrQuWRGmZU4XISbnwnI5DzExRVfhhTjsNgUopXEpgDUObnKCbKFq/7/W7ln082BQHXMk07c5SdfiEj6NpwiA7gf2bTqN+741BJrJVuk/iW3/JtB4ONqSQNSglYsiMlO/8uhTVg4AMmeRQUjzk7+vZS07aYzriDwZapeakCxElI2Xf3eBYoRrJBT5QnbBae1KFI8JxMoITfbkpOkWzdCX04U44FLuRt6YWkINuiuUOirg6NrGqr7JHNE92ESQtcRKXbUpnCzmqLbuO4pALvDyM5qWEEG4031bv74bjzYnYUqm1fxmQrYwUZILw06+XrVuetaHHyHHACYF/1NrBLf7r8uBPRhGPGkjJxvdFgyZU9nEk2KlcQJD6x3SMxUAQX2uqMXS+zfcEtPE1k3QLbPj5O8DOQ7+gNLCSLPTPI3R+nLO56zWRBKXFSQ+Sp72fGWIVk6cBpF+x7tZ2BP5YUJHFjn+tm7Wmj2sk1g+QNXGdS5kUYMUYabcjDtaVRT8peiTZ9czLMDvcumJuUPejNfbICKZl+DrvsNT4sAgTsiVtzH8jG6X97xvgoxCBfkDKFWAkuTuulRNU4c2Oc7qFWM9IzylnyL26DUvdXs1PzGK9lIcVAFqzVrKCFGRATBTc2Kb0Aqum5pcoeL8WTwqhn0vVZhZxIxWBE+YXer0KmrXXyZ1vIRrrXGROgPiS/BR9rMnWO3kKLLtCkMt51jEurMIQImHAoCco851bMOOoQj3WeSobehGYfDmQvIJngx407T0ovb32rnLUoNMKN9Y50FoYCfIlCYjGCv8aSAjzG6wpIaynTVbIpFYTvGFhM1k3UJZBaa8YnT6bA7LbR/b6EWmDloe6R683RO1M3wZoISYb4bGQpymgcl+XIuNGLQy/TJOdUYaJvjny6jt/3qefBC2u2kodFyIpdgJ0jhql+qwJSSnRhnOQ== X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 01ccb3b3-6f05-408f-781e-08db02a7bada X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2023 09:52:42.4324 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: NQINPiZkAObLNWwsGZ7tkxyY9qa3vG8LiCkQPh88fCV8xyx1n1kv3cT3nty0y1mHoe4avD7pX+mwg5KubHWvqA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB4992 X-Proofpoint-GUID: wLtP4AkZhmDrQidncmJdTN4u2K3MPmjV X-Proofpoint-ORIG-GUID: wLtP4AkZhmDrQidncmJdTN4u2K3MPmjV X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-30_09,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 spamscore=0 impostorscore=0 malwarescore=0 bulkscore=0 lowpriorityscore=0 suspectscore=0 priorityscore=1501 mlxscore=0 clxscore=1015 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301300094 Received-SPF: pass client-ip=205.220.178.238; envelope-from=prvs=13943e2a21=bin.meng@windriver.com; helo=mx0b-0064b401.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+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 Jan 30 09:51:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13120825 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 909E8C61DA4 for ; Mon, 30 Jan 2023 09:54:14 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMQqa-0003Aq-Em; Mon, 30 Jan 2023 04:53:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMQqT-00038y-Ob for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:53:01 -0500 Received: from mx0a-0064b401.pphosted.com ([205.220.166.238]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMQqR-00023g-VE for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:53:01 -0500 Received: from pps.filterd (m0250810.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30U9iKOg022663; Mon, 30 Jan 2023 01:52:46 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=qVi+cX+axJVFtj52FK6mlqj5ScHeG3UF/5wRyJEMVdk=; b=NVVaY7UX7Lg5+lL/ksQ5PGH+GmjkA4fL9VBmxIl92vRrSds9OIpQ2YYc6M0t7JWb5KjF NIxZVAap5FOcRKWOozxa3sIa4tCJ+6uBkD1jXSXffikjr1l938tUfe/TvXJ6qIH7pL3j 7VPvYu2EoD++gP+JWBQe17uxfQyhDp5U1QLe7Ges+wozR5yJuahF0VXEReutBccDxKUS PsT0k9psP3QsPbo/a0d8Zs9BvBkLehtCPUxid2hxf58+CPBISt66hjvBcNLxiSBEtZwV PWLs39PKohsDo0S1Z6SSp24njuhd55hJnAvbj16NiuJ0lELk0ksI6R6/eKmvBDQSFaUi Rg== Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2175.outbound.protection.outlook.com [104.47.57.175]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3ncyv89rk4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Jan 2023 01:52:46 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ffy02g6IiBzAZWb0sl26iEbFXqKlkC0dYnTz02DRbVOYp9yH3yNVoSOst/bACUneKZCdpUTNZqLGE+FQsyd2wgqK8dg0nt+E9mwvIq/to5mXBLMW1atijygSjdXv4XrUZP7d/WeBWTwV9aLTLr1obEqCGjLJMTpQLqtyzbkiCF/u52OxIi4ubkYFQ+IZTiO6tJvl8O0SPix2IxFqx7I2vUB5BjcrkKs89h97eQy9K1RuQYU0UqJf0XEUW6btI2/PkALq+KMx4HR4kjLhmZaoZEV+2UX0DrY6Co92PVeWQa1Dl1Wl4mJewbyIek3fov3ZLr5NvZDjpMmoPlWKmryF3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qVi+cX+axJVFtj52FK6mlqj5ScHeG3UF/5wRyJEMVdk=; b=aGyABp3GKPwIO0+DKxzAzvpBA9kE6lha9WYskCHy4h22ilmnly5tdQWI5/CPP2BSb1E2jCxsZmEu34KKC3zZaY9rZJiBstkKznDtiXZ/nAUDN64gL9H6pAm0SKV7W8q96G2uj9WBCCXj256u0we4jT1paAZIshbHBqO8kMcMKFxFnw9uz6xK2fysKcmJ4n+zgDvASDtEARPCfpkG76q4z53LTLy9WcAFFnPkg8GLTUVX+IFfN0ZsHV05kWpfMZgq7bINbND6N8Tn/TAPcy553pQ4J3I0K3BswPwvY8otVq10aWjh9Jm6waQ/+duPGH34Sj5kwg8fFw0D/tQkG03AlQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by BL1PR11MB6025.namprd11.prod.outlook.com (2603:10b6:208:390::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36; Mon, 30 Jan 2023 09:52:44 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9%2]) with mapi id 15.20.6043.036; Mon, 30 Jan 2023 09:52:44 +0000 From: Bin Meng To: Greg Kurz , Christian Schoenebeck , qemu-devel@nongnu.org Cc: Guohuai Shi Subject: [PATCH v4 12/16] hw/9pfs: Translate Windows errno to Linux value Date: Mon, 30 Jan 2023 17:51:58 +0800 Message-Id: <20230130095202.2773186-13-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230130095202.2773186-1-bin.meng@windriver.com> References: <20230130095202.2773186-1-bin.meng@windriver.com> X-ClientProxiedBy: BYAPR02CA0061.namprd02.prod.outlook.com (2603:10b6:a03:54::38) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|BL1PR11MB6025:EE_ X-MS-Office365-Filtering-Correlation-Id: 5d401cbd-bd08-493f-988f-08db02a7bc12 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HppBHrh+3q2md8KWg8P/PFDei1nrD2co3gQHIV0yQ7cNbLJi1yk3V47m25soc0YGHKUhwRtmg3n9XEKqxDM9OtIlg6R5jrlh/fQ0gh8Kl52c0CIRYxwRV6wEUFmwKd+09siTSysXsD2bp8yHTlEO+kZ9vKOWysFO5J62f+DOSc3J46fvgZRXeI3IDcyWpgbBKfIP0yp5NQg24jb9TZxsnlKan0mGf+KNc4YulT47SI9G4RqpL36vV2vZyj+zBG2Py0gTQyEGjI4rpcW27+xLd+7dXjQBf+2oZl9YWEWEQTUe79qq8IqAM92grUhFtZsF8xIoVu0f2F1izZUqxo7KNrIkWDQ6wvirObQY68Bmp2nmmSdQMtsmvNtpgVzBEnSkYn8n08+JIia5qVT3DZiKuNYRz6f4wLcACQI4IvbklX6rct78ShYOt+khyWViJC6LqFRzxbwtrf7J9pAiKvFvl/nQPnnPJg55mboMqYVosYnzZDKK/wlF6HZINcKnbpg57i/gSXuDFBIrZzR5NrYeurQtk+LzqMhCVslpFzTLcGTjfoUH5nGrr9sl2DwWE6CFLdBUyQq9jj9D5SlXqWS4GZSHz+6Ynk864bZ4E0qOk34dLDGW4FMw3KeRght6WlJgsk4xiiCzW/YhqrBsokVA2GPxo2NRzC1dPxwi3GtCzHxgaacODF4VOOwQjh+ZTNkAHpcdXYHD8sUcj5rJ9Vk95A== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5358.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(4636009)(396003)(136003)(346002)(366004)(376002)(39850400004)(451199018)(2906002)(26005)(6512007)(186003)(478600001)(6666004)(107886003)(6486002)(316002)(110136005)(36756003)(86362001)(38100700002)(38350700002)(41300700001)(8936002)(2616005)(4326008)(66556008)(66476007)(66946007)(8676002)(52116002)(6506007)(1076003)(5660300002)(44832011)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dd/zWTJ2cR6FoRHgE2lf1ZJRo0zru8qldrez1o34Z8VLQcOhdmfHMX1ZXSyc3EVcWhk3+CqCM9qnR2IASoKyxRMJkwFBiIga1lH4dH0/ag1qeoIo5Apzj3LPDksdvS1+X99aP6o6w4A8wwluL6wuXKGx5tnr8FWvYKnD+fStZ/42r4axPIvTDGpmeGByGLcbhpURlVUe4tWJq1F+2FYMeqQfoVVVP1DM3CxqFIAt9Aqb5X3JBxknGHbFzOJ/QcbkhhJMH6sixd3VRQH4MUrJbMixwB1o2wLERT96kP20AGNqatQT3vUUAlIzg6YgypRhatUMjcMJ+BsoqXY8xRFjVhpDJFDvAoou/gYB65IaiLBsOE4wNRpKAQhK11QuPo/s9yHcDhaCNa9aSoVYSOfLNO1xmJynY1DE7MjAv2daRGB429xv4nS723y2YyYlu37EY1BzzCuqofLOy+sLx8RQkdVlX8I/enOioI9KO0qR/3vBLztsXmVo4D4jVGaz2+oTyWmPbJpoQZvn0VohI//C8v9XtwTSJDkr6PXiPQpEIXMujfnDzPAsNEYos41GS85RtFwuDJ8MKAWSPUM/gJEid1aO4TY8+Dn4Zb3ntyKpKNQSttkErZ3TWmXMX++R815TqOH0SZ5liKeyJyqi6SJSHoNtEXe3f6qdOG+GoHk19C8d8OfYPj1AdQ/4Q34XChR/zieFf4eiDB/0fGlPcuPdmeAsxf9oS18gP2oujBcon1PM4uyf2tI2KKzbuyiPdM4rsrV+8IGzqrgLy/tAjrmTUKHSrtt2MxIsQbkJbJWU/dd9AlwBTCwE+HMjTEHy/Ebsh0EfRzKMAHtKR+cHv4bFhSg2vpTxpSuvQD6V+AwZaV8PPPs7JLZh9grgyLCS5Mq89SvKUzTJS0dP3L5glLy6CwfRE1DkSKnSFWka7ZOoK+z5CXImiuQgfyZU9kjkREykTzrO3pq3AaqSVePNsbdrxcE+tHhkeagGrugp+ydzrI78Vr/FTh31a39xLjiyb4HP8kWmXLbtNQWmST+NKr9FQFWUNUfi9uck+jATTeB+wujYlGE5wUWyooUdgY2Drc3HZ60rLu3hqTHC9POfajn5rg8/SzGNSuuk1Pe/yCkehyz1JJPQKPMK+LeMQBwo8XwMocOa9yJF6oDcdupFYCaERlc3jdWaDa5TaOAGi7Bcpir2GsVG3LASHVtHr0mppR5KYELuFAnSzWCsakF/GHONEPEUZK4KR4mECryiBTiZvR7l85HYrQOfZoqKFdWxUeCODtggllDziPeHk2uMo7Yk2Q7KLssNSHVMOmo5TiRjxmtpMlmw901WltI2agrhgBOh3CD5OZnrHJ/qPBvM5XCLezInmcYAMWNjJ51bcoaunHJnoh+6XRfivlfZUv+noPLmZ9iPnjV8eewUrU6zNbTotMbX7vNbGjsCKFYv+5lTxCfIW1QW699yNNCY2Olpmthaz4w4SZBFu+Wk9tYjWtZNza2lDGnaJPOXV7VaXXi+GLofOX/+qDATzUsVSjl9oSU4fHna6ApYTYy2EwrES1aAk2D2MWGJjKTFooGIPE5oGOVHzP+jh19vO0ATR54oToFchjI9pZnsE6T4+8rGxPAlUg== X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5d401cbd-bd08-493f-988f-08db02a7bc12 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2023 09:52:44.4311 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: YD8jUiEDo2GT4C08ayD2fm2R7h7SUwapEoJeqzEoZAw+0BYTyVhnnYR0pHxULRYdnHPZRhXTZtQeICcNgvGzbA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR11MB6025 X-Proofpoint-GUID: vagcdxnEzmk3WoqgBlHKdH6dZohn2hGU X-Proofpoint-ORIG-GUID: vagcdxnEzmk3WoqgBlHKdH6dZohn2hGU X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-30_09,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 impostorscore=0 priorityscore=1501 suspectscore=0 spamscore=0 lowpriorityscore=0 adultscore=0 clxscore=1015 mlxscore=0 malwarescore=0 phishscore=0 mlxlogscore=703 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301300094 Received-SPF: pass client-ip=205.220.166.238; envelope-from=prvs=13943e2a21=bin.meng@windriver.com; helo=mx0a-0064b401.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+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 Jan 30 09:51:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13120821 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 1EDE3C54EAA for ; Mon, 30 Jan 2023 09:53:39 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMQqY-0003AO-J0; Mon, 30 Jan 2023 04:53:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMQqS-00038Y-Gk for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:53:00 -0500 Received: from mx0b-0064b401.pphosted.com ([205.220.178.238]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMQqQ-00023Z-T5 for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:53:00 -0500 Received: from pps.filterd (m0250812.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30U8cKgI019681; Mon, 30 Jan 2023 09:52:48 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=sdc1sBW+ClvCoAfMr2NakYHq4WgtRTi5ldHN/9cqbdI=; b=XOjh3n4GijSSrXa00liZuIqlauSCygfCNpUC6ohPcvf94ckp3r204lGci5/plEXNgsyX cUdAUiHCiu6QcOp5PNyyqoWz6I5Ze0pR8qrVMt9Ew9jilRJTcnx7Wf6RwlfyfkcDsY0T TIYAQNUYVsNav4p1RWeQJzPwgibH/EKOtpBeIhSy/MfLNnDXj3sb8YA/YAQuOgJNdKUF CdWwojBxRH56vtdjAoNUVLJdPBa/l5e9KmGuCLnTONwlPAghYjXSdSZyQ034ZcevY2nL CEZ/xLk9oYn2vhAh6PhjRL9Blzjuk+W12mRf/L3rYhMRIycEM+D+r0jSZlNUJXXdUzzP kA== Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2042.outbound.protection.outlook.com [104.47.66.42]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3nctpat10p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Jan 2023 09:52:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B1Zsrd1Aqv4zo7buhzlhzFo574A4T+lYBBHsDmvL+bMrf393AD231tKaKnYxYSthLHqajbN6aqOpEZrs4OI3r8RmfNEyBxJzlIaFUHPd+N9UjvxKrlKuJwr5SzMQ+1N4HsQ1HxXJlz48AObRCkClapW7x268Io593b/sbp1qbu/A6PjWYbwM6IGrn9/HQ+Ec6QlqC3Q6RpjICmdaejhWdAeFBUzT7GajUU4iCuXW5oh3yMxMVvMPK8sPSjaosf2tKmvFcmXK+l5mZV5kxo9fMbO5ytBRrRGxtoO055a6g4MUmkt+fWYYvdrL8o+IuuW7Dh7HG08IUQjDMkzGjr07RA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sdc1sBW+ClvCoAfMr2NakYHq4WgtRTi5ldHN/9cqbdI=; b=fIEawzISyuVJjcBdD7Ap0gKG4W7X2KxrvqGpky8li5pG+n5ThVkZQSUOe9xy2uvGE6ulJ1GPVRvqVUK2GiQrweLxCYvw6IgSGnuQzCFiJz3E6G++C2zvL9+vcngXVTOuTPstgraXS/ZEnsv7frYQ4Y7ZYLKZjqLLyK7oN6upIQY7L+AAO3++eXNtTjgYZsvw9HlxNdqIpoSDyjEwCnRieMyDCLZ5MDjKgZQsRW1gEOTstZ/Mb1hyvfoQ2TVx06rx/O5qtrHExLYUB7RV4AKsq8RM+hC5Zvov3L3P0uLs1VnySOoOVFMt/qFcuZRupdcAzrg9yh/tTILuPVDrfXApMw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by SJ0PR11MB4992.namprd11.prod.outlook.com (2603:10b6:a03:2d4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36; Mon, 30 Jan 2023 09:52:46 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9%2]) with mapi id 15.20.6043.036; Mon, 30 Jan 2023 09:52:46 +0000 From: Bin Meng To: Greg Kurz , Christian Schoenebeck , qemu-devel@nongnu.org Cc: Guohuai Shi Subject: [PATCH v4 13/16] fsdev: Disable proxy fs driver on Windows Date: Mon, 30 Jan 2023 17:51:59 +0800 Message-Id: <20230130095202.2773186-14-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230130095202.2773186-1-bin.meng@windriver.com> References: <20230130095202.2773186-1-bin.meng@windriver.com> X-ClientProxiedBy: BYAPR02CA0061.namprd02.prod.outlook.com (2603:10b6:a03:54::38) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|SJ0PR11MB4992:EE_ X-MS-Office365-Filtering-Correlation-Id: a6b4ef69-037d-49dc-e28e-08db02a7bd48 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dshwUJpQ5GDPK8Bqx5rovjRXCb4qjwrXWqev94DuhUVlcXgyQSbhNlyugsgiSeSc78ndcrPM7uXxwbyG1wv0vo2a9VxC8qF3jZVvHr/wQU5dgeR2ucXiFNev2C6DipE8mOKn3/fp9Cfs1/ot/pQaZBENeglqvDN+oSx1RUyiE3xKLZCOsRkOM1FRZ0ICUkTPMVFJrZ7oAtMLOMtneOn3Xr/+Hoszcxc5MXVMgUNTBh/PBT52Q4ZXZ10Ic9gKBqNf0mgkZ2ZRDREdUPq/aAov2c22ShJN7BPuEHFYkyebKgM0wK3rdaeob1zb6lYMqwZnMTjQXPGVjzyC2DbDEmFNfBd1Pd8vtScqp5IhZqoIcoL+M7xMDiK6A1YPa/PFUP2GIWwyjOaRJZv9nifh/fPV9Tz6PpPl2Gx+D7NGW1F6TANqvC1sfKvhrbnZerYmjIC59dZ1I6IzvRWVWxoRpGiHQMZDK2yuWMuf0MEg6SX11ER8kBqpnZsQmEzzOiJcLQ1NAZl81Ndr1XNZPayKsGaqHwhR5/EiaWE/trecmUoKijYMfnZD6N04WDcmCqqn5UYndOFBwBvF2Bv9ryLc6KEPuUNIg2dN6hRdLFayfTj+J+ZWSweZgAk3eRcBavhEcub1DXOcNqC9E2JNFlUYuE96Nl/Zgy2Z55L+neQMce/SaunoVE4ADmKicLhgB/nD2yFmuli+rAvT3ontV/+24SPWOw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5358.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(4636009)(396003)(376002)(39850400004)(366004)(346002)(136003)(451199018)(2906002)(4744005)(83380400001)(66556008)(41300700001)(8936002)(44832011)(6512007)(26005)(107886003)(6506007)(6666004)(1076003)(2616005)(186003)(5660300002)(86362001)(38100700002)(38350700002)(66476007)(4326008)(66946007)(316002)(478600001)(110136005)(8676002)(52116002)(36756003)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CGheJ0td+CI/4BwwsruJh9xtqVKj44o1wCnDzLe1W4y1rmYldj1zqa4dOgH/yTyRMOUFNTlj46du4KQh2C4eqxPh9+Xx9tEaOdue36e6IMdmMWoG7yqloJU1/d7diDzImlsiEQCP2EcFWrtRcIPXKh9gk+YRkrYRBAG126EKt+7tateyajMHOUM9W+hUFCA/ek5yXSQWw7xGaB2ra4lpwSPpgJcgDBimpbJwSYpwDohN5MhUqOwXULLpU9W7lqAyHRHNdJLTrppXlv9FwGfoVMJymVjx35nIzlB/UPnucnkMi8yl5+axgxZqq2QAWXstpW9YpvowLgN3LFwFUVx64segaOE8zjmhmt/Y1KC/Okdm1ZENs4iWc4FF6XMj10HhWJ9i7lL7Jf5z2YRolLNbpLD6ZJJ++kDTQ2AF8v0r9vLEB0zuhSVBocAyen51GqilttAtGjhIYqzR+ejz/thKI1s0MeupYX6IWyoeriznW/4cpjsOmlPH2VU1g1Z/q58nO/hoxeXxfvnX5tEbSW4rYafkO9ivpvqn3x9ydMLrAE5/fgAXfrJlSJqUeR7tMEAFWegsizmCynz3gC1YDE/ymsfZ0w9Xu1F4A6nQlnbaC0yzGMo6EaF22nDngaXoJfzDOGIzBNoqmBlIfNwr8Pq9sQ3awXztC2ESBqEEYDAIV2u6Y+txRCdBY7STupq2lF//H3Z/8dlwbX1HM7+mHj6KkOM+tvmYzZR+bcuJr2A7fPHnY3uT9COM7MYXU6E+RL35qET1wb/SU2Bku5xvhyMJ3iIcUKRfSFpHS6Dk+Qx3OTZJQuRxjp+PoW1aOT/rGL+saeIfJB2yh70msuAv0ox/53rOmHFjkHzw8GFkVn9gxampy3GUpXkgrrdKQpVzeBUbq8lr0ljDLzyWEhiDDk6M2X6uCY2dq+QllB5XgLCyHECN340jPjhSWKooqbCDZy4mF0isNvtJ+Lo/uUy+/7jZNAmUiDOmHFxXEHMU81yZGM9Lql39Iww/AG/7f5SUkBr7efgcwGvVS4q7Fyc7ZBuk597LVpNPL34ljVWWY1yms/c1X5yuKk+IjaBa72XQ/1mUee5R+0CaKQuVTBbrBgqx3gP9kzYviaphxq+bkKDrzAt/Fj6zAyjAIqLWn4cffbZ2o8YtnR3Z1TrIyKnFG0WIXs3dGTXNyKYZ0NWvpJeWtaIV0v0lV82KNd2YADhoK/+hHLqA6mLmTzO/k2eVljwW9Lu6TXzixVKuXKPc+VPCW/W0F7QPboGbPhrv5NG1fyUPbrGJXTa6LgRTrOMzsGgQXn8M94xLns5YBIsAceZ7IN238gMQxyUGy0Tm4zfCB8K+BFXLpBo6atLjSJm5AwoW7MzG0GO34xgWbeVfrpjtDl76mpMfXrMvFnEF3PU0ObI4/LVpsXmtzx2bX2RUG+axygTu8hps0UIjSYhW9a0xf+6x7GjU1PYZGGMDfILG2cO4Nd+VFaQNBuR29F+RrhiH5d9oy31srC2eqaoH7+QCbD2LAyCc7cV/GFBAAL3vCdmDEek7mfSp6eOjkJ+ko3oIrO6C0CwK58al31/Ts8lcKhTdZyKpwt+M98e0m4HY0M/ZsowXa6LWE/XQVvglqouOWA== X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: a6b4ef69-037d-49dc-e28e-08db02a7bd48 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2023 09:52:46.4333 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: eu6azlQGqCRJYJmxMqGmQejVhRzA/BHFc2V/wGFFHXknh5Z8VzfIA1vkNe3az75TxO7RczvTW14RqxkMdwlQfQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB4992 X-Proofpoint-GUID: eojn1l51hplSqWfekzneQUg2RU84LIVL X-Proofpoint-ORIG-GUID: eojn1l51hplSqWfekzneQUg2RU84LIVL X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-30_09,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 spamscore=0 impostorscore=0 malwarescore=0 bulkscore=0 lowpriorityscore=0 suspectscore=0 priorityscore=1501 mlxscore=0 clxscore=1015 adultscore=0 mlxlogscore=738 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301300094 Received-SPF: pass client-ip=205.220.178.238; envelope-from=prvs=13943e2a21=bin.meng@windriver.com; helo=mx0b-0064b401.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+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 Jan 30 09:52:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13120823 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 8B027C636CC for ; Mon, 30 Jan 2023 09:54:03 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMQqt-0003DT-S8; Mon, 30 Jan 2023 04:53:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMQqX-0003AG-5z for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:53:05 -0500 Received: from mx0b-0064b401.pphosted.com ([205.220.178.238]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMQqV-00024E-Fy for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:53:04 -0500 Received: from pps.filterd (m0250812.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30U91W7r003981; Mon, 30 Jan 2023 09:52:52 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : content-transfer-encoding : mime-version; s=PPS06212021; bh=nuUMh1QaGvriG9gaT76BowvaIQgTa1Bz5THTubxNj78=; b=Vw+iOaTX40BquGg6OlC2P9mPRQRcXWksFiW7tgxXpriuQsgDUvqr/OGQAneIWG5b0dQn XUYNqPo2s9VYT98RLVU9c9O/P615dHUjqrFtPQIrbsXbOGzWeGuoh1bGaNYHgmc0WcaZ aEEpH9yJ5o6s9nxR+uPUFnAj/hc9XJnrQGXWcZCIP48+do337yBiXDkOHa/UC2MTpLBM q5BckCevpckD7zueaXBicupzg3qwB2b0aWM1Qasrsg4jfWp9Nz3Kh8VHZgCuvzdqtD39 rf9zjZAkQOBJE+1sp6+rmOCw1xXlwZox45U9Vn4VDk8jyI5hf1kScRswWOYZeEgnWauG 5w== Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2043.outbound.protection.outlook.com [104.47.66.43]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3nctpat10v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Jan 2023 09:52:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EwucTqDJ5qOpG1g9nWmQAv8pc7GBx6c1SedDZvWWpsGOwR/iNb4kCIhGzBKQFCZgGDNRYDrVfgJCU0b//HBJpxqeQjZBy61N09JeHzx8gQubsZRZmPZPaAGOaCtdfOatqaWrDk58tJBAD1AE57NZqECqQ3X91gO83W+slgbtDU3GcSD3byhr2KDrMnR3p/Srco6zwDgENUpk6CsMSNaP9ah0JCbwPSYuSpy4zJRFMekxm+FTbuAd06q8PC2F+rAbbqwPxD9AA83jEpghm0kg0GauSRtu6U3QTSmnTsoFCQcT34TKftH7zIW6dup3dMv67Dq7IPG5DaUNTTzlwFZcCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=nuUMh1QaGvriG9gaT76BowvaIQgTa1Bz5THTubxNj78=; b=GOj5s7DdlHHTlymZPT+Jn0PZELxn07bUZjF+Rxkbhq05bdbWuinOsqkLTYjHosVULN408fu1BFJ2vtSxCP1rQogIE8mQGw/uRzQ0jj0e8pOqxISjS2jlNgrd+3G2YDqHDQyyQT12ii5kYnlF0ZLf8G0dnS86XXH2+8ytMF3nQ38f81dNdfxlUdwar/yheD67fWNvdYSp0VpAHYM1aeJgRt005sYV0UANzOAD+bZLtdRrZp7hj0rlHrlwEyZVoAXzqvdxDGLWwM56LmDZNPEIAhwnx7cc46hOkUzc+pDP4LvGlO5N6J+2HlHpsYbU9HhtGZjbQCCKB9ItYAdikoXHnQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by SJ0PR11MB4992.namprd11.prod.outlook.com (2603:10b6:a03:2d4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36; Mon, 30 Jan 2023 09:52:50 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9%2]) with mapi id 15.20.6043.036; Mon, 30 Jan 2023 09:52:48 +0000 From: Bin Meng To: Greg Kurz , Christian Schoenebeck , qemu-devel@nongnu.org Cc: Guohuai Shi , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH v4 14/16] hw/9pfs: Update synth fs driver for Windows Date: Mon, 30 Jan 2023 17:52:00 +0800 Message-Id: <20230130095202.2773186-15-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230130095202.2773186-1-bin.meng@windriver.com> References: <20230130095202.2773186-1-bin.meng@windriver.com> X-ClientProxiedBy: BYAPR02CA0061.namprd02.prod.outlook.com (2603:10b6:a03:54::38) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|SJ0PR11MB4992:EE_ X-MS-Office365-Filtering-Correlation-Id: 5243b51e-affa-4859-ff86-08db02a7be9f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5z5hNhBzCzcjdLxQEGdjY2OmYPqVfLnFH83R410bkgMvKdgaywQlMY/tOMlAyB9CWnE6OqOhlDZSyXpvL+JXsKOocCUA6oqHUvWeRjQIaL9/lxZa5ZZwgEyydShlYRINERntP+ZbQNogR92Hmbw1hJp2YPeYq1KYCHy5GKlxYrOkhXqWpgnK1tFEY2ecxxt/sHAkL9/qPSecAfmlgH6MvymxfvalOLi+ieczOBbbfNoVVukt0of2mhji8VR3MebJjnPx3vIMfSoJ++9ZihZS0hsmVWpiv/e83kGUZRGWbtPjT9gW4mNfLOBNmXulmqG5qmBQtQpngQKWmgenXaVAvPemqFNUheRF8X2zAd6mqFhug38TWcM0u6TKtEedodtrUWX6JgwykVSji5x+gk9C39qVSCc8hPPTWOSZhQV0mIDjvO9Fkb2f3Ep0TRmWRVxIXF6Dn3GU8SHeAgt0CJ4q3Zj2ckQFcMnbSz7zMId9QElLLM06mQl/Jt3M3qpIilTZKKOPcMZQ67gyhgSXHIVKZNhZv8cl2SUnfNeQROtQgFgjtZhhKhRPtTDo4FawjNe7c1trTBAqDvr12IDpdqn7NRFGSSpRE/iIyVuBsvJZYdCbbszlmjstoNCY5r+iwEcHBVl5qbvzgwWXMsi8jxKN087ceGCXvH+p19eptw0ohQ16dArUKH3IGEBmXYFhV7sdH2CGqSi479L8M5nDlTW5iw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5358.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(4636009)(396003)(376002)(39850400004)(366004)(346002)(136003)(451199018)(2906002)(83380400001)(66556008)(41300700001)(8936002)(44832011)(6512007)(26005)(6506007)(6666004)(1076003)(2616005)(186003)(5660300002)(86362001)(38100700002)(38350700002)(66476007)(4326008)(66946007)(54906003)(316002)(478600001)(110136005)(8676002)(52116002)(36756003)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?De1z4JVa3fXuj3MYoN6VrSqgB8hl?= =?utf-8?q?xZ9Eb4QDNZQSWQ2G00fa2B0e1Bs3cf3+Z/MBGsCQd5CNCP6kMHoBIdpaUteu3fFtA?= =?utf-8?q?LJfDaZkcDtHw5MCxEZVQEiSQvBi+71KmLOKiTRJojDSt3gKHDIwy1zFVuA0EF8p33?= =?utf-8?q?HfrrnKm91E1c+t/+OMm0rFSbzNdqErqGJ6P+B5vIJ7zAKfnm2lvQ2W3MVNk6ngeME?= =?utf-8?q?p1UGX2HMaYBHQqu31BKSqTz10kDZSr3Ok7r1kk+bcvX/srzF/mR9TvhUdCn3TnqgL?= =?utf-8?q?oUKF2aghUKdOlM6NwIJ77HLkrV5/X+qM0mnCprwmt7zgA8tNh/MZ9VzMbocglyg7H?= =?utf-8?q?noHr2CllLS1ycKhLo72rcL+PwOL5YT1BHpsHGZ+pfTy+VkeLMmxTDCIKW+O6bHWOv?= =?utf-8?q?ZeKilJa32Qq4AFnN+Fknf89Orznnds8e7mPefou5xJ0sScQBIBnmEhoz7ZB6q6JQZ?= =?utf-8?q?dNB8CsTVulYfAdq4pi13J3DoWgYigQAoVRZGshd9AIS7Ups0Qgr16px1khGoGLjMH?= =?utf-8?q?ilnGwEyrcStVj566H36rGHz58MCMcQqeoPKj8JdToZUXE8wSJ2r850pzAT+t3V7Vb?= =?utf-8?q?zxXjWsj4zfk3sBZLVJuwCU9wyfPZyp0mZcY6TuwFglj0+eDDk/tAFbv9UJFg5pKMk?= =?utf-8?q?u3exwsYBwHIvLiQCFfPbt75shlfQIAOrgiMBSm8dGAFkj3CYGBpJVzuBf35phBgzP?= =?utf-8?q?mHZ69jJAxhxr18/Wm8hTyZgcVJXBLm5Z8gIoOkLwOEe+S2Xtd6i0EJmD2WcQzQ6b7?= =?utf-8?q?J5Q645Jnu+zseC1avGlZaWWypWN2nZ74Ip5/wqQqjiplt/gyGV9v4AqiRRGkGRNum?= =?utf-8?q?wqgYtKq4M3om4TJ4E9Zz2PNTemhVcYZ6cbNnOm+WTYXQUCQ1oho7w7tvnvPHOMa5I?= =?utf-8?q?xfvYFWA7D3iODDaOWsAk2YC5bIPu1jYViSr/6HJHqkFDGLfoqhj8ikKuj6/f+qO3q?= =?utf-8?q?gQxLUpPrsaeVmKWwLDfz+aq595Qm9JQdrl4VU7Iz1J6/s3ayz4L0dVA8AjnFP9jCD?= =?utf-8?q?HxJjeKTmNQ6gqgAL0f1Ro/o35MnLzlr6M0QsDsp5Tqg35ifLC8PHXKyszpmW9MEQ5?= =?utf-8?q?ONxrXhny5pn/S3uYgST3KPL4H0CfCaHHqXBgsfD/2SIw+pgpKcYdH38csHKWTQ3Dy?= =?utf-8?q?vjQjIi50W7+SLVWl6q+yttdaZsp/bP9B1YgZZKJO6pLkUFjiBzw0Y+NTRUN5qWhtD?= =?utf-8?q?GFdJ2W88mVdENyXz5+LIvrkc+A/E+N7+koaN/iT1zdq9gMWMlAl/9+px3Jfg52BgA?= =?utf-8?q?GysuNil+BByAks4COC6eUurrB5rc7vKl1F5nDrF9Qj1ocA6H9EqvGGdzc0hf7hF/J?= =?utf-8?q?4xW6Bppw2Kvehfg5j4mYxs6QWvbPnydAfUVY5J0YOC+hc/L0IRv2EGoSYZn+0yCii?= =?utf-8?q?yHuTP5D3XulBE9TTcpOSwVsH8tA805IztVlJJ9agUiAB7D+yeObitvFtpQdSVcl90?= =?utf-8?q?PuOffTX3caDnikqDqjOfl9e2/gQhZwoIIjpXYjFQZkexE6do6ldeyMM13DUllEEkm?= =?utf-8?q?YGf2jIPWR7z1qThEY01CEj1PY8jCchNK6Q=3D=3D?= X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5243b51e-affa-4859-ff86-08db02a7be9f X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2023 09:52:48.6819 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: nF1gfaTaQuPT5QGVUU39z0jN1tBWWco5xQiRjWlKhFtVSl1VgpLeFnWISpRpQt9n/5RDMfZ/TUWNoReMWImu3Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB4992 X-Proofpoint-GUID: ZxZA_mnYh4WDk6UwJG5NEI7sPFsfyIfr X-Proofpoint-ORIG-GUID: ZxZA_mnYh4WDk6UwJG5NEI7sPFsfyIfr X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-30_09,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 spamscore=0 impostorscore=0 malwarescore=0 bulkscore=0 lowpriorityscore=0 suspectscore=0 priorityscore=1501 mlxscore=0 clxscore=1015 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301300094 Received-SPF: pass client-ip=205.220.178.238; envelope-from=prvs=13943e2a21=bin.meng@windriver.com; helo=mx0b-0064b401.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+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 Jan 30 09:52: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: 13120835 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 98DCAC54EED for ; Mon, 30 Jan 2023 09:55:02 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMQqy-0003J3-PK; Mon, 30 Jan 2023 04:53:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMQqc-0003BO-3M for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:53:13 -0500 Received: from mx0b-0064b401.pphosted.com ([205.220.178.238]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMQqV-00024G-Pd for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:53:09 -0500 Received: from pps.filterd (m0250812.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30U91W7s003981; Mon, 30 Jan 2023 09:52:53 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=3vCoOHxbCSjHUbC+8+fF0U3s0PhEtrD3RWGpqDkLTgw=; b=s8oSLHGsc2skE68kjNpPEJFKvMxEFjSz07mlClBapytTFYEOMpQO1hfMK4oECYmhY9Bi pCVy4AyAWfbj4BmI2phKJJvkSNp6C5P+mb3nJ67b2OSbhsM6by0QC4siEyhfsXg37AqQ 6UoQws7kzdpi0fBXoVRFb0QLs9qSlwxiGYkD+VT4Qj61SzuHc1+bGOp8drhyC9AVZroS eeGhDN8d6U3u8eINeyYe9iTP1CAOK7yRKCdozQrA6B7usfT9f1vGHzionaseAW+nfGR9 aMEG7EuBfbrP9xPqpOm4VwQ9iBWOgctWzL34EklHlpb8aOIYoLe1uPtPfmh2mfDilnjQ bw== Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2040.outbound.protection.outlook.com [104.47.66.40]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3nctpat10w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Jan 2023 09:52:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HqTdkS2AVpkCoAcj8iiSrabBQEdWkbJIJJM+m15IZ8lBz465krp+cMB5TLDj/KOyoH55PU34MOb/HDTtuQasdxDkNg4CrGg/Qty4AELhEABAjmhr01cvZxPpI8n6tr1LTvoD3vskQaSC6Kv74EQmtVDqznFYy0ip4ziLYeAIlJ17eWjReItPLbW7SyJkU/LQTNSrpSXZIs5pSYyXsmiKKvMB6t59qA+XJUFxD9R/d8WmVwkqBN8PMJMt1f+VJBWtwwjXoXWEudZihIy9mUN3fmEjKLeSsvwmbO9TVi1AgrMBAdg1X2TZ2bcJ/i9zUzU2+qmcy0viIQAHm6mVcenidg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3vCoOHxbCSjHUbC+8+fF0U3s0PhEtrD3RWGpqDkLTgw=; b=MibDSnx0ZQMHIbjQWkygFYvadS/XpOo3T/sxyUXvfup8d/qUo7kYQhpZAzlneRQDx9of+9LGF24RB6r/w9VPRv/gVujSbpCzUxsTdKJkR3TZ0s874kPB22Rat7Sb/AcI7an8r/OTcmUgZ1fRPqwF9EqSF760w/H/S3IAsFsziig854BclazpQ3f7IHxtOfc6qN0iW04pI8lOzHiK2pHHiHA628Zv5ZfvfzYjbG5nISUXmwPTkK3A1+HDAVrl95GZaWxdsFs6ilomjONOMrDSpot1Unij6BaSR+MYZHN83l+EbpAkbi2z3OrowZN9Sk4EkkecE6tZzDy9qtiVWracbw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by SJ0PR11MB4992.namprd11.prod.outlook.com (2603:10b6:a03:2d4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36; Mon, 30 Jan 2023 09:52:51 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9%2]) with mapi id 15.20.6043.036; Mon, 30 Jan 2023 09:52:51 +0000 From: Bin Meng To: Greg Kurz , Christian Schoenebeck , qemu-devel@nongnu.org Cc: Guohuai Shi , Xuzhou Cheng , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH v4 15/16] tests/qtest: virtio-9p-test: Adapt the case for win32 Date: Mon, 30 Jan 2023 17:52:01 +0800 Message-Id: <20230130095202.2773186-16-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230130095202.2773186-1-bin.meng@windriver.com> References: <20230130095202.2773186-1-bin.meng@windriver.com> X-ClientProxiedBy: BYAPR02CA0061.namprd02.prod.outlook.com (2603:10b6:a03:54::38) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|SJ0PR11MB4992:EE_ X-MS-Office365-Filtering-Correlation-Id: 355b998a-af23-4f06-51f1-08db02a7c060 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: T3/9jNoXe1SIL/vtbtOLtS7JYpkB5u2ns+G4XhxbyIwis9nkAjgcB8HFR73th5a79/BYTl4OpMRCy311pSnlyXETJ7v3db9Rk9D7WxiZWmOPXkzHDaRUhymu3nXaiW4u1SovwfJRTgb0Rrf5Qb/LbS5/cCkVuaA9eoWFz+ZBlYtjsyiB602owEWsyL1OFwan0W61Oq8UwQ6LXeaT66ey7QqB2Kp21F7xFRlCt8RYL8blUVTwCIZZUnSy/UctYnx4bVeezVTQMaPPclR8oaaSignz+WTUdm15/bfMNXhoGQ1k/ZkvKS+h6wxgFdF1wLgYht9jL/jRW4OMHS7fJdFliLlanFITCZDpuS4hZTP1+ex6iPfjFMe/Dr9udVa2JobADfqzqNFdUZHmsJhskjIAeOQ5X/up2CFiBd2TE+IXM4UwGLxtg+r3eA25CFu9LoIbzho8clS+ncXdMbevZZ9njA2mqKsSBo6yOphiSrsgn0R263xUxRT52CMOsIPVHk+aUkYLVurg/c3HbFM9zTeHUq7TvWmnwppamk6CEYTFOpIFbQC9jFz+GjKq8iC6G4hl1oy0XQcuYHppMDdnnZqveveJmP9sOrMbofvhV82GINCAT//lfQM8MwY8Xd0Iin0zaGaRPC6oyGC5vFsM/GmwfVjb8OkOcxOP0bQmeIiTwMqV+JHJPtSqom6PX+rx4Vl1Qaf51XT92Mox2k4Vfq+DXw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5358.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(4636009)(396003)(376002)(39850400004)(366004)(346002)(136003)(451199018)(2906002)(4744005)(66556008)(41300700001)(8936002)(44832011)(6512007)(26005)(6506007)(6666004)(1076003)(2616005)(186003)(5660300002)(86362001)(38100700002)(38350700002)(66476007)(4326008)(66946007)(54906003)(316002)(478600001)(110136005)(8676002)(52116002)(36756003)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NVltrcNcRx8++QKs+6/KR3geQ9UqDkI937TRTKKB1BIuKTjtd4BH8kwobOZxRHqvhlpx5Mw7GFxml7GdM7QNHdJu3obkNSiMfCOQojIv1X0M1xf0vAFzed9P1EfYa0bLHLu/rCfWn3FbeUjx8Dzdng7HhB+S7z/h2kNfONyNrEu7W1Pzv2QWvN68dcVfVy+ZJxDAph15BirqU//mNA92v5whIjAWgy2Xfd0QSmR5yyd8eKZ0YwwYVXT+gWPvesualA87f3YRfPzeSvcaQl4yQQxG7iBwpi4M/chUklxfbx1721Q9TFN+TVPUImJD67pKDViDgrlqzrKc0f9kRVIeDEBt70lWTp1skm8okRqztpQxNh6TW0YeQLImH8zuoJpNCH/qb83yo7SmuWN9weTwloGeepyxXnly1YNpAojEmjO20R2EgyezjWQiEIp+nDPvf3Z8sBeh3DVyVljCLUQzkYWMvvDx81VMScwm9BGBVuKrPmhHp/dQ80cQuMV4piWBk6MIxfVbljzGcWwWDo8A0NTgMiUrfhtT1uPaeAu9X2PcjX5BCrOG4y5UrPNSNA01F54+cSsHx4g3jwRe4pHGtH93chu7UWY+NYKDayf2x+n7POIKxZDqbGZdJHzosvh8HysiALZ2I7dIJSvndgN9LPVpoKBN/WF3PnE556jG22PTwVv71OXJhaoaPpMogf0zCo2wNvt7PVHxluGTr+aUtELi6IqA4TWbtPjatbPidmyDi07EFJYP4Pat1iJOTh6D9C1Pv1pmXfC39JNVhzg9oAxKO/dzaI/UHbl9KvFhSJ30JyjUgENXIOFo9yyjKTPnOdtNnboTMxXHD6eGKsv68ZSXKu1Jxr7kwjPMKMaW1ZPau5jrDuIikKGXBWUFbUtqg30gdAfK3prD2kRL/MmIQb3iMlhQOSj/ZJtN2usiGhvQmxG89Q9bFFgOnBR0jp7wzHl53uWS0eJwlVPqClVYXSvwH2ldPRdKJQ9ANYfKHWfRNqCHESgolJ+ZW6mLsk9rYKGCJEsBln1+sQRkAd5zIHU5H+2aFbuXB7zJkn++uY8yn6wCS2nhJNh6uAWDvmKREJ59iGjV+9rTS+awrjA7TYwDZJofAjQR9ZH7zBdwNyqBYPlHh0H4995pybTyunBmoPIVlvm8k7TZFNxy0QcZMIzvH3o4by4ZFMuhD/JFcO9Thkrrez/CJbilXX9s+cQzoTtMhjVmR/XAOi/sxEDYnUcf/JtJTxZx4FA9qCYmoahzvsDb2xnl3R6wTm5Q2HP2sBorQrgKfC+Fuy5+HIyB9/CoxTiOqk7eJRARatft2sSf9olg13S1081XdMjA0BXnFBC/zQgVdcxGy749YKW/nCPuacUpyvdHBP5WiT0llVG/LjtD4GsfAMdu7Ygqj8AUpJ9R/xh0U0K4hSIGLP6QynMz9vWD1Y7/dvRMwySdkZPDxLAfSI6lTsh+dilbMtEUkuM6yITJ8xjOGZKEScjX0UdMFwH9j1GbcVGmhNibkhw4/db96nrZvvgDhz5A7NKdBXd0kIGxuXbLpO8SWYrcKaE/BTogYw+VK8MTUticHxVMghdUu1yhkjOtPSzMpgdTo2AdTPOVO4qEaA15dFLM1g== X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 355b998a-af23-4f06-51f1-08db02a7c060 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2023 09:52:51.6370 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: hU4XKEl/N5riscI4X5Ln8QPJsLiI/N4t/1Tj/ShBcfw7VZ35QHtyfAZc5PrETZKyEc2zNNfDxP+E6N9LWxrncA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB4992 X-Proofpoint-GUID: 8oyvZ28CR2nL6iupOWosAqBllq9Bbe7a X-Proofpoint-ORIG-GUID: 8oyvZ28CR2nL6iupOWosAqBllq9Bbe7a X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-30_09,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 spamscore=0 impostorscore=0 malwarescore=0 bulkscore=0 lowpriorityscore=0 suspectscore=0 priorityscore=1501 mlxscore=0 clxscore=1015 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301300094 Received-SPF: pass client-ip=205.220.178.238; envelope-from=prvs=13943e2a21=bin.meng@windriver.com; helo=mx0b-0064b401.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+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 Jan 30 09:52: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: 13120822 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 2C8FAC61DA4 for ; Mon, 30 Jan 2023 09:53:48 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMQqt-0003DW-U2; Mon, 30 Jan 2023 04:53:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMQqU-00039r-HJ for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:53:03 -0500 Received: from mx0b-0064b401.pphosted.com ([205.220.178.238]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMQqS-00023q-Q7 for qemu-devel@nongnu.org; Mon, 30 Jan 2023 04:53:02 -0500 Received: from pps.filterd (m0250812.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30U8OtRK025559; Mon, 30 Jan 2023 09:52:56 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=scX7/GExEU1Y5uS9tlcdpKJc4lxQrcY+YBKv1AXl5YA=; b=kOeXnQQffAbSGo97+Cog5tatlFbfok+T2+Uf6BlLED08eu1SVYHWBD8BMFSGKKVYIwMa 9NmS96otRXM+3d8cQYwhUvsckK3bRnUp5h9NLVLUrbxpFYun9fOfuwBT8hrB9HO0Krqm Eq5fwmovvUK782jMQ6oNy1Jv6tRRM1DbEDvJb6aITvFKix9GuWbQ0wMHooTSMt0qpyR+ QcwwqISIFCfP7iOmE8nKYX2sAA5TbCOSsepihpgwsmKoht31EseACrNhxw2uff8janhO j4Wr88LLWKKyv6Gl7Ti2ECPBn2V4HpQSiXeXsGmD11PcKAonW3ULrwis1j29yHxrtaGk Lw== Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2047.outbound.protection.outlook.com [104.47.66.47]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3nctpat10x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Jan 2023 09:52:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ofYjYS5ctjHnB5Td6JNQ3985ycsLZZKDuE/uY6Du4wlD82V+niutX59G2lr1pI9L8EEHmID0CYD9IvOuxbSUyDKdIZiA2Sr356n+fYSHHFdO+SsJTVdHEPBvEg+KDO5bwSEhVATALfhOONOKK2VRBKiam7/gC0BfCIBrHhktCRPR6UnQtIhcod4KF2r9944uP7/v2LU/q6e4fKm7PfHcWLFCMw82202YaffmTQDpkU0oOFA4iaeIrHJCSaYQe3QjFvV+lTMQ5RHuIBa9HAdZn2VdfL27hhM1Q6xsRXyGVoF1RxiAHfQrF5Uvt59bKGdfvQ4d5BMGpw/RwwG6XM4SgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=scX7/GExEU1Y5uS9tlcdpKJc4lxQrcY+YBKv1AXl5YA=; b=WAUtz/szGey/E8BYLGwEbWRkLhGusyBMp25zl/xaN5f2qFhfms9HkRXmKwj4ckWJhj1JlKQ+VHTRY6KiTU3q1Dn9YfTGQVjKB8iRGJ4wIoOK699qEZ0205hDUxlicAqIhIx4MfQFmZlfFLNAwShaUETRDAP+A/J4Jkh2ABlQPy2TZ8eb66bI1Nv5RSA5oHoaazxYz64p+KeIObj/QF2D5LqrECLCJySErBCkxVzdwTFmROfjVkIDdn0LjLttsoxmk3BqrLUlM30bIHNq8Jq4/JpTIb03zsjJZsqagZF1k09I1VNwwlIGbZN5ky+T+JgbDVCGAFMwQcKNVMTW5Gsqqg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) by SJ0PR11MB4992.namprd11.prod.outlook.com (2603:10b6:a03:2d4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36; Mon, 30 Jan 2023 09:52:54 +0000 Received: from DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9]) by DM4PR11MB5358.namprd11.prod.outlook.com ([fe80::6c5d:5b92:1599:ce9%2]) with mapi id 15.20.6043.036; Mon, 30 Jan 2023 09:52:54 +0000 From: Bin Meng To: Greg Kurz , Christian Schoenebeck , qemu-devel@nongnu.org Cc: Guohuai Shi , =?utf-8?q?Daniel_P=2E_Berrang?= =?utf-8?q?=C3=A9?= , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Thomas Huth Subject: [PATCH v4 16/16] meson.build: Turn on virtfs for Windows Date: Mon, 30 Jan 2023 17:52:02 +0800 Message-Id: <20230130095202.2773186-17-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230130095202.2773186-1-bin.meng@windriver.com> References: <20230130095202.2773186-1-bin.meng@windriver.com> X-ClientProxiedBy: BYAPR02CA0061.namprd02.prod.outlook.com (2603:10b6:a03:54::38) To DM4PR11MB5358.namprd11.prod.outlook.com (2603:10b6:5:395::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5358:EE_|SJ0PR11MB4992:EE_ X-MS-Office365-Filtering-Correlation-Id: e518301f-6713-4e87-2d1f-08db02a7c236 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LKzu4wtHYICGXchgaaZgpyHuL37pn3cNUlEENodYT8A4vnPYG9EkS3XRS/80Se29HsFZUD9ysBPgKeHl3ywJfMxqIr+jCtLcHTNDe3oJqfouoxiFnfPeAyUV5szt1FQWvqus/yjdeA9NTFKGwCBQhVmFV6sJNGPrKP2tw32NwwPCoEjnFn2gQRsinRdIrVJ0wOZcmMm8YFzYSH8WbEuDQqQUft1YSky0PN/QabEL+BzpqxHxdvzIOyXAx5dkXPg5/oIXgK8353g+8BDibu+ury4ll2XIUCm11nuWMLx87JS3SLMLoxBu+HwLRsUMh6P19qHKahEGM45kfnplb5w2YCr0Jg9K8kkk70BWvP/ZGf8/TicFbAeCRu7Pz+M29Vj7TqT5R9LIblMw15W4Kox+NtLGPMTSwsiei4abGt+kLbprQYF5/vKZmfFTEJgIj4bv8+Xv2VKbGmz1HLZwUrWV8BlTvK0Hog0UvjYcqCQAxHV85vW4rA8mmdyXfVCoxkijEc5ThquYiXFuzR4a4NWzFsObM2ykjfmCBpmtzS6r3DYNgoQ7MBUE4q3nacvJ9/b1aQ6Jhtnn5UhMSWvHEpF2lRMxnSTQTTHU3PTE660jiOCeM9wlLKnTMYPKBPq3eLg3+AG8zib611/Ul10XeiiXMNlfjr6OEUpGOkX8lPH3PaccfByhhVeFU+1f9ZPy7ObPZ9sqndzTyKQ2sKfdUSXBKw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5358.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(4636009)(396003)(376002)(39850400004)(366004)(346002)(136003)(451199018)(2906002)(83380400001)(66556008)(41300700001)(8936002)(44832011)(6512007)(26005)(6506007)(6666004)(1076003)(2616005)(186003)(5660300002)(86362001)(38100700002)(38350700002)(66476007)(4326008)(66946007)(54906003)(316002)(478600001)(110136005)(8676002)(52116002)(36756003)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: aDNmtD5fsRhMc29CDN4mXwfefnq1tGWmZzAQa/54PM4yycZAKcWr9uG328BIZYK2l2Z4JjR2OAdfIebOc28d9oF+vXmyFFRuHBGH6HBcklZ2n5t4Snfh/Mnd6Lmqz9FCIGk3A1E2kMRzpHQAjrlFbdXCQnTbIWqfs8ElIE7UbLe3vSt9846tvhWUlt0h1jxd3GBu17a1cSMzmsflHFD19AEEVIvLyZQ+7m7zT4+4yaieFMB4zIm149LklSScFzMAGTDCxmq1OO8bwEV/yYCBY8ROysFjb2lDSQ4fl7AlhpQgFlDleEX8Lyuw2j8KgnhWtWlYYhP043gEnKogof0E98/1zsctYtbjJ001HNRoQlPFz0T9A2PqqYNgSETaSsrBxw/9cNr0MDUDmvpykrqJO8na7O7CpGz1Bm/Hey05pNphvHvq+IRhEoLd5Ye/Xx2ef8a+6na3Ms9Rhdz6NMedlKqLJcRsZivKqfmxwMv1cfJs9M1h5Ye9jzM88OL986PzWcX27+uV/P1Kg0RVjbHDjDM3e9HuBQE9TwI4e+GjqESUbgBFW5wgXaQa1+NDq2xynFMlCeRnyRYazmo4n2jiQUYfuhK/H0QNsKGEfQ+KPpsF6+tba7H20xwiMQKQVVG6Unj2+MiGBY57ibtYmER+3BtBD9TF5cE164hcFww3F3u9YCKrIJAw6tONSB/m5HEacX3QSvhWOesDy9ON3g/9w8GgwILyvfgwvVgZUnRVMgrOK/Q5DLn4kkEIu9yHYkmTFBq34XwyQWYZqKkf8NZINvAirbHY4G4kigZ3ShLUm2RQRb47+K2w5NPX0AchLtxx7Jb87kOciKcr13cq9ZgeQo1JN/LIrh5v9GjGLaM3NS5AwNsvUlcE1jvMr440uvazJM6LcgyHmbJTArxa7gi/LEQj+erEdHa3uaq+0XahqYNeiAJ4m6m2zsf+d8fWD1Cln3Qx3tPpC3yv5UsF/vswOXZrri2mezSaWw9/earQ6vo1r4/hVa+HVTKPpNqAMQ8tv3yReaBDGaNW3+9ztGESPftG9wOQKDOvYYxVJjHOG6jbsNYYli2UPxu0vJSsxgwfP5zozf7hVFU8rOJrmUNmvagHUQf94avuxSnVcds5/bzh7Gr54wPIT7uQI0T2OmRp8t6q5np6A5bP/p0XwS8KNUtuJEQ7VVs0KcAz3JbUrW/OuolFK5kJooG1WIHdW+OIXn/BAj/oSJj0ehMHxlJfCDvh6qFYAgrchAb1IMs/PiDhaUQA4UZme13CDQcTbf1zLQuH46dZLcpz43k/nvBqkDK5oM/r/eXlJDiAg6T6p+6lpSq7uzykBMtnyxFIWt+B0EI6/Rrp6kp1nLmRYQu2X5QRBt8WAwui87Bom+T4d+/LiebyG+k6o8knkOFZmKRjV7iNDfc+FbhXIJZBkfLTIGgF7ovRKrdTD4nHeergqma4Yyt6EMtLO9GfrvDlK8JNvOv3OdQ3Wfgmd4ymG8fdnHOsyHg+J6h2EQX6bzxdhqOgKdhRdxNOzfjXXdowoENxlOfgwNcH/Usu2yt1m1XfB1C/ozJjb7LNwiheXMFxt/Kme6loIXqKcJ1Kj8j0XIRPC4eXi5VDxthFjBTCrG8o+w== X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: e518301f-6713-4e87-2d1f-08db02a7c236 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2023 09:52:54.7318 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Wf3+hLvGuHrxy3Wgc9oEK4JwgyEd6zJqPKNPPw7l87jU3k6ZDKUyS9JGGbI/9xkyao9e1vx4LKjBiD0Xb0FRDQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB4992 X-Proofpoint-GUID: IEoQJcG0g5ostKxyf298g-cxnCKJOk0B X-Proofpoint-ORIG-GUID: IEoQJcG0g5ostKxyf298g-cxnCKJOk0B X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-30_09,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 spamscore=0 impostorscore=0 malwarescore=0 bulkscore=0 lowpriorityscore=0 suspectscore=0 priorityscore=1501 mlxscore=0 clxscore=1015 adultscore=0 mlxlogscore=803 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301300094 Received-SPF: pass client-ip=205.220.178.238; envelope-from=prvs=13943e2a21=bin.meng@windriver.com; helo=mx0b-0064b401.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+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 6d3b665629..8123136fdf 100644 --- a/meson.build +++ b/meson.build @@ -1751,16 +1751,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)