Deleted Added
full compact
gr_util.c (243334) gr_util.c (244735)
1/*-
2 * Copyright (c) 2008 Sean C. Farley <scf@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2008 Sean C. Farley <scf@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/lib/libutil/gr_util.c 243334 2012-11-20 14:03:09Z bapt $");
28__FBSDID("$FreeBSD: head/lib/libutil/gr_util.c 244735 2012-12-27 14:09:50Z bapt $");
29
30#include <sys/param.h>
31#include <sys/errno.h>
32#include <sys/stat.h>
33
34#include <ctype.h>
35#include <err.h>
36#include <fcntl.h>

--- 64 unchanged lines hidden (view full) ---

101gr_lock(void)
102{
103 if (*group_file == '\0')
104 return (-1);
105
106 for (;;) {
107 struct stat st;
108
29
30#include <sys/param.h>
31#include <sys/errno.h>
32#include <sys/stat.h>
33
34#include <ctype.h>
35#include <err.h>
36#include <fcntl.h>

--- 64 unchanged lines hidden (view full) ---

101gr_lock(void)
102{
103 if (*group_file == '\0')
104 return (-1);
105
106 for (;;) {
107 struct stat st;
108
109 lockfd = open(group_file, O_RDONLY, 0);
110 if (lockfd < 0 || fcntl(lockfd, F_SETFD, 1) == -1)
111 err(1, "%s", group_file);
112 if (flock(lockfd, LOCK_EX|LOCK_NB) == -1) {
109 lockfd = flopen(group_file, O_RDONLY|O_NONBLOCK, 0);
110 if (lockfd == -1) {
113 if (errno == EWOULDBLOCK) {
114 errx(1, "the group file is busy");
115 } else {
116 err(1, "could not lock the group file: ");
117 }
118 }
119 if (fstat(lockfd, &st) == -1)
120 err(1, "fstat() failed: ");

--- 431 unchanged lines hidden ---
111 if (errno == EWOULDBLOCK) {
112 errx(1, "the group file is busy");
113 } else {
114 err(1, "could not lock the group file: ");
115 }
116 }
117 if (fstat(lockfd, &st) == -1)
118 err(1, "fstat() failed: ");

--- 431 unchanged lines hidden ---