From nobody Sun Nov 2 11:45:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1527312820674124.65806127976259; Fri, 25 May 2018 22:33:40 -0700 (PDT) Received: from localhost ([::1]:47841 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fMRpj-0004gl-VF for importer@patchew.org; Sat, 26 May 2018 01:33:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35825) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fMRgf-0006PR-Md for qemu-devel@nongnu.org; Sat, 26 May 2018 01:24:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fMRge-0004dq-K5 for qemu-devel@nongnu.org; Sat, 26 May 2018 01:24:17 -0400 Received: from mail-qk0-x244.google.com ([2607:f8b0:400d:c09::244]:37439) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fMRge-0004d2-FD for qemu-devel@nongnu.org; Sat, 26 May 2018 01:24:16 -0400 Received: by mail-qk0-x244.google.com with SMTP id j12-v6so2334173qkk.4 for ; Fri, 25 May 2018 22:24:16 -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 n128-v6sm17675166qkf.42.2018.05.25.22.24.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 25 May 2018 22:24:14 -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=+MHBuP7PRgoMyV40CRRVPL3AGLCyBQOL1uG7ZqRanfo=; b=bBBDWdvEcOdWHN96nWOH5bYlSftpvEPt8VQEGhIg+NHVc+oYNlyzwQE5kCa2VKlzFX Y4gdKEmy0P6mcUYHAfwsxpZvqkP+EncDAW5H6OgTz3VxB6XR+RMidvFA4VpprcAnSa9h vLwTChCUb2o0vNwBcaW/X4ain1YJuQPZlFQo0z1f80jsQzoCADrroM8rdEgo/slGkP/u lIqDUl2gQV7yEr5qhU+J0BsnMi0Oog/EoQeBO0iZHhuDxhw4efDWA8hlUP5+uvqLe/18 M0JYVJ1fguumcRHLFTZhyCf3X1O6M7T80kkriWNoAjnUhLiNpHyyRFAaVwNsM24XyRHc f3GQ== 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=+MHBuP7PRgoMyV40CRRVPL3AGLCyBQOL1uG7ZqRanfo=; b=AO1pnhRCJ2XV6aQQ6XNkatn1PF7W1Opv7jvOSUuHiAKueYWumwCuTqZSsU37xQQyLi BJH+6l0A5nebVnfDnxOlojVK4Y2AZCZc8ethUSHn/ggaUq8prGqiOqv9oSopIl/f5oPX IAuYYjbyERTFZ9pvHvhL+9PXs+KDR4kul7eZUCGBhjDzty5KboJmwGXQCUzbG5JAFS02 6C5Kvx3PcGzcxP5DxSRlgO2SXYz/pkSN0sjIq3zPwusroQu/8HcT14k4caM2qm0ZvM8P NNm3YnaUWChO+QdTF07MIxmND7TpKkav9JlkyNvBMTzCsJ9w4TxhGyabcB1MtFdyivo+ HVjw== X-Gm-Message-State: ALKqPwcq/Gdwb3Ki7pZ4DhfCny6gsKVBdrBl+5pZqz9l8skA1PIZ5dR0 8/jwLbk1bK0KqbHRgUOEUzXTWpExTPs= X-Google-Smtp-Source: ADUXVKI/BKJipOwBqOjK2f/zcC0S33I2wZZpmcHRwKHLSN8hiSfVCZlAxUJwIDE/z93TFU64Tg0FXg== X-Received: by 2002:a37:c602:: with SMTP id b2-v6mr4496722qkj.413.1527312255543; Fri, 25 May 2018 22:24:15 -0700 (PDT) From: keno@juliacomputing.com To: qemu-devel@nongnu.org Date: Sat, 26 May 2018 01:23:14 -0400 Message-Id: <4e5e163637c9c696eb43d46a08a0aad5cd818d8a.1527310210.git.keno@alumni.harvard.edu> 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 12/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 , Keno Fischer , groug@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Keno Fischer This function is new in Mac OS 10.13. Provide a fallback implementation when building against older SDKs. Signed-off-by: Keno Fischer --- hw/9pfs/9p-local.c | 2 +- hw/9pfs/9p-util.c | 38 ++++++++++++++++++++++++++++++++++++++ hw/9pfs/9p-util.h | 7 +++++++ hw/9pfs/9p.c | 1 + 4 files changed, 47 insertions(+), 1 deletion(-) diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index 3e358b7..70ab541 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -1082,7 +1082,7 @@ static int local_utimensat(FsContext *s, V9fsPath *fs= _path, goto out; } =20 - ret =3D utimensat(dirfd, name, buf, AT_SYMLINK_NOFOLLOW); + ret =3D utimensat_nofollow(dirfd, name, buf); close_preserve_errno(dirfd); out: g_free(dirpath); diff --git a/hw/9pfs/9p-util.c b/hw/9pfs/9p-util.c index 98004ac..8403f5f 100644 --- a/hw/9pfs/9p-util.c +++ b/hw/9pfs/9p-util.c @@ -104,3 +104,41 @@ int fsetxattrat_nofollow(int dirfd, const char *filena= me, const char *name, #endif return ret; } + +#ifndef __has_builtin +#define __has_builtin(x) 0 +#endif + +int utimensat_nofollow(int dirfd, const char *filename, const struct times= pec times[2]) +{ +#ifdef CONFIG_DARWIN +#if defined(__MAC_10_13) /* Check whether we have an SDK version that defi= nes utimensat */ +#if __MAC_OS_X_VERSION_MIN_REQUIRED >=3D __MAC_10_13 +#define UTIMENSAT_AVAILABLE 1 +#elif __has_builtin(__builtin_available) +#define UTIMENSAT_AVAILABLE __builtin_available(macos 10.13, *) +#else +#define UTIMENSAT_AVAILABLE 0 +#endif + if (UTIMENSAT_AVAILABLE) + { + return utimensat(dirfd, filename, times, AT_SYMLINK_NOFOLLOW); + } +#endif + // utimensat not available. Use futimes. + int fd =3D openat_file(dirfd, filename, O_PATH_9P_UTIL | O_NOFOLLOW, 0= ); + if (fd =3D=3D -1) + return -1; + + struct timeval futimes_buf[2]; + futimes_buf[0].tv_sec =3D times[0].tv_sec; + futimes_buf[0].tv_usec =3D times[0].tv_nsec * 1000; + futimes_buf[1].tv_sec =3D times[1].tv_sec; + futimes_buf[1].tv_usec =3D times[1].tv_nsec * 1000; + int ret =3D futimes(fd, futimes_buf); + close_preserve_errno(fd); + return ret; +#else + return utimensat(dirfd, filename, times, AT_SYMLINK_NOFOLLOW); +#endif +} diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index cb26343..2329c82 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -19,6 +19,12 @@ #define O_PATH_9P_UTIL 0 #endif =20 +/* Compatibility with OLD SDK Versions for Darwin */ +#if defined(CONFIG_DARWIN) && !defined(UTIME_NOW) +#define UTIME_NOW -1 +#define UTIME_OMIT -2 +#endif + static inline void close_preserve_errno(int fd) { int serrno =3D errno; @@ -66,5 +72,6 @@ ssize_t flistxattrat_nofollow(int dirfd, const char *file= name, char *list, size_t size); ssize_t fremovexattrat_nofollow(int dirfd, const char *filename, const char *name); +int utimensat_nofollow(int dirfd, const char *filename, const struct times= pec times[2]); =20 #endif diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 4ae4da6..8e0594a 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -21,6 +21,7 @@ #include "virtio-9p.h" #include "fsdev/qemu-fsdev.h" #include "9p-xattr.h" +#include "9p-util.h" #include "coth.h" #include "trace.h" #include "migration/blocker.h" --=20 2.8.1