rp_pppoe: Copy acName and pppd_pppoe_service after option parsing
[mpls-ppp.git] / pppd / plugins / radius / lock.c
blob482e97cdb63127f62d4c6b5a8e7d3c43022cefd2
1 /*
2 * $Id: lock.c,v 1.1 2004/11/14 07:26:26 paulus Exp $
4 * Copyright (C) 1997 Lars Fenneberg
6 * See the file COPYRIGHT for the respective terms and conditions.
7 * If the file is missing contact me at lf@elemental.net
8 * and I'll send you a copy.
12 #include "includes.h"
13 #include <unistd.h>
14 #include <fcntl.h>
16 int do_lock_exclusive(int fd)
18 struct flock fl;
19 int res;
21 memset((void *)&fl, 0, sizeof(fl));
23 fl.l_type = F_WRLCK;
24 fl.l_whence = fl.l_start = 0;
25 fl.l_len = 0; /* 0 means "to end of file" */
27 res = fcntl(fd, F_SETLK, &fl);
29 if ((res == -1) && (errno == EAGAIN))
30 errno = EWOULDBLOCK;
32 return res;
35 int do_unlock(int fd)
37 struct flock fl;
39 memset((void *)&fl, 0, sizeof(fl));
41 fl.l_type = F_UNLCK;
42 fl.l_whence = fl.l_start = 0;
43 fl.l_len = 0; /* 0 means "to end of file" */
45 return fcntl(fd, F_SETLK, &fl);