Commit Graph

17 Commits

Author SHA1 Message Date
Sami Kerola d89bfedff5 flock: move long_options struct to function scope
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-09-29 22:22:33 +02:00
Sami Kerola 75332f0f2b flock: fix coding style
Sanitize indentation, spacing, brace positions, comment line lenghts and
positions etc. This commit does not change a thing in code.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-09-29 22:22:22 +02:00
Petr Uzel 87d83b6ad2 flock: make flock(1) work on NFSv4
To pleace an exclusive lock on a file, NFSv4 requires
the file to be opened RW because of the emulation of flock()
by fcntl():

http://www.spinics.net/lists/linux-nfs/msg18502.html

So instead of O_RDONLY, open the file in O_RDWR if access()
indicates it is possible (unless shared lock is requested).

From: Michal Kubecek <mkubecek@suse.cz>
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2011-09-27 15:02:44 +02:00
Karel Zak 2e49d90f34 flock: cleanup usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-16 13:07:30 +02:00
Josiah Worcester d78104d14e fsck, checktty, flock: Use more portable includes.
Signed-off-by: Josiah Worcester <josiahw@gmail.com>
2011-06-14 13:58:37 +02:00
Karel Zak 1fc0b941d6 flock: properly report exec() errors
Reported-by: Barry Davis <barry_davis@stormagic.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-08-20 11:45:00 +02:00
François Revol 1bf4407a1d portability: use standard constants
Signed-off-by: François Revol <revol@free.fr>
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-07-26 11:41:04 +02:00
Mike Frysinger 60cd48bd14 flock: fix hang when parent ignores SIGCHLD
If flock is executed from a process which has set SIGCHLD to SIG_IGN, then
flock will eat cpu and hang indefinitely if given a command to execute.
So before we fork(), make sure to set SIGCHLD handling back to the default
so that the later waitpid() doesn't freak out on us.

[kzak@redhat.com: - add a check for waitpid() return value]

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2009-12-07 15:23:40 +01:00
Karel Zak db1749cf6c flock: add NLS support, remove tailing white-spaces
Signed-off-by: Karel Zak <kzak@redhat.com>
2009-03-11 13:37:45 +01:00
Karel Zak 56d23414c1 flock: fix printf format error in usage()
flock.c: In function ‘usage’:
flock.c:75: warning: too few arguments for format

Signed-off-by: Karel Zak <kzak@redhat.com>
2009-03-11 13:37:45 +01:00
Karel Zak 841f86dbc2 flockc: segfaults when file name is not given
$ flock -s
Segmentation fault

ltrace:
__libc_start_main(0x8048870, 2, 0xbfe9f404, 0x8049070, 0x8049060 <unfinished ...>
getopt_long(2, 0xbfe9f404, "+sexnouw:hV?", 0x80494e0, 0xbfe9f354) = 115
getopt_long(2, 0xbfe9f404, "+sexnouw:hV?", 0x80494e0, 0xbfe9f354) = -1
strtol(0, 0xbfe9f34c, 10, 0x80494e0, 0xbfe9f354 <unfinished ...>
--- SIGSEGV (Segmentation fault) ---
+++ killed by SIGSEGV +++

Addresses-Red-Had-Bugzilla: #489672
Signed-off-by: Karel Zak <kzak@redhat.com>
2009-03-11 13:37:40 +01:00
Alexey Gladkov ff5717391c flock: Allow lock directory
With this patch, you can lock directory. Additionally,
lockfile opens with O_NOCTTY.

Try to open file with O_CREAT flag first, and without it
if open fails with EISDIR.  Suggested by H. Peter Anvin.

Signed-off-by: Alexey Gladkov <legion@altlinux.org>
2008-12-03 10:33:53 +01:00
maximilian attems d3e8f6598b remove CVS keywords
this patch removes old CVS keywords from comments.

mount(8) works for newer Linux then 0.99 ;)

Signed-off-by: maximilian attems <max@stro.at>
2008-07-28 11:10:08 +02:00
Karel Zak a120aaa70d Imported from util-linux-2.13-pre7 tarball. 2006-12-07 00:27:22 +01:00
Karel Zak baf39af15b Imported from util-linux-2.13-pre2 tarball. 2006-12-07 00:26:58 +01:00
Karel Zak 48d7b13a1e Imported from util-linux-2.13-pre1 tarball. 2006-12-07 00:26:54 +01:00
Karel Zak d162fcb550 Imported from util-linux-2.12j tarball. 2006-12-07 00:26:24 +01:00