From nobody Sun Feb 8 06:54:29 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1527816589773244.87019183171947; Thu, 31 May 2018 18:29:49 -0700 (PDT) Received: from localhost ([::1]:46891 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOYsy-00048u-RR for importer@patchew.org; Thu, 31 May 2018 21:29:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33275) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOYqs-0002wc-DH for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOYqn-0002oi-LQ for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:34 -0400 Received: from mail-qt0-x241.google.com ([2607:f8b0:400d:c0d::241]:40623) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOYqn-0002oF-Fg for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:29 -0400 Received: by mail-qt0-x241.google.com with SMTP id h2-v6so30291358qtp.7 for ; Thu, 31 May 2018 18:27:29 -0700 (PDT) Received: from localhost.localdomain (96-86-104-61-static.hfc.comcastbusiness.net. [96.86.104.61]) by smtp.gmail.com with ESMTPSA id o68-v6sm2003842qkc.19.2018.05.31.18.27.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 31 May 2018 18:27:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=juliacomputing-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=WYR4twGVelsi4IuqZWK9UvlDJY+hHMIUVvjMzSo2niQ=; b=iUkg2BMKHqojNDridP/lOTrG4EH2w2hBcAAewnn8f+KXasvAWkYNP4oDoer1xDuhiv Qe6v2MbCGOalGG6d312tMaHxtGEJUHcbGYbogSRlAj12eXYEVH3GXSHoyChAB8gwQO/e L6a7JTH/mXCRV6QjfizVacrIcuUFrYV5ZusOnYBLjWUJWusqqi4TauGhmOgA2DfdmaUS hRLgmRWCvvyqIfwvnp8q+0dXP/CNBRGtg/fXV3kSCxEENh7VO4edPqCvUI4KTi1pP1o3 DyzPsJQ4UZto5Om0ngUdkw9IOXumItASfaR2z0FkjLcBbu/m50OH6w2p0znRFXCMF3Xc Esog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=WYR4twGVelsi4IuqZWK9UvlDJY+hHMIUVvjMzSo2niQ=; b=OadLyAkdw32zUEcBsrY7aBOyb3UMsh+CbxGJeDEVOvgm+XkTcnPVfpu0IFncqFaIga cmEz1tRKCFVjONI6F3L8jryUPLMGe8c6OEUkvTcOff/ArV2nsQZYFFSIt8xe7dCd1xQv +C0lG17jrN49Lh45RTLgNWZAdJdNgxIMnhTCOqGF7EJMCz/GNf5Y+TmvBFNRo7XdvKpS Ed/vPCk2VJo90uET6evh33z3ycZtZ8044pgzP1GDYhwPMgOZzPxvt5+UyMUZwXk1qBun lLFyDE/OTRCnfl3837A2c8x5JhumeiKivyDBM8twTlPHDNWFrvdzMhtECv10LUOFsl6U 9RAg== X-Gm-Message-State: APt69E2VjimBVHSNlMN5VPHWBfrHxa5MAo1COtstxq0Y8TR9K4PNHlBd WoTgOqwFS+NpGuYbFFEDumECwKc99s0= X-Google-Smtp-Source: ADUXVKKUEZPIPgTCZFClBAvhkubxeCO4XnSo1gA2Jjq1f6QGR/S4lpN1/7c/0Vd6gjFhz54AAyhwbA== X-Received: by 2002:aed:30c3:: with SMTP id 61-v6mr9082876qtf.172.1527816448464; Thu, 31 May 2018 18:27:28 -0700 (PDT) From: Keno Fischer To: qemu-devel@nongnu.org Date: Thu, 31 May 2018 21:25:56 -0400 Message-Id: <1f6bc60305b8c1cd00f5e2a361a05d7b4bc56338.1527814874.git.keno@juliacomputing.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::241 Subject: [Qemu-devel] [PATCH v2 01/20] cutils: Provide strchrnul X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keno Fischer , groug@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" strchrnul is a GNU extension and thus unavailable on a number of targets. In the review for a commit removing strchrnul from 9p, I was asked to create a qemu_strchrnul helper to factor out this functionality. Do so, and use it in a number of other places in the code base that inlined the replacement pattern in a place where strchrnul could be used. Signed-off-by: Keno Fischer Acked-by: Greg Kurz --- Changes since v1: New patch hw/9pfs/9p-local.c | 2 +- include/qemu/cutils.h | 1 + monitor.c | 8 ++------ util/cutils.c | 13 +++++++++++++ util/qemu-option.c | 6 +----- util/uri.c | 6 ++---- 6 files changed, 20 insertions(+), 16 deletions(-) diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index b37b1db..bcf2798 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -65,7 +65,7 @@ int local_open_nofollow(FsContext *fs_ctx, const char *pa= th, int flags, assert(*path !=3D '/'); =20 head =3D g_strdup(path); - c =3D strchrnul(path, '/'); + c =3D qemu_strchrnul(path, '/'); if (*c) { /* Intermediate path element */ head[c - path] =3D 0; diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h index a663340..bc40c30 100644 --- a/include/qemu/cutils.h +++ b/include/qemu/cutils.h @@ -122,6 +122,7 @@ int qemu_strnlen(const char *s, int max_len); * Returns: the pointer originally in @input. */ char *qemu_strsep(char **input, const char *delim); +const char *qemu_strchrnul(const char *s, int c); time_t mktimegm(struct tm *tm); int qemu_fdatasync(int fd); int fcntl_setfl(int fd, int flag); diff --git a/monitor.c b/monitor.c index 922cfc0..e1f01c4 100644 --- a/monitor.c +++ b/monitor.c @@ -798,9 +798,7 @@ static int compare_cmd(const char *name, const char *li= st) p =3D list; for(;;) { pstart =3D p; - p =3D strchr(p, '|'); - if (!p) - p =3D pstart + strlen(pstart); + p =3D qemu_strchrnul(p, '|'); if ((p - pstart) =3D=3D len && !memcmp(pstart, name, len)) return 1; if (*p =3D=3D '\0') @@ -3401,9 +3399,7 @@ static void cmd_completion(Monitor *mon, const char *= name, const char *list) p =3D list; for(;;) { pstart =3D p; - p =3D strchr(p, '|'); - if (!p) - p =3D pstart + strlen(pstart); + p =3D qemu_strchrnul(p, '|'); len =3D p - pstart; if (len > sizeof(cmd) - 2) len =3D sizeof(cmd) - 2; diff --git a/util/cutils.c b/util/cutils.c index 0de69e6..6e078b0 100644 --- a/util/cutils.c +++ b/util/cutils.c @@ -545,6 +545,19 @@ int qemu_strtou64(const char *nptr, const char **endpt= r, int base, } =20 /** + * Searches for the first occurrence of 'c' in 's', and returns a pointer + * to the trailing null byte if none was found. + */ +const char *qemu_strchrnul(const char *s, int c) +{ + const char *e =3D strchr(s, c); + if (!e) { + e =3D s + strlen(s); + } + return e; +} + +/** * parse_uint: * * @s: String to parse diff --git a/util/qemu-option.c b/util/qemu-option.c index 58d1c23..54eca12 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -77,11 +77,7 @@ const char *get_opt_value(const char *p, char **value) =20 *value =3D NULL; while (1) { - offset =3D strchr(p, ','); - if (!offset) { - offset =3D p + strlen(p); - } - + offset =3D qemu_strchrnul(p, ','); length =3D offset - p; if (*offset !=3D '\0' && *(offset + 1) =3D=3D ',') { length++; diff --git a/util/uri.c b/util/uri.c index 8624a7a..8bdef84 100644 --- a/util/uri.c +++ b/util/uri.c @@ -52,6 +52,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/cutils.h" =20 #include "qemu/uri.h" =20 @@ -2266,10 +2267,7 @@ struct QueryParams *query_params_parse(const char *q= uery) /* Find the next separator, or end of the string. */ end =3D strchr(query, '&'); if (!end) { - end =3D strchr(query, ';'); - } - if (!end) { - end =3D query + strlen(query); + end =3D qemu_strchrnul(query, ';'); } =20 /* Find the first '=3D' character between here and end. */ --=20 2.8.1 From nobody Sun Feb 8 06:54:29 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1527816651493863.8724573062129; Thu, 31 May 2018 18:30:51 -0700 (PDT) Received: from localhost ([::1]:46896 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOYu2-00051j-H4 for importer@patchew.org; Thu, 31 May 2018 21:30:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33282) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOYqs-0002wm-Mq for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOYqo-0002qE-T6 for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:34 -0400 Received: from mail-qt0-x243.google.com ([2607:f8b0:400d:c0d::243]:37548) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOYqo-0002pr-OE for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:30 -0400 Received: by mail-qt0-x243.google.com with SMTP id q13-v6so30303423qtp.4 for ; Thu, 31 May 2018 18:27:30 -0700 (PDT) Received: from localhost.localdomain (96-86-104-61-static.hfc.comcastbusiness.net. [96.86.104.61]) by smtp.gmail.com with ESMTPSA id o68-v6sm2003842qkc.19.2018.05.31.18.27.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 31 May 2018 18:27:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=juliacomputing-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=P2b6eNHIwBEVaKG1WtWdNoOELbPgOnDMY56CVCNFFNY=; b=ZlPFJVRMvxmLi9uF86Bxd9y6X01WfV8Cyj2qrtgWUTB7tY9T08yVfGFEI4QUKVME1s s3no73HlFUxwVyR5zIOLv/o9jUzIN2zcPfnjcAqoxUK1MopIwusJLHcHarpeZoo+gqV8 Rfst9KiyPA7AJsrjdtO0RFG9vERx1InZxQLLCsipAqEZciQOQS3IR8Z1mqfhg1oMI1Co By0TGUAoiC032wtG4YW2kMK6PIVFKtqtue27PCXj1cc0hbW53dm1SsjOf5Mf8tYDry0m 9nH4sk5XsoeIE4n+SXiKnHmU0NXstmgRtLd3TtVBwnb5hJ5dzNGZqeHdtrpAXHu21wZc 5nmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=P2b6eNHIwBEVaKG1WtWdNoOELbPgOnDMY56CVCNFFNY=; b=lt3l+Mvylk4xnwnVmYV260AZcjoKR4z3deKHnzNcI6D/eIcmWkRPCWKwwB5f5L3Xbl V3cywK+dil1QZl2YdR0y6fC/aqDsGxkDoIDYcU7dz4rZ7rE9uR2+ejguYVT7ZM5BNzQW Gc88zpfRaDYsoh+NVDBi6RYQAUKA7JFK8x/n6QEU26NanjC0NLxNtrUGFsd8gUm4gLOk SVL3JEVTalJRHGGezL59ZgwPFBuHzYLjnF6vBm3o3UUT4S++2z3otxLvNsnAF2mlI5x9 SW/iaakYQPvPXorLcYtulxr6lXg4c+jtXwpwrpuxDajLU41/pN+a2TNre6+RyYGbaRC3 HAUA== X-Gm-Message-State: APt69E3xMZYZYRlvCmOGSbnSWPIpV5gStEN4blQmpvNOmmF5R/Eybsxb qYTy1lIpd9LOJ/JVw0IJy4QBVPphU1Y= X-Google-Smtp-Source: ADUXVKKCPqPmEKWmlo+KK+RI0e2R86rkt+RM/EBbtGI8RY86ajOMxfB1GnWgS2bfKeuG1S3gns0KOA== X-Received: by 2002:a0c:c242:: with SMTP id w2-v6mr8434807qvh.91.1527816449786; Thu, 31 May 2018 18:27:29 -0700 (PDT) From: Keno Fischer To: qemu-devel@nongnu.org Date: Thu, 31 May 2018 21:25:57 -0400 Message-Id: <62bbed45cc9c775ba23cd5572e8cf2d77d769dfb.1527814874.git.keno@juliacomputing.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::243 Subject: [Qemu-devel] [PATCH v2 02/20] 9p: proxy: Fix size passed to `connect` X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keno Fischer , groug@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The size to pass to the `connect` call is the size of the entire `struct sockaddr_un`. Passing anything shorter than this causes errors on darwin. Signed-off-by: Keno Fischer --- Changes since v1: New patch hw/9pfs/9p-proxy.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/9pfs/9p-proxy.c b/hw/9pfs/9p-proxy.c index e2e0329..47a94e0 100644 --- a/hw/9pfs/9p-proxy.c +++ b/hw/9pfs/9p-proxy.c @@ -1088,7 +1088,7 @@ static int proxy_ioc_getversion(FsContext *fs_ctx, V9= fsPath *path, =20 static int connect_namedsocket(const char *path, Error **errp) { - int sockfd, size; + int sockfd; struct sockaddr_un helper; =20 if (strlen(path) >=3D sizeof(helper.sun_path)) { @@ -1102,8 +1102,7 @@ static int connect_namedsocket(const char *path, Erro= r **errp) } strcpy(helper.sun_path, path); helper.sun_family =3D AF_UNIX; - size =3D strlen(helper.sun_path) + sizeof(helper.sun_family); - if (connect(sockfd, (struct sockaddr *)&helper, size) < 0) { + if (connect(sockfd, (struct sockaddr *)&helper, sizeof(helper)) < 0) { error_setg_errno(errp, errno, "failed to connect to '%s'", path); close(sockfd); return -1; --=20 2.8.1 From nobody Sun Feb 8 06:54:29 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1527816587806251.1935641799895; Thu, 31 May 2018 18:29:47 -0700 (PDT) Received: from localhost ([::1]:46892 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOYt1-0004B6-0s for importer@patchew.org; Thu, 31 May 2018 21:29:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33281) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOYqs-0002wl-Mn for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOYqq-0002sA-By for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:34 -0400 Received: from mail-qt0-x242.google.com ([2607:f8b0:400d:c0d::242]:36433) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOYqq-0002ri-7W for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:32 -0400 Received: by mail-qt0-x242.google.com with SMTP id q6-v6so30289075qtn.3 for ; Thu, 31 May 2018 18:27:32 -0700 (PDT) Received: from localhost.localdomain (96-86-104-61-static.hfc.comcastbusiness.net. [96.86.104.61]) by smtp.gmail.com with ESMTPSA id o68-v6sm2003842qkc.19.2018.05.31.18.27.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 31 May 2018 18:27:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=juliacomputing-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=rif/Z2RWOcNT62+1Jsw048p3o4TD89HGclIs6z9l+8U=; b=XQmH5qF3DXAELKi77bKN5j5bqw/Q5vdvDeSP8Lb1rG5CPch0TgVME36KNlJbir8RiV J6345BNCzlrrGmo2vCEnt5UmtCQB7f7GSDyDNH94mSNr0VdErCnlmjiG65uGlTonVp4x HNuxRV7qptL5LbDeRQUwduPTb4PzLXjBQZhbPYMupOELQBg6CfsJH/M5g6z7WL/iYrJW od2T9YBm6HsFYzfuP1SGEWvOJW1UXqs+wPYrVDvr237JyBEKSqZDjgfS6E7UEAN4oWr4 GgOjBFn5jMXnZcoo2rTVMiwyBNqlWGkwhhWDXwXlihM/NYbZA36aOE0VqZzrLufr0USX LBkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=rif/Z2RWOcNT62+1Jsw048p3o4TD89HGclIs6z9l+8U=; b=gTprdBJnezjlzlbMBa+M7UoI5bi2RcEh9ckfhaFio+xUaz8CFmPwLj5SJvEYIM1iYj Vm3VrJPp6++45e2/1iPoYvLXg3558FIQLAIYTGchW4w+QHudDQ29KtwPfW7Fe5wLekcx 0DlSgpCFVPgpJY+z5rwhPdY8ArL4sTs2DTBImcpxPI02dG3rAKup2OtX/0TOp5swtMks QWT14YrW1fsjz9q3sJdkHDH60rWSnrE8TXXFvRaMUUf8kcTFDDfZVnoXfrXk4BH0f2FN KjjZlZwtCsyvRYh89iDdpEdgE8VJtuyY+nc2H9V9KVif0B6pEs5c8ztreWwgp0psePH1 ONJg== X-Gm-Message-State: APt69E2PbQYyGbwCKjyWXfUSREIWRTrPfF1Bbu5Lo3MqVx8KJoiRbUo2 jmJkayC6z0d3cknHD4cFrkXPNug/smQ= X-Google-Smtp-Source: ADUXVKLiRNeJSlAhdArezb1IEHvBzFyZlY4Vv0YDowau1I0h5g8QrtTa2/gHWyS6FS3Dmc622OGRVw== X-Received: by 2002:aed:37e6:: with SMTP id j93-v6mr9352914qtb.111.1527816451307; Thu, 31 May 2018 18:27:31 -0700 (PDT) From: Keno Fischer To: qemu-devel@nongnu.org Date: Thu, 31 May 2018 21:25:58 -0400 Message-Id: X-Mailer: git-send-email 2.8.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::242 Subject: [Qemu-devel] [PATCH v2 03/20] 9p: xattr: Fix crash due to free of uninitialized value X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keno Fischer , groug@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" If the size returned from llistxattr is 0, we skipped the malloc call, leaving xattr.value uninitialized. However, this value is later passed to `g_free` without any further checks, causing an error. Fix that by always calling g_malloc unconditionally. If `size` is 0, it will return a pointer that is safe to pass to g_free, likely NULL. Signed-off-by: Keno Fischer --- Changes since v1: New patch hw/9pfs/9p.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index d74302d..b80db65 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -3256,8 +3256,8 @@ static void coroutine_fn v9fs_xattrwalk(void *opaque) xattr_fidp->fs.xattr.len =3D size; xattr_fidp->fid_type =3D P9_FID_XATTR; xattr_fidp->fs.xattr.xattrwalk_fid =3D true; + xattr_fidp->fs.xattr.value =3D g_malloc0(size); if (size) { - xattr_fidp->fs.xattr.value =3D g_malloc0(size); err =3D v9fs_co_llistxattr(pdu, &xattr_fidp->path, xattr_fidp->fs.xattr.value, xattr_fidp->fs.xattr.len); --=20 2.8.1 From nobody Sun Feb 8 06:54:29 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1527816592317164.84727100220323; Thu, 31 May 2018 18:29:52 -0700 (PDT) Received: from localhost ([::1]:46893 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOYt5-0004Ew-GO for importer@patchew.org; Thu, 31 May 2018 21:29:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33285) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOYqs-0002wv-Vc for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOYqs-0002ty-0G for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:35 -0400 Received: from mail-qt0-x242.google.com ([2607:f8b0:400d:c0d::242]:34561) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOYqr-0002ta-Ql for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:33 -0400 Received: by mail-qt0-x242.google.com with SMTP id m5-v6so30317112qti.1 for ; Thu, 31 May 2018 18:27:33 -0700 (PDT) Received: from localhost.localdomain (96-86-104-61-static.hfc.comcastbusiness.net. [96.86.104.61]) by smtp.gmail.com with ESMTPSA id o68-v6sm2003842qkc.19.2018.05.31.18.27.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 31 May 2018 18:27:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=juliacomputing-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=2M5h9h/yt61QfyXREUavr1tG2L6rBnfGbsX86iOEfhA=; b=jOdbU6Mt1S8ccMYCF938Tw4k9wNBCsH6/h4v2RyvM3LsDsFJQYXsSaLw9gKB1Xax97 U6xtCc2FLt8uNoiZt4lKtjcenE0KrWz5o+OHlXwVvY+iWWzlPNG48IemQ85a2PyQwdSt r/naEKO1Bv44FZPmsUWIwBA0mXxv5BAm+SFxvrky7S8AvojJZmOTihnuQ8wjO+zVUPTN X4nkWufhj+wIauQJAtB12FqHNIpmT18mAnaPKUfW+WozC5GULERggNU/2roJNtVT67TD +6HI7pVeL7LrjPH36EWddnOKXCOPem7Vrwx2bL5GHx9pT2KJarQY7irib/H3xlKB52xJ n9CA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=2M5h9h/yt61QfyXREUavr1tG2L6rBnfGbsX86iOEfhA=; b=L4IM8KbsBMSbc2VfZ0Bwz0w+WL/XgXUTRbmDtYcI17xP9kQ6259V6h2qrKF34zlzVX ni9EAmfvXyuO+N7kERRoEn8iNOtGjlP2CB+BLOPkKbRv23SldsuXC2FOWv/29/grO7yH k29DtoFoJIMLZ8VvqvAonIywKbj/L9O5mvcer5kyMZ5J7wUY/I2hrdSMb4BvXdYUvHlF Fic+NgIi7fp3E1NWorPZa/gF5aUe9phZQ/nk+XfYrRrCOgCi8iGdEBn3C3Sh3zwNgEFP d5+lCvnxljJoP29P/IC68DULOrinsdPWiJinDx/hQoM6+HN0Jbtk0eNL1LBrSxKnfFr6 lL3g== X-Gm-Message-State: APt69E0MW43DgB78KEuIxmNTXOxGiWy/JaQ2CpS7t+zG53khqjtz9ARb sN1Hx94G8Mtd2wbD/H3BUOuW72Ev7Xs= X-Google-Smtp-Source: ADUXVKLixNyaL4Azq6dZwyvXVzOj/MtECFki/0GCPHpxjIHZjsiEne6q4FzPP7Tq/eIBZBHcUt+z8w== X-Received: by 2002:ac8:2bd7:: with SMTP id n23-v6mr8765205qtn.304.1527816452926; Thu, 31 May 2018 18:27:32 -0700 (PDT) From: Keno Fischer To: qemu-devel@nongnu.org Date: Thu, 31 May 2018 21:25:59 -0400 Message-Id: X-Mailer: git-send-email 2.8.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::242 Subject: [Qemu-devel] [PATCH v2 04/20] 9p: linux: Fix a couple Linux assumptions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keno Fischer , groug@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" - Guard Linux only headers. - Add qemu/statfs.h header to abstract over the which headers are needed for struct statfs - Define `ENOATTR` only if not only defined (it's defined in system headers on Darwin). Signed-off-by: Keno Fischer --- Changes since v1: * New qemu/statfs.h header to factor out the header selection to a common place. I did not write a configure check, since the rest of 9p only supports linux/darwin anyway, so there didn't seem to be much point, but I can write one if requested. * Now also covers fsdev/virtfs-proxy-helper.c fsdev/file-op-9p.h | 2 +- fsdev/virtfs-proxy-helper.c | 4 +++- hw/9pfs/9p-local.c | 2 ++ include/qemu/statfs.h | 19 +++++++++++++++++++ include/qemu/xattr.h | 4 +++- 5 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 include/qemu/statfs.h diff --git a/fsdev/file-op-9p.h b/fsdev/file-op-9p.h index 3fa062b..111f804 100644 --- a/fsdev/file-op-9p.h +++ b/fsdev/file-op-9p.h @@ -16,7 +16,7 @@ =20 #include #include -#include +#include "qemu/statfs.h" #include "qemu-fsdev-throttle.h" =20 #define SM_LOCAL_MODE_BITS 0600 diff --git a/fsdev/virtfs-proxy-helper.c b/fsdev/virtfs-proxy-helper.c index 6f132c5..94fb069 100644 --- a/fsdev/virtfs-proxy-helper.c +++ b/fsdev/virtfs-proxy-helper.c @@ -13,17 +13,19 @@ #include #include #include +#ifdef CONFIG_LINUX #include #include -#include #include #include #ifdef CONFIG_LINUX_MAGIC_H #include #endif +#endif #include "qemu-common.h" #include "qemu/sockets.h" #include "qemu/xattr.h" +#include "qemu/statfs.h" #include "9p-iov-marshal.h" #include "hw/9pfs/9p-proxy.h" #include "fsdev/9p-iov-marshal.h" diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index bcf2798..adc169a 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -27,10 +27,12 @@ #include "qemu/error-report.h" #include "qemu/option.h" #include +#ifdef CONFIG_LINUX #include #ifdef CONFIG_LINUX_MAGIC_H #include #endif +#endif #include =20 #ifndef XFS_SUPER_MAGIC diff --git a/include/qemu/statfs.h b/include/qemu/statfs.h new file mode 100644 index 0000000..dde289f --- /dev/null +++ b/include/qemu/statfs.h @@ -0,0 +1,19 @@ +/* + * Host statfs header abstraction + * + * This work is licensed under the terms of the GNU GPL, version 2, or any + * later version. See the COPYING file in the top-level directory. + * + */ +#ifndef QEMU_STATFS_H +#define QEMU_STATFS_H + +#ifdef CONFIG_LINUX +# include +#endif +#ifdef CONFIG_DARWIN +# include +# include +#endif + +#endif diff --git a/include/qemu/xattr.h b/include/qemu/xattr.h index a83fe8e..f1d0f7b 100644 --- a/include/qemu/xattr.h +++ b/include/qemu/xattr.h @@ -22,7 +22,9 @@ #ifdef CONFIG_LIBATTR # include #else -# define ENOATTR ENODATA +# if !defined(ENOATTR) +# define ENOATTR ENODATA +# endif # include #endif =20 --=20 2.8.1 From nobody Sun Feb 8 06:54:29 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1527816849642739.2050366061497; Thu, 31 May 2018 18:34:09 -0700 (PDT) Received: from localhost ([::1]:46912 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOYxE-0007N6-Ms for importer@patchew.org; Thu, 31 May 2018 21:34:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33305) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOYqu-0002xW-2B for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOYqt-0002vY-9C for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:36 -0400 Received: from mail-qt0-x230.google.com ([2607:f8b0:400d:c0d::230]:34667) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOYqt-0002v8-4X for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:35 -0400 Received: by mail-qt0-x230.google.com with SMTP id m5-v6so30317154qti.1 for ; Thu, 31 May 2018 18:27:35 -0700 (PDT) Received: from localhost.localdomain (96-86-104-61-static.hfc.comcastbusiness.net. [96.86.104.61]) by smtp.gmail.com with ESMTPSA id o68-v6sm2003842qkc.19.2018.05.31.18.27.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 31 May 2018 18:27:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=juliacomputing-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=p8zPs4iWTBqjU8a4XjcsjIL6xqMmB1ONcP18/0NsEPI=; b=haEROXKepbNQ0/kPX20txeZz0n8kNfdWRo1TSM925Hz+UGXrZ5im7JFecePqxdilUd PvTBsq8OXop6/e1rUBMyRmzVufIiupHeOa5BAj8LKu3ulOV4IxiwsEo4M4Jq33UXqkJw GtGSVlCR5+mJqrHj1bP05hcMegT+7YuJTMf4Z7C9JyPx+U4LIg+kuMcdZBa/vkxPm6dK BhBYuGAQyFzmIXsdCi4SkhNLN4EZI9421xMCzj7uasG+H7R0uH0wZC5ZAaMu5Xe06Kp6 5jC4qaWIwhIwOxgla1tdDPciNQNN/5i6xqE4JV3asZT0CyCwPkBGhMFWDyqR6bAgGH3J OqjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=p8zPs4iWTBqjU8a4XjcsjIL6xqMmB1ONcP18/0NsEPI=; b=XrONBQJ0Yk83aNKbY/65BvFJskSBTlQbqWoG4TSN3T5mf7XwxJBhYRq7Tm1PYGW8Tq x2rmsHXqrpdp6GW8jcwQ462pJ5MqYwhKXiPaoRU0TKS4Vodm2I1FuQFqYOF/GITo80yX l6QVH0eBzWBfN/OK0+J5ClTb7FoadvW4QhglBFvTTfcmZxD2unwmeXbK8WkzNc7xSsTM EOt8g7n0p+XAhUClE7vpvnRRz1FJpnKzDWns3YJVrhW639Jl6fPmId8jSDSZWrz+wB2o UB6gu8wlK0NNiWYYyXmU/XFvElTeLzebdMdK5yHd0g3VP+pDlzVQjnxVF0Tjzj3jiUw0 ExGw== X-Gm-Message-State: APt69E1rp/s3ZRpOhet8eZ6ap4TB0sVM4h450WeWSE/eRmuOJjvuL8lR E62/jNmnF8LBj0IPL8DEDL5pbXeP5gE= X-Google-Smtp-Source: ADUXVKJYvRkuSUicAa8EZ67L86ZsgqP+eHt7EhRSO48IgSulmgzQDHRw0WwOGClk8RKSp+jVP5cTNA== X-Received: by 2002:aed:3d92:: with SMTP id i18-v6mr9169763qtf.149.1527816454226; Thu, 31 May 2018 18:27:34 -0700 (PDT) From: Keno Fischer To: qemu-devel@nongnu.org Date: Thu, 31 May 2018 21:26:00 -0400 Message-Id: X-Mailer: git-send-email 2.8.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::230 Subject: [Qemu-devel] [PATCH v2 05/20] 9p: Properly set errp in fstatfs error path X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keno Fischer , groug@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" In the review of 9p: Avoid warning if FS_IOC_GETVERSION is not defined Grep Kurz noted this error path was failing to set errp. Fix that. Signed-off-by: Keno Fischer --- Changes since v1: New patch hw/9pfs/9p-local.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index adc169a..576c8e3 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -1420,6 +1420,8 @@ static int local_init(FsContext *ctx, Error **errp) */ if (fstatfs(data->mountfd, &stbuf) < 0) { close_preserve_errno(data->mountfd); + error_setg_errno(errp, errno, + "failed to stat file system at '%s'", ctx->fs_root); goto err; } switch (stbuf.f_type) { --=20 2.8.1 From nobody Sun Feb 8 06:54:29 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15278167877407.626520292665987; Thu, 31 May 2018 18:33:07 -0700 (PDT) Received: from localhost ([::1]:46909 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOYwA-0006dS-MT for importer@patchew.org; Thu, 31 May 2018 21:33:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33324) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOYqv-0002xc-H6 for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOYqu-0002x7-J9 for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:37 -0400 Received: from mail-qt0-x243.google.com ([2607:f8b0:400d:c0d::243]:39684) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOYqu-0002wq-FF for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:36 -0400 Received: by mail-qt0-x243.google.com with SMTP id p23-v6so5420032qtn.6 for ; Thu, 31 May 2018 18:27:36 -0700 (PDT) Received: from localhost.localdomain (96-86-104-61-static.hfc.comcastbusiness.net. [96.86.104.61]) by smtp.gmail.com with ESMTPSA id o68-v6sm2003842qkc.19.2018.05.31.18.27.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 31 May 2018 18:27:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=juliacomputing-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=pMnsnLDbSb64hFWTXM7nkBodAIa5H5oenqdRGktkS7M=; b=c6kXxciIJHK2LtmuDa0YNgIgldtZLKnQor53+ym8nE9LFgpdXHEsMDNiL0UpXcFXpC n0qIpZ5gQ0qdlpUZyEkUnEpnccekgGfAqNd4CcclW8hmRGkgWvIZYplRnf4H1TrpGWsh zgBPT0iONZ3fRy35km80l+vVetPcT3yGl76Os99+yy+B2PnV3j8+dxOIZx2z2Dym9Y/p I41CkOjMvFISfk4Mw1o/FqBZu2NcLwYQnvizekoiyIgIs38qa56CHTIe86O4d/Gn47D8 YqOlHneIjLdxUQefd9k5GVoKVzDd5QZ4BiPPF4twfBWDCMUtPt7OIMW45jj8+NJaAXir E0rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=pMnsnLDbSb64hFWTXM7nkBodAIa5H5oenqdRGktkS7M=; b=b2l8rjp2wkGKEfIqWpvLxShekzEllnzZEF9kzBUee+WvubaXXBkU/nAd0MjEDu9GcA CfvdtBj+nkFjngfjG+qc8RkTRufgOhJsH0WwwEZpwhPCoJVP6ZQxsoCzGI0QXc/TWsGP AWVo2lZ0faZuawqTN7IfYCEMpy/0qCssrMmWlygHvNblwDAnsMXMXxTq4VZ3//5MnubT N0ZkmVjUtTnR60Z57v8iINGMjwq/0yz2HHrQjIUKzO9lthf9s0RgRQDrTQmioeda836+ oYn46eqWHIE8VjFaUA6RaZaQzzXCY5HWZoitSg9DtNydFcDCychzCErOs4j6qVFX07Wo B6OQ== X-Gm-Message-State: APt69E3Asym/WQrdSHVH9Oh8RYqWzxdXa/X7yrponIBPrbPsGFDt1qmd jC4IseYqe8nF1f/V6iqtkiphHTzgXeg= X-Google-Smtp-Source: ADUXVKIleCVdEBXjp+631ZMuoV1mz2nvKuc3TRwIZ6UnoriR64qqG02TwXg7T9p5NwmczHZlnjmq/A== X-Received: by 2002:a0c:870a:: with SMTP id 10-v6mr8967571qvh.169.1527816455606; Thu, 31 May 2018 18:27:35 -0700 (PDT) From: Keno Fischer To: qemu-devel@nongnu.org Date: Thu, 31 May 2018 21:26:01 -0400 Message-Id: <0758699faca2ee5526d2b64e0a5fdda7e7845cbc.1527814874.git.keno@juliacomputing.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::243 Subject: [Qemu-devel] [PATCH v2 06/20] 9p: Avoid warning if FS_IOC_GETVERSION is not defined X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keno Fischer , groug@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Both `stbuf` and `local_ioc_getversion` where unused when FS_IOC_GETVERSION was not defined, causing a compiler warning. Reorgnaize the code to avoid this warning. Signed-off-by: Keno Fischer --- Changes since v1: * As request in review, logic is factored into a local_ioc_getversion_init function. hw/9pfs/9p-local.c | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index 576c8e3..6222891 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -1375,10 +1375,10 @@ static int local_unlinkat(FsContext *ctx, V9fsPath = *dir, return ret; } =20 +#ifdef FS_IOC_GETVERSION static int local_ioc_getversion(FsContext *ctx, V9fsPath *path, mode_t st_mode, uint64_t *st_gen) { -#ifdef FS_IOC_GETVERSION int err; V9fsFidOpenState fid_open; =20 @@ -1397,32 +1397,19 @@ static int local_ioc_getversion(FsContext *ctx, V9f= sPath *path, err =3D ioctl(fid_open.fd, FS_IOC_GETVERSION, st_gen); local_close(ctx, &fid_open); return err; -#else - errno =3D ENOTTY; - return -1; -#endif } +#endif =20 -static int local_init(FsContext *ctx, Error **errp) +static int local_ioc_getversion_init(FsContext *ctx, LocalData *data) { +#ifdef FS_IOC_GETVERSION struct statfs stbuf; - LocalData *data =3D g_malloc(sizeof(*data)); =20 - data->mountfd =3D open(ctx->fs_root, O_DIRECTORY | O_RDONLY); - if (data->mountfd =3D=3D -1) { - error_setg_errno(errp, errno, "failed to open '%s'", ctx->fs_root); - goto err; - } - -#ifdef FS_IOC_GETVERSION /* * use ioc_getversion only if the ioctl is definied */ if (fstatfs(data->mountfd, &stbuf) < 0) { - close_preserve_errno(data->mountfd); - error_setg_errno(errp, errno, - "failed to stat file system at '%s'", ctx->fs_root); - goto err; + return -1; } switch (stbuf.f_type) { case EXT2_SUPER_MAGIC: @@ -1433,6 +1420,26 @@ static int local_init(FsContext *ctx, Error **errp) break; } #endif + return 0; +} + +static int local_init(FsContext *ctx, Error **errp) +{ + LocalData *data =3D g_malloc(sizeof(*data)); + + data->mountfd =3D open(ctx->fs_root, O_DIRECTORY | O_RDONLY); + if (data->mountfd =3D=3D -1) { + error_setg_errno(errp, errno, "failed to open '%s'", ctx->fs_root); + goto err; + } + + if (local_ioc_getversion_init(ctx, data) < 0) { + close_preserve_errno(data->mountfd); + error_setg_errno(errp, errno, + "failed initialize ioc_getversion for file system at '%s'", + ctx->fs_root); + goto err; + } =20 if (ctx->export_flags & V9FS_SM_PASSTHROUGH) { ctx->xops =3D passthrough_xattr_ops; --=20 2.8.1 From nobody Sun Feb 8 06:54:29 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1527816927101606.3898488524568; Thu, 31 May 2018 18:35:27 -0700 (PDT) Received: from localhost ([::1]:46917 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOYyQ-0008G9-5M for importer@patchew.org; Thu, 31 May 2018 21:35:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33337) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOYqx-0002yk-Ug for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOYqw-0002zT-Gv for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:39 -0400 Received: from mail-qk0-x232.google.com ([2607:f8b0:400d:c09::232]:45558) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOYqw-0002z4-Bh for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:38 -0400 Received: by mail-qk0-x232.google.com with SMTP id c198-v6so18725321qkg.12 for ; Thu, 31 May 2018 18:27:38 -0700 (PDT) Received: from localhost.localdomain (96-86-104-61-static.hfc.comcastbusiness.net. [96.86.104.61]) by smtp.gmail.com with ESMTPSA id o68-v6sm2003842qkc.19.2018.05.31.18.27.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 31 May 2018 18:27:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=juliacomputing-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=/K+FKvBNps/a4B5+A2+Zx4W2/IBvsoRH15D/8qoQTK4=; b=lDe7rSi63w+ZnVHBR/bsrTNC26sHChy42oW0o3LJgRdqhKI5Edr1nyFA9mN4A6T2Cm yD5O2+k28CiYg837LUZ+ms2mQ7uXDuTS5lxOT+Nr52wlAIXsFNslYA+E1ZVrT0wnQ6yG rGHZYOAH0cCkC2hL66gp7SQOXoe1//xTd/CC7RIUOr/D2Xlbtrr2yNtfUmTnj+LMHxkp A++V1yV7crzLqT9DEAkC+Io1zvFgY+bOIzSdlVlPiKn6J0GDwCOCwipJ0IvYElaXam0Q ZfZK8f45FdNkvDCYq7ADn7OG+dgpqzz+UZG/XJYCvaRFBkOouBDIIUv/BQS6unFGx9oa bksA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=/K+FKvBNps/a4B5+A2+Zx4W2/IBvsoRH15D/8qoQTK4=; b=Ogf9n/ti6bXuT8xml1p3pkDo21CKdjt8YlkFXZNUfmzulaBXQv0v3OdFpqRn/P2oR9 anGDn6os2X3gyP9r/fVDa7dmrlOMbGaufq8n6bfFrEYTGXFrWRYCVNmnZcxyTCbucOOu rmgeGEfmi3AwNRVDnz5TxgtBcfYJyAQ+UQJsXvNVhZg3rrwF1amQM3i5l1nnvi3J1U7/ KatuO+894sorKFvKqxWwRji01rtRhXxPqFy72XmTilUVsokBcj0OTKckDuDegMSWu0rF hGCW+8kW0nYxtFcRylRsNhICuhnEaO5hYnP/UbNfd//1aOWxfwax8X4dp8zfeGh5DRXL Snvg== X-Gm-Message-State: APt69E1sXKymJk5UF5QBUqhOwg02+DbdCE4ipvTAGQcqwrPkU9TcPc+G X51KRHvdI8n+xj/c0r3eRHgO//lvNZc= X-Google-Smtp-Source: ADUXVKIRFlPOU4ARk3ZRSllZq/47mO3lZa5fbcfKEhXgSqFzu0FKEu3EeEaJFNqLtOlY6SmBC6ofrA== X-Received: by 2002:a37:3147:: with SMTP id x68-v6mr8500043qkx.358.1527816457389; Thu, 31 May 2018 18:27:37 -0700 (PDT) From: Keno Fischer To: qemu-devel@nongnu.org Date: Thu, 31 May 2018 21:26:02 -0400 Message-Id: X-Mailer: git-send-email 2.8.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::232 Subject: [Qemu-devel] [PATCH v2 07/20] 9p: Move a couple xattr functions to 9p-util X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keno Fischer , groug@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" These functions will need custom implementations on Darwin. Since the implementation is very similar among all of them, and 9p-util already has the _nofollow version of fgetxattrat, let's move them all there. Signed-off-by: Keno Fischer --- Changes since v1: * fgetxattr_follow is dropped in favor of a different approach later in the series. hw/9pfs/9p-util.c | 33 +++++++++++++++++++++++++++++++++ hw/9pfs/9p-util.h | 4 ++++ hw/9pfs/9p-xattr.c | 33 --------------------------------- 3 files changed, 37 insertions(+), 33 deletions(-) diff --git a/hw/9pfs/9p-util.c b/hw/9pfs/9p-util.c index f709c27..614b7fc 100644 --- a/hw/9pfs/9p-util.c +++ b/hw/9pfs/9p-util.c @@ -24,3 +24,36 @@ ssize_t fgetxattrat_nofollow(int dirfd, const char *file= name, const char *name, g_free(proc_path); return ret; } + +ssize_t flistxattrat_nofollow(int dirfd, const char *filename, + char *list, size_t size) +{ + char *proc_path =3D g_strdup_printf("/proc/self/fd/%d/%s", dirfd, file= name); + int ret; + + ret =3D llistxattr(proc_path, list, size); + g_free(proc_path); + return ret; +} + +ssize_t fremovexattrat_nofollow(int dirfd, const char *filename, + const char *name) +{ + char *proc_path =3D g_strdup_printf("/proc/self/fd/%d/%s", dirfd, file= name); + int ret; + + ret =3D lremovexattr(proc_path, name); + g_free(proc_path); + return ret; +} + +int fsetxattrat_nofollow(int dirfd, const char *filename, const char *name, + void *value, size_t size, int flags) +{ + char *proc_path =3D g_strdup_printf("/proc/self/fd/%d/%s", dirfd, file= name); + int ret; + + ret =3D lsetxattr(proc_path, name, value, size, flags); + g_free(proc_path); + return ret; +} diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index dc0d2e2..79ed6b2 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -60,5 +60,9 @@ ssize_t fgetxattrat_nofollow(int dirfd, const char *path,= const char *name, void *value, size_t size); int fsetxattrat_nofollow(int dirfd, const char *path, const char *name, void *value, size_t size, int flags); +ssize_t flistxattrat_nofollow(int dirfd, const char *filename, + char *list, size_t size); +ssize_t fremovexattrat_nofollow(int dirfd, const char *filename, + const char *name); =20 #endif diff --git a/hw/9pfs/9p-xattr.c b/hw/9pfs/9p-xattr.c index d05c1a1..c696d8f 100644 --- a/hw/9pfs/9p-xattr.c +++ b/hw/9pfs/9p-xattr.c @@ -60,17 +60,6 @@ ssize_t pt_listxattr(FsContext *ctx, const char *path, return name_size; } =20 -static ssize_t flistxattrat_nofollow(int dirfd, const char *filename, - char *list, size_t size) -{ - char *proc_path =3D g_strdup_printf("/proc/self/fd/%d/%s", dirfd, file= name); - int ret; - - ret =3D llistxattr(proc_path, list, size); - g_free(proc_path); - return ret; -} - /* * Get the list and pass to each layer to find out whether * to send the data or not @@ -196,17 +185,6 @@ ssize_t pt_getxattr(FsContext *ctx, const char *path, = const char *name, return local_getxattr_nofollow(ctx, path, name, value, size); } =20 -int fsetxattrat_nofollow(int dirfd, const char *filename, const char *name, - void *value, size_t size, int flags) -{ - char *proc_path =3D g_strdup_printf("/proc/self/fd/%d/%s", dirfd, file= name); - int ret; - - ret =3D lsetxattr(proc_path, name, value, size, flags); - g_free(proc_path); - return ret; -} - ssize_t local_setxattr_nofollow(FsContext *ctx, const char *path, const char *name, void *value, size_t size, int flags) @@ -235,17 +213,6 @@ int pt_setxattr(FsContext *ctx, const char *path, cons= t char *name, void *value, return local_setxattr_nofollow(ctx, path, name, value, size, flags); } =20 -static ssize_t fremovexattrat_nofollow(int dirfd, const char *filename, - const char *name) -{ - char *proc_path =3D g_strdup_printf("/proc/self/fd/%d/%s", dirfd, file= name); - int ret; - - ret =3D lremovexattr(proc_path, name); - g_free(proc_path); - return ret; -} - ssize_t local_removexattr_nofollow(FsContext *ctx, const char *path, const char *name) { --=20 2.8.1 From nobody Sun Feb 8 06:54:29 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1527816978475349.749797968808; Thu, 31 May 2018 18:36:18 -0700 (PDT) Received: from localhost ([::1]:46928 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOYzJ-0000e9-JN for importer@patchew.org; Thu, 31 May 2018 21:36:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33358) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOYr2-00032l-El for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOYqy-00031O-2l for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:44 -0400 Received: from mail-qt0-x242.google.com ([2607:f8b0:400d:c0d::242]:33781) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOYqx-00030m-Th for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:39 -0400 Received: by mail-qt0-x242.google.com with SMTP id e8-v6so30315164qth.0 for ; Thu, 31 May 2018 18:27:39 -0700 (PDT) Received: from localhost.localdomain (96-86-104-61-static.hfc.comcastbusiness.net. [96.86.104.61]) by smtp.gmail.com with ESMTPSA id o68-v6sm2003842qkc.19.2018.05.31.18.27.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 31 May 2018 18:27:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=juliacomputing-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=0kfBeqSC6bMbymBCvOqHOirFVLO38eL6EEW5yH7t0VA=; b=TZvZmG2vydwPWfcqtAhsRNf7hYUERPSfqWwAMzrVw0jnKWNmrBFL6UXKrICeMl/p83 UCsDNgPmruj5UI9D13tNYl6k81YUaw4eZjtc4GiVBl2FCRfOZDl86chnlJ+zDRPOszY/ afZ08Rkbp02L1wGvCk9Oco4dwKL2DPfAr7yGMyKy8Y5FciI2q/irKVmPzrd8YrIY2JkN axE++FOveNZOuiVAqw39T8ujfk31KMY69c/qrGFdPIPn7S4o2kdMRT6ifMoMOLSiUxIb OxFgOEndGHMoAe4mCDyq3PArBQsIAg5X5a/FvDbyrEWqE+YqaqX1WfGx323kAW8UC4uk 7PGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=0kfBeqSC6bMbymBCvOqHOirFVLO38eL6EEW5yH7t0VA=; b=NUynbrekva5rUFYKqL3Np9AgcZB8j0OfKKZlBf01HMt4aNtp5RXzI2Ler26reYK23R 5h+3R0mHg9FiJN6ScMpSXPEnXCgM3dPVrZeDFyqOfF7AphfeQwC88pCMxyXiwT6arCoZ bI7WVBS/ZFGEdlyWr0ZlSD3gwuIY7DDwGdOV6YsBHMU8OPC3SK9csI/Fg/HbGvR2DgJk JsarjqOdYGaj1ponHWxnoR4FfGLjaTpzCu+YbqaDF3aoR/K8c7q4EXfZO/7NLGoc7dUs sT+kcY1Txy0pcTl6Uv3NK5IKXPeVpQBrXf322BIcUpb8Ngr6j5aEC2gxZykScKscKc7M 6U+A== X-Gm-Message-State: APt69E2DeiQYKDeAO40uZfBHX12qEDNxbyDDa4uIqSK8blfTCV0Q/+5O qwuCZvHlvkdElaaiipwlFKIvGgjbH1M= X-Google-Smtp-Source: ADUXVKIJTJGcPEuI7uTsuKeMpJbnJ+yb4zy3RU6cCN0O8cs0PQNT8ycXERkTmFeM1bfhUaqtI95WRQ== X-Received: by 2002:a0c:9805:: with SMTP id c5-v6mr8765516qvd.9.1527816459034; Thu, 31 May 2018 18:27:39 -0700 (PDT) From: Keno Fischer To: qemu-devel@nongnu.org Date: Thu, 31 May 2018 21:26:03 -0400 Message-Id: <667649d1ce2e1a948a5be1103a21cb495eff2c13.1527814874.git.keno@juliacomputing.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::242 Subject: [Qemu-devel] [PATCH v2 08/20] 9p: Rename 9p-util -> 9p-util-linux X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keno Fischer , groug@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The current file only has the Linux versions of these functions. Rename the file accordingly and update the Makefile to only build it on Linux. A Darwin version of these will follow later in the series. Signed-off-by: Keno Fischer Reviewed-by: Greg Kurz --- Changes since v1: New patch hw/9pfs/9p-util-linux.c | 59 +++++++++++++++++++++++++++++++++++++++++++++= ++++ hw/9pfs/9p-util.c | 59 ---------------------------------------------= ---- hw/9pfs/Makefile.objs | 3 ++- 3 files changed, 61 insertions(+), 60 deletions(-) create mode 100644 hw/9pfs/9p-util-linux.c delete mode 100644 hw/9pfs/9p-util.c diff --git a/hw/9pfs/9p-util-linux.c b/hw/9pfs/9p-util-linux.c new file mode 100644 index 0000000..defa3a4 --- /dev/null +++ b/hw/9pfs/9p-util-linux.c @@ -0,0 +1,59 @@ +/* + * 9p utilities (Linux Implementation) + * + * Copyright IBM, Corp. 2017 + * + * Authors: + * Greg Kurz + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "qemu/xattr.h" +#include "9p-util.h" + +ssize_t fgetxattrat_nofollow(int dirfd, const char *filename, const char *= name, + void *value, size_t size) +{ + char *proc_path =3D g_strdup_printf("/proc/self/fd/%d/%s", dirfd, file= name); + int ret; + + ret =3D lgetxattr(proc_path, name, value, size); + g_free(proc_path); + return ret; +} + +ssize_t flistxattrat_nofollow(int dirfd, const char *filename, + char *list, size_t size) +{ + char *proc_path =3D g_strdup_printf("/proc/self/fd/%d/%s", dirfd, file= name); + int ret; + + ret =3D llistxattr(proc_path, list, size); + g_free(proc_path); + return ret; +} + +ssize_t fremovexattrat_nofollow(int dirfd, const char *filename, + const char *name) +{ + char *proc_path =3D g_strdup_printf("/proc/self/fd/%d/%s", dirfd, file= name); + int ret; + + ret =3D lremovexattr(proc_path, name); + g_free(proc_path); + return ret; +} + +int fsetxattrat_nofollow(int dirfd, const char *filename, const char *name, + void *value, size_t size, int flags) +{ + char *proc_path =3D g_strdup_printf("/proc/self/fd/%d/%s", dirfd, file= name); + int ret; + + ret =3D lsetxattr(proc_path, name, value, size, flags); + g_free(proc_path); + return ret; +} diff --git a/hw/9pfs/9p-util.c b/hw/9pfs/9p-util.c deleted file mode 100644 index 614b7fc..0000000 --- a/hw/9pfs/9p-util.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 9p utilities - * - * Copyright IBM, Corp. 2017 - * - * Authors: - * Greg Kurz - * - * This work is licensed under the terms of the GNU GPL, version 2 or late= r. - * See the COPYING file in the top-level directory. - */ - -#include "qemu/osdep.h" -#include "qemu/xattr.h" -#include "9p-util.h" - -ssize_t fgetxattrat_nofollow(int dirfd, const char *filename, const char *= name, - void *value, size_t size) -{ - char *proc_path =3D g_strdup_printf("/proc/self/fd/%d/%s", dirfd, file= name); - int ret; - - ret =3D lgetxattr(proc_path, name, value, size); - g_free(proc_path); - return ret; -} - -ssize_t flistxattrat_nofollow(int dirfd, const char *filename, - char *list, size_t size) -{ - char *proc_path =3D g_strdup_printf("/proc/self/fd/%d/%s", dirfd, file= name); - int ret; - - ret =3D llistxattr(proc_path, list, size); - g_free(proc_path); - return ret; -} - -ssize_t fremovexattrat_nofollow(int dirfd, const char *filename, - const char *name) -{ - char *proc_path =3D g_strdup_printf("/proc/self/fd/%d/%s", dirfd, file= name); - int ret; - - ret =3D lremovexattr(proc_path, name); - g_free(proc_path); - return ret; -} - -int fsetxattrat_nofollow(int dirfd, const char *filename, const char *name, - void *value, size_t size, int flags) -{ - char *proc_path =3D g_strdup_printf("/proc/self/fd/%d/%s", dirfd, file= name); - int ret; - - ret =3D lsetxattr(proc_path, name, value, size, flags); - g_free(proc_path); - return ret; -} diff --git a/hw/9pfs/Makefile.objs b/hw/9pfs/Makefile.objs index fd90b62..083508f 100644 --- a/hw/9pfs/Makefile.objs +++ b/hw/9pfs/Makefile.objs @@ -1,4 +1,5 @@ -common-obj-y =3D 9p.o 9p-util.o +common-obj-y =3D 9p.o +common-obj-$(CONFIG_LINUX) +=3D 9p-util-linux.o common-obj-y +=3D 9p-local.o 9p-xattr.o common-obj-y +=3D 9p-xattr-user.o 9p-posix-acl.o common-obj-y +=3D coth.o cofs.o codir.o cofile.o --=20 2.8.1 From nobody Sun Feb 8 06:54:29 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 152781711638193.23344657526536; Thu, 31 May 2018 18:38:36 -0700 (PDT) Received: from localhost ([::1]:46937 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOZ1W-0002KC-9s for importer@patchew.org; Thu, 31 May 2018 21:38:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33362) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOYr3-00033n-3n for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOYqz-000333-L5 for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:45 -0400 Received: from mail-qk0-x241.google.com ([2607:f8b0:400d:c09::241]:42727) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOYqz-00032X-GU for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:41 -0400 Received: by mail-qk0-x241.google.com with SMTP id j80-v6so16999940qke.9 for ; Thu, 31 May 2018 18:27:41 -0700 (PDT) Received: from localhost.localdomain (96-86-104-61-static.hfc.comcastbusiness.net. [96.86.104.61]) by smtp.gmail.com with ESMTPSA id o68-v6sm2003842qkc.19.2018.05.31.18.27.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 31 May 2018 18:27:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=juliacomputing-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=uFwA25ae3YVoMkhsDHZIq6dK58QiW7McLaLJNiZgJrc=; b=Mn2CGYZtEibKqpmlQjnLJYaEUr9xO975g16ndO7+BY4jDxlk29lzbviXpkAwepJmHa Z2WIXAy28WW1dUX/u/ECFjGDZAUz+r5iJQoQCeMYUJ6n7Z8C25KxpJG2ZO8Kd9tjKJM3 3WKeO6E0Fd7wuL0pbDZOzFlLe8lWwr4MR0JWaxY2U6PXYWH4OreQhL/sgtduAv1nGd1H CeM30CZ2DZtwK1puaHXDeGMwhCy8xcUFipwrfceHDKs/2Z5JWSkdHl/rftYKWwudfzsV MChhbntQFh363+2avOY8mC6QFPyfs9Z9j1wzsM2QrK93exn7lNgnCfXu2FUPSssXzucH S4EQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=uFwA25ae3YVoMkhsDHZIq6dK58QiW7McLaLJNiZgJrc=; b=caTzjBdZf3Vv1tqfZv7HEB6oMXuGWiOjwHvwSwF9Llht7kMTyJXszlmLeeHcnoLtwm e+tqPnfgaQ+K/1aKfQK8FnXXRd2NEKM4MRMzUIQZkFRrw1Knuxk/UVUZWT8+f7BOFt+t XHNtCdHk1ljPBhTKlwB06G+nJ65mLhH72TZZcU+ddf1Vdga5s4IU4eTLORIKZqlH6iZf 5gV6WssfBrWSfE8n9Ujt7xw/fgdG8uOlQJLPDb7UC89iA/XjaTs7cbssxzGICxUy8sff nXf/TttVxWfbsG3BOskj4SsPNIAdKkCCgVyyNNsY6FQ3pB8R9zntzqFWDBaF8pbbnwg3 2l6A== X-Gm-Message-State: APt69E14cjVmNs90x3+kgfQ8v7afnpN8/CERyAGNSA+zelG1qsyIj3Ay +9kNxL8RVupbjwh4lTUX4bC+yvIi84g= X-Google-Smtp-Source: ADUXVKKScA2BX51wlSOJWdUD1kE5JwwtUtKzdjqXgueGYnQ5LBDBLqNFeXGoCEMaxiVrwpy44KheNQ== X-Received: by 2002:a37:a8ce:: with SMTP id r197-v6mr8172141qke.93.1527816460607; Thu, 31 May 2018 18:27:40 -0700 (PDT) From: Keno Fischer To: qemu-devel@nongnu.org Date: Thu, 31 May 2018 21:26:04 -0400 Message-Id: <21ef05f216f09056c252d2d23a18dd75008e8c72.1527814874.git.keno@juliacomputing.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::241 Subject: [Qemu-devel] [PATCH v2 09/20] 9p: Properly check/translate flags in unlinkat X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keno Fischer , groug@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This code previously relied on P9_DOTL_AT_REMOVEDIR and AT_REMOVEDIR having the same numerical value and deferred any errorchecking to the syscall itself. However, while the former assumption is true on Linux, it is not true in general. Thus, add appropriate error checking and translation to the 9p unlinkat server code. Signed-off-by: Keno Fischer --- Changes since v1: * Code was moved from 9p-local.c to server entry point in 9p.c hw/9pfs/9p.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index b80db65..a757374 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -2522,7 +2522,7 @@ static void coroutine_fn v9fs_unlinkat(void *opaque) { int err =3D 0; V9fsString name; - int32_t dfid, flags; + int32_t dfid, flags, rflags =3D 0; size_t offset =3D 7; V9fsPath path; V9fsFidState *dfidp; @@ -2549,6 +2549,15 @@ static void coroutine_fn v9fs_unlinkat(void *opaque) goto out_nofid; } =20 + if (flags & ~P9_DOTL_AT_REMOVEDIR) { + err =3D -EINVAL; + goto out_nofid; + } + + if (flags & P9_DOTL_AT_REMOVEDIR) { + rflags |=3D AT_REMOVEDIR; + } + dfidp =3D get_fid(pdu, dfid); if (dfidp =3D=3D NULL) { err =3D -EINVAL; @@ -2567,7 +2576,7 @@ static void coroutine_fn v9fs_unlinkat(void *opaque) if (err < 0) { goto out_err; } - err =3D v9fs_co_unlinkat(pdu, &dfidp->path, &name, flags); + err =3D v9fs_co_unlinkat(pdu, &dfidp->path, &name, rflags); if (!err) { err =3D offset; } --=20 2.8.1 From nobody Sun Feb 8 06:54:29 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1527817170818407.2105628412936; Thu, 31 May 2018 18:39:30 -0700 (PDT) Received: from localhost ([::1]:46941 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOZ2M-000307-Sr for importer@patchew.org; Thu, 31 May 2018 21:39:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33361) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOYr3-00033l-3Q for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOYr1-00034X-1q for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:45 -0400 Received: from mail-qk0-x244.google.com ([2607:f8b0:400d:c09::244]:32772) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOYr0-000348-SC for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:42 -0400 Received: by mail-qk0-x244.google.com with SMTP id h7-v6so11577115qkm.0 for ; Thu, 31 May 2018 18:27:42 -0700 (PDT) Received: from localhost.localdomain (96-86-104-61-static.hfc.comcastbusiness.net. [96.86.104.61]) by smtp.gmail.com with ESMTPSA id o68-v6sm2003842qkc.19.2018.05.31.18.27.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 31 May 2018 18:27:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=juliacomputing-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=7rOcwMMLBYxlFhZR6LiH7C46Zpzdyri90EpUDCKW6C0=; b=khmaPiB1pw59N7NfxWX6Nh89OIuf+MK0B08b7sLHSc599QcOzc8ywK5BNWjcnfamqB TAJ3kalFBti7w1oAsBxhgE1PnuPUY9x/rrJylqSYqPLK2v4M5xhCtlfeRPRzWVapya9L 6lvJEjsbeKP5lEaA7mMN57RNEjL93G52Kcxv4QpRoZpKDUZxetQHT3OskaYFn3UG8k7n ZzY+yOX9r2Slz9kLmeNGXlIQFO/3HAp1xe6FYAhm/rlP2zB66ReHS2YEXBPWRn9L4VQR WrCsByjGYi2QlP7PX+f/A2IDKYzoenIlF2K0WUV9NTflSWZn3ALt4+4hxxHDWP/Gwu3L U3Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=7rOcwMMLBYxlFhZR6LiH7C46Zpzdyri90EpUDCKW6C0=; b=BLQEEvJzf13caMyPfQuIKsz01RvGi0ZlZP5OWsGzpwu/lSwc4IGurqHA1UpMY46kny I1zI5pS+zQhzeFgwV5Z0pbbNo8y47WoQzDCMOutKj9woQaK2z09SmQDejMCHwDD6INHs GNCD8rsOL7DqeVE4s5TRww97Z256YxhmPAsmN3KlMVrjg4tjwrL0bToi63V+/h7IwSjM a1X6g2Vj8LRg89A+5E7bD+wBrvOGaONThmgWKf67ew4XMFHtRpF1RBxNACLfLCTJ/rXW KucaE7kX2ewu9+TC3DeDe1kR6Z63lYRWApIfG2dpp/MvbHa+GjgP0EFr9Tqkj0/elusK RTOw== X-Gm-Message-State: APt69E1oYi3SmmQbPZ4oM/sPsZa7EKK76mhV6nmqehPesay1vdXUUMB0 bCT98Hvguv7XtXSp9HxtxAjRr6sAiZ0= X-Google-Smtp-Source: ADUXVKJWK/E56s30P9b3cuZzbyVHkF2c5+8frmS8QV0085latb/hdcKbCwUR4XpCOUHAmQmtHv6Img== X-Received: by 2002:a37:4788:: with SMTP id u130-v6mr8815848qka.301.1527816461907; Thu, 31 May 2018 18:27:41 -0700 (PDT) From: Keno Fischer To: qemu-devel@nongnu.org Date: Thu, 31 May 2018 21:26:05 -0400 Message-Id: <0257b0ef53ac4c12f1ca29a86b2ff3276853be32.1527814874.git.keno@juliacomputing.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::244 Subject: [Qemu-devel] [PATCH v2 10/20] 9p: darwin: Handle struct stat(fs) differences X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keno Fischer , groug@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Keno Fischer --- Changes since v1: * Now also covers fsdev/virtfs-proxy-helper.c fsdev/virtfs-proxy-helper.c | 14 +++++++++++--- hw/9pfs/9p-proxy.c | 17 ++++++++++++++--- hw/9pfs/9p-synth.c | 2 ++ hw/9pfs/9p.c | 16 ++++++++++++++-- 4 files changed, 41 insertions(+), 8 deletions(-) diff --git a/fsdev/virtfs-proxy-helper.c b/fsdev/virtfs-proxy-helper.c index 94fb069..3bc1269 100644 --- a/fsdev/virtfs-proxy-helper.c +++ b/fsdev/virtfs-proxy-helper.c @@ -506,12 +506,15 @@ static void stat_to_prstat(ProxyStat *pr_stat, struct= stat *stat) pr_stat->st_size =3D stat->st_size; pr_stat->st_blksize =3D stat->st_blksize; pr_stat->st_blocks =3D stat->st_blocks; +#ifdef CONFIG_DARWIN + pr_stat->st_atim_nsec =3D stat->st_atimespec.tv_nsec; + pr_stat->st_mtim_nsec =3D stat->st_mtimespec.tv_nsec; + pr_stat->st_ctim_nsec =3D stat->st_ctimespec.tv_nsec; +#else pr_stat->st_atim_sec =3D stat->st_atim.tv_sec; - pr_stat->st_atim_nsec =3D stat->st_atim.tv_nsec; pr_stat->st_mtim_sec =3D stat->st_mtim.tv_sec; - pr_stat->st_mtim_nsec =3D stat->st_mtim.tv_nsec; pr_stat->st_ctim_sec =3D stat->st_ctim.tv_sec; - pr_stat->st_ctim_nsec =3D stat->st_ctim.tv_nsec; +#endif } =20 static void statfs_to_prstatfs(ProxyStatFS *pr_stfs, struct statfs *stfs) @@ -524,10 +527,15 @@ static void statfs_to_prstatfs(ProxyStatFS *pr_stfs, = struct statfs *stfs) pr_stfs->f_bavail =3D stfs->f_bavail; pr_stfs->f_files =3D stfs->f_files; pr_stfs->f_ffree =3D stfs->f_ffree; +#ifdef CONFIG_DARWIN + pr_stfs->f_fsid[0] =3D stfs->f_fsid.val[0]; + pr_stfs->f_fsid[1] =3D stfs->f_fsid.val[1]; +#else pr_stfs->f_fsid[0] =3D stfs->f_fsid.__val[0]; pr_stfs->f_fsid[1] =3D stfs->f_fsid.__val[1]; pr_stfs->f_namelen =3D stfs->f_namelen; pr_stfs->f_frsize =3D stfs->f_frsize; +#endif } =20 /* diff --git a/hw/9pfs/9p-proxy.c b/hw/9pfs/9p-proxy.c index 47a94e0..8a2c174 100644 --- a/hw/9pfs/9p-proxy.c +++ b/hw/9pfs/9p-proxy.c @@ -117,10 +117,15 @@ static void prstatfs_to_statfs(struct statfs *stfs, P= roxyStatFS *prstfs) stfs->f_bavail =3D prstfs->f_bavail; stfs->f_files =3D prstfs->f_files; stfs->f_ffree =3D prstfs->f_ffree; +#ifdef CONFIG_DARWIN + stfs->f_fsid.val[0] =3D prstfs->f_fsid[0] & 0xFFFFFFFFU; + stfs->f_fsid.val[1] =3D prstfs->f_fsid[1] >> 32 & 0xFFFFFFFFU; +#else stfs->f_fsid.__val[0] =3D prstfs->f_fsid[0] & 0xFFFFFFFFU; stfs->f_fsid.__val[1] =3D prstfs->f_fsid[1] >> 32 & 0xFFFFFFFFU; stfs->f_namelen =3D prstfs->f_namelen; stfs->f_frsize =3D prstfs->f_frsize; +#endif } =20 /* Converts proxy_stat structure to VFS stat structure */ @@ -137,12 +142,18 @@ static void prstat_to_stat(struct stat *stbuf, ProxyS= tat *prstat) stbuf->st_size =3D prstat->st_size; stbuf->st_blksize =3D prstat->st_blksize; stbuf->st_blocks =3D prstat->st_blocks; - stbuf->st_atim.tv_sec =3D prstat->st_atim_sec; - stbuf->st_atim.tv_nsec =3D prstat->st_atim_nsec; + stbuf->st_atime =3D prstat->st_atim_sec; stbuf->st_mtime =3D prstat->st_mtim_sec; - stbuf->st_mtim.tv_nsec =3D prstat->st_mtim_nsec; stbuf->st_ctime =3D prstat->st_ctim_sec; +#ifdef CONFIG_DARWIN + stbuf->st_atimespec.tv_nsec =3D prstat->st_atim_nsec; + stbuf->st_mtimespec.tv_nsec =3D prstat->st_mtim_nsec; + stbuf->st_ctimespec.tv_nsec =3D prstat->st_ctim_nsec; +#else + stbuf->st_atim.tv_nsec =3D prstat->st_atim_nsec; + stbuf->st_mtim.tv_nsec =3D prstat->st_mtim_nsec; stbuf->st_ctim.tv_nsec =3D prstat->st_ctim_nsec; +#endif } =20 /* diff --git a/hw/9pfs/9p-synth.c b/hw/9pfs/9p-synth.c index 54239c9..eb68b42 100644 --- a/hw/9pfs/9p-synth.c +++ b/hw/9pfs/9p-synth.c @@ -426,7 +426,9 @@ static int synth_statfs(FsContext *s, V9fsPath *fs_path, stbuf->f_bsize =3D 512; stbuf->f_blocks =3D 0; stbuf->f_files =3D synth_node_count; +#ifndef CONFIG_DARWIN stbuf->f_namelen =3D NAME_MAX; +#endif return 0; } =20 diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index a757374..212f569 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -905,11 +905,17 @@ static void stat_to_v9stat_dotl(V9fsState *s, const s= truct stat *stbuf, v9lstat->st_blksize =3D stbuf->st_blksize; v9lstat->st_blocks =3D stbuf->st_blocks; v9lstat->st_atime_sec =3D stbuf->st_atime; - v9lstat->st_atime_nsec =3D stbuf->st_atim.tv_nsec; v9lstat->st_mtime_sec =3D stbuf->st_mtime; - v9lstat->st_mtime_nsec =3D stbuf->st_mtim.tv_nsec; v9lstat->st_ctime_sec =3D stbuf->st_ctime; +#ifdef CONFIG_DARWIN + v9lstat->st_atime_nsec =3D stbuf->st_atimespec.tv_nsec; + v9lstat->st_mtime_nsec =3D stbuf->st_mtimespec.tv_nsec; + v9lstat->st_ctime_nsec =3D stbuf->st_ctimespec.tv_nsec; +#else + v9lstat->st_atime_nsec =3D stbuf->st_atim.tv_nsec; + v9lstat->st_mtime_nsec =3D stbuf->st_mtim.tv_nsec; v9lstat->st_ctime_nsec =3D stbuf->st_ctim.tv_nsec; +#endif /* Currently we only support BASIC fields in stat */ v9lstat->st_result_mask =3D P9_STATS_BASIC; =20 @@ -2959,9 +2965,15 @@ static int v9fs_fill_statfs(V9fsState *s, V9fsPDU *p= du, struct statfs *stbuf) f_bavail =3D stbuf->f_bavail/bsize_factor; f_files =3D stbuf->f_files; f_ffree =3D stbuf->f_ffree; +#ifdef CONFIG_DARWIN + fsid_val =3D (unsigned int)stbuf->f_fsid.val[0] | + (unsigned long long)stbuf->f_fsid.val[1] << 32; + f_namelen =3D MAXNAMLEN; +#else fsid_val =3D (unsigned int) stbuf->f_fsid.__val[0] | (unsigned long long)stbuf->f_fsid.__val[1] << 32; f_namelen =3D stbuf->f_namelen; +#endif =20 return pdu_marshal(pdu, offset, "ddqqqqqqd", f_type, f_bsize, f_blocks, f_bfree, --=20 2.8.1 From nobody Sun Feb 8 06:54:29 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1527816787573426.3678534712582; Thu, 31 May 2018 18:33:07 -0700 (PDT) Received: from localhost ([::1]:46910 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOYwE-0006eP-Kg for importer@patchew.org; Thu, 31 May 2018 21:33:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33379) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOYr3-00034Q-Pw for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOYr2-00036J-K6 for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:45 -0400 Received: from mail-qk0-x241.google.com ([2607:f8b0:400d:c09::241]:40686) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOYr2-00035u-FV for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:44 -0400 Received: by mail-qk0-x241.google.com with SMTP id r66-v6so18731601qkr.7 for ; Thu, 31 May 2018 18:27:44 -0700 (PDT) Received: from localhost.localdomain (96-86-104-61-static.hfc.comcastbusiness.net. [96.86.104.61]) by smtp.gmail.com with ESMTPSA id o68-v6sm2003842qkc.19.2018.05.31.18.27.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 31 May 2018 18:27:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=juliacomputing-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=L68nHRkEn0HuX90KY/3eElE7cAN+upBxcoYsXFPKTUQ=; b=xkRjBYTu5v0PGwaE2QZ2ekB2duNJyr233s35RQ4hsABaRAUZ9fh66YZDGGJdULYth7 tts1HM7jL81dXi7T4AgT8iyb5mqOtquqLuIMd1zBTqnPHsqKaggb/NaxZ4J0QVKzqJdK 9SZeg7xbQVL4E7NY+mGKo2zyT/tJkzaTqh+mW2bx5oGcAfqa8HEmTtR6vVGb2pEAbbco o8WRgoiW+d1EScmZ6Joo91mBcAy0/PG7HlvHj6Ip8vUZwYR5C7HTWXofzyuOAtyJ+IBJ 1hhU/H9fPSQHO4/u8PPPaq+EC9x3X4odCFe/GboN0GRgxQEFd4gFiQhvqzskC6Gp/AK+ 3mcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=L68nHRkEn0HuX90KY/3eElE7cAN+upBxcoYsXFPKTUQ=; b=BnVUrqKIxssUa7bLEwuCUrBunfQntQT1KPiMKY4iPfbTHj8QoEEsWJ+qppnQfiAi/T JY3tN6rFV4YrhO3Aik5LHGnVlRi6uEgEfKhhrRsHSKpfYGVUA4Pd5wQFvR5aK/0rNEkg t/Lbv6emgsIhZgPNO7zcWNEI5st0oMr+/gekF05nO2n64e/RbA2V9khTTvyxrS9dmtAE fLjsxoN/jp4wn44yIJGWkF48ZOSRQI6BBZypFsY+VRtB54ZZqDqsBYjtplfWV9fVVQd4 BI19orSdDGD03SHz0zzKLxmdtaU1zlDLWtfsj5OFBRSRXL1SdK0T+Q9lytcyV2b/ey7H q7RQ== X-Gm-Message-State: APt69E1a60TIRWArHhQ0g29QXKAqYH1BirL0pySZuJScmLvPZuj3RU8e ZSKObKnOFBDb93BTzCTne48AyOmYTKY= X-Google-Smtp-Source: ADUXVKK689UuPk64os+cYfW+uOMymUyHtg+AtSmFDpEiYvOh9zThsozeg5v7ozhk2TdR9siOynrraw== X-Received: by 2002:a37:8b07:: with SMTP id n7-v6mr4112161qkd.353.1527816463571; Thu, 31 May 2018 18:27:43 -0700 (PDT) From: Keno Fischer To: qemu-devel@nongnu.org Date: Thu, 31 May 2018 21:26:06 -0400 Message-Id: X-Mailer: git-send-email 2.8.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::241 Subject: [Qemu-devel] [PATCH v2 11/20] 9p: darwin: Handle struct dirent differences X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keno Fischer , groug@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" On darwin d_seekoff exists, but is optional and does not seem to be commonly used by file systems. Use `telldir` instead to obtain the seek offset. Signed-off-by: Keno Fischer --- Changes since v1: * Drop setting d_seekoff in synth_direntry * Factor telldir vs d_off logic into v9fs_dent_telldir * Error path for telldir failure hw/9pfs/9p-synth.c | 2 ++ hw/9pfs/9p.c | 36 ++++++++++++++++++++++++++++++++---- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/hw/9pfs/9p-synth.c b/hw/9pfs/9p-synth.c index eb68b42..a312f8c 100644 --- a/hw/9pfs/9p-synth.c +++ b/hw/9pfs/9p-synth.c @@ -221,7 +221,9 @@ static void synth_direntry(V9fsSynthNode *node, { strcpy(entry->d_name, node->name); entry->d_ino =3D node->attr->inode; +#ifndef CONFIG_DARWIN entry->d_off =3D off + 1; +#endif } =20 static struct dirent *synth_get_dentry(V9fsSynthNode *dir, diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 212f569..9751246 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -1738,6 +1738,25 @@ static int v9fs_xattr_read(V9fsState *s, V9fsPDU *pd= u, V9fsFidState *fidp, return offset; } =20 +/** + * Get the seek offset of a dirent. If not available from the structure it= self, + * obtain it by calling telldir. + */ +static int v9fs_dent_telldir(V9fsPDU *pdu, V9fsFidState *fidp, + struct dirent *dent) +{ +#ifdef CONFIG_DARWIN + /* + * Darwin has d_seekoff, which appears to function similarly to d_off. + * However, it does not appear to be supported on all file systems, + * so use telldir for correctness. + */ + return v9fs_co_telldir(pdu, fidp); +#else + return dent->d_off; +#endif +} + static int coroutine_fn v9fs_do_readdir_with_stat(V9fsPDU *pdu, V9fsFidState *fidp, uint32_t max_count) @@ -1801,7 +1820,11 @@ static int coroutine_fn v9fs_do_readdir_with_stat(V9= fsPDU *pdu, count +=3D len; v9fs_stat_free(&v9stat); v9fs_path_free(&path); - saved_dir_pos =3D dent->d_off; + saved_dir_pos =3D v9fs_dent_telldir(pdu, fidp, dent); + if (saved_dir_pos < 0) { + err =3D saved_dir_pos; + break; + } } =20 v9fs_readdir_unlock(&fidp->fs.dir); @@ -1915,7 +1938,7 @@ static int coroutine_fn v9fs_do_readdir(V9fsPDU *pdu,= V9fsFidState *fidp, V9fsString name; int len, err =3D 0; int32_t count =3D 0; - off_t saved_dir_pos; + off_t saved_dir_pos, off; struct dirent *dent; =20 /* save the directory position */ @@ -1951,10 +1974,15 @@ static int coroutine_fn v9fs_do_readdir(V9fsPDU *pd= u, V9fsFidState *fidp, /* Fill the other fields with dummy values */ qid.type =3D 0; qid.version =3D 0; + off =3D v9fs_dent_telldir(pdu, fidp, dent); + if (off < 0) { + err =3D off; + break; + } =20 /* 11 =3D 7 + 4 (7 =3D start offset, 4 =3D space for storing count= ) */ len =3D pdu_marshal(pdu, 11 + count, "Qqbs", - &qid, dent->d_off, + &qid, off, dent->d_type, &name); =20 v9fs_readdir_unlock(&fidp->fs.dir); @@ -1966,7 +1994,7 @@ static int coroutine_fn v9fs_do_readdir(V9fsPDU *pdu,= V9fsFidState *fidp, } count +=3D len; v9fs_string_free(&name); - saved_dir_pos =3D dent->d_off; + saved_dir_pos =3D off; } =20 v9fs_readdir_unlock(&fidp->fs.dir); --=20 2.8.1 From nobody Sun Feb 8 06:54:29 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1527817286186207.74686006942522; Thu, 31 May 2018 18:41:26 -0700 (PDT) Received: from localhost ([::1]:46963 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOZ4E-0004f5-5J for importer@patchew.org; Thu, 31 May 2018 21:41:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33392) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOYr4-00035d-Lk for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOYr3-00037r-SG for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:46 -0400 Received: from mail-qt0-x242.google.com ([2607:f8b0:400d:c0d::242]:46918) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOYr3-00037N-NF for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:45 -0400 Received: by mail-qt0-x242.google.com with SMTP id h5-v6so22286473qtm.13 for ; Thu, 31 May 2018 18:27:45 -0700 (PDT) Received: from localhost.localdomain (96-86-104-61-static.hfc.comcastbusiness.net. [96.86.104.61]) by smtp.gmail.com with ESMTPSA id o68-v6sm2003842qkc.19.2018.05.31.18.27.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 31 May 2018 18:27:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=juliacomputing-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=vLHkSALVaGK1wFXtf9DTVfvI4Clr8oZ6T8vCp8aCeG0=; b=unpAdG23/L0bymkaBOWWV72lDkimMy25GndNmWxaELYGE+laTyjkgRnxj9cMPRsKgf KowqXHdtzECie/p07IitqTWhYr1+S/eP096/2aqQPak/8Y5to5VwOmASvJ3moNE/ral8 1EqPQHVKDZmGvsmv5SoT9CIrXGcoI0pxiFulqdT6Wg9Qd7vsrkKlSKWtqEKxSquXdBQP /4gh9hTysmqBLQI5fW4mcFhRFB8RLVnBqsKGS5VvYhYgv++CvG2L9/0HZMf4pwAo3Atm 6K73fIMLQNHrnxJFwYix3lHH4wXejh/7kRivgJthnRmcy01k67oHOetds7oGycMwz9Eg dHmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=vLHkSALVaGK1wFXtf9DTVfvI4Clr8oZ6T8vCp8aCeG0=; b=JBDbilEsyOZkyYyK9oIKVq6AGqLAODediMJ+i67V/y85IwjkbMa3DX/9J+cu0GSa3d xRGYJbPjHpz6FxgwBcUGTTgBEn/eB8hOmaYwAPJGdfGYjLJZjbKvKGsb0C6qeukDwLJi Zb585L1zfA+PlEJKN+pwzL1qH5OEFivcLBYrLME40Q0R/+/qv2gzLMP3U9ruVxVLpvmR lALyngOqItsB2GaPaLjcvwYeRlNMekz6A5UzGN9toeBv9MD2RocvDXuea2qd2+NUJnv5 eceNmH3Q/g40xn8NtHsdY6VLWlaE4wXPaTl9zCbTELdMFa/S9CoN69Ax73DYx0mqImu6 t3eQ== X-Gm-Message-State: APt69E3GCINEtTwV8lOinO8PFukPzyq7kq0T4BxO7oi//izlgkE9nOxR pQkpifZsjcvR6fLbq4WK8ngCQelJAno= X-Google-Smtp-Source: ADUXVKKb+KT68lu8OfV2fBG/hRes2v28Ooj33PoQgIJGqHrjfjI2M92JJycwjv/nLKscZTW5xL2Rlg== X-Received: by 2002:a0c:c602:: with SMTP id v2-v6mr8689212qvi.11.1527816464836; Thu, 31 May 2018 18:27:44 -0700 (PDT) From: Keno Fischer To: qemu-devel@nongnu.org Date: Thu, 31 May 2018 21:26:07 -0400 Message-Id: X-Mailer: git-send-email 2.8.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::242 Subject: [Qemu-devel] [PATCH v2 12/20] 9p: darwin: Explicitly cast comparisons of mode_t with -1 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keno Fischer , groug@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Comparisons of mode_t with -1 require an explicit cast, since mode_t is unsigned on Darwin. Signed-off-by: Keno Fischer --- Changes from v1: Split from strchrnul change hw/9pfs/9p-local.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index 6222891..1f0b1b0 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -310,7 +310,7 @@ update_map_file: if (credp->fc_gid !=3D -1) { gid =3D credp->fc_gid; } - if (credp->fc_mode !=3D -1) { + if (credp->fc_mode !=3D (mode_t)-1) { mode =3D credp->fc_mode; } if (credp->fc_rdev !=3D -1) { @@ -416,7 +416,7 @@ static int local_set_xattrat(int dirfd, const char *pat= h, FsCred *credp) return err; } } - if (credp->fc_mode !=3D -1) { + if (credp->fc_mode !=3D (mode_t)-1) { uint32_t tmp_mode =3D cpu_to_le32(credp->fc_mode); err =3D fsetxattrat_nofollow(dirfd, path, "user.virtfs.mode", &tmp= _mode, sizeof(mode_t), 0); --=20 2.8.1 From nobody Sun Feb 8 06:54:29 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1527816980609373.8787203262501; Thu, 31 May 2018 18:36:20 -0700 (PDT) Received: from localhost ([::1]:46927 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOYzI-0000dm-AM for importer@patchew.org; Thu, 31 May 2018 21:36:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33403) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOYr6-00037F-8B for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOYr5-00039i-D3 for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:48 -0400 Received: from mail-qt0-x241.google.com ([2607:f8b0:400d:c0d::241]:44371) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOYr5-00039J-7z for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:47 -0400 Received: by mail-qt0-x241.google.com with SMTP id d3-v6so30268765qtp.11 for ; Thu, 31 May 2018 18:27:47 -0700 (PDT) Received: from localhost.localdomain (96-86-104-61-static.hfc.comcastbusiness.net. [96.86.104.61]) by smtp.gmail.com with ESMTPSA id o68-v6sm2003842qkc.19.2018.05.31.18.27.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 31 May 2018 18:27:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=juliacomputing-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=ewYMITy0s7pdZUhT4+HJW5Ikyi4LpGRALIJtRDylmoA=; b=VEyLW/JO17407WG2KcSRkM7gCXO3inPf3mFB/igfYGgaTQijRWtj/uKhE8amThI/JL OUw6dLMhwnQlzGN2E2YCiSplP1uZVMZPM9F3vK4G3wc4rX5VgOBYxjMiGkF5gioG6ktX C4x12CnIP2H+d2u9qYEEaK3Mp1sCaEwUf7a3mlJEOq2Zl/uhoIMdUvnXsqVkcom7hmlO buboNvjBMIJYcyR5r/EfXBXHhNItvSbMTsxcSpZ/WnR2MpQ2fT7d23hKrS3M/40mCQj+ Lv4sPesxOPCHnBaBvU8AfzXtQPicw4LdeZ8pcgmZnztPmOdljjCGnLMXE6ZsnTjQBI8v bTUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=ewYMITy0s7pdZUhT4+HJW5Ikyi4LpGRALIJtRDylmoA=; b=iWN5DHIAF5XLpmN4HCFDIwPwwODt6ZbNXBB1bokXlFcUghc6rf0CXCe1xE78l/CoyE oqeFO49dLyv1McQ6o8NmJMUQ6bgOhVMBmAdhEx2hatTJpwnbCtto6WJGTcmVaw+sxine T4mbv89GKe1SkPQvYYEiEj8wAEeLeLLk7X2qYMmv/TM2wVkdCjAHKyh553OiwE30rS7M Sse6DjCvQH5xGVoFnYDNSxS9uUzu20DQy3cIyXP0bYryKM6A6AwLQj8yUiJVRqxKeJFC bNFWyIIkVy/HYg5dBYulY256+g2XVjq4fowZCnJNzIP23+cDlpdBo2Eo4KxVqNEIwXDx oIZQ== X-Gm-Message-State: APt69E0NkbJtXYmZxkb+i4BCOx6yBkX48MMRjEPsaLkfnzbroSc5ZhT6 jzDTx+QpCoORdmT4UT4gsMtqf4CpTJU= X-Google-Smtp-Source: ADUXVKL3qY2l+LAcnFFg1ozuq0UzZh/OsfFlmgS/EhZySqr32L1J3vbbEgTRXmJWPxYPNpt3/eadeg== X-Received: by 2002:ac8:2b4e:: with SMTP id 14-v6mr3415746qtv.412.1527816466403; Thu, 31 May 2018 18:27:46 -0700 (PDT) From: Keno Fischer To: qemu-devel@nongnu.org Date: Thu, 31 May 2018 21:26:08 -0400 Message-Id: X-Mailer: git-send-email 2.8.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::241 Subject: [Qemu-devel] [PATCH v2 13/20] 9p: darwin: Ignore O_{NOATIME, DIRECT} X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keno Fischer , groug@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Darwin doesn't have either of these flags. Darwin does have F_NOCACHE, which is similar to O_DIRECT, but has different enough semantics that other projects don't generally map them automatically. In any case, we don't support O_DIRECT on Linux at the moment either. Signed-off-by: Keno Fischer --- Changes from v1: Undo accidental formatting change hw/9pfs/9p.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 9751246..70cfab9 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -123,11 +123,18 @@ static int dotl_to_open_flags(int flags) { P9_DOTL_NONBLOCK, O_NONBLOCK } , { P9_DOTL_DSYNC, O_DSYNC }, { P9_DOTL_FASYNC, FASYNC }, +#ifndef CONFIG_DARWIN + { P9_DOTL_NOATIME, O_NOATIME }, + /* On Darwin, we could map to F_NOCACHE, which is + similar, but doesn't quite have the same + semantics. However, we don't support O_DIRECT + even on linux at the moment, so we just ignore + it here. */ { P9_DOTL_DIRECT, O_DIRECT }, +#endif { P9_DOTL_LARGEFILE, O_LARGEFILE }, { P9_DOTL_DIRECTORY, O_DIRECTORY }, { P9_DOTL_NOFOLLOW, O_NOFOLLOW }, - { P9_DOTL_NOATIME, O_NOATIME }, { P9_DOTL_SYNC, O_SYNC }, }; =20 @@ -156,10 +163,12 @@ static int get_dotl_openflags(V9fsState *s, int oflag= s) */ flags =3D dotl_to_open_flags(oflags); flags &=3D ~(O_NOCTTY | O_ASYNC | O_CREAT); +#ifndef CONFIG_DARWIN /* * Ignore direct disk access hint until the server supports it. */ flags &=3D ~O_DIRECT; +#endif return flags; } =20 --=20 2.8.1 From nobody Sun Feb 8 06:54:29 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1527817050244791.2822263274489; Thu, 31 May 2018 18:37:30 -0700 (PDT) Received: from localhost ([::1]:46931 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOZ0T-0001UH-CV for importer@patchew.org; Thu, 31 May 2018 21:37:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33414) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOYr7-00038q-Qd for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOYr6-0003Bc-Us for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:49 -0400 Received: from mail-qt0-x243.google.com ([2607:f8b0:400d:c0d::243]:39686) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOYr6-0003BB-Pu for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:48 -0400 Received: by mail-qt0-x243.google.com with SMTP id p23-v6so5420484qtn.6 for ; Thu, 31 May 2018 18:27:48 -0700 (PDT) Received: from localhost.localdomain (96-86-104-61-static.hfc.comcastbusiness.net. [96.86.104.61]) by smtp.gmail.com with ESMTPSA id o68-v6sm2003842qkc.19.2018.05.31.18.27.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 31 May 2018 18:27:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=juliacomputing-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=/MaJEVrK3FhyA2JlHLrkBIaW2tFpb5chJydOqPbQgV8=; b=WAYbBeLstbsXmA6mitXNB/TVeoOpx1sHO7bPXl23KTKg2v7BQnxzxdVhBqkU5FmuwY FoEgoE2THgREK9QAgY8uAYKVHiiROwUwCbsAjeii5QZ25/gTNvsmsrPWReJWcJdR7Pww k3xp21e1ptD2EOgyw47N+fzws5uPFr/z7P6iovRVGVCw+zkSM4iZ0J2V0eopA3+rj3sJ O6R23R/qWnrPQmdHEhBEUh8MxT8ZB326L2CngTcoN1izkOoJSYgy5AckzEBKY2cE+yQJ 2o2XqLL7de/VpdIwLhCNQ2Y9ikoMDea/zUlFKSmuXIOho0G37Z5CmlO0QrtI51GPOBLJ BrnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=/MaJEVrK3FhyA2JlHLrkBIaW2tFpb5chJydOqPbQgV8=; b=a4PfBtHs1lV+qZtIIEMrGCZnRaR6fM3ZTbNPPGSa1vckfu0ko6i9gD+FPUaHvyrWp2 WuR/GD7KaIqFD+02JL8zqDDILaDl7m7n9gJuKbdluSw5sR4YHNOEr3TYtErczwRXC1wf HmoutQBe9c2HvMG3kcdJ+dsFqbQGCMb/OEepleNTyx+Hm6HWoVMCXfmYQJSPuMo0vS3+ rNPZQWut9zl/JXUx5AHCZmRd5hJKJIxrKlGz5NtVP+PKrQs8y4aI01Mhmi65a8ySV6oC RJC5ipIcfIyk/gHyFMzhIg7Ro1gussE+i9eKeNZuFcX7RONhfA2UMD1UjguIC1FMkjk6 RmLg== X-Gm-Message-State: APt69E0L0q8RkRux0V/EBrok2wCC4xX4Gum1M7dL3dmICbRNKasQ/qRl ty/w8IS85Pzw7ztKe9hCaJ1QEdGI8gI= X-Google-Smtp-Source: ADUXVKJzVbwxwrNKyNqqxfbK7ErWdYupK2n2vo1Fnz20UWHBi5t7zZEmIwbIQoRN2FWwA+Qg+6Lpeg== X-Received: by 2002:ac8:1bf0:: with SMTP id m45-v6mr9208040qtk.337.1527816467869; Thu, 31 May 2018 18:27:47 -0700 (PDT) From: Keno Fischer To: qemu-devel@nongnu.org Date: Thu, 31 May 2018 21:26:09 -0400 Message-Id: <08ddd5a3e1b0679ac63f36fe4a28988b6c2bfea4.1527814874.git.keno@juliacomputing.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::243 Subject: [Qemu-devel] [PATCH v2 14/20] 9p: darwin: Provide a compatibility definition for XATTR_SIZE_MAX X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keno Fischer , groug@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Keno Fischer --- No change from v1. hw/9pfs/9p.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 70cfab9..24802b9 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -3374,6 +3374,13 @@ out_nofid: v9fs_string_free(&name); } =20 +#if defined(CONFIG_DARWIN) && !defined(XATTR_SIZE_MAX) +/* Darwin doesn't seem to define a maximum xattr size in its user + user space header, but looking at the kernel source, HFS supports + up to INT32_MAX, so use that as the maximum. +*/ +#define XATTR_SIZE_MAX INT32_MAX +#endif static void coroutine_fn v9fs_xattrcreate(void *opaque) { int flags; --=20 2.8.1 From nobody Sun Feb 8 06:54:29 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15278172292379.387559019253786; Thu, 31 May 2018 18:40:29 -0700 (PDT) Received: from localhost ([::1]:46944 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOZ3M-0003ni-Ez for importer@patchew.org; Thu, 31 May 2018 21:40:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33425) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOYr9-0003B1-9X for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOYr8-0003D3-8a for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:51 -0400 Received: from mail-qt0-x235.google.com ([2607:f8b0:400d:c0d::235]:45394) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOYr8-0003Cl-4K for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:50 -0400 Received: by mail-qt0-x235.google.com with SMTP id i18-v6so19637972qtp.12 for ; Thu, 31 May 2018 18:27:50 -0700 (PDT) Received: from localhost.localdomain (96-86-104-61-static.hfc.comcastbusiness.net. [96.86.104.61]) by smtp.gmail.com with ESMTPSA id o68-v6sm2003842qkc.19.2018.05.31.18.27.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 31 May 2018 18:27:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=juliacomputing-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=XKoufBc6Rt52qAjMxnrQN7vEz39QaTNJfQ6AgLpZ+Cc=; b=zSBckPBX5NQF0uRjUL/uajdswPSqwaFmSA7D+6Z8LGYMJ+Wo8sOW9EkULYZzDyMpLs a5a/amBWamXPo6Y5adQOknKHH0WgVwogYbGkIjhD+mPcpl5tblMweN5zsPoj4qeLOBTA DcmPPmGFejAAIdfLqlFU+sBISIkGVLg2EpWj3CT+apqiyUA5wT8aTght0rd35IGiif37 sX4QeU9AKW9IobIoR9/gm5b4MqEO1mhVrfX4hOf+pvtbgUXRoLt0HjVi3c+qbJmNx1ZZ hjRZMMKZlv3CugGS22aHSq+ub2hHC16GzaKP53OAzsMsKxpGp3uEOJJAmA54HmsLnORQ ofxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=XKoufBc6Rt52qAjMxnrQN7vEz39QaTNJfQ6AgLpZ+Cc=; b=KQ5sdmA+M2DAk4fTLjs0sQWRBCX6U7+yxf0uqySwitZ6zAHjxbxKhjzb6mOruEZYv/ pULnTz0WGe6be5oPCRwl57jauEEyym+WG7WD20JEe0pX4il7pNb4KmX86nhLduAseAS0 QcmMLcU/awMWMrjv2mcuW/MSnw5Dvu2O96NMo9cFGza0GWyos0wYucI+VmJ1GEr8aCid lYN4h6lzorXrRNxHxg0u01TKpcQ6+sdyvimTmgKAIAV8S2BMixOf8o6u406wi6mMGHwO FWN6NAPJz+tZhwdNx8u9cdG+Gn3eAgbIDwWJq9OORTlM/fgT38r1ctXqvVusRkVRCZd+ qfhw== X-Gm-Message-State: APt69E3DCc7DoTsAH/spnVUtq0nxcAwjCFddAOeGBiXPRc7Nikyuy3B9 guD3ovCYAnU2yg4afwraV8ZlJaj4oCg= X-Google-Smtp-Source: ADUXVKICwYqny8rHT26E2ReSybaNZ5kTUARLxrVlbCvgqX6K9cxHe86+mP/F9G7DrE2KiHgxlZlnbQ== X-Received: by 2002:ac8:2f2a:: with SMTP id j39-v6mr9212864qta.74.1527816469182; Thu, 31 May 2018 18:27:49 -0700 (PDT) From: Keno Fischer To: qemu-devel@nongnu.org Date: Thu, 31 May 2018 21:26:10 -0400 Message-Id: <5d222847166f7f3f2b05e7e8a0a0ab3d7520b49d.1527814874.git.keno@juliacomputing.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::235 Subject: [Qemu-devel] [PATCH v2 15/20] 9p: darwin: *xattr_nofollow implementations X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keno Fischer , groug@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This implements the darwin equivalent of the functions that were moved to 9p-util(-linux) earlier in this series in the new 9p-util-darwin file. Signed-off-by: Keno Fischer --- Changes from v1: * New 9p-util-darwin.c rather than ifdefs in 9p-util.c * Drop incorrect AT_NOFOLLOW from the actual call hw/9pfs/9p-util-darwin.c | 64 ++++++++++++++++++++++++++++++++++++++++++++= ++++ hw/9pfs/Makefile.objs | 1 + 2 files changed, 65 insertions(+) create mode 100644 hw/9pfs/9p-util-darwin.c diff --git a/hw/9pfs/9p-util-darwin.c b/hw/9pfs/9p-util-darwin.c new file mode 100644 index 0000000..cdb4c9e --- /dev/null +++ b/hw/9pfs/9p-util-darwin.c @@ -0,0 +1,64 @@ +/* + * 9p utilities (Darwin Implementation) + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "qemu/xattr.h" +#include "9p-util.h" + +ssize_t fgetxattrat_nofollow(int dirfd, const char *filename, const char *= name, + void *value, size_t size) +{ + int ret; + int fd =3D openat_file(dirfd, filename, + O_RDONLY | O_PATH_9P_UTIL | O_NOFOLLOW, 0); + if (fd =3D=3D -1) { + return -1; + } + ret =3D fgetxattr(fd, name, value, size, 0, 0); + close_preserve_errno(fd); + return ret; +} + +ssize_t flistxattrat_nofollow(int dirfd, const char *filename, + char *list, size_t size) +{ + int ret; + int fd =3D openat_file(dirfd, filename, + O_RDONLY | O_PATH_9P_UTIL | O_NOFOLLOW, 0); + if (fd =3D=3D -1) { + return -1; + } + ret =3D flistxattr(fd, list, size, 0); + close_preserve_errno(fd); + return ret; +} + +ssize_t fremovexattrat_nofollow(int dirfd, const char *filename, + const char *name) +{ + int ret; + int fd =3D openat_file(dirfd, filename, O_PATH_9P_UTIL | O_NOFOLLOW, 0= ); + if (fd =3D=3D -1) { + return -1; + } + ret =3D fremovexattr(fd, name, 0); + close_preserve_errno(fd); + return ret; +} + +int fsetxattrat_nofollow(int dirfd, const char *filename, const char *name, + void *value, size_t size, int flags) +{ + int ret; + int fd =3D openat_file(dirfd, filename, O_PATH_9P_UTIL | O_NOFOLLOW, 0= ); + if (fd =3D=3D -1) { + return -1; + } + ret =3D fsetxattr(fd, name, value, size, 0, flags); + close_preserve_errno(fd); + return ret; +} diff --git a/hw/9pfs/Makefile.objs b/hw/9pfs/Makefile.objs index 083508f..24a8695 100644 --- a/hw/9pfs/Makefile.objs +++ b/hw/9pfs/Makefile.objs @@ -1,5 +1,6 @@ common-obj-y =3D 9p.o common-obj-$(CONFIG_LINUX) +=3D 9p-util-linux.o +common-obj-$(CONFIG_DARWIN) +=3D 9p-util-darwin.o common-obj-y +=3D 9p-local.o 9p-xattr.o common-obj-y +=3D 9p-xattr-user.o 9p-posix-acl.o common-obj-y +=3D coth.o cofs.o codir.o cofile.o --=20 2.8.1 From nobody Sun Feb 8 06:54:29 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1527817523878305.53005993508725; Thu, 31 May 2018 18:45:23 -0700 (PDT) Received: from localhost ([::1]:46992 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOZ87-0007ly-5b for importer@patchew.org; Thu, 31 May 2018 21:45:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33454) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOYrE-0003FE-DF for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOYr9-0003F4-T9 for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:56 -0400 Received: from mail-qt0-x243.google.com ([2607:f8b0:400d:c0d::243]:46056) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOYr9-0003Ec-Nj for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:51 -0400 Received: by mail-qt0-x243.google.com with SMTP id i18-v6so19638014qtp.12 for ; Thu, 31 May 2018 18:27:51 -0700 (PDT) Received: from localhost.localdomain (96-86-104-61-static.hfc.comcastbusiness.net. [96.86.104.61]) by smtp.gmail.com with ESMTPSA id o68-v6sm2003842qkc.19.2018.05.31.18.27.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 31 May 2018 18:27:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=juliacomputing-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=HgDNU/Me434L8Npz9IS7yDR0zIwXQJWgxumsb/AGB5Y=; b=nrqfVc1olH3mHhmQOH5BUsSPeSX4DCkf+qYpsaxn35iG88QW5TcK1zquf1JviF+c/c 2NnPXsaL8HUOJSWtuKuai7o7bpqiVqBzDTVeyMrFxtagNVLWsVYAi4xm/w90s9gy3afJ +hfkASi9hJjnw2R17bPjVu0AZM4IhhroU7CVRu/RewDxJ4yEPoN6MOKElIcWie6t3acG k9/fpxCBrqiAWuD86EEo/4PZPvxuMfxIqDTqQ2bzk+U8LMsfhO+4lqshUILSiAqsggU+ 5DvmVNdAzEWm0r6WBwdR8YWigvu+WcpnuHc9NoOmC4ZwArTmwwwpDZ1sbxsEz93M/ZUm BWYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=HgDNU/Me434L8Npz9IS7yDR0zIwXQJWgxumsb/AGB5Y=; b=AbTrk60cV3Xia2Uyu5yvLExYzstBEZdUfWvjSAGv0XnSQMVmOL2ZD4sN2Bg9wV07WW 1nyejStDlz0J9cjczRiFkoucku2smqH25U8TMSaJtIETu1gjH6bFslbc5W9HnuQctv4R Q2l6RmdEw69w0S/8YY6K0Fg4hNn3RYX8dkEeI/aftLz3DUjaxjEBHPSEPByxcppUMzNo 3F3m+MttW2R/98u4zpHbof8TezGAWzl8P0zV3aporrqt8GqdhWLeXc4wHjlrg3LXqay9 GnLP+B+SDvYSz/XKuKxcnlle/fD5omOJE5P3WCuEnOyoWb1MyZoFAnEkuDUNmPc6Pme9 5tZA== X-Gm-Message-State: APt69E01OY38Wh3BiOHarkaiHscxynJO9NXjs+E+8m/yWcyCmqbsX9r0 xkYDuQEs/0CxEMcC0LEpD8tfE7yDVGI= X-Google-Smtp-Source: ADUXVKIU03bGLtRYvizH/yqiDKjs2xlBOzutG5bbZvOasQNlQjjeum0BKyEvwoFBIiUK1AVhrZvcvw== X-Received: by 2002:aed:3e87:: with SMTP id n7-v6mr9310012qtf.189.1527816470771; Thu, 31 May 2018 18:27:50 -0700 (PDT) From: Keno Fischer To: qemu-devel@nongnu.org Date: Thu, 31 May 2018 21:26:11 -0400 Message-Id: <66d4d3eb6fe9c098b77a6790f015912cd35d86b0.1527814874.git.keno@juliacomputing.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::243 Subject: [Qemu-devel] [PATCH v2 16/20] 9p: darwin: Compatibility for f/l*xattr X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keno Fischer , groug@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" On darwin `fgetxattr` takes two extra optional arguments, and the l* variants are not defined (in favor of an extra flag to the regular variants. Signed-off-by: Keno Fischer --- Changes from v1: New patch, qemu_fgetxattr had previously been moved to 9p-util as fgetxattr_follow. The remaining functions are required by the proxy-helper. Makefile | 6 ++++++ fsdev/virtfs-proxy-helper.c | 9 +++++---- hw/9pfs/9p-local.c | 12 ++++++++---- hw/9pfs/9p-util.h | 17 +++++++++++++++++ 4 files changed, 36 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 6d588d1..dac6efd 100644 --- a/Makefile +++ b/Makefile @@ -544,7 +544,13 @@ qemu-bridge-helper$(EXESUF): qemu-bridge-helper.o $(CO= MMON_LDADDS) qemu-keymap$(EXESUF): qemu-keymap.o ui/input-keymap.o $(COMMON_LDADDS) =20 fsdev/virtfs-proxy-helper$(EXESUF): fsdev/virtfs-proxy-helper.o fsdev/9p-m= arshal.o fsdev/9p-iov-marshal.o $(COMMON_LDADDS) +ifdef CONFIG_DARWIN +fsdev/virtfs-proxy-helper$(EXESUF): hw/9pfs/9p-util-darwin.o +endif +ifdef CONFIG_LINUX +fsdev/virtfs-proxy-helper$(EXESUF): hw/9pfs/9p-util-linux.o fsdev/virtfs-proxy-helper$(EXESUF): LIBS +=3D -lcap +endif =20 scsi/qemu-pr-helper$(EXESUF): scsi/qemu-pr-helper.o scsi/utils.o $(crypto-= obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS) ifdef CONFIG_MPATH diff --git a/fsdev/virtfs-proxy-helper.c b/fsdev/virtfs-proxy-helper.c index 3bc1269..a26f8b8 100644 --- a/fsdev/virtfs-proxy-helper.c +++ b/fsdev/virtfs-proxy-helper.c @@ -28,6 +28,7 @@ #include "qemu/statfs.h" #include "9p-iov-marshal.h" #include "hw/9pfs/9p-proxy.h" +#include "hw/9pfs/9p-util.h" #include "fsdev/9p-iov-marshal.h" =20 #define PROGNAME "virtfs-proxy-helper" @@ -459,7 +460,7 @@ static int do_getxattr(int type, struct iovec *iovec, s= truct iovec *out_iovec) v9fs_string_init(&name); retval =3D proxy_unmarshal(iovec, offset, "s", &name); if (retval > 0) { - retval =3D lgetxattr(path.data, name.data, xattr.data, size); + retval =3D qemu_lgetxattr(path.data, name.data, xattr.data, si= ze); if (retval < 0) { retval =3D -errno; } else { @@ -469,7 +470,7 @@ static int do_getxattr(int type, struct iovec *iovec, s= truct iovec *out_iovec) v9fs_string_free(&name); break; case T_LLISTXATTR: - retval =3D llistxattr(path.data, xattr.data, size); + retval =3D qemu_llistxattr(path.data, xattr.data, size); if (retval < 0) { retval =3D -errno; } else { @@ -1000,7 +1001,7 @@ static int process_requests(int sock) retval =3D proxy_unmarshal(&in_iovec, PROXY_HDR_SZ, "sssdd", &= path, &name, &value, &size, &flags); if (retval > 0) { - retval =3D lsetxattr(path.data, + retval =3D qemu_lsetxattr(path.data, name.data, value.data, size, flags); if (retval < 0) { retval =3D -errno; @@ -1016,7 +1017,7 @@ static int process_requests(int sock) retval =3D proxy_unmarshal(&in_iovec, PROXY_HDR_SZ, "ss", &path, &name); if (retval > 0) { - retval =3D lremovexattr(path.data, name.data); + retval =3D qemu_lremovexattr(path.data, name.data); if (retval < 0) { retval =3D -errno; } diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index 1f0b1b0..7830526 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -776,16 +776,20 @@ static int local_fstat(FsContext *fs_ctx, int fid_typ= e, mode_t tmp_mode; dev_t tmp_dev; =20 - if (fgetxattr(fd, "user.virtfs.uid", &tmp_uid, sizeof(uid_t)) > 0)= { + if (qemu_fgetxattr(fd, "user.virtfs.uid", + &tmp_uid, sizeof(uid_t)) > 0) { stbuf->st_uid =3D le32_to_cpu(tmp_uid); } - if (fgetxattr(fd, "user.virtfs.gid", &tmp_gid, sizeof(gid_t)) > 0)= { + if (qemu_fgetxattr(fd, "user.virtfs.gid", + &tmp_gid, sizeof(gid_t)) > 0) { stbuf->st_gid =3D le32_to_cpu(tmp_gid); } - if (fgetxattr(fd, "user.virtfs.mode", &tmp_mode, sizeof(mode_t)) >= 0) { + if (qemu_fgetxattr(fd, "user.virtfs.mode", + &tmp_mode, sizeof(mode_t)) > 0) { stbuf->st_mode =3D le32_to_cpu(tmp_mode); } - if (fgetxattr(fd, "user.virtfs.rdev", &tmp_dev, sizeof(dev_t)) > 0= ) { + if (qemu_fgetxattr(fd, "user.virtfs.rdev", + &tmp_dev, sizeof(dev_t)) > 0) { stbuf->st_rdev =3D le64_to_cpu(tmp_dev); } } else if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) { diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index 79ed6b2..50a03c7 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -19,6 +19,23 @@ #define O_PATH_9P_UTIL 0 #endif =20 +#ifdef CONFIG_DARWIN +#define qemu_fgetxattr(...) fgetxattr(__VA_ARGS__, 0, 0) +#define qemu_lgetxattr(...) getxattr(__VA_ARGS__, 0, XATTR_NOFOLLOW) +#define qemu_llistxattr(...) listxattr(__VA_ARGS__, XATTR_NOFOLLOW) +#define qemu_lremovexattr(...) removexattr(__VA_ARGS__, XATTR_NOFOLLOW) +static inline int qemu_lsetxattr(const char *path, const char *name, + const void *value, size_t size, int flags= ) { + return setxattr(path, name, value, size, 0, flags | XATTR_NOFOLLOW); +} +#else +#define qemu_fgetxattr fgetxattr +#define qemu_lgetxattr lgetxattr +#define qemu_llistxattr llistxattr +#define qemu_lremovexattr lremovexattr +#define qemu_lsetxattr lsetxattr +#endif + static inline void close_preserve_errno(int fd) { int serrno =3D errno; --=20 2.8.1 From nobody Sun Feb 8 06:54:29 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1527817167136813.226534922967; Thu, 31 May 2018 18:39:27 -0700 (PDT) Received: from localhost ([::1]:46940 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOZ2M-0002zz-AB for importer@patchew.org; Thu, 31 May 2018 21:39:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33455) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOYrE-0003FF-DR for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOYrB-0003HU-Oe for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:56 -0400 Received: from mail-qt0-x244.google.com ([2607:f8b0:400d:c0d::244]:33784) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOYrB-0003Gf-IS for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:53 -0400 Received: by mail-qt0-x244.google.com with SMTP id e8-v6so30315652qth.0 for ; Thu, 31 May 2018 18:27:53 -0700 (PDT) Received: from localhost.localdomain (96-86-104-61-static.hfc.comcastbusiness.net. [96.86.104.61]) by smtp.gmail.com with ESMTPSA id o68-v6sm2003842qkc.19.2018.05.31.18.27.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 31 May 2018 18:27:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=juliacomputing-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=OE0Zy8CDugHpEmi12AOp1k9xmDvO0CZ47e+5iaB2K0g=; b=E9Ei55UYpe+Dde8g4crW/i34FS6ru8MCn35qIxwITjSf0ZJ2UYXXjczvb6enL0r6FZ NTxQOoFu8xOiqz8cL5oMOr7rS+JfA7bULtWDlzZ6rPuqVvZsFcDD+exPN/MDAyn2QvuU 1OkaZkjETbNdZ1mTR2dOpNlpERPmzRQPA7LqbmuPzF2ZzQmOeWUc4AVjRkZVQOxNpWpp hQgnimRE6x3U6ATBnKDjZDGwkqtMrZuXwjw5UraYqygIGRh58QS1wic+8ddTVnduBemW hIayAbH2c2tDEg8ORHmsmSw1TFybWR5bCRr3rZYdoUAcwFXp5790JyN1hwpdcWwyz2Sa 7VLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=OE0Zy8CDugHpEmi12AOp1k9xmDvO0CZ47e+5iaB2K0g=; b=Sxcj6CIJAXTqcRxW2CR4WD/Nys1e+KxqN19Aahxh8OxVZ9JjY09aEN5Gs2U+6FO/nT aYH62/z1/z3o+6eLUnJcX0MfCYG8Sp5c1v2tWxFSyc6csaqEHk7ECJgjzn6d/x27Quqk ZArHdUoHkxIlCI+TXa4IiTOG6MXd+ghUPT+GDdsXfbLATlyKikz/mOXmY8itv+kFbhUx z6HxcioQEx+JEPsR6jy9Ef9LQDlhYY85GxrQ2WVUqWzY0KdSNAOsOK6o5iIx8K3hnBNI y64I5RLyBIAMvYlkh5+Wf5TZkcgnzipkbTgKA524j3rFNFhmrT7e4dnzwhIEfFwaRH0o DYng== X-Gm-Message-State: APt69E2+1Oh9Jtfg7m2a+bkhjpy4uHaBHVyZIgZO1xwEH4xNKPcvK3H/ Gruj4YTXHjcTe52r/FJsEebgLYvuIfg= X-Google-Smtp-Source: ADUXVKJZYznaoGj2ZYMMTT+An0Ixz/De7qDGOGuwwy7JmEOUEQwZ+qKb6aKfwkAfH12O0XcSQ/uGjw== X-Received: by 2002:ac8:327c:: with SMTP id y57-v6mr9143547qta.14.1527816472547; Thu, 31 May 2018 18:27:52 -0700 (PDT) From: Keno Fischer To: qemu-devel@nongnu.org Date: Thu, 31 May 2018 21:26:12 -0400 Message-Id: X-Mailer: git-send-email 2.8.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::244 Subject: [Qemu-devel] [PATCH v2 17/20] 9p: darwin: Provide a fallback implementation for utimensat X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keno Fischer , groug@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This function is new in Mac OS 10.13. Provide a fallback implementation when building against older SDKs. The complication in the definition comes having to separately handle the used SDK version and the target OS version. - If the SDK version is too low (__MAC_10_13 not defined), utimensat is not defined in the header, so we must not try to use it (doing so would error= ). - Otherwise, if the targetted OS version is at least 10.13, we know this function is available, so we can unconditionally call it. - Lastly, we check for the availability of the __builtin_available macro to potentially insert a dynamic check for this OS version. However, __builti= n_available is only available with sufficiently recent versions of clang and while all Apple clang versions that ship with Xcode versions that support the 10.13 SDK support with builtin, we want to allow building with compilers other than Apple clang that may not support this builtin. Signed-off-by: Keno Fischer --- Changes from v1: * Correct calculation of tv_usec * Support UTIME_NOW/UTIME/OMIT * Now covers fsdev/virtfs-proxy-helper.c fsdev/virtfs-proxy-helper.c | 3 +- hw/9pfs/9p-local.c | 2 +- hw/9pfs/9p-util-darwin.c | 96 +++++++++++++++++++++++++++++++++++++++++= ++++ hw/9pfs/9p-util-linux.c | 6 +++ hw/9pfs/9p-util.h | 8 ++++ hw/9pfs/9p.c | 1 + 6 files changed, 113 insertions(+), 3 deletions(-) diff --git a/fsdev/virtfs-proxy-helper.c b/fsdev/virtfs-proxy-helper.c index a26f8b8..d8dd3f5 100644 --- a/fsdev/virtfs-proxy-helper.c +++ b/fsdev/virtfs-proxy-helper.c @@ -957,8 +957,7 @@ static int process_requests(int sock) &spec[0].tv_sec, &spec[0].tv_nsec, &spec[1].tv_sec, &spec[1].tv_nsec); if (retval > 0) { - retval =3D utimensat(AT_FDCWD, path.data, spec, - AT_SYMLINK_NOFOLLOW); + retval =3D utimensat_nofollow(AT_FDCWD, path.data, spec); if (retval < 0) { retval =3D -errno; } diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index 7830526..47e8580 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -1071,7 +1071,7 @@ static int local_utimensat(FsContext *s, V9fsPath *fs= _path, goto out; } =20 - ret =3D utimensat(dirfd, name, buf, AT_SYMLINK_NOFOLLOW); + ret =3D utimensat_nofollow(dirfd, name, buf); close_preserve_errno(dirfd); out: g_free(dirpath); diff --git a/hw/9pfs/9p-util-darwin.c b/hw/9pfs/9p-util-darwin.c index cdb4c9e..ac414bc 100644 --- a/hw/9pfs/9p-util-darwin.c +++ b/hw/9pfs/9p-util-darwin.c @@ -62,3 +62,99 @@ int fsetxattrat_nofollow(int dirfd, const char *filename= , const char *name, close_preserve_errno(fd); return ret; } + +#ifndef __has_builtin +#define __has_builtin(x) 0 +#endif + +static int update_times_from_stat(int fd, struct timespec times[2], + int update0, int update1) +{ + struct stat buf; + int ret =3D fstat(fd, &buf); + if (ret =3D=3D -1) { + return ret; + } + if (update0) { + times[0] =3D buf.st_atimespec; + } + if (update1) { + times[1] =3D buf.st_mtimespec; + } + return 0; +} + +int utimensat_nofollow(int dirfd, const char *filename, + const struct timespec times_in[2]) +{ + int ret, fd; + int special0, special1; + struct timeval futimes_buf[2]; + struct timespec times[2]; + memcpy(times, times_in, 2 * sizeof(struct timespec)); + +/* Check whether we have an SDK version that defines utimensat */ +#if defined(__MAC_10_13) +# if __MAC_OS_X_VERSION_MIN_REQUIRED >=3D __MAC_10_13 +# define UTIMENSAT_AVAILABLE 1 +# elif __has_builtin(__builtin_available) +# define UTIMENSAT_AVAILABLE __builtin_available(macos 10.13, *) +# else +# define UTIMENSAT_AVAILABLE 0 +# endif + if (UTIMENSAT_AVAILABLE) { + return utimensat(dirfd, filename, times, AT_SYMLINK_NOFOLLOW); + } +#endif + + /* utimensat not available. Use futimes. */ + fd =3D openat_file(dirfd, filename, O_PATH_9P_UTIL | O_NOFOLLOW, 0); + if (fd =3D=3D -1) { + return -1; + } + + special0 =3D times[0].tv_nsec =3D=3D UTIME_OMIT; + special1 =3D times[1].tv_nsec =3D=3D UTIME_OMIT; + if (special0 || special1) { + /* If both are set, nothing to do */ + if (special0 && special1) { + ret =3D 0; + goto done; + } + + ret =3D update_times_from_stat(fd, times, special0, special1); + if (ret < 0) { + goto done; + } + } + + special0 =3D times[0].tv_nsec =3D=3D UTIME_NOW; + special1 =3D times[1].tv_nsec =3D=3D UTIME_NOW; + if (special0 || special1) { + ret =3D futimes(fd, NULL); + if (ret < 0) { + goto done; + } + + /* If both are set, we are done */ + if (special0 && special1) { + ret =3D 0; + goto done; + } + + ret =3D update_times_from_stat(fd, times, special0, special1); + if (ret < 0) { + goto done; + } + } + + futimes_buf[0].tv_sec =3D times[0].tv_sec; + futimes_buf[0].tv_usec =3D times[0].tv_nsec / 1000; + futimes_buf[1].tv_sec =3D times[1].tv_sec; + futimes_buf[1].tv_usec =3D times[1].tv_nsec / 1000; + ret =3D futimes(fd, futimes_buf); + +done: + close_preserve_errno(fd); + return ret; +} diff --git a/hw/9pfs/9p-util-linux.c b/hw/9pfs/9p-util-linux.c index defa3a4..3902378 100644 --- a/hw/9pfs/9p-util-linux.c +++ b/hw/9pfs/9p-util-linux.c @@ -57,3 +57,9 @@ int fsetxattrat_nofollow(int dirfd, const char *filename,= const char *name, g_free(proc_path); return ret; } + +int utimensat_nofollow(int dirfd, const char *filename, + const struct timespec times[2]) +{ + return utimensat(dirfd, filename, times, AT_SYMLINK_NOFOLLOW); +} diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index 50a03c7..b1dc08a 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -36,6 +36,12 @@ static inline int qemu_lsetxattr(const char *path, const= char *name, #define qemu_lsetxattr lsetxattr #endif =20 +/* Compatibility with old SDK Versions for Darwin */ +#if defined(CONFIG_DARWIN) && !defined(UTIME_NOW) +#define UTIME_NOW -1 +#define UTIME_OMIT -2 +#endif + static inline void close_preserve_errno(int fd) { int serrno =3D errno; @@ -81,5 +87,7 @@ ssize_t flistxattrat_nofollow(int dirfd, const char *file= name, char *list, size_t size); ssize_t fremovexattrat_nofollow(int dirfd, const char *filename, const char *name); +int utimensat_nofollow(int dirfd, const char *filename, + const struct timespec times[2]); =20 #endif diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 24802b9..71b2dc9 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -21,6 +21,7 @@ #include "virtio-9p.h" #include "fsdev/qemu-fsdev.h" #include "9p-xattr.h" +#include "9p-util.h" #include "coth.h" #include "trace.h" #include "migration/blocker.h" --=20 2.8.1 From nobody Sun Feb 8 06:54:29 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1527817425266712.2765683669675; Thu, 31 May 2018 18:43:45 -0700 (PDT) Received: from localhost ([::1]:46980 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOZ6W-0006Oo-4o for importer@patchew.org; Thu, 31 May 2018 21:43:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33456) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOYrE-0003FG-Dt for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOYrD-0003Iz-3N for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:56 -0400 Received: from mail-qt0-x241.google.com ([2607:f8b0:400d:c0d::241]:40627) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOYrC-0003IZ-VC for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:55 -0400 Received: by mail-qt0-x241.google.com with SMTP id h2-v6so30292303qtp.7 for ; Thu, 31 May 2018 18:27:54 -0700 (PDT) Received: from localhost.localdomain (96-86-104-61-static.hfc.comcastbusiness.net. [96.86.104.61]) by smtp.gmail.com with ESMTPSA id o68-v6sm2003842qkc.19.2018.05.31.18.27.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 31 May 2018 18:27:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=juliacomputing-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=8Zat6Jv7yNhqDbVlvEPyIjxl3spjALOuCv6+GJx/Y9k=; b=r8TuLHQ5WzPaSoZsdXD6tmYEZWwjxvuzNHvNyxZPLHnsAHNEfVkpNrSayz7taayOgq qRx8F4JdZGM6WQFhS9QvzIpB1V13y5bhYNl+mvC1e6pY9nUwbEA9BkoMUH9SSEtCF4GH WBOFh/0F47Yyt1swo9LxZS3bCC9ptwH4wjqp6J0QgtW2G9CPnpEu3vY1FbqyQeSkqS8M BJ/69ggd+wieeDLEk3Zvz5RCYlPRNMLkmOAn0nBuheuOadmMukGKTa/y9n4oFqZyZ8iN +nDd/zLV5L4xGDfyk4d6RyB5KkA/RGLCdSaubnY0FlIPRUF+SW1G/+EUqhtBkxfJdwpV q8kQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=8Zat6Jv7yNhqDbVlvEPyIjxl3spjALOuCv6+GJx/Y9k=; b=XOhNjmRny83NREe7NWy4GfUNBPdOIhqUyslwi4Fit3IA3yvt67TTslEVkpwwIu4SmP xi4VBINMRU/wQsM/qJyUcbFfngE0YA8qKiq1qJ10VbjWHse1nn7cvqzTNnNVX1SgfLah S1xU/9ydmwu6c7MdtckddAHq0QE7Arqgz6shvkz/HO3syA6ezXs8/O82y+LMQ3u9gII+ PLkmLrZLUlOCi1dY1LyrcxYIuhIvXY6EKdB/hh80momFaBygXFI06+jNkMj9OqR0pCYN mhjwhHmqHNzkPVh+AkMeIWairrM7okN6jPsmRS9EmNS+I3oYCUv94BFBvIeEl39WdEYR PSnA== X-Gm-Message-State: APt69E0QR1oPzLI3LnLQ2jyKNGzEJGqCgM6ttii39jv6J0hSaLh3XUyx SSmbbBFlR/pEjomnYJuNCY+H9hpMBJY= X-Google-Smtp-Source: ADUXVKIuTgvt4Hy+YI2h0oDNdiMdzVx7tvHGnTVptYdD4x5WgbUS+ga4xeG5YiqkGT/kagoqwrO0rw== X-Received: by 2002:ac8:286a:: with SMTP id 39-v6mr9330466qtr.131.1527816474084; Thu, 31 May 2018 18:27:54 -0700 (PDT) From: Keno Fischer To: qemu-devel@nongnu.org Date: Thu, 31 May 2018 21:26:13 -0400 Message-Id: <35ccf95a6898df4e6b5d6f2a61e5612410cc3699.1527814874.git.keno@juliacomputing.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::241 Subject: [Qemu-devel] [PATCH v2 18/20] 9p: darwin: Implement compatibility for mknodat X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keno Fischer , groug@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Darwin does not support mknodat. However, to avoid race conditions with later setting the permissions, we must avoid using mknod on the full path instead. We could try to fchdir, but that would cause problems if multiple threads try to call mknodat at the same time. However, luckily there is a solution: Darwin as an (unexposed in the C library) system call that sets the cwd for the current thread only. This should suffice to use mknod safely. Signed-off-by: Keno Fischer --- Changes from v1: New patch. The previous series marked mknodat unsupported. hw/9pfs/9p-local.c | 5 +++-- hw/9pfs/9p-util-darwin.c | 25 +++++++++++++++++++++++++ hw/9pfs/9p-util-linux.c | 5 +++++ hw/9pfs/9p-util.h | 2 ++ 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index 47e8580..c7a2b08 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -668,7 +668,7 @@ static int local_mknod(FsContext *fs_ctx, V9fsPath *dir= _path, =20 if (fs_ctx->export_flags & V9FS_SM_MAPPED || fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) { - err =3D mknodat(dirfd, name, fs_ctx->fmode | S_IFREG, 0); + err =3D qemu_mknodat(dirfd, name, fs_ctx->fmode | S_IFREG, 0); if (err =3D=3D -1) { goto out; } @@ -683,7 +683,7 @@ 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) { - err =3D mknodat(dirfd, name, credp->fc_mode, credp->fc_rdev); + err =3D qemu_mknodat(dirfd, name, credp->fc_mode, credp->fc_rdev); if (err =3D=3D -1) { goto out; } @@ -696,6 +696,7 @@ static int local_mknod(FsContext *fs_ctx, V9fsPath *dir= _path, =20 err_end: unlinkat_preserve_errno(dirfd, name, 0); + out: close_preserve_errno(dirfd); return err; diff --git a/hw/9pfs/9p-util-darwin.c b/hw/9pfs/9p-util-darwin.c index ac414bc..49fe7d3 100644 --- a/hw/9pfs/9p-util-darwin.c +++ b/hw/9pfs/9p-util-darwin.c @@ -158,3 +158,28 @@ done: close_preserve_errno(fd); return ret; } + +#ifndef SYS___pthread_fchdir +# define SYS___pthread_fchdir 349 +#endif + +static int fchdir_thread_local(int fd) +{ + return syscall(SYS___pthread_fchdir, fd); +} + +int qemu_mknodat(int dirfd, const char *filename, mode_t mode, dev_t dev) +{ + int preserved_errno, err; + if (fchdir_thread_local(dirfd) < 0) { + return -1; + } + err =3D mknod(filename, mode, dev); + preserved_errno =3D errno; + /* Stop using the thread-local cwd */ + fchdir_thread_local(-1); + if (err < 0) { + errno =3D preserved_errno; + } + return err; +} diff --git a/hw/9pfs/9p-util-linux.c b/hw/9pfs/9p-util-linux.c index 3902378..06399c5 100644 --- a/hw/9pfs/9p-util-linux.c +++ b/hw/9pfs/9p-util-linux.c @@ -63,3 +63,8 @@ int utimensat_nofollow(int dirfd, const char *filename, { return utimensat(dirfd, filename, times, AT_SYMLINK_NOFOLLOW); } + +int qemu_mknodat(int dirfd, const char *filename, mode_t mode, dev_t dev) +{ + return mknodat(dirfd, filename, mode, dev); +} diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index b1dc08a..127564d 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -90,4 +90,6 @@ ssize_t fremovexattrat_nofollow(int dirfd, const char *fi= lename, int utimensat_nofollow(int dirfd, const char *filename, const struct timespec times[2]); =20 +int qemu_mknodat(int dirfd, const char *filename, mode_t mode, dev_t dev); + #endif --=20 2.8.1 From nobody Sun Feb 8 06:54:29 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1527817324618177.8376016058172; Thu, 31 May 2018 18:42:04 -0700 (PDT) Received: from localhost ([::1]:46972 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOZ4t-0005BF-PR for importer@patchew.org; Thu, 31 May 2018 21:42:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33481) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOYrF-0003FI-Vd for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOYrE-0003KZ-Es for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:57 -0400 Received: from mail-qt0-x22e.google.com ([2607:f8b0:400d:c0d::22e]:34666) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOYrE-0003KB-9L for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:56 -0400 Received: by mail-qt0-x22e.google.com with SMTP id m5-v6so30317914qti.1 for ; Thu, 31 May 2018 18:27:56 -0700 (PDT) Received: from localhost.localdomain (96-86-104-61-static.hfc.comcastbusiness.net. [96.86.104.61]) by smtp.gmail.com with ESMTPSA id o68-v6sm2003842qkc.19.2018.05.31.18.27.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 31 May 2018 18:27:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=juliacomputing-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=i7MhZc+tIIRKA4U6ikcPVCRG0VkhFryqrjxztGNwlsI=; b=N+unzIdJcDdHRnkmrXU6iAhIirN2co+5AZ8FLR4c4jWPc6ZoKgeTD5vCHQaoXLBURV cQRV0eMQFoa+6hAZfnY91DsdBi2nTKog4BkbE43W4e1jSApTkbgm1ZJXC1HH5aq1+ksk FcByvbZ1giOvW5DgpmKiYxc0rz6ckcTqooq5u8+5mlwSH9E1ELonhIlkcf9g242Xpit9 NB5cYKWI/9P4fBsy0fWh4QaQWuQrVUD5Pdy4W9f15Gsd/Un7it+Nr+JhDGKJhukV6n3n FrbYVcNtLybtUOxKbktsArt9ZN0jC1DahWx4rrCTzmL9EexoItummqLumxZmdEMKr8UI KrAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=i7MhZc+tIIRKA4U6ikcPVCRG0VkhFryqrjxztGNwlsI=; b=Uqh/M8c7LHqni7lbimzH4PfVQdE24dmFIfaFxyIuob4vDOmdVubDMX1/Ub2Ci1ZcMI sN78+y79++MOGnsjNg2oi6FZwfg6rpDlKcPJBtuYJUYugHSTXNChHQt02aPeKTguGRi0 ASPv3WxGfaZage3qRtJSAKPp0XHp/n41VQ8Poyp0xqOp55x4WRQhOcr2AxltfJjtUHEN ff2uZbsXdlDSpRmWIC9YFIvzhEyZMzA9NvQy2v3F9W78nbU9bmM9ycrX+tCaNXrZIu0q y5AIYfE4Oq0eTAkqaQx8FDVP9/oK5kLRJiiBkLT73BYhpClw11Gdo7fgcRo7RzqAZAso 5E0g== X-Gm-Message-State: APt69E2qjjogoRq/1wjj9ZXlqcwCrJETg253ARK7sfWU5clD0Jr3pukG 2QoywAIK5BODxw9csijS6oBz7Xs341Y= X-Google-Smtp-Source: ADUXVKLw27frXqaQ7Y/eyX+pC7q3Ghl2oMiH4lDGp9qL0m9fXmFlTbOnlnvOJkF5ZSBpv4UJ8MMH5g== X-Received: by 2002:a0c:e8cf:: with SMTP id m15-v6mr1004541qvo.52.1527816475314; Thu, 31 May 2018 18:27:55 -0700 (PDT) From: Keno Fischer To: qemu-devel@nongnu.org Date: Thu, 31 May 2018 21:26:14 -0400 Message-Id: X-Mailer: git-send-email 2.8.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::22e Subject: [Qemu-devel] [PATCH v2 19/20] 9p: darwin: virtfs-proxy: Implement setuid code for darwin X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keno Fischer , groug@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Darwin does not have linux capabilities, so make that code linux-only. Darwin also does not have setresuid/gid. The correct way to temporarily drop capabilities is to call seteuid/gid. Also factor out the code that acquires acquire_dac_override into a separate function in the linux implementation. I had originally done this when I thought it made sense to have only one `setugid` function, but I retained this because it seems clearer this way. Signed-off-by: Keno Fischer --- Changes from v1: New patch. fsdev/virtfs-proxy-helper.c | 200 +++++++++++++++++++++++++++-------------= ---- 1 file changed, 125 insertions(+), 75 deletions(-) diff --git a/fsdev/virtfs-proxy-helper.c b/fsdev/virtfs-proxy-helper.c index d8dd3f5..6baf2a6 100644 --- a/fsdev/virtfs-proxy-helper.c +++ b/fsdev/virtfs-proxy-helper.c @@ -82,6 +82,7 @@ static void do_perror(const char *string) } } =20 +#ifdef CONFIG_LINUX static int do_cap_set(cap_value_t *cap_value, int size, int reset) { cap_t caps; @@ -121,6 +122,85 @@ error: return -1; } =20 +static int acquire_dac_override(void) +{ + cap_value_t cap_list[] =3D { + CAP_DAC_OVERRIDE, + }; + return do_cap_set(cap_list, ARRAY_SIZE(cap_list), 0); +} + +/* + * from man 7 capabilities, section + * Effect of User ID Changes on Capabilities: + * If the effective user ID is changed from nonzero to 0, then the permitt= ed + * set is copied to the effective set. If the effective user ID is changed + * from 0 to nonzero, then all capabilities are are cleared from the effec= tive + * set. + * + * The setfsuid/setfsgid man pages warn that changing the effective user I= D may + * expose the program to unwanted signals, but this is not true anymore: f= or an + * unprivileged (without CAP_KILL) program to send a signal, the real or + * effective user ID of the sending process must equal the real or saved u= ser + * ID of the target process. Even when dropping privileges, it is enough = to + * keep the saved UID to a "privileged" value and virtfs-proxy-helper won't + * be exposed to signals. So just use setresuid/setresgid. + */ +static int setugid(int uid, int gid, int *suid, int *sgid) +{ + int retval; + + *suid =3D geteuid(); + *sgid =3D getegid(); + + if (setresgid(-1, gid, *sgid) =3D=3D -1) { + retval =3D -errno; + goto err_out; + } + + if (setresuid(-1, uid, *suid) =3D=3D -1) { + retval =3D -errno; + goto err_sgid; + } + + if (uid !=3D 0 || gid !=3D 0) { + /* + * We still need DAC_OVERRIDE because we don't change + * supplementary group ids, and hence may be subjected DAC rules + */ + if (acquire_dac_override() < 0) { + retval =3D -errno; + goto err_suid; + } + } + return 0; + +err_suid: + if (setresuid(-1, *suid, *suid) =3D=3D -1) { + abort(); + } +err_sgid: + if (setresgid(-1, *sgid, *sgid) =3D=3D -1) { + abort(); + } +err_out: + return retval; +} + +/* + * This is used to reset the ugid back with the saved values + * There is nothing much we can do checking error values here. + */ +static void resetugid(int suid, int sgid) +{ + if (setresgid(-1, sgid, sgid) =3D=3D -1) { + abort(); + } + if (setresuid(-1, suid, suid) =3D=3D -1) { + abort(); + } +} + static int init_capabilities(void) { /* helper needs following capabilities only */ @@ -135,6 +215,51 @@ static int init_capabilities(void) }; return do_cap_set(cap_list, ARRAY_SIZE(cap_list), 1); } +#else +static int setugid(int uid, int gid, int *suid, int *sgid) +{ + int retval; + + *suid =3D geteuid(); + *sgid =3D getegid(); + + if (setegid(gid) =3D=3D -1) { + retval =3D -errno; + goto err_out; + } + + if (seteuid(uid) =3D=3D -1) { + retval =3D -errno; + goto err_sgid; + } + +err_sgid: + if (setgid(*sgid) =3D=3D -1) { + abort(); + } +err_out: + return retval; +} + +/* + * This is used to reset the ugid back with the saved values + * There is nothing much we can do checking error values here. + */ +static void resetugid(int suid, int sgid) +{ + if (setegid(sgid) =3D=3D -1) { + abort(); + } + if (seteuid(suid) =3D=3D -1) { + abort(); + } +} + +static int init_capabilities(void) +{ + return 0; +} +#endif =20 static int socket_read(int sockfd, void *buff, ssize_t size) { @@ -279,81 +404,6 @@ static int send_status(int sockfd, struct iovec *iovec= , int status) } =20 /* - * from man 7 capabilities, section - * Effect of User ID Changes on Capabilities: - * If the effective user ID is changed from nonzero to 0, then the permitt= ed - * set is copied to the effective set. If the effective user ID is changed - * from 0 to nonzero, then all capabilities are are cleared from the effec= tive - * set. - * - * The setfsuid/setfsgid man pages warn that changing the effective user I= D may - * expose the program to unwanted signals, but this is not true anymore: f= or an - * unprivileged (without CAP_KILL) program to send a signal, the real or - * effective user ID of the sending process must equal the real or saved u= ser - * ID of the target process. Even when dropping privileges, it is enough = to - * keep the saved UID to a "privileged" value and virtfs-proxy-helper won't - * be exposed to signals. So just use setresuid/setresgid. - */ -static int setugid(int uid, int gid, int *suid, int *sgid) -{ - int retval; - - /* - * We still need DAC_OVERRIDE because we don't change - * supplementary group ids, and hence may be subjected DAC rules - */ - cap_value_t cap_list[] =3D { - CAP_DAC_OVERRIDE, - }; - - *suid =3D geteuid(); - *sgid =3D getegid(); - - if (setresgid(-1, gid, *sgid) =3D=3D -1) { - retval =3D -errno; - goto err_out; - } - - if (setresuid(-1, uid, *suid) =3D=3D -1) { - retval =3D -errno; - goto err_sgid; - } - - if (uid !=3D 0 || gid !=3D 0) { - if (do_cap_set(cap_list, ARRAY_SIZE(cap_list), 0) < 0) { - retval =3D -errno; - goto err_suid; - } - } - return 0; - -err_suid: - if (setresuid(-1, *suid, *suid) =3D=3D -1) { - abort(); - } -err_sgid: - if (setresgid(-1, *sgid, *sgid) =3D=3D -1) { - abort(); - } -err_out: - return retval; -} - -/* - * This is used to reset the ugid back with the saved values - * There is nothing much we can do checking error values here. - */ -static void resetugid(int suid, int sgid) -{ - if (setresgid(-1, sgid, sgid) =3D=3D -1) { - abort(); - } - if (setresuid(-1, suid, suid) =3D=3D -1) { - abort(); - } -} - -/* * send response in two parts * 1) ProxyHeader * 2) Response or error status --=20 2.8.1 From nobody Sun Feb 8 06:54:29 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1527817457003230.25984357212053; Thu, 31 May 2018 18:44:17 -0700 (PDT) Received: from localhost ([::1]:46982 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOZ72-0006un-9S for importer@patchew.org; Thu, 31 May 2018 21:44:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33498) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOYrH-0003Gx-DU for qemu-devel@nongnu.org; Thu, 31 May 2018 21:28:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOYrG-0003Mw-Ew for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:59 -0400 Received: from mail-qk0-x242.google.com ([2607:f8b0:400d:c09::242]:38366) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOYrG-0003MM-A3 for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:58 -0400 Received: by mail-qk0-x242.google.com with SMTP id y4-v6so555063qka.5 for ; Thu, 31 May 2018 18:27:58 -0700 (PDT) Received: from localhost.localdomain (96-86-104-61-static.hfc.comcastbusiness.net. [96.86.104.61]) by smtp.gmail.com with ESMTPSA id o68-v6sm2003842qkc.19.2018.05.31.18.27.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 31 May 2018 18:27:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=juliacomputing-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=yryvrHh1q7WVNjHsOwKFkC1+fQue38nWq7Neelwz9os=; b=NkgQDxbBOlT//tD96ad0Hm7XZvZUMylh+Gfm6QohBOGBLFfFA8IeQyssPV7NEtMzhj l7cp/x8uHkEQrum4tsckWIFxmc3jvNH2F4nxHJBocntFIvhevlzgov74d/oQYTUuGito n9wFsFwldEyJ2HglrEjgZRcnu2Qp3nri+aW5Jxs8OH22JtpKaFkwIaZZccXMuBPaIJDU i+q4C2by4UUhSEjcxpF5r0JCDu7s4n3uWUSDhiLnb6An7q9IX1dSqCAEK/3zxI0G+okM XwwBUhgOpWRTVUFAn3SDB4Sovxk/WFxh4Ar1zJIBqKlhe/pdiS4z6UqBQfEI7jihAX4p 7Nlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=yryvrHh1q7WVNjHsOwKFkC1+fQue38nWq7Neelwz9os=; b=Kp7WSx6/+HjHqISVKUc5EVvyynF9+wPnzWqCo81C5fPN1UMPbeYSR4kj60zznDq2US gmKkH3riEJOE2Hk3kRo0ukdp6JciwMrqkzCnpKIIw5Sg1PWg3IW8L0BKYMHjFxL5rSv5 hSoFooJYZ8m9qRUGAfft565sTX3B1oImvjEM7le8jo1VO9tOtbS6Xtxs2HbZ6kI8sCnR +CYmJrRPXPEWwbGqn7DgdxoJ0ZPYwf94mHhdhvK2P7asRqpU/JJz2lt2gKxY1Ugb+IHc wZ3J6GfLxrzVQdRLQBejthh9Bw/QMuG1nMo0eL6XwuespyjDaaDJ34GRb+c+JqWPgZBH t9XQ== X-Gm-Message-State: APt69E0XAptTNvWjx7y3gBF4S/A4kUt3b/2dxkZmkjoMi9UCVOt5cxl2 GU0y5ZyC6AftJSKaKOmFaoQmhDpZx98= X-Google-Smtp-Source: ADUXVKJ/jTtBKmn5skMfcOnclzGRX86pHYsFNGIn66l6d8S8ihuTz+N1YQukQOYZdLBznvhNVFiR8A== X-Received: by 2002:a37:c84d:: with SMTP id c74-v6mr8482306qkj.245.1527816477424; Thu, 31 May 2018 18:27:57 -0700 (PDT) From: Keno Fischer To: qemu-devel@nongnu.org Date: Thu, 31 May 2018 21:26:15 -0400 Message-Id: <9c0317e40b127c5f263f82ac628b28f89fddf33e.1527814874.git.keno@juliacomputing.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::242 Subject: [Qemu-devel] [PATCH v2 20/20] 9p: darwin: configure: Allow VirtFS on Darwin X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keno Fischer , groug@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Keno Fischer --- Changes from v1: Now builds the proxy-helper on Darwin. Makefile.objs | 1 + configure | 22 +++++++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Makefile.objs b/Makefile.objs index c6c3554..a2245c9 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -104,6 +104,7 @@ common-obj-$(CONFIG_WIN32) +=3D os-win32.o common-obj-$(CONFIG_POSIX) +=3D os-posix.o =20 common-obj-$(CONFIG_LINUX) +=3D fsdev/ +common-obj-$(CONFIG_DARWIN) +=3D fsdev/ =20 common-obj-y +=3D migration/ =20 diff --git a/configure b/configure index a6a4616..4808459 100755 --- a/configure +++ b/configure @@ -5535,16 +5535,28 @@ if test "$want_tools" =3D "yes" ; then fi fi if test "$softmmu" =3D yes ; then - if test "$linux" =3D yes; then - if test "$virtfs" !=3D no && test "$cap" =3D yes && test "$attr" =3D y= es ; then + if test "$virtfs" !=3D no; then + if test "$linux" =3D yes; then + if test "$cap" =3D yes && test "$attr" =3D yes ; then + virtfs=3Dyes + tools=3D"$tools fsdev/virtfs-proxy-helper\$(EXESUF)" + else + if test "$virtfs" =3D yes; then + error_exit "VirtFS requires libcap devel and libattr devel under= Linux" + fi + virtfs=3Dno + fi + elif test "$darwin" =3D yes; then virtfs=3Dyes tools=3D"$tools fsdev/virtfs-proxy-helper\$(EXESUF)" else if test "$virtfs" =3D yes; then - error_exit "VirtFS requires libcap devel and libattr devel" + error_exit "VirtFS is supported only on Linux and Darwin" fi virtfs=3Dno fi + fi + if test "$linux" =3D yes; then if test "$mpath" !=3D no && test "$mpathpersist" =3D yes ; then mpath=3Dyes else @@ -5555,10 +5567,6 @@ if test "$softmmu" =3D yes ; then fi tools=3D"$tools scsi/qemu-pr-helper\$(EXESUF)" else - if test "$virtfs" =3D yes; then - error_exit "VirtFS is supported only on Linux" - fi - virtfs=3Dno if test "$mpath" =3D yes; then error_exit "Multipath is supported only on Linux" fi --=20 2.8.1