lockf(1): return EX_UNAVAILABLE if -n is used and the lock file does not

exist

Apply EX_UNAVAILABLE patch part from PR 170775 to match the documentation.

Checked with a command from PR 210770:
lockf -n /tmp/doesnotexist echo; echo $?

PR:		210770
MFC after:	1 week
This commit is contained in:
avos 2019-03-20 07:40:38 +00:00
parent cc46385367
commit 4a9d286dec

View File

@ -174,6 +174,8 @@ acquire_lock(const char *name, int flags)
if ((fd = open(name, O_RDONLY|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);
err(EX_CANTCREAT, "cannot open %s", name);
}
return (fd);