From patchwork Sun Jun 17 00:56:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keno Fischer X-Patchwork-Id: 930429 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=juliacomputing.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=juliacomputing-com.20150623.gappssmtp.com header.i=@juliacomputing-com.20150623.gappssmtp.com header.b="EF5gB6dQ"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 417bWr2ZYMz9s2R for ; Sun, 17 Jun 2018 11:01:12 +1000 (AEST) Received: from localhost ([::1]:53371 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUM45-0008KV-UV for incoming@patchwork.ozlabs.org; Sat, 16 Jun 2018 21:01:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56780) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUM0R-0005h2-Ll for qemu-devel@nongnu.org; Sat, 16 Jun 2018 20:57:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fUM0N-0003Ej-I0 for qemu-devel@nongnu.org; Sat, 16 Jun 2018 20:57:23 -0400 Received: from mail-qk0-x242.google.com ([2607:f8b0:400d:c09::242]:38969) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fUM0N-0003EX-D3 for qemu-devel@nongnu.org; Sat, 16 Jun 2018 20:57:19 -0400 Received: by mail-qk0-x242.google.com with SMTP id g14-v6so7673997qkm.6 for ; Sat, 16 Jun 2018 17:57:19 -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=MH6IPQdpjOg6JGiAgiA/ioo+6cY2H9F6KPcwdZB/J8E=; b=EF5gB6dQfDnzWIhxt4L6GvejFq7urWOHvufzdbLKMlyJzBGiAtBNg/oK5u2zcgYW48 UU517mrcZ3yi6/0gQQgvooGETxV/qQaaMF5535+6rLcIvfuxMyMMnaZiC4ll6k59azVY IFQqMM5raOOsob7Jk1Gfrtr4mtXeEHu8wG3yopoICp4NU+pALqH4aXifzRwC60i6Bhpl UfSRbb4lGk5glULh9vVy8Wgm6AvBQIpZUgx5fEcXFF0tVl63P7MBAvCZgkgnE1SL7nu0 ebDS714cQc3yc+x+opGZbcZGlZlkHmYoDesKtjZk1dVDpHHKjGTzU3IHL1xwnNLpHpGy /UNQ== 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=MH6IPQdpjOg6JGiAgiA/ioo+6cY2H9F6KPcwdZB/J8E=; b=m4HTLtx5ieyzKWuF21fvMJbWw3fPqnFHL+l8/IYrUEe5dECBqyV6jILHfnrW0E/U44 n0c2Ca1//QOBTrStVVEZa/eNJENNH6dRjkPu7s4STrsGfqAs62qyNBoZiiJE91jLxnF+ mk70Ekzxu3ooOsORhlWbCkH/KuDQYWPKayb+yhovR25cepSe9BBTJFFlNH7/qXDsTUvV xpXOL3Or99FGx7mqV/PWV5kP64Jhu+1/AotfxdFftf881baRdkcORf4HNlBR5qsPvEy1 5n26IFV2VaCbVNoNP21uAmg4b1wkSMck90RFzazKn7KP3KlX+6hNJjjWXnOxb6tmFKDa 04uA== X-Gm-Message-State: APt69E3f4+e8ih4l8iOFerCAxKIdEiD5anYmXzz5eU8nzRxfP6o/bIY+ w8iJDsxBWuezEuO/lHFUdc+eHOY1afY= X-Google-Smtp-Source: ADUXVKLaiN/n9Fi3nbEir63oO2dMik1t6vLwyLvCVhnVIqX5wUwOelsogEGjIRnPf3KfwrmXYAxXTg== X-Received: by 2002:a37:4ac4:: with SMTP id x187-v6mr6006845qka.156.1529197038555; Sat, 16 Jun 2018 17:57:18 -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 x21-v6sm7302186qto.2.2018.06.16.17.57.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 16 Jun 2018 17:57:17 -0700 (PDT) From: Keno Fischer To: qemu-devel@nongnu.org Date: Sat, 16 Jun 2018 20:56:45 -0400 Message-Id: <603b0ffda828e4c6a7ac9799853df0d6a5be3822.1529196703.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 v3 01/13] 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 , Keno Fischer , groug@kaod.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Keno Fischer - 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 --- 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 @@ #include #include -#include +#include "qemu/statfs.h" #include "qemu-fsdev-throttle.h" #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 828e8d6..d713983 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 #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 From patchwork Sun Jun 17 00:56:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keno Fischer X-Patchwork-Id: 930430 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=juliacomputing.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=juliacomputing-com.20150623.gappssmtp.com header.i=@juliacomputing-com.20150623.gappssmtp.com header.b="uaHLlU0f"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 417bWy0GpSz9s29 for ; Sun, 17 Jun 2018 11:01:18 +1000 (AEST) Received: from localhost ([::1]:53372 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUM4B-0008OE-Gk for incoming@patchwork.ozlabs.org; Sat, 16 Jun 2018 21:01:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56781) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUM0R-0005h4-Ly for qemu-devel@nongnu.org; Sat, 16 Jun 2018 20:57:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fUM0O-0003Ey-GQ for qemu-devel@nongnu.org; Sat, 16 Jun 2018 20:57:23 -0400 Received: from mail-qt0-x241.google.com ([2607:f8b0:400d:c0d::241]:45247) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fUM0O-0003Ep-B1 for qemu-devel@nongnu.org; Sat, 16 Jun 2018 20:57:20 -0400 Received: by mail-qt0-x241.google.com with SMTP id i18-v6so12370287qtp.12 for ; Sat, 16 Jun 2018 17:57:20 -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=h//ZK5ZCkiR4iWAoGD2v/GhWc/kxwptw2dvQV9YsLK0=; b=uaHLlU0fckf6J1AfyBOwa2eZA2LPGvhEEgNqNc5KxiNWAdtYElCDMeNUEb0WgJZxhQ OodYw44dPlBbaytg5aiZpsJQbz7N7n8dQYnUi+zKueVkQ0J6lXrxc66mJ3Jhh2rYmrXF JK+Nyg3B8Gtc/bI3gGeuNhum9CXRBmSzJvxm7cDKKlXga38+CC6OWYBRkSXCdjI+PGxu IrzaovQHN+IlIcaHfXFf/UxAytPonZHijvu7uuJgBjhW5G3P35dl4CijD1zYRpUVN2uk s1STD4BL4eciiSe8MkpxlSKCWseffPWv9Q4auryLHsL+trjT0WDbP0ovXeOu+h7aiJSa g4pA== 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=h//ZK5ZCkiR4iWAoGD2v/GhWc/kxwptw2dvQV9YsLK0=; b=lNlJA63ZEw48tDynxX4JexHUDnldWu8hs8971gmMhS4VjPPCFXkXyO9sFqGCOxBOFI k+8nFSIrP78uBfthNddORSlvULw2J0zNCYHXljglkeid5Xkyv1jdKBtARpmOC57mYThD RyVUDrSdiKFlDyufs+Na+CMrR59+HYz5T0fu0pW/YlmmcTSy60CRq1Te2geq4TC0qkZy qH8z/QS0tDcaPi2RJRd7zLs2lVFx30J+4XdXfZGrsYrSunvDe/LvyYXZoy4GCmtC5XnV p38Dul8gBHca1PzDmr1n96i4g4px4NIMyZ2N0RY54Z1xKi2+fls9kVsrQvZHubK2lXmQ 1gRA== X-Gm-Message-State: APt69E2Y1DpV1Qfzs/qPoRAnBRt67iaTEyRpAXcSu9/0bLaSiqiaNp9G ZpMxhQxO6BlD6JBc6iF7fT4rex+g88s= X-Google-Smtp-Source: ADUXVKJpk4sJ9KR8AAgyL+Z+vV81ODC4V4JECIUAWvastykhOPMTiQOs0N6RVpCMMqWU0cJygOZvDQ== X-Received: by 2002:a0c:f489:: with SMTP id i9-v6mr6392763qvm.0.1529197039500; Sat, 16 Jun 2018 17:57:19 -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 x21-v6sm7302186qto.2.2018.06.16.17.57.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 16 Jun 2018 17:57:18 -0700 (PDT) From: Keno Fischer To: qemu-devel@nongnu.org Date: Sat, 16 Jun 2018 20:56:46 -0400 Message-Id: <2fafd9bc91e8104f302eda0bc7da5e90b868c7e3.1529196703.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 v3 02/13] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 --- 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 later. + * 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 = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename); + int ret; + + ret = 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 = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename); + int ret; + + ret = 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 = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename); + int ret; + + ret = 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 = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename); + int ret; + + ret = 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 later. - * 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 = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename); - int ret; - - ret = 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 = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename); - int ret; - - ret = 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 = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename); - int ret; - - ret = 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 = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename); - int ret; - - ret = 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 e3fa673..95e3bc0 100644 --- a/hw/9pfs/Makefile.objs +++ b/hw/9pfs/Makefile.objs @@ -1,5 +1,6 @@ ifeq ($(call lor,$(CONFIG_VIRTIO_9P),$(CONFIG_XEN)),y) -common-obj-y = 9p.o 9p-util.o +common-obj-y = 9p.o +common-obj-$(CONFIG_LINUX) += 9p-util-linux.o common-obj-y += 9p-local.o 9p-xattr.o common-obj-y += 9p-xattr-user.o 9p-posix-acl.o common-obj-y += coth.o cofs.o codir.o cofile.o From patchwork Sun Jun 17 00:56:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keno Fischer X-Patchwork-Id: 930434 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=juliacomputing.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=juliacomputing-com.20150623.gappssmtp.com header.i=@juliacomputing-com.20150623.gappssmtp.com header.b="tcUC6G9Y"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 417bc96pXmz9s29 for ; Sun, 17 Jun 2018 11:04:57 +1000 (AEST) Received: from localhost ([::1]:53388 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUM7j-0002Kk-Gg for incoming@patchwork.ozlabs.org; Sat, 16 Jun 2018 21:04:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56787) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUM0R-0005h9-Mk for qemu-devel@nongnu.org; Sat, 16 Jun 2018 20:57:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fUM0Q-0003FO-Cq for qemu-devel@nongnu.org; Sat, 16 Jun 2018 20:57:23 -0400 Received: from mail-qk0-x243.google.com ([2607:f8b0:400d:c09::243]:40486) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fUM0Q-0003FJ-7q for qemu-devel@nongnu.org; Sat, 16 Jun 2018 20:57:22 -0400 Received: by mail-qk0-x243.google.com with SMTP id r66-v6so7667766qkr.7 for ; Sat, 16 Jun 2018 17:57:22 -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=iHYdMVdKbYIX0TzYjHw3lSfvTsIARHO4irsE2aq/rLk=; b=tcUC6G9Y//J/OGBn9G9yEex8gHbLq7pLqRx4UEqmBLax5FAXa5/2M1C0lzMIZoGCFM Ye/oS1Y2821dL6p4YkrO/U/WkxLHEzZvk7hYo8aFUOzqmBB8MV0eK4ZBOv2gROA4dwAP nhy5nKwq8zoF6QjFZRHnDyD51ZNGRlMkLeMEkgzp0KDiq7ECxKPVb7EcPKERXkbVyfCo 7HTTUF51NPPoza3Mo96/JOJJcb2/wVOUfa0mY+4UubwL7u0M2bJzFrkiNHjM/bubFVZz 2pGoa/+F0eas5XWJyAlKJzyNEB8pT427VSa8GuK1L/4ONLkA4TIpdO4X76SzZrY8Rjaz vYpQ== 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=iHYdMVdKbYIX0TzYjHw3lSfvTsIARHO4irsE2aq/rLk=; b=s//YxanC0jSzW6FDkvhjbZGfSd7uU2vdy228Sc8yYK3W93kOOTDM/18lkHwq301cyB koEr7dxN5rjkJ6pbAXFulPcnTY2uh6C9ENE6bYx3h/UyEX79amlUQxxvHKokcuc+s3q1 vxV+KrlWkOoQ/mtcml33yH9O3he1cZ7PUrXP9KcMoKH7xRavCMMuqYGFOPXQ6Bs80/R8 U27gMQwqYVkYRNooWx9MIdIS3TzxNZ3L+KsFn3bgwmvHZKZ0tbQHJ5+QgJPiEAXdeNoW Km3fr2mFkkX81YvfkMjXWStwdPwJNDQ72ZJSGDjCk1aoEWvdktJ9uIPn6r6o9kjKPg6q efOQ== X-Gm-Message-State: APt69E26QJXT8OQRRj0p8eaaGwVcdcvp5vTbKRAfSwM1rpMAcAFDwCEY xtuNKcxK5g7cwEbwTYgJbELxtdVJoWc= X-Google-Smtp-Source: ADUXVKLvvBhKnMcCf58EE5ZaDPP4fCU60wlQn7OIy6xPyYjAGBcysukTjAECmF/jxNtFLbKjZQWA2g== X-Received: by 2002:a37:9d13:: with SMTP id g19-v6mr5899213qke.217.1529197041419; Sat, 16 Jun 2018 17:57:21 -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 x21-v6sm7302186qto.2.2018.06.16.17.57.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 16 Jun 2018 17:57:20 -0700 (PDT) From: Keno Fischer To: qemu-devel@nongnu.org Date: Sat, 16 Jun 2018 20:56:48 -0400 Message-Id: <7d1009b3e1f8c1ee7a5c7bf1fa71282d0345010c.1529196703.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::243 Subject: [Qemu-devel] [PATCH v3 04/13] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 --- 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 = node->attr->inode; +#ifndef CONFIG_DARWIN entry->d_off = off + 1; +#endif } static struct dirent *synth_get_dentry(V9fsSynthNode *dir, diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 8e6b908..06139c9 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -1738,6 +1738,25 @@ static int v9fs_xattr_read(V9fsState *s, V9fsPDU *pdu, V9fsFidState *fidp, return offset; } +/** + * Get the seek offset of a dirent. If not available from the structure itself, + * 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(V9fsPDU *pdu, count += len; v9fs_stat_free(&v9stat); v9fs_path_free(&path); - saved_dir_pos = dent->d_off; + saved_dir_pos = v9fs_dent_telldir(pdu, fidp, dent); + if (saved_dir_pos < 0) { + err = saved_dir_pos; + break; + } } 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 = 0; int32_t count = 0; - off_t saved_dir_pos; + off_t saved_dir_pos, off; struct dirent *dent; /* save the directory position */ @@ -1951,10 +1974,15 @@ static int coroutine_fn v9fs_do_readdir(V9fsPDU *pdu, V9fsFidState *fidp, /* Fill the other fields with dummy values */ qid.type = 0; qid.version = 0; + off = v9fs_dent_telldir(pdu, fidp, dent); + if (off < 0) { + err = off; + break; + } /* 11 = 7 + 4 (7 = start offset, 4 = space for storing count) */ len = pdu_marshal(pdu, 11 + count, "Qqbs", - &qid, dent->d_off, + &qid, off, dent->d_type, &name); v9fs_readdir_unlock(&fidp->fs.dir); @@ -1966,7 +1994,7 @@ static int coroutine_fn v9fs_do_readdir(V9fsPDU *pdu, V9fsFidState *fidp, } count += len; v9fs_string_free(&name); - saved_dir_pos = dent->d_off; + saved_dir_pos = off; } v9fs_readdir_unlock(&fidp->fs.dir); From patchwork Sun Jun 17 00:56:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keno Fischer X-Patchwork-Id: 930428 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=juliacomputing.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=juliacomputing-com.20150623.gappssmtp.com header.i=@juliacomputing-com.20150623.gappssmtp.com header.b="C4IpiX3e"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 417bWm4vWPz9s29 for ; Sun, 17 Jun 2018 11:01:08 +1000 (AEST) Received: from localhost ([::1]:53369 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUM42-0008Hm-7N for incoming@patchwork.ozlabs.org; Sat, 16 Jun 2018 21:01:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56794) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUM0S-0005hQ-4G for qemu-devel@nongnu.org; Sat, 16 Jun 2018 20:57:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fUM0R-0003Fc-9o for qemu-devel@nongnu.org; Sat, 16 Jun 2018 20:57:24 -0400 Received: from mail-qk0-x242.google.com ([2607:f8b0:400d:c09::242]:42649) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fUM0R-0003FW-5G for qemu-devel@nongnu.org; Sat, 16 Jun 2018 20:57:23 -0400 Received: by mail-qk0-x242.google.com with SMTP id j80-v6so7659717qke.9 for ; Sat, 16 Jun 2018 17:57:22 -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=UoSGfF6b9Eh1bDOJSj76wXhy+XcPWYROsCZ65drpFpE=; b=C4IpiX3eVuK/ALkSXu+EtTabu08Ryod75csmfotI+iuBzq8AXxxg8U0H5HePGlGrX+ 4t/mNx14Kx/13uhbx5n/PGjMzLFvQpgvblmHyWlXrxE5d6Z1fTW8+p4ZUxtqT8FP5j18 OmPmAC9Q+IJJUsH+TUTUm0so6nKVcG1/KgrD+b/bqI9Dy76jsCZBlTkx0yY3iRhxBLab mDjNn9Lds9b52wJ6d8Wjm18swlR06Vse5BuU00SxK3Oech/QhrO9PssrSzngyFEUXxBQ /LTT0I5dxnrt2VXd/19588eZlwZ4f0farvF+LLMvHEfCumvqi3h3L8sW/W8i3m7VEJro Bx3A== 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=UoSGfF6b9Eh1bDOJSj76wXhy+XcPWYROsCZ65drpFpE=; b=aHi+lGezTR8GZFJ+qsgsRlBBFGLleYjO77qXOlagxvpFNWfyN/SAX1unQaGOeHob9j Ki6PF3n7zJrdvalMT6hkzPLxyMZ07XpJgqApRphbuZUaZVEJ9W1QRcg5fsvUuZzegE3p uRWPv4KnxTOXipMw+PPHwZsqLjENpS5c2DaNV/tlCrVTgfabl9oWn2FuEUdCzhHSD6Jo P3+ifbqpLwb0JeMP6pTG45+2d1ilfWYcQtb5OmoatC1uG9oPa+Nk+qP38jdXpb2QGPup w3Gqo492i4YXPrHF7vTsP0vTbJy8u62S5qvBtai0jSbIqWsaSXxyangoelMY500Ulrkc wnrg== X-Gm-Message-State: APt69E3l3ssUek78l7V1OTwWWo0X8BtNSuSreDkRPJSZ8u0UT6qH2Dux XHCq2S4lgbEiDa+VHmbDbnluOW466fU= X-Google-Smtp-Source: ADUXVKKfCKeUtQ9SB2rVObVzUaP70th/axTnbofmueFYCJWd8LSdHjsfPbt7bCzlxsK+EI7XJCRXgQ== X-Received: by 2002:a37:86c3:: with SMTP id i186-v6mr6198401qkd.70.1529197042408; Sat, 16 Jun 2018 17:57:22 -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 x21-v6sm7302186qto.2.2018.06.16.17.57.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 16 Jun 2018 17:57:21 -0700 (PDT) From: Keno Fischer To: qemu-devel@nongnu.org Date: Sat, 16 Jun 2018 20:56:49 -0400 Message-Id: <08ebbb93dbfc29bbb727c05a16cd5ded6dec42b3.1529196703.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 v3 05/13] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Comparisons of mode_t with -1 require an explicit cast, since mode_t is unsigned on Darwin. Signed-off-by: Keno Fischer --- 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 d713983..98d4073 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -310,7 +310,7 @@ update_map_file: if (credp->fc_gid != -1) { gid = credp->fc_gid; } - if (credp->fc_mode != -1) { + if (credp->fc_mode != (mode_t)-1) { mode = credp->fc_mode; } if (credp->fc_rdev != -1) { @@ -416,7 +416,7 @@ static int local_set_xattrat(int dirfd, const char *path, FsCred *credp) return err; } } - if (credp->fc_mode != -1) { + if (credp->fc_mode != (mode_t)-1) { uint32_t tmp_mode = cpu_to_le32(credp->fc_mode); err = fsetxattrat_nofollow(dirfd, path, "user.virtfs.mode", &tmp_mode, sizeof(mode_t), 0); From patchwork Sun Jun 17 00:56:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keno Fischer X-Patchwork-Id: 930427 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=juliacomputing.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=juliacomputing-com.20150623.gappssmtp.com header.i=@juliacomputing-com.20150623.gappssmtp.com header.b="qNL37sZT"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 417bTD6Frdz9s2R for ; Sun, 17 Jun 2018 10:58:56 +1000 (AEST) Received: from localhost ([::1]:53357 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUM1u-0006Jz-Ga for incoming@patchwork.ozlabs.org; Sat, 16 Jun 2018 20:58:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56825) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUM0T-0005hp-0c for qemu-devel@nongnu.org; Sat, 16 Jun 2018 20:57:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fUM0S-0003GC-6z for qemu-devel@nongnu.org; Sat, 16 Jun 2018 20:57:25 -0400 Received: from mail-qk0-x244.google.com ([2607:f8b0:400d:c09::244]:38513) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fUM0S-0003Fm-1h for qemu-devel@nongnu.org; Sat, 16 Jun 2018 20:57:24 -0400 Received: by mail-qk0-x244.google.com with SMTP id y4-v6so7674844qka.5 for ; Sat, 16 Jun 2018 17:57:23 -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=fPovA32VQtt2A9u9VWCYZSyi3kThCbyYmHRhyf1HCC0=; b=qNL37sZTBScBwciTCZsHvYl1vf5zNl+VGW2giqLiBAPYcRc9Eac4S81zK2CCXxMDXh /kSTvf2IPFWv+17F78WIq9B7bEY8eNX+RQw576C0zvrada56b5Qv4qpKpPUT+n79RX4T Mqx0Fa0dHcLuSbvf9Rg3nvsRUfpEb/ZZp95iBgFDkFA+ckXSxDNf5zGEDI36XQOnzWGQ AwllCsFR+wDiQeyqjvfRcb1afKtHxtFcjOP7SzZrTnjKMBiRCauAz1ltDBslo3Z0BBS8 cB7/nIbZPhgwANdu7KpgLz90Rfw4hMZtHsWUxRrFtkyE/wAb86HMBxhagfR9F1z+9rdR CROg== 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=fPovA32VQtt2A9u9VWCYZSyi3kThCbyYmHRhyf1HCC0=; b=DDB9A8KbSciXZ6PHJrIQrxjbVO1IFquKR+RHSr8UgWpbv8d36R/cauVxclBYL7B74I AqHJTb0jzA+zBmiEEr63No3PuOkD+sToUQ6wGRIf24fS01rExOPpBLJcK1eXKfuhJ2+9 SJBMjRLcTgK9+GwmxuZQjzBZ8K2ghhiytaqzbMTrAagJ0re0u4t8ZL9V/61xEbnn1sAQ GuMgmhHzuHlmae7yw/Hpq3qJbt9usOiytltxxP64GAyAtgebN4Qh4qxxHqrLHV5yCgm1 Qt7ykxhxZvPjDEycXu2SNKxyJmXirJR2ZHVtW3O/gFa+LH129WH72bd21mdTN0GxSRBv Bvqg== X-Gm-Message-State: APt69E3Un4SKkcL0MW/iJdJFH3NCfovXNMKFN1vgJv+x8AjpWzl4cQ0V OtQ0ywg4cKcGK7jMZvKKJqf1rb1txIc= X-Google-Smtp-Source: ADUXVKKMNveVcfLOvQXfUL2PlfatXMrN7/xd3ftUIdthx2vgmd9DGLT9msFpvyXNNkzAwJUwyVgMmw== X-Received: by 2002:ae9:d805:: with SMTP id u5-v6mr6050787qkf.13.1529197043199; Sat, 16 Jun 2018 17:57:23 -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 x21-v6sm7302186qto.2.2018.06.16.17.57.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 16 Jun 2018 17:57:22 -0700 (PDT) From: Keno Fischer To: qemu-devel@nongnu.org Date: Sat, 16 Jun 2018 20:56:50 -0400 Message-Id: <823a49a8771e3214dc953ed9d7facd02df3060e4.1529196703.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 v3 06/13] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 Reviewed-by: Greg Kurz --- 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 06139c9..e650459 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 }, }; @@ -156,10 +163,12 @@ static int get_dotl_openflags(V9fsState *s, int oflags) */ flags = dotl_to_open_flags(oflags); flags &= ~(O_NOCTTY | O_ASYNC | O_CREAT); +#ifndef CONFIG_DARWIN /* * Ignore direct disk access hint until the server supports it. */ flags &= ~O_DIRECT; +#endif return flags; } From patchwork Sun Jun 17 00:56:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keno Fischer X-Patchwork-Id: 930424 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=juliacomputing.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=juliacomputing-com.20150623.gappssmtp.com header.i=@juliacomputing-com.20150623.gappssmtp.com header.b="F/kz5PRb"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 417bST09hbz9s2R for ; Sun, 17 Jun 2018 10:58:15 +1000 (AEST) Received: from localhost ([::1]:53354 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUM1F-0005jJ-B8 for incoming@patchwork.ozlabs.org; Sat, 16 Jun 2018 20:58:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56837) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUM0T-0005iJ-Ut for qemu-devel@nongnu.org; Sat, 16 Jun 2018 20:57:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fUM0T-0003Gc-9b for qemu-devel@nongnu.org; Sat, 16 Jun 2018 20:57:26 -0400 Received: from mail-qk0-x241.google.com ([2607:f8b0:400d:c09::241]:35378) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fUM0T-0003GP-5N for qemu-devel@nongnu.org; Sat, 16 Jun 2018 20:57:25 -0400 Received: by mail-qk0-x241.google.com with SMTP id d130-v6so7676791qkc.2 for ; Sat, 16 Jun 2018 17:57:25 -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=A3N5nyGUFyifKUe37O6CMAsLpH70U67lubKcTGml49g=; b=F/kz5PRbX8WQnWVl9rrUeJj9/at46Urvg7Dx5ygO6cZo09/HjkQpN5jhKLq6k2juWN tasClMgUZORvTRWuUT8U8Mu020ZXVklvRxfcWpisW5alhSfQUzdULm+TgMB9lbJTTX9D o0FKKvWVJn6oj6HwhqgFmP2gpjKJSt91ofn0W0SJeeIvZG6rMRDsVMsEe2nNHLqzVV6C 6lDPzLyGRxLyHcRWukx4JYCM33V53sCSRUH8Nm+JSSla7SWmdcRcw9ZyNmiN+cAt/MeV xX93+d7aOO/O8ddy5sVxTpKgfhUVr8PdGgWGXF4Es5XaNNSpYBeN+2q8tYKGO17vNGsA 2Zvg== 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=A3N5nyGUFyifKUe37O6CMAsLpH70U67lubKcTGml49g=; b=SPgCftyrYkVqZSyZtquVrNM+jYId6ULxIyMK0CJnvbY/aDBVP1+c6+/ueUsU5w8wwk kAtT19W4MiqjeowFdUIyMt+GF28cSTVoWsZ1o0dT+sDQziPgo4jUehBxG8f9GoVrCSeh s5PPaAq4jDYe3SHQLyZ/nPrfv0Bts6OvFsJjb0hnFj1cOMNZ+w+mJDAqJfwWIxLb/w9/ a8pxj+uA27pFIbZ7vIp6a6id8Nm2PAq0OgePmheBGlSjiUZmz6xlLZOfy0dPlkX/xJtn bOj1pOq2zqN17Kzm0gD0vFqTem2w/lpc2/eLv//VEUIYysvLRr1v082N+YyAq85z1n5a HSdg== X-Gm-Message-State: APt69E1w7fEzXj0mLooCCB92mHM6UqzaNNLbAOWjz0Guzr5CSCugChYG GZ0EapfMD1hSI8aFpODpOKz3Yv9YD2k= X-Google-Smtp-Source: ADUXVKJU7/gvomjbwYtIiL/7Aw9X64lj8E1hi16J1D2FAS+YkutysrlDkhXl0qAv6J9MGC0dz0JKCg== X-Received: by 2002:a37:9301:: with SMTP id v1-v6mr5980213qkd.216.1529197044317; Sat, 16 Jun 2018 17:57:24 -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 x21-v6sm7302186qto.2.2018.06.16.17.57.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 16 Jun 2018 17:57:23 -0700 (PDT) From: Keno Fischer To: qemu-devel@nongnu.org Date: Sat, 16 Jun 2018 20:56:51 -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 v3 07/13] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Keno Fischer --- hw/9pfs/9p.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index e650459..abfb8dc 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -3374,6 +3374,13 @@ out_nofid: v9fs_string_free(&name); } +#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, rflags = 0; From patchwork Sun Jun 17 00:56:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keno Fischer X-Patchwork-Id: 930432 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=juliacomputing.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=juliacomputing-com.20150623.gappssmtp.com header.i=@juliacomputing-com.20150623.gappssmtp.com header.b="c3dXaFQ7"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 417bby1L3Xz9s29 for ; Sun, 17 Jun 2018 11:04:46 +1000 (AEST) Received: from localhost ([::1]:53385 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUM7X-0002F4-Sx for incoming@patchwork.ozlabs.org; Sat, 16 Jun 2018 21:04:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56848) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUM0V-0005iM-6L for qemu-devel@nongnu.org; Sat, 16 Jun 2018 20:57:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fUM0U-0003Gp-3B for qemu-devel@nongnu.org; Sat, 16 Jun 2018 20:57:27 -0400 Received: from mail-qt0-x244.google.com ([2607:f8b0:400d:c0d::244]:32913) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fUM0T-0003Gi-UP for qemu-devel@nongnu.org; Sat, 16 Jun 2018 20:57:26 -0400 Received: by mail-qt0-x244.google.com with SMTP id l10-v6so12414206qtj.0 for ; Sat, 16 Jun 2018 17:57:25 -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=a39E3ASG8sy/zL/I8k/4+p165bB01iLXVFh9FxOdrh8=; b=c3dXaFQ734yUkySnr4NtXgvRl06MlKrtd6FePX2/Z4ZvzatwBBuK4cV8ujAduiJBGL nXpzeHB+q1k+Fdlntwy9SGLov191OE7XNVD29NhdL2C3Ezq7W7PzvoSyKVt2LPGR2vMY FMBnUTJEw0N0IxCIwiRsw/f5uH41ZodTwyocos/ANZ0uLl+aH1o3xj2EQbP6cPH9MKcx j2WOknoJyA91p5xrMRiaLeRqQIoZvt3UFVIeBUSkqHrCISzG9WMhnp1y8HjBRRKg9ysJ aZ0NG2UTXlaJmegTqor+3anSJwWZv3digfBeuEFdHpZ2LUeSB2XJDF1htOvVqACU09dT +NzQ== 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=a39E3ASG8sy/zL/I8k/4+p165bB01iLXVFh9FxOdrh8=; b=CNrI7aWjuYpSfRzvyAJwVoRdvB74v0Ie0/nE+UFM8am0rVDYF1F0QfboTZH/MOAGbs Jg5AzaPsNHRkv9eAAadE85AehL0fXBPE1NUwi9umtZDoZH/YZcuTikZlO6EVfJEL0VfY Ozh6CpHHRr9Wt48qVopgm3gvQ8H+/hqe8Ww7Z7StFHUMKbhc1ZuDpS7Lguwk5jTHCZiS EghFqdlglMfIvzIYmHLni6s3JKuEM+JYm92DLznAUNKhs3QQ1u2VZb0rY8OLhmSYzEzJ iVTsAl/uiVJ4RigMp+AQUu1vvy066CQqsfjHi51PSxYjPCCQ1Wor46q0PXb1rQnVJ6wv 0hPQ== X-Gm-Message-State: APt69E1mAk13B9lOKsCcoipuaEiynvBw8w1b/RCLnNpB+jD5NofbOz7k Infh1K/zmW0BAHXBMQ+c9/txRuN34Ls= X-Google-Smtp-Source: ADUXVKIRfgMX+voGCxWGCxWkbHvx4Gqe9uilqtqbbBY9yatAsBhozOZoTgUQgj8VPvtEmuWVtZHSPw== X-Received: by 2002:ac8:65d1:: with SMTP id t17-v6mr6723933qto.347.1529197045155; Sat, 16 Jun 2018 17:57:25 -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 x21-v6sm7302186qto.2.2018.06.16.17.57.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 16 Jun 2018 17:57:24 -0700 (PDT) From: Keno Fischer To: qemu-devel@nongnu.org Date: Sat, 16 Jun 2018 20:56:52 -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 v3 08/13] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 --- 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 later. + * 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 = openat_file(dirfd, filename, + O_RDONLY | O_PATH_9P_UTIL | O_NOFOLLOW, 0); + if (fd == -1) { + return -1; + } + ret = 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 = openat_file(dirfd, filename, + O_RDONLY | O_PATH_9P_UTIL | O_NOFOLLOW, 0); + if (fd == -1) { + return -1; + } + ret = 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 = openat_file(dirfd, filename, O_PATH_9P_UTIL | O_NOFOLLOW, 0); + if (fd == -1) { + return -1; + } + ret = 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 = openat_file(dirfd, filename, O_PATH_9P_UTIL | O_NOFOLLOW, 0); + if (fd == -1) { + return -1; + } + ret = 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 95e3bc0..0de39af 100644 --- a/hw/9pfs/Makefile.objs +++ b/hw/9pfs/Makefile.objs @@ -1,6 +1,7 @@ ifeq ($(call lor,$(CONFIG_VIRTIO_9P),$(CONFIG_XEN)),y) common-obj-y = 9p.o common-obj-$(CONFIG_LINUX) += 9p-util-linux.o +common-obj-$(CONFIG_DARWIN) += 9p-util-darwin.o common-obj-y += 9p-local.o 9p-xattr.o common-obj-y += 9p-xattr-user.o 9p-posix-acl.o common-obj-y += coth.o cofs.o codir.o cofile.o From patchwork Sun Jun 17 00:56:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keno Fischer X-Patchwork-Id: 930431 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=juliacomputing.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=juliacomputing-com.20150623.gappssmtp.com header.i=@juliacomputing-com.20150623.gappssmtp.com header.b="UKQVXCae"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 417bXn2V0nz9s29 for ; Sun, 17 Jun 2018 11:02:01 +1000 (AEST) Received: from localhost ([::1]:53376 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUM4s-0000Rh-UG for incoming@patchwork.ozlabs.org; Sat, 16 Jun 2018 21:01:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56860) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUM0W-0005iN-4B for qemu-devel@nongnu.org; Sat, 16 Jun 2018 20:57:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fUM0V-0003H6-2v for qemu-devel@nongnu.org; Sat, 16 Jun 2018 20:57:28 -0400 Received: from mail-qt0-x244.google.com ([2607:f8b0:400d:c0d::244]:39038) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fUM0U-0003H1-Tt for qemu-devel@nongnu.org; Sat, 16 Jun 2018 20:57:27 -0400 Received: by mail-qt0-x244.google.com with SMTP id p23-v6so12394487qtn.6 for ; Sat, 16 Jun 2018 17:57:26 -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=TeI3LEG8sexNlbXeStsmTHHyP+QSHtm3m4viZlj0tuo=; b=UKQVXCaeTnPTJKTnJk4YGsW/fjf3Vti66t1oZYFfQKf6K8WHGPGRA2jt9qcg+4KGe9 hl12UbzmbhI36ZVWnk+rbEHZo+033/KBnTMIZnzZynlhB1hAo+IKn24/CRQ4dVVnl0ma nxnGM6doenZ6Q1csY59WVOwrtaxZbs/OEsn/zI3CBMWvKBSrf7YrCyL9nfhperC6pPrH FijAqq/mfLWhwKLpcQlk3JGkj15h9lBfDexSvIrEl+QRU9OkTVP51jCb1ODppIU90Cwi EC1YeOeDxRcETPOc6XSt2jAwzPi9RNJ6V6zvT9pLWYwMBGHpVl2Dr5DvEryPOGcptaGB 6bsg== 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=TeI3LEG8sexNlbXeStsmTHHyP+QSHtm3m4viZlj0tuo=; b=CrXGB3Zpa9AT70IyRARWcIs7EFhfvfjObB02DPpgN2+cSnUUtAy8cxxn9aAre1MjUp lv/7wq7CP3K6L4/ljlBgBfBamgOyKlxsZ+mDWkxG7dDcYsEqFi9nlsENtWYVLe+Br0DZ mtrtsMlgH0LNFBofXhbpapSixBIcsfoC8u9N6bngw9eFRqFnapSeJqjf5f1v9pCmPscb pBdTx2ZdIH0nLMcnLPvrbp5tu/sBmHCOPXmKfTLoSs7q8fI60oTrriq0q62tWsi9fUzC 42jyZf7Wu/SyVGQQ0v+3vfEF5AGHDUWAqhIhBLI2F1Vy58bBWtcJQEsPZaBwsi7CQ4+h fRUQ== X-Gm-Message-State: APt69E3xIhuC/ibpKHwn/1ioowOe5kW6zw5vNjrvUWkQ4lPrMmd2JTuy uXAhRLL2UlB/rYxv40b7JSH5MpcEYVA= X-Google-Smtp-Source: ADUXVKKXSydxpYs1kmGdgEbKcyDlkAtbyZsC8PN5i7oGybWXznJ4RZbT55YjvgZmsTpRw0yrfnqUiA== X-Received: by 2002:ac8:39f:: with SMTP id t31-v6mr6720191qtg.216.1529197046108; Sat, 16 Jun 2018 17:57:26 -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 x21-v6sm7302186qto.2.2018.06.16.17.57.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 16 Jun 2018 17:57:25 -0700 (PDT) From: Keno Fischer To: qemu-devel@nongnu.org Date: Sat, 16 Jun 2018 20:56:53 -0400 Message-Id: <7cdeccb2d0f1b5543c07f40bb053769744ae9777.1529196703.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::244 Subject: [Qemu-devel] [PATCH v3 09/13] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 Reviewed-by: Greg Kurz --- 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 e46f2b6..046e553 100644 --- a/Makefile +++ b/Makefile @@ -545,7 +545,13 @@ qemu-bridge-helper$(EXESUF): qemu-bridge-helper.o $(COMMON_LDADDS) qemu-keymap$(EXESUF): qemu-keymap.o ui/input-keymap.o $(COMMON_LDADDS) fsdev/virtfs-proxy-helper$(EXESUF): fsdev/virtfs-proxy-helper.o fsdev/9p-marshal.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 += -lcap +endif 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" #define PROGNAME "virtfs-proxy-helper" @@ -459,7 +460,7 @@ static int do_getxattr(int type, struct iovec *iovec, struct iovec *out_iovec) v9fs_string_init(&name); retval = proxy_unmarshal(iovec, offset, "s", &name); if (retval > 0) { - retval = lgetxattr(path.data, name.data, xattr.data, size); + retval = qemu_lgetxattr(path.data, name.data, xattr.data, size); if (retval < 0) { retval = -errno; } else { @@ -469,7 +470,7 @@ static int do_getxattr(int type, struct iovec *iovec, struct iovec *out_iovec) v9fs_string_free(&name); break; case T_LLISTXATTR: - retval = llistxattr(path.data, xattr.data, size); + retval = qemu_llistxattr(path.data, xattr.data, size); if (retval < 0) { retval = -errno; } else { @@ -1000,7 +1001,7 @@ static int process_requests(int sock) retval = proxy_unmarshal(&in_iovec, PROXY_HDR_SZ, "sssdd", &path, &name, &value, &size, &flags); if (retval > 0) { - retval = lsetxattr(path.data, + retval = qemu_lsetxattr(path.data, name.data, value.data, size, flags); if (retval < 0) { retval = -errno; @@ -1016,7 +1017,7 @@ static int process_requests(int sock) retval = proxy_unmarshal(&in_iovec, PROXY_HDR_SZ, "ss", &path, &name); if (retval > 0) { - retval = lremovexattr(path.data, name.data); + retval = qemu_lremovexattr(path.data, name.data); if (retval < 0) { retval = -errno; } diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index 98d4073..768ef6f 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_type, mode_t tmp_mode; dev_t tmp_dev; - 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 = 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 = 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 = 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 = 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 +#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 = errno; From patchwork Sun Jun 17 00:56:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keno Fischer X-Patchwork-Id: 930433 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=juliacomputing.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=juliacomputing-com.20150623.gappssmtp.com header.i=@juliacomputing-com.20150623.gappssmtp.com header.b="pfPouAib"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 417bc06Brwz9s29 for ; Sun, 17 Jun 2018 11:04:48 +1000 (AEST) Received: from localhost ([::1]:53387 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUM7a-0002H0-G0 for incoming@patchwork.ozlabs.org; Sat, 16 Jun 2018 21:04:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56875) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUM0X-0005jC-Ah for qemu-devel@nongnu.org; Sat, 16 Jun 2018 20:57:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fUM0V-0003HM-WE for qemu-devel@nongnu.org; Sat, 16 Jun 2018 20:57:29 -0400 Received: from mail-qk0-x243.google.com ([2607:f8b0:400d:c09::243]:42650) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fUM0V-0003HI-QX for qemu-devel@nongnu.org; Sat, 16 Jun 2018 20:57:27 -0400 Received: by mail-qk0-x243.google.com with SMTP id j80-v6so7659765qke.9 for ; Sat, 16 Jun 2018 17:57: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=klfVx99XCNxcT9mF+bCFviXrRMY0EIBLNUH3/i3hZ3c=; b=pfPouAibfqXbRImdax45295e/sGMv/wgoRa78i8XW5fWFeHW/PLtbW06gC5V0h9zRp p7rzYb8yCIu6poJn6bpr6S/icvV/jv/2QCwhYPbdLgfijf7X4d8+icBFRfneiTpqIhRZ yxnaK0RzplUkjI6S4PUPLQwTZDobN6cLNsnVWWKex19eJYyFwUQjV74/1nS0k6P8O4ps L2tSSEHpDqVMF114cjjPgEkWwjEGm4wlI9AlKEBDB1YUspOZdo7RtDzyOr38T40/5Qg1 uAL3KYV8i/xc/exxL6QEBZ1g8HJbcjgBzV06dmxkFNXwWciBDIFLxQsI8Bby8Q7ACMW7 sUyg== 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=klfVx99XCNxcT9mF+bCFviXrRMY0EIBLNUH3/i3hZ3c=; b=cncLl7d12QHEu4xx6ATZPUSSNCcb8BdSk94UbdHo4VpGRFmDxf3KY0lgzJi1zVb6bt MGtJHe9SCaPsiq1dhBPmUlIfA2uZM1LoSgLjBAh01GocsO3i8iIRMLtX7A7Gz43tSgYe HQ6vfG7yRLRxm7tKPpnD9ip6/mqQwnq8o0084UFQthQzFpTbTU4Gqa4tsXX7yvpVkxBq CyonVOQmRq6O/mDntLDA2ms1EzK30aWno27vpaJSxMCbNUbQzUAupo/YqAkp+R6yMa59 aJm20y6CxYUJkMuOQTXA7ERMaeeUw/271iyOgoo+xyh2cXgmCwGlIVgaRU+7QzKBz7dT WCsw== X-Gm-Message-State: APt69E3OITV5uLBaXy7GVsMqrVNBrHVCoVx19xqBdpZey5hohdARFyXu fLUamD1AKbeKYTzIBjB5SAYyn+DRGLM= X-Google-Smtp-Source: ADUXVKIlxtQ5QUZZmWOc3TXBAroDsP8tR/TOT67ZHDxsAGgc/O3d6kdPp9D/xnIJY4Rz2yAk6317/A== X-Received: by 2002:a37:b401:: with SMTP id d1-v6mr6150264qkf.332.1529197047002; Sat, 16 Jun 2018 17:57:27 -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 x21-v6sm7302186qto.2.2018.06.16.17.57.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 16 Jun 2018 17:57:26 -0700 (PDT) From: Keno Fischer To: qemu-devel@nongnu.org Date: Sat, 16 Jun 2018 20:56:54 -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::243 Subject: [Qemu-devel] [PATCH v3 10/13] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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, __builtin_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 --- 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 = utimensat(AT_FDCWD, path.data, spec, - AT_SYMLINK_NOFOLLOW); + retval = utimensat_nofollow(AT_FDCWD, path.data, spec); if (retval < 0) { retval = -errno; } diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index 768ef6f..56bcabf 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; } - ret = utimensat(dirfd, name, buf, AT_SYMLINK_NOFOLLOW); + ret = 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 = fstat(fd, &buf); + if (ret == -1) { + return ret; + } + if (update0) { + times[0] = buf.st_atimespec; + } + if (update1) { + times[1] = 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 >= __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 = openat_file(dirfd, filename, O_PATH_9P_UTIL | O_NOFOLLOW, 0); + if (fd == -1) { + return -1; + } + + special0 = times[0].tv_nsec == UTIME_OMIT; + special1 = times[1].tv_nsec == UTIME_OMIT; + if (special0 || special1) { + /* If both are set, nothing to do */ + if (special0 && special1) { + ret = 0; + goto done; + } + + ret = update_times_from_stat(fd, times, special0, special1); + if (ret < 0) { + goto done; + } + } + + special0 = times[0].tv_nsec == UTIME_NOW; + special1 = times[1].tv_nsec == UTIME_NOW; + if (special0 || special1) { + ret = futimes(fd, NULL); + if (ret < 0) { + goto done; + } + + /* If both are set, we are done */ + if (special0 && special1) { + ret = 0; + goto done; + } + + ret = update_times_from_stat(fd, times, special0, special1); + if (ret < 0) { + goto done; + } + } + + futimes_buf[0].tv_sec = times[0].tv_sec; + futimes_buf[0].tv_usec = times[0].tv_nsec / 1000; + futimes_buf[1].tv_sec = times[1].tv_sec; + futimes_buf[1].tv_usec = times[1].tv_nsec / 1000; + ret = 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 +/* 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 = errno; @@ -81,5 +87,7 @@ 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); +int utimensat_nofollow(int dirfd, const char *filename, + const struct timespec times[2]); #endif diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index abfb8dc..dc53691 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" From patchwork Sun Jun 17 00:56:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keno Fischer X-Patchwork-Id: 930436 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=juliacomputing.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=juliacomputing-com.20150623.gappssmtp.com header.i=@juliacomputing-com.20150623.gappssmtp.com header.b="KO6z5aCX"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 417bgd62RNz9s19 for ; Sun, 17 Jun 2018 11:07:57 +1000 (AEST) Received: from localhost ([::1]:53404 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUMAd-0004rX-GB for incoming@patchwork.ozlabs.org; Sat, 16 Jun 2018 21:07:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56897) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUM0b-0005nZ-Kt for qemu-devel@nongnu.org; Sat, 16 Jun 2018 20:57:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fUM0W-0003Hk-VT for qemu-devel@nongnu.org; Sat, 16 Jun 2018 20:57:33 -0400 Received: from mail-qk0-x241.google.com ([2607:f8b0:400d:c09::241]:32952) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fUM0W-0003Hf-Qd for qemu-devel@nongnu.org; Sat, 16 Jun 2018 20:57:28 -0400 Received: by mail-qk0-x241.google.com with SMTP id c131-v6so7676449qkb.0 for ; Sat, 16 Jun 2018 17:57: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=vh5LdMOCHgYJoIli+G6PHSrgiRQSvuDE/jknU0oT/cM=; b=KO6z5aCXDri56HZIQGNgkJcBwr9lCbyVsqwaJqM7qILGkPJ3GiMA8/Fq1x4QfEkR9D Mvlk/aSHXwuv6tqzFZ+ErrwzXOPl+/W5pgXazIe4exBpyj2fQSxlWH1oBWI4dpnLDUB/ CDsXbsCsIvTrSAdcqmlaJ0SuaaOUWKy9fI8xqWkpWS85LTDQFvoIlhEVG8O7Dm6lNvVg 7pt8h+JAXPhnsLxe1jt87L0OWXzgCEaA7cvfPmt58vRRIaDTo5EMCagWy/0AOIqsMiB0 NiE9QD9uZqmZamT2vieSZf0jWOVXq7hbpPALLCIwm7WsnhJLOOabgNl5Off9H1q+52rs 9JvQ== 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=vh5LdMOCHgYJoIli+G6PHSrgiRQSvuDE/jknU0oT/cM=; b=JuuhPuqNQHvXgoMyVk5ub54QgybbU8UZHMYWuz3UsHzvddeGdKJy8eYwi7diExqae7 XhJlv5ENxcgLkMKpHF8fn8eb1IRmPZ36sOle+9u/+l1DVtFNkNCuRtfMpd2RA2Yxyi9W mNErUKjjdy61+7w6ELaqPET2CJVRFqaOPrH+xpStWpTDyUOtQYe/H5x0aH5dhL3ipqBP IKLJbB0447pBV+8ZeFv9xVQ+o7LztL5QVR7nxacGpgYTpaL/1nZK+F3UHXQO6U9FqErW d55E+hqxDp8HsORy2hbxqWTBscubX5oLH4UAuMxUj9qOEiD4Tyr1tWue+2QJS3ntpOrL 42xA== X-Gm-Message-State: APt69E3ZbI+cQy3vncx/ND4VXTQKJ97NQr4gS0PdSOjM/kplRiwV36SX 8akztK46nhCCUjUADfkeNosmm9XhJ7U= X-Google-Smtp-Source: ADUXVKLuJDyhJeyttCCUUNRMQ52d6gHhz9zRLDR8XnId9KAhvNjK/dBbgRQBkvutHgZ4BqhX2LCx+g== X-Received: by 2002:a37:c84d:: with SMTP id c74-v6mr5953269qkj.245.1529197048012; Sat, 16 Jun 2018 17:57:28 -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 x21-v6sm7302186qto.2.2018.06.16.17.57.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 16 Jun 2018 17:57:27 -0700 (PDT) From: Keno Fischer To: qemu-devel@nongnu.org Date: Sat, 16 Jun 2018 20:56:55 -0400 Message-Id: <6843f92c494c66ccc0db503f9aa56b28eddb61fc.1529196703.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 v3 11/13] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 since v2: - Silence clang warning for deprecated uses of `syscall`. It is unforunate that we have to use this depreacted interface, but there does not seem to be a better option. hw/9pfs/9p-local.c | 5 +++-- hw/9pfs/9p-util-darwin.c | 31 +++++++++++++++++++++++++++++++ hw/9pfs/9p-util-linux.c | 5 +++++ hw/9pfs/9p-util.h | 2 ++ 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index 56bcabf..450f31c 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, if (fs_ctx->export_flags & V9FS_SM_MAPPED || fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) { - err = mknodat(dirfd, name, fs_ctx->fmode | S_IFREG, 0); + err = qemu_mknodat(dirfd, name, fs_ctx->fmode | S_IFREG, 0); if (err == -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 = mknodat(dirfd, name, credp->fc_mode, credp->fc_rdev); + err = qemu_mknodat(dirfd, name, credp->fc_mode, credp->fc_rdev); if (err == -1) { goto out; } @@ -696,6 +696,7 @@ static int local_mknod(FsContext *fs_ctx, V9fsPath *dir_path, 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..194f068 100644 --- a/hw/9pfs/9p-util-darwin.c +++ b/hw/9pfs/9p-util-darwin.c @@ -158,3 +158,34 @@ done: close_preserve_errno(fd); return ret; } + +#ifndef SYS___pthread_fchdir +# define SYS___pthread_fchdir 349 +#endif + +// This is an undocumented OS X syscall. It would be best to avoid it, +// but there doesn't seem to be another safe way to implement mknodat. +// Dear Apple, please implement mknodat before you remove this syscall. +static int fchdir_thread_local(int fd) +{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + return syscall(SYS___pthread_fchdir, fd); +#pragma clang diagnostic pop +} + +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 = mknod(filename, mode, dev); + preserved_errno = errno; + /* Stop using the thread-local cwd */ + fchdir_thread_local(-1); + if (err < 0) { + errno = 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 *filename, int utimensat_nofollow(int dirfd, const char *filename, const struct timespec times[2]); +int qemu_mknodat(int dirfd, const char *filename, mode_t mode, dev_t dev); + #endif From patchwork Sun Jun 17 00:56:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keno Fischer X-Patchwork-Id: 930437 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=juliacomputing.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=juliacomputing-com.20150623.gappssmtp.com header.i=@juliacomputing-com.20150623.gappssmtp.com header.b="RqWqlObr"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 417bgh3txmz9s19 for ; Sun, 17 Jun 2018 11:08:00 +1000 (AEST) Received: from localhost ([::1]:53405 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUMAg-0004uT-5z for incoming@patchwork.ozlabs.org; Sat, 16 Jun 2018 21:07:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56899) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUM0b-0005nl-RX for qemu-devel@nongnu.org; Sat, 16 Jun 2018 20:57:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fUM0Y-0003I4-2y for qemu-devel@nongnu.org; Sat, 16 Jun 2018 20:57:33 -0400 Received: from mail-qk0-x243.google.com ([2607:f8b0:400d:c09::243]:34526) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fUM0X-0003Hv-TJ for qemu-devel@nongnu.org; Sat, 16 Jun 2018 20:57:30 -0400 Received: by mail-qk0-x243.google.com with SMTP id q70-v6so7676318qke.1 for ; Sat, 16 Jun 2018 17:57:29 -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=m1kYcz4sX7cJoOtZ1tb9MxDZscufeKa7l2chgfbmT8E=; b=RqWqlObrWM3GfaQcGIlSU/TtYy3+zLAwjID0KcAF5yjsH3DudPFcKvsmoodYHvWklw BSRf0cDqKDF9hasBgFr3sg9M85MJgnrfbM0rywRRkZ4GQNNRHzBnxvZ+USuFB0JTAXwQ /rfe4zNp6dyK0/C+jdpqxSlfnuSJpHOHx+aIOrnV+ngOVlTlIJMfRa8dKS7WdP93sv4g 8afeoX7Cll38DddUcIf78NX4F8h3wMVoGyo41um2WphFHyuKYR4365WvB7Q+IDqw4ByO H8i+51aXE3cepzpNXLrA5jD7sd2qBTfZrogHlsLKGBWULGfUUpTdBXaLuuw2uXA3VtMy lOKw== 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=m1kYcz4sX7cJoOtZ1tb9MxDZscufeKa7l2chgfbmT8E=; b=HlNZ49ll1hDo7bmbwD7HSNCOZg2xr611xLDXi8rKR54hm776jRfXzjH1ppC7KN1++Q tDFJphuayfJieeqTXmnEM2gQb8DvQZubunVK0Zgsoh+mTVEBQEjSkBD0ZjvOeIUauHo1 zhPkGaVqWuXgexzEFnWftQ1NuFmrYrYDWkVeVpOSK81cYPqMQU3Ey7BoCQ5lBeCoToFb 3aIt85ihGnWa81ASW6CMSDWUZOSnkLMVxzIUe6CaOD+NhTR4nd1fUAMK8Th6S/5OJqo8 LjIzJXQAcK5TXoYpQ+ShnWrgDTkEOMP4Y6TCk1m3nllc58y5eaG3a1vyWfkAGmLHQYwb dLMw== X-Gm-Message-State: APt69E0L+0cqRA7pvIgg3kPVu1Wovu1092QHwyjBBy30Brdp/EdrFsRO krpQ2uzkuLl3eL8Z8QbddB9pllFOPrg= X-Google-Smtp-Source: ADUXVKKFdUN22ySwY+HqWvPWCWk+V4GmRjmSGLvpPOjvZIRfef2hNbwzdZ9G3RmFB5kQjv8MTlyryg== X-Received: by 2002:a37:204c:: with SMTP id g73-v6mr6152195qkg.164.1529197048876; Sat, 16 Jun 2018 17:57:28 -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 x21-v6sm7302186qto.2.2018.06.16.17.57.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 16 Jun 2018 17:57:28 -0700 (PDT) From: Keno Fischer To: qemu-devel@nongnu.org Date: Sat, 16 Jun 2018 20:56:56 -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::243 Subject: [Qemu-devel] [PATCH v3 12/13] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 --- 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) } } +#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; } +static int acquire_dac_override(void) +{ + cap_value_t cap_list[] = { + 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 permitted + * 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 effective + * set. + * + * The setfsuid/setfsgid man pages warn that changing the effective user ID may + * expose the program to unwanted signals, but this is not true anymore: for 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 user + * 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 = geteuid(); + *sgid = getegid(); + + if (setresgid(-1, gid, *sgid) == -1) { + retval = -errno; + goto err_out; + } + + if (setresuid(-1, uid, *suid) == -1) { + retval = -errno; + goto err_sgid; + } + + if (uid != 0 || gid != 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 = -errno; + goto err_suid; + } + } + return 0; + +err_suid: + if (setresuid(-1, *suid, *suid) == -1) { + abort(); + } +err_sgid: + if (setresgid(-1, *sgid, *sgid) == -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) == -1) { + abort(); + } + if (setresuid(-1, suid, suid) == -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 = geteuid(); + *sgid = getegid(); + + if (setegid(gid) == -1) { + retval = -errno; + goto err_out; + } + + if (seteuid(uid) == -1) { + retval = -errno; + goto err_sgid; + } + +err_sgid: + if (setgid(*sgid) == -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) == -1) { + abort(); + } + if (seteuid(suid) == -1) { + abort(); + } +} + +static int init_capabilities(void) +{ + return 0; +} +#endif 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) } /* - * 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 permitted - * 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 effective - * set. - * - * The setfsuid/setfsgid man pages warn that changing the effective user ID may - * expose the program to unwanted signals, but this is not true anymore: for 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 user - * 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[] = { - CAP_DAC_OVERRIDE, - }; - - *suid = geteuid(); - *sgid = getegid(); - - if (setresgid(-1, gid, *sgid) == -1) { - retval = -errno; - goto err_out; - } - - if (setresuid(-1, uid, *suid) == -1) { - retval = -errno; - goto err_sgid; - } - - if (uid != 0 || gid != 0) { - if (do_cap_set(cap_list, ARRAY_SIZE(cap_list), 0) < 0) { - retval = -errno; - goto err_suid; - } - } - return 0; - -err_suid: - if (setresuid(-1, *suid, *suid) == -1) { - abort(); - } -err_sgid: - if (setresgid(-1, *sgid, *sgid) == -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) == -1) { - abort(); - } - if (setresuid(-1, suid, suid) == -1) { - abort(); - } -} - -/* * send response in two parts * 1) ProxyHeader * 2) Response or error status From patchwork Sun Jun 17 00:56:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keno Fischer X-Patchwork-Id: 930435 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=juliacomputing.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=juliacomputing-com.20150623.gappssmtp.com header.i=@juliacomputing-com.20150623.gappssmtp.com header.b="D8xFxoc6"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 417bcv6r6Qz9s2R for ; Sun, 17 Jun 2018 11:05:35 +1000 (AEST) Received: from localhost ([::1]:53390 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUM8L-0002pC-Ij for incoming@patchwork.ozlabs.org; Sat, 16 Jun 2018 21:05:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56901) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUM0b-0005nn-SA for qemu-devel@nongnu.org; Sat, 16 Jun 2018 20:57:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fUM0Y-0003II-Vm for qemu-devel@nongnu.org; Sat, 16 Jun 2018 20:57:33 -0400 Received: from mail-qk0-x235.google.com ([2607:f8b0:400d:c09::235]:42874) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fUM0Y-0003ID-RL for qemu-devel@nongnu.org; Sat, 16 Jun 2018 20:57:30 -0400 Received: by mail-qk0-x235.google.com with SMTP id j80-v6so7659797qke.9 for ; Sat, 16 Jun 2018 17:57: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=vPFjMCbD3tS6pxUt6OYAE5HtCYWreVnJupsfjL37kd4=; b=D8xFxoc6yAtdYCUmMBkT/+ZtPn1F71nP5GEIk5WMEbit4UNntrEcZdc5KBWCxWUegc EDUiH+qP3uTSQMseiuxqXZOzMebFZHENHElbipOBCqiLh8/x4rwSDcrInHnNoM8XUMTl o1HO/3h/Rxm3mM+ShIR5c4rju90vwd1Eubisx37PmLJuUA2aCQa6jHkfvRC6eh2uqMKF X6CInbWWOZ/kMMRlUND59CX9jJbSMS+Hu1B14wMNuKy50CbqN9DrFnRala6rDHhF6D72 La7VdQswdgPpoM2haOLkqKhf4F9609jTn0o/r/Li2EfEsqju2gVp907d+hMGItQFTSpN znYQ== 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=vPFjMCbD3tS6pxUt6OYAE5HtCYWreVnJupsfjL37kd4=; b=MGFD8YZ8yZD8q47SggZjAA9ve06f8SiHPntV3iVdGIy1EJJlA2e9gdeSJSOw1TT5LL 075RbmkbFz2huTCySZCYH9Hz2sE20+Xa9XKsjeZhrU8rnWcNvrWfs8ORgOOR9e7ZySKv jKJMinleWV03Qw25zvQatWhdE7TA1R/MN0b2qTZdC2YumMYyZNKvQTns7I/86G/hHc5Q PzAF/YIYE6PNmn59P97S3ODK89gBUKrSqOuBELM4Uxlw2RDLN4OVIYw2O+O/+lgen4Dg VvxqW4wBhU1psvZi/A5KfLYeLZT2qeSmAyr2ssD+Jnpu6e/xFftL0guW5HZTk62VlZO0 9Q+g== X-Gm-Message-State: APt69E01iZ+bODmmB11yK4gz8EQ+j0xNXKSZrUKBL9m7wkIl3Nj6hefR rvye3WCzOTolUCKE47Sr3lfgbYY0mzw= X-Google-Smtp-Source: ADUXVKKYJrCg/wySzCingW5eJmo8h4XlXZ11nQ++8nZP26aTx9JE1e10WdjXy38jxt5qn2qNxlWHgg== X-Received: by 2002:a37:c31d:: with SMTP id a29-v6mr5953202qkj.213.1529197050011; Sat, 16 Jun 2018 17:57: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 x21-v6sm7302186qto.2.2018.06.16.17.57.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 16 Jun 2018 17:57:29 -0700 (PDT) From: Keno Fischer To: qemu-devel@nongnu.org Date: Sat, 16 Jun 2018 20:56:57 -0400 Message-Id: <6619399bfc7df3fdd4d2f5b78ed28b1e95fce1c9.1529196703.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::235 Subject: [Qemu-devel] [PATCH v3 13/13] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Keno Fischer --- Makefile.objs | 1 + configure | 22 +++++++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Makefile.objs b/Makefile.objs index 7a9828d..c968a9a 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -104,6 +104,7 @@ common-obj-$(CONFIG_WIN32) += os-win32.o common-obj-$(CONFIG_POSIX) += os-posix.o common-obj-$(CONFIG_LINUX) += fsdev/ +common-obj-$(CONFIG_DARWIN) += fsdev/ common-obj-y += migration/ diff --git a/configure b/configure index 195c9bd..74f593a 100755 --- a/configure +++ b/configure @@ -5568,16 +5568,28 @@ if test "$want_tools" = "yes" ; then fi fi if test "$softmmu" = yes ; then - if test "$linux" = yes; then - if test "$virtfs" != no && test "$cap" = yes && test "$attr" = yes ; then + if test "$virtfs" != no; then + if test "$linux" = yes; then + if test "$cap" = yes && test "$attr" = yes ; then + virtfs=yes + tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)" + else + if test "$virtfs" = yes; then + error_exit "VirtFS requires libcap devel and libattr devel under Linux" + fi + virtfs=no + fi + elif test "$darwin" = yes; then virtfs=yes tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)" else if test "$virtfs" = yes; then - error_exit "VirtFS requires libcap devel and libattr devel" + error_exit "VirtFS is supported only on Linux and Darwin" fi virtfs=no fi + fi + if test "$linux" = yes; then if test "$mpath" != no && test "$mpathpersist" = yes ; then mpath=yes else @@ -5588,10 +5600,6 @@ if test "$softmmu" = yes ; then fi tools="$tools scsi/qemu-pr-helper\$(EXESUF)" else - if test "$virtfs" = yes; then - error_exit "VirtFS is supported only on Linux" - fi - virtfs=no if test "$mpath" = yes; then error_exit "Multipath is supported only on Linux" fi