Commit Graph

30 Commits

Author SHA1 Message Date
cperciva
e304f418da Remove whitespace which accidentaly snuck into r364831. 2020-08-26 19:28:30 +00:00
cperciva
d0e6339a5a Add -w option to lockf(1).
By default, lockf(1) opens its lock file O_RDONLY|O_EXLOCK.  On NFS, if the
file already exists, this is split into opening the file read-only and then
requesting an exclusive lock -- and the second step fails because NFS does
not permit exclusive locking on files which are opened read-only.

The new -w option changes the open flags to O_WRONLY|O_EXLOCK, allowing it
to work on NFS -- at the cost of not working if the file cannot be opened
for writing.

(Whether the traditional BSD behaviour of allowing exclusive locks to be
obtained on a file which cannot be opened for writing is a good idea is
perhaps questionable since it may allow less-privileged users to perform
a local denial of service; however this behaviour has been present for a
long time and changing it now seems like it would cause problems.)

Reviewed by:	rmacklem
Differential Revision:	https://reviews.freebsd.org/D26005
2020-08-26 19:26:48 +00:00
fernape
c05e9e0e3c lockf(1): Add EXAMPLES section
* Add pretty small EXAMPLES section
 * While here, fix a warning in line 98 (new sentence in new line)

Approved by:	bcr@
Differential Revision:	https://reviews.freebsd.org/D25205
2020-06-18 08:31:04 +00:00
markj
67e12a6d15 lockf(1): add a reference to lockf(3).
Submitted by:	Conrad Meyer
MFC after:	1 week
2015-04-06 22:53:23 +00:00
bapt
1f77f137dc use .Mt to mark up email addresses consistently (part3)
PR:		191174
Submitted by:	Franco Fichtner  <franco at lastsummer.de>
2014-06-23 08:23:05 +00:00
eadler
93bce4ba3b Add option to lockf to avoid creating a file if it does not exist.
PR:	bin/170775
Submitted by:	Matthew Story <matthewstory@gmail.com>
Reviewed by:	scottl
MFC after:	1 week
2013-05-10 17:30:29 +00:00
eadler
1ef5fe44d3 Remove trailing whitespace per mdoc lint warning
Disussed with:	gavin
No objection from:	doc
Approved by:	joel
MFC after:	3 days
2012-03-29 05:02:12 +00:00
uqs
3960614646 mdoc: order prologue macros consistently by Dd/Dt/Os
Although groff_mdoc(7) gives another impression, this is the ordering
most widely used and also required by mdocml/mandoc.

Reviewed by:	ru
Approved by:	philip, ed (mentors)
2010-04-14 19:08:06 +00:00
dwmalone
6df81d1188 Lockf was exiting with status 1 if the command did not exit normally.
This is easy to confuse with the actual exit status of the program.
Instead exit with EX_SOFTWARE if the command doesn't exit normally.

MFC after:	1 month
2008-08-21 07:36:17 +00:00
ru
c98af9169a Also fix a "blank line" issue that sneaked in from rev. 1.19.
Submitted by:	John Hein
2007-10-31 19:26:01 +00:00
ru
21b82a0c29 Remove newly acquired hard sentence breaks. 2007-10-30 19:23:42 +00:00
csjp
11b9e24e5b Revision 1.12 of lockf.c fixed a "thundering herd" scenario when the
lock experienced contention a number of processes would race to acquire
lock when it was released.  This problem resulted in a lot of CPU
load as well as locks being picked up out of order.

Unfortunately, a regression snuck in which allowed multiple threads
to pickup the same lock when -k was not used.  This could occur when
multiple processes open a file descriptor to inode X (one process
will be blocked) and the file is unlinked on unlock (thereby removing
the directory entry allow another process to create a new directory
entry for the same file name and lock it).

This changes restores the old algorithm of: wait for the lock, then
acquire lock when we want to unlink the file on exit (specifically
when -k is not used) and keeps the new algorithm for when -k is used,
which yields fairness and improved performance.

Also, update the man page to inform users that if lockf(1) is being
used to facilitate concurrency between a number of processes, it
is recommended that -k be used to reduce CPU load and yeld
fairness with regard to lock ordering.

Collaborated with:	jdp
PR:		bin/114341
PR:		bin/116543
PR:		bin/111101
MFC after:	1 week
2007-10-12 14:56:52 +00:00
ru
38f526ca48 Markup cosmetics. 2006-12-20 16:57:13 +00:00
keramida
ac7c9f771d Fix all the spelling mistakes I could find in the man pages for words
that have at least 3 characters.

MFC after:	1 week
Thanks to:	Music band ``Chingon''
		for keeping me company while searching for these.
2005-07-31 03:30:48 +00:00
ru
19aa3916e2 Markup and wording fixes.
Approved by:	re (blanket)
2005-06-14 11:50:53 +00:00
eivind
64e1569cd3 Document a couple of gotchas. 2005-05-26 22:30:12 +00:00
ru
6cc4b6c220 Added the EXIT STATUS section where appropriate. 2005-01-17 07:44:44 +00:00
ru
fb1d8b3724 Mechanically kill hard sentence breaks. 2004-07-02 22:22:35 +00:00
charnier
ad8a79e6a5 Use `The .Nm utility' 2002-04-20 12:18:28 +00:00
ru
24c7b0a61d mdoc(7) police: s/BSD/.Bx/ where appropriate. 2001-08-14 10:01:54 +00:00
dd
911ca14c87 Remove whitespace at EOL. 2001-07-15 08:06:20 +00:00
ru
36f138439b mdoc(7) police: removed HISTORY info from the .Os call. 2001-07-10 14:16:33 +00:00
obrien
88f98d711e Add history. 2000-12-10 01:10:54 +00:00
peter
3b842d34e8 $Id$ -> $FreeBSD$ 1999-08-28 01:08:13 +00:00
jdp
2756040b8b Add a "-k" option, to specify that the lock file should be kept
rather than removed.

Submitted by:	Nick Barnes <Nick.Barnes@pobox.com>
1998-07-08 05:29:05 +00:00
charnier
409a50cddf .Sh AUTHOR -> .Sh AUTHORS. Use .An/.Aq. 1998-03-23 07:48:45 +00:00
peter
f390c26dd9 Revert $FreeBSD$ to $Id$ 1997-02-22 19:58:13 +00:00
jkh
808a36ef65 Make the long-awaited change from $Id$ to $FreeBSD$
This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore.  This update would have been
insane otherwise.
1997-01-14 07:20:47 +00:00
jdp
4d96d1de07 On failure, return various exit codes from <sysexits.h>. In particular,
return EX_TEMPFAIL if the file was already locked.  This makes it easier
to distinguish between lock collisions and failures within the command
being executed.

Also, don't complain if the unlink() fails in the cleanup handler.  It
doesn't matter anyway, and it obscured the exit status returned from
the command that was executed.
1997-01-09 19:53:21 +00:00
jdp
e83b4a256a Initial import of the lockf utility. It executes an arbitrary command
while holding an exclusive lock on a file.
1997-01-08 20:12:59 +00:00