From patchwork Thu Sep 19 10:14:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 1987324 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=mAZaHGHi; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X8Wbs4VmXz1y1g for ; Thu, 19 Sep 2024 20:15:04 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 76F533858429 for ; Thu, 19 Sep 2024 10:15:02 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by sourceware.org (Postfix) with ESMTPS id 97BD63858CDA for ; Thu, 19 Sep 2024 10:14:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 97BD63858CDA Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 97BD63858CDA Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1726740887; cv=none; b=mtJdkb48qpk8XAEdeS9w2qAAbqT/i+NsdOWseMbhmTRl4pBCnebjlWPy+Gho9P6+JXJhV/K0S4V1J6GGg12YMmY0kKK6L2afPw+RjvskKFGGKp8zBta+NgxBYYrQQ3hIv0DNbCo0CivME5nfdNTky8Czq0OY+vaQ/e0stztzvNk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1726740887; c=relaxed/simple; bh=EEKzkSedsr3zW6myYNqKmkpbhSeQUwZygS1Uz9M2He8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=SUjUwojVT/iKmiZ8DT5KcJJ822Aa8A2xtvHcDD5kIis/RJeXwS9QoiXSTTh18gyfn0EITMPZRQ51iAjTuuhzZ5TM5ZXWu0+URZEdilzqFocMXbMkPBk4HazBRlzjvMqSmu3ldhtNj3mvX7up0G61j4ulMV1P8mkda4fMYGs0BCc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-52f01b8738dso572496e87.1 for ; Thu, 19 Sep 2024 03:14:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726740883; x=1727345683; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=mR8vGtOeP3A+5Q+oPGs4Qw6PUVjT6aVMzqzId5Y12rk=; b=mAZaHGHixlR/mIqFrt5ccFy+xvM0oOkuDAsKmVCicOABlb0GgTY11JwxFPWJtXeIGK sedVrsAEAlqkIR6y1GZXNdnst5TbprQIwCkAl3pmIOhFf/TkgeKD3jd7dT2gxiCKPX1x L4BfwA2JCEPMk14gGHFyh+xCz8quTsaUNDpKyTu4Cv8o1ndIfw2BuvnPn/5dU6v1z6dW URgoJesFAxCJSyJ98R9y8nREhyA7ohwJ7ZYhlWY/e9VTjF9O8nEVz3NjQrXG5gzvyKqG zl4Z0Wm2D6Xr0HXDhgt8jV+QNGEPywzI/7sP0uCKtL0HP+s9+lp/s1yIDszHr7B8Uao2 k6AA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726740883; x=1727345683; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=mR8vGtOeP3A+5Q+oPGs4Qw6PUVjT6aVMzqzId5Y12rk=; b=AqGbTB77fxmGIm0R3AR8XEVNTaRGr2jU2s5TweSjGlmiIWHCIh7q0UFsx2+yhwixgC FrMz2ifdr6OWuCI71rx5ItZvmbNfoLOfwY6kPb71ZBDULz2J/oBCTPEzYEC0MUJFAv5/ FNzhRR3ZFWEaCcNkNiSc+XS17YIOrpExpBXzIxZx79/5RSQo/L7R1RRuz2DYl/t/l+tN EATtye+yP5wnPxqFcw6YQ8W+X0lpsH5Yr0tvu6DNmrnorUStsHED2aEndMawnsB1DoLh YH3jHPS320EgV9NpMwsXEVEaVPznklXuQsMwccca3jumWe1xHH8E/sVJiRm3ZHijyai3 4N8Q== X-Gm-Message-State: AOJu0Yy7Ar1QhCcNt/om4jr7YIiD+Czcem81dYxyNEUWyituOGEHr7mg cvM4EXd6ycPWDbQf2ogh1XzvrC/YbxQldXMwSBzVcF0bbJuzZ3sIVSWRd9Bvt4Q= X-Google-Smtp-Source: AGHT+IH75S+zuJili5dBXOt6qlhurK8+G0Iy5CAq93jTI4X8wI2+/XazLNOk0Fbglokud66JT82iEQ== X-Received: by 2002:a05:6512:104b:b0:535:6cf6:92f7 with SMTP id 2adb3069b0e04-53678ff48camr14750792e87.59.1726740882977; Thu, 19 Sep 2024 03:14:42 -0700 (PDT) Received: from surface-pro-6.systematica.ru ([2a02:6bf:fff0:1:ddff:557a:adf7:d750]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-536a60a58b7sm228945e87.59.2024.09.19.03.14.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Sep 2024 03:14:42 -0700 (PDT) From: Sergey Bugaev To: libc-alpha@sourceware.org, bug-hurd@gnu.org Cc: Samuel Thibault Subject: [PATCH] hurd: Avoid file_check_access () RPC for access (F_OK) Date: Thu, 19 Sep 2024 13:14:39 +0300 Message-ID: <20240919101439.179663-1-bugaevc@gmail.com> X-Mailer: git-send-email 2.46.1 MIME-Version: 1.0 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org A common use case of access () / faccessat () is checking for file existence, not any specific access permissions. In that case, we can avoid doing the file_check_access () RPC; whether the given path had been successfully resolved to a file is all we need to know to answer. This is prompted by GLib switching to use faccessat (F_OK) to implement g_file_query_exists () for local files. https://gitlab.gnome.org/GNOME/glib/-/merge_requests/4272 Signed-off-by: Sergey Bugaev --- sysdeps/mach/hurd/faccessat.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sysdeps/mach/hurd/faccessat.c b/sysdeps/mach/hurd/faccessat.c index 998e31962..6d3d123ab 100644 --- a/sysdeps/mach/hurd/faccessat.c +++ b/sysdeps/mach/hurd/faccessat.c @@ -185,6 +185,15 @@ __faccessat_common (int fd, const char *file, int type, int at_flags, return errfunc (err); } + /* If all we wanted was to check for a file existing at the path, + then we already got our answer, and we don't need to call + file_check_access (). */ + if (type == F_OK) + { + __mach_port_deallocate (__mach_task_self (), io); + return 0; + } + /* Find out what types of access we are allowed to this file. */ err = __file_check_access (io, &allowed); __mach_port_deallocate (__mach_task_self (), io);