From patchwork Sun Feb 27 22:35:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 12762176 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BBA5BC433F5 for ; Sun, 27 Feb 2022 22:42:25 +0000 (UTC) Received: from localhost ([::1]:33068 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nOSFE-0002Wi-P9 for qemu-devel@archiver.kernel.org; Sun, 27 Feb 2022 17:42:24 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52122) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nOS8w-0006F0-9q for qemu-devel@nongnu.org; Sun, 27 Feb 2022 17:35:54 -0500 Received: from [2607:f8b0:4864:20::82e] (port=42719 helo=mail-qt1-x82e.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nOS8u-00033J-Nu for qemu-devel@nongnu.org; Sun, 27 Feb 2022 17:35:54 -0500 Received: by mail-qt1-x82e.google.com with SMTP id 11so7495846qtt.9 for ; Sun, 27 Feb 2022 14:35:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5V3o5RrwtkJ65v1m3Fl9y6glfQnm4FrYqCfEyCvWZQg=; b=WAqocweAlmkKrk63o+NP+Y2pFSKLXNQkFX8+LIi1mxJ0rUZGC4VGSyzM7BK+5RpLYh /iYg5Hjkc0sDxa+Ln0I0c5LtTBwYSTYXWZ3JUQKQATxaQUkmbculoRYwpJTj/jTf5sqs /JoJB0IzUf+nmrOWI3QnFAfCAKLT7Ni+lHKj3OaFbvHfJGKFvJs/AZ4a84yzRMsQAkvn L1TbU3EJ/zTygOehA0wkEi0XBNwUJ+Q4i4ZRX419ToXVhZLEL2KdSPgB+VSfMW6Hiz8j SV7BelqRWMVFJOOWzmN1XtUDD28wvPTBVMPEJb3UVr7sLl33JrfXGBOzmva92ybrrfE9 Pi2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5V3o5RrwtkJ65v1m3Fl9y6glfQnm4FrYqCfEyCvWZQg=; b=sYEFzI7kBWdO1NEOn6KdLYoM0pUcGdXYxpJun2N6qC+NqyQG5g2M45OLfYTj8NKTe0 3r8Jmh3811tnPhzB+pRMjVgsz7gyoobGI7qbUjQ2G1kenA4qKXxxAn4xeED94k7dhjDA cKOjY3+x7DiyG3ufAVv41FLGkMGVQ/rQ+tDZGzgmsA92Fa3mNuzbPPI6ewOQlwInJCWC iS3zvhfNEdW7POQE19p1aXjGx+8Ut8ygeeltVZX0UiwdIkGugBmkLcDVTgnTMVVpkF70 I5Whecx6SUfTQhn5RIT4QKyxL90CX1nXjximz90NNtf0/gqRulIiRwTCxNKk9f9cjVI+ WNhw== X-Gm-Message-State: AOAM531qHohsjVzVnzHd5d9hqTNWq1VdVi+aTBicRN+CNcTYBpFT/vmO Jpf+jpm/tajoVBbb0A9DmpPnSEtozIfUpw== X-Google-Smtp-Source: ABdhPJxWnZbWCnr6+a6we7eaRmmSN/+wfN8tBl4d25iko8ss6IJLv3Qcazmo0EisTkchm/HkJlXsRA== X-Received: by 2002:ac8:5bc2:0:b0:2de:adca:6624 with SMTP id b2-20020ac85bc2000000b002deadca6624mr12615508qtb.120.1646001351544; Sun, 27 Feb 2022 14:35:51 -0800 (PST) Received: from localhost.localdomain (209-6-248-219.s2265.c3-0.wrx-ubr1.sbo-wrx.ma.cable.rcncustomer.com. [209.6.248.219]) by smtp.gmail.com with ESMTPSA id 85-20020a370758000000b00648b7e3b8a4sm4206485qkh.111.2022.02.27.14.35.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Feb 2022 14:35:51 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v9 07/11] 9p: darwin: *xattr_nofollow implementations Date: Sun, 27 Feb 2022 17:35:18 -0500 Message-Id: <20220227223522.91937-8-wwcohen@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220227223522.91937-1-wwcohen@gmail.com> References: <20220227223522.91937-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::82e (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::82e; envelope-from=wwcohen@gmail.com; helo=mail-qt1-x82e.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , Christian Schoenebeck , Greg Kurz , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , hi@alyssa.is, Michael Roitzsch , Will Cohen , Paolo Bonzini , Keno Fischer Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Keno Fischer 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 [Michael Roitzsch: - Rebase for NixOS] Signed-off-by: Michael Roitzsch Signed-off-by: Will Cohen --- hw/9pfs/9p-util-darwin.c | 64 ++++++++++++++++++++++++++++++++++++++++ hw/9pfs/meson.build | 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 0000000000..cdb4c9e24c --- /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/meson.build b/hw/9pfs/meson.build index 1b28e70040..12443b6ad5 100644 --- a/hw/9pfs/meson.build +++ b/hw/9pfs/meson.build @@ -14,6 +14,7 @@ fs_ss.add(files( 'coxattr.c', )) fs_ss.add(when: 'CONFIG_LINUX', if_true: files('9p-util-linux.c')) +fs_ss.add(when: 'CONFIG_DARWIN', if_true: files('9p-util-darwin.c')) fs_ss.add(when: 'CONFIG_XEN', if_true: files('xen-9p-backend.c')) softmmu_ss.add_all(when: 'CONFIG_FSDEV_9P', if_true: fs_ss)