From nobody Sun Nov 26 04:10:47 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4SdFd425Vxz52kyw; Sun, 26 Nov 2023 04:10:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4SdFd41Vb9z3K3q; Sun, 26 Nov 2023 04:10:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700971848; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=lljoR0r8+kRgRYOuchQM2nQIsGcYwZjowXCJaqnZcX0=; b=AQ8N97X6D4DIJm6BO6mGNruzTyg7QCdwzyjXL9g2K6yoZ1Cs2SueEHrLjEl0Yu/KLbU36M 9B46kJXVjc+6a88v+BqnpzvFrO95OMQSB0h+E0t78UAdSo5vW+M8lpkL/o15oNnhLDynen jk6rDrrvCzRpBThWW1URD+wHIddE7Ix/WLlFTdpr2jOejZhWj0RN49Wlp0pvRZdtw6B27u Duexvyd6Q28mnOR5EFItbEX+RttxQZyQ6goBzlWYcnqJ6ajUKo0qYmhVxSec9DKl0PFAmC JIU6N6v586RIeutzgQ7TQLRUp1q7fuwn4Ossmm3O5QgN2f/HnJomhcnX29sEHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700971848; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=lljoR0r8+kRgRYOuchQM2nQIsGcYwZjowXCJaqnZcX0=; b=Z2QcSXaVeq3NqqmyY3KH0X3EbdylYJlBrmm8HgY8tHjDwKBGfpGglrGkR5JDtFdlQmI523 TIm7OPA5HgUXaEv3NRzxx8nfChvjTZTqh6D7H501Fb6trvmhOFDWL6RSocNkSK+ZtlUAE/ 4nkMXq4oa/Kj7Pq000BFAXnAU+oqkXo2NqrZot6klVB3TFTGSLGO1vxwtWh5E6a0aDoLIw VGS2BjUXWdnbdrkV+URClgl6fzNw6L9kObmlB5Uf+2s/2JUa2RjNCCoI4+/hs5YsETXQ/O wI4AZGEruvzRrUEaPC9NuswKofmfRjGPB16l4373bBnEUifH41x0JWxjZ00OiQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1700971848; a=rsa-sha256; cv=none; b=GPCLCB43Kl1lDSQEHrjsJg66Q1OldOdKyR0k1ulOxc1p15W05QKM8/659FamppEn+pPlEd EEAbv6aQGZODgIAbwOlDTZrjmxhyuoLjOX993VpoKGrw274DmilKS5xYS+DzsXiyRq/1Fx tZhnEZF4+/szXt78nm1XyobguiwEBDWFNMj81PX7+QB/k0UnnBRIRkmjkOA3Qyak3mx2R1 OzZdk/VsGxR0KhosOpBDSfR4M0aVGv85/UDGYDiaJkiTABzQ7X62y6tOOXs/JJ436a/MO7 lcK0KeAYBoH14G3GZWulpHvJFY33y4hA9Y0nwv7EtgY2sckNw+nyysJTmacZYQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4SdFd40VVnzgd7; Sun, 26 Nov 2023 04:10:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3AQ4AlxH038025; Sun, 26 Nov 2023 04:10:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3AQ4AlpE038022; Sun, 26 Nov 2023 04:10:47 GMT (envelope-from git) Date: Sun, 26 Nov 2023 04:10:47 GMT Message-Id: <202311260410.3AQ4AlpE038022@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kyle Evans Subject: git: 3041e6950d07 - main - lockf: hide unavailable error with -n -s List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3041e6950d07f0d11c9f91fefbf3c273cbbe4407 Auto-Submitted: auto-generated The branch main has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=3041e6950d07f0d11c9f91fefbf3c273cbbe4407 commit 3041e6950d07f0d11c9f91fefbf3c273cbbe4407 Author: Kyle Evans AuthorDate: 2023-11-22 04:41:36 +0000 Commit: Kyle Evans CommitDate: 2023-11-26 04:08:40 +0000 lockf: hide unavailable error with -n -s The error message is expected, allow -s to suppress just that one since it would loosely fall under the definition of "failure to acquire the lock" described in the manpage for the -s option. Reviewed by: 0mp, allanjude Feedback from: des Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D42711 --- usr.bin/lockf/lockf.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/usr.bin/lockf/lockf.c b/usr.bin/lockf/lockf.c index c98c584bc6a9..246f134f10f9 100644 --- a/usr.bin/lockf/lockf.c +++ b/usr.bin/lockf/lockf.c @@ -38,7 +38,7 @@ #include #include -static int acquire_lock(const char *name, int flags); +static int acquire_lock(const char *name, int flags, int silent); static void cleanup(void); static void killed(int sig); static void timeout(int sig); @@ -125,13 +125,14 @@ main(int argc, char **argv) * avoiding the separate step of waiting for the lock. This * yields fairness and improved performance. */ - lockfd = acquire_lock(lockname, flags | O_NONBLOCK); + lockfd = acquire_lock(lockname, flags | O_NONBLOCK, silent); while (lockfd == -1 && !timed_out && waitsec != 0) { if (keep) - lockfd = acquire_lock(lockname, flags); + lockfd = acquire_lock(lockname, flags, silent); else { wait_for_lock(lockname); - lockfd = acquire_lock(lockname, flags | O_NONBLOCK); + lockfd = acquire_lock(lockname, flags | O_NONBLOCK, + silent); } } if (waitsec > 0) @@ -168,15 +169,18 @@ main(int argc, char **argv) * on success, or -1 on failure. */ static int -acquire_lock(const char *name, int flags) +acquire_lock(const char *name, int flags, int silent) { int fd; if ((fd = open(name, O_EXLOCK|flags, 0666)) == -1) { if (errno == EAGAIN || errno == EINTR) return (-1); - else if (errno == ENOENT && (flags & O_CREAT) == 0) - err(EX_UNAVAILABLE, "%s", name); + else if (errno == ENOENT && (flags & O_CREAT) == 0) { + if (!silent) + warn("%s", name); + exit(EX_UNAVAILABLE); + } err(EX_CANTCREAT, "cannot open %s", name); } return (fd);