From nobody Fri Dec 15 16:50:58 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 4SsFbR1Hm2z53nWj; Fri, 15 Dec 2023 16:50:59 +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 4SsFbQ2fgdz4bGb; Fri, 15 Dec 2023 16:50:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1702659058; 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=33tm4KXhKaAsgi85fb4eXn99crIRqofmPjLRKKMn7BE=; b=w9yTbicxqRzxUmO8BzAZD6v1VX2ZROuu5bwdugphw75A8NJoL9J3z1KMI3824VK+/7yBF4 +QcBrgVOGvTDKeA2262KaTlq668BPALGz3Dqnbe14RRD+3QW9e140dv1V9B1J009LVOOa5 jPrmw/b7zFNRwodUZ4FmjQA9lIpbs667HTVEf+JShhFlKQAwYqVzwWuFNgEevWAgZ3fmZV wByIpZqlN5zq57FGAu+3OXVxs/8gbqOHJaXuYjYz39bRP4mJi76PERepOkjjcwswx9DPEK FS9SmhOqlzXHod5tzW/8UwcrQeXDfrFCDSkDsKul2WV+q1q490g6I4rlLy2WHw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1702659058; a=rsa-sha256; cv=none; b=cru9GG4GJ3KSjcDMif3KAhxyLb7LWAXg5PeVA6u6B/MReabFz4TrftBKOXligImpI+kNUH RcigfEBb0tHhDWL79RYiud41+sP8SBy+pkY9fxeQC6+3i7DyS9MQvr5TxT8PO1NPvrORxk BrvV+8J3ZVsZCKqSk1po1MkCjHvfOW8QH78LWzejTE4pXVBpiEM9Xd9yGE8Fnm6xkxujUS e1/o8+X8tiiDT+KZj0pI0oY6iSYBuVLU24v1ivbU2P0A+82gDy8Zjpf0mhSM+Hbs+WgwNH 3cvel7CVzvUdzDXsc8ymuycFQDFYwaZGWcOcPK6ol4+dCGi27YhJ1Cy9z56fDg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1702659058; 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=33tm4KXhKaAsgi85fb4eXn99crIRqofmPjLRKKMn7BE=; b=wntaTmSKMyfJonty/MuNcrPcgzcKhfv9M83p0l+hUwmBt5z0pUJ00MQHav31P+fER58w1g srcwdYJ1Q7jTMJLozI4BpCBKj74yl+5CRdcLM11WDWLLAE4ApAkF1F6erR0V1uj6ICtnSS ERg21hqigRTNy4hoqd3kIY1OzrijErAAFRzul7aQp2gWNx/P4+ArWftsMT0/X8VbNf8Nyz bKWkAtTf/kzTQu3c1Mkufr3J/uhz0pOjEf+t4eTwlN4STHUmGDvhmvqCcyJjBqplEfUAtG BiAr2A3Lm7gZnzT/vmuo544ROIY1/OixoONNz728cg0vlfbOgIpX4Z9y59ujgw== 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 4SsFbQ1dpYz3wp; Fri, 15 Dec 2023 16:50:58 +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 3BFGowCv011603; Fri, 15 Dec 2023 16:50:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3BFGowXk011590; Fri, 15 Dec 2023 16:50:58 GMT (envelope-from git) Date: Fri, 15 Dec 2023 16:50:58 GMT Message-Id: <202312151650.3BFGowXk011590@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kyle Evans Subject: git: 6128f0c28db5 - stable/14 - 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/stable/14 X-Git-Reftype: branch X-Git-Commit: 6128f0c28db5c77374e1898e16f44131ebebc861 Auto-Submitted: auto-generated The branch stable/14 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=6128f0c28db5c77374e1898e16f44131ebebc861 commit 6128f0c28db5c77374e1898e16f44131ebebc861 Author: Kyle Evans AuthorDate: 2023-11-22 04:41:36 +0000 Commit: Kyle Evans CommitDate: 2023-12-15 00:58:15 +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. (cherry picked from commit 3041e6950d07f0d11c9f91fefbf3c273cbbe4407) --- 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 4fbabea8c08f..ff1e7a6d6216 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);