Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-7]: src/usr.bin/flock Pull up following revision(s) (requested by...
details: https://anonhg.NetBSD.org/src/rev/65d7d53bec02
branches: netbsd-7
changeset: 798313:65d7d53bec02
user: martin <martin%NetBSD.org@localhost>
date: Sat Aug 30 14:06:55 2014 +0000
description:
Pull up following revision(s) (requested by manu in ticket #68):
usr.bin/flock/flock.c: revision 1.9 - 1.11
usr.bin/flock/flock.1: revision 1.10
Annotate functions using format strings.
Improve Linux compatibility, by making exclusive lock the default.
Also check for file descriptor value being sane.
diffstat:
usr.bin/flock/flock.1 | 5 +++--
usr.bin/flock/flock.c | 18 +++++++++++++-----
2 files changed, 16 insertions(+), 7 deletions(-)
diffs (85 lines):
diff -r 127a4ef468bf -r 65d7d53bec02 usr.bin/flock/flock.1
--- a/usr.bin/flock/flock.1 Fri Aug 29 11:58:30 2014 +0000
+++ b/usr.bin/flock/flock.1 Sat Aug 30 14:06:55 2014 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: flock.1,v 1.9 2013/09/21 15:01:14 khorben Exp $
+.\" $NetBSD: flock.1,v 1.9.4.1 2014/08/30 14:06:55 martin Exp $
.\"
.\" Copyright (c) 2012 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -28,7 +28,7 @@
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.\"
-.Dd November 2, 2012
+.Dd August 18, 2014
.Dt FLOCK 1
.Os
.Sh NAME
@@ -87,6 +87,7 @@
.Ar seconds .
.It Fl x , Fl Fl exclusive
Obtain an exclusive lock.
+This is the default.
.El
.Sh EXIT STATUS
.Ex -std
diff -r 127a4ef468bf -r 65d7d53bec02 usr.bin/flock/flock.c
--- a/usr.bin/flock/flock.c Fri Aug 29 11:58:30 2014 +0000
+++ b/usr.bin/flock/flock.c Sat Aug 30 14:06:55 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: flock.c,v 1.9 2014/01/07 02:07:08 joerg Exp $ */
+/* $NetBSD: flock.c,v 1.9.4.1 2014/08/30 14:06:55 martin Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: flock.c,v 1.9 2014/01/07 02:07:08 joerg Exp $");
+__RCSID("$NetBSD: flock.c,v 1.9.4.1 2014/08/30 14:06:55 martin Exp $");
#include <stdio.h>
#include <string.h>
@@ -43,6 +43,7 @@
#include <errno.h>
#include <getopt.h>
#include <paths.h>
+#include <limits.h>
#include <time.h>
static struct option flock_longopts[] = {
@@ -155,6 +156,7 @@
int fd = -1;
int debug = 0;
int verbose = 0;
+ long l;
char *mcargv[] = {
__UNCONST(_PATH_BSHELL), __UNCONST("-c"), NULL, NULL
};
@@ -207,15 +209,21 @@
argv += optind;
if ((lock & ~LOCK_NB) == 0)
- usage("Missing lock type flag");
+ lock |= LOCK_EX; /* default to exclusive like linux */
switch (argc) {
case 0:
usage("Missing lock file argument");
case 1:
if (cls)
- usage("Close is valid only for descriptors");
- fd = strtol(argv[0], NULL, 0); // XXX: error checking
+ usage("Close is not valid for descriptors");
+ errno = 0;
+ l = strtol(argv[0], &v, 0);
+ if ((l == LONG_MIN || l == LONG_MAX) && errno == ERANGE)
+ err(EXIT_FAILURE, "Bad file descriptor `%s'", argv[0]);
+ if (l > INT_MAX || l < 0 || *v)
+ errx(EXIT_FAILURE, "Bad file descriptor `%s'", argv[0]);
+ fd = (int)l;
if (debug) {
fprintf(stderr, "descriptor %s lock %s\n",
argv[0], lock2name(lock));
Home |
Main Index |
Thread Index |
Old Index