*
* $Id$
* Derived from:
- * $FreeBSD: src/lib/libutil/flopen.c,v 1.7 2007/05/23 12:09:33 des Exp $
+ * $FreeBSD: head/lib/libutil/flopen.c 184094 2008-10-20 18:11:30Z des $
*/
#include "config.h"
-#include <sys/file.h>
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
+#include <string.h>
#include <unistd.h>
#include "config.h"
flopen(const char *path, int flags, ...)
{
int fd, operation, serrno, trunc;
- struct stat sb, fsb;
struct flock lock;
+ struct stat sb, fsb;
mode_t mode;
#ifdef O_EXLOCK
va_end(ap);
}
+ memset(&lock, 0, sizeof lock);
lock.l_type = ((flags & O_ACCMODE) == O_RDONLY) ? F_RDLCK : F_WRLCK;
- lock.l_start = 0;
lock.l_whence = SEEK_SET;
- lock.l_len = 0;
operation = (flags & O_NONBLOCK) ? F_SETLK : F_SETLKW;
trunc = (flags & O_TRUNC);
*
* $Id$
* Derived from:
- * $FreeBSD: src/lib/libutil/pidfile.c,v 1.5 2007/05/11 11:10:05 des Exp $
+ * $FreeBSD: head/lib/libutil/pidfile.c 184091 2008-10-20 17:41:08Z des $
*/
#include "config.h"
static int
_vpf_remove(struct pidfh *pfh, int freeit)
{
- struct flock lock;
int error;
- lock.l_type = F_UNLCK;
- lock.l_start = 0;
- lock.l_whence = SEEK_SET;
- lock.l_len = 0;
-
error = vpf_verify(pfh);
if (error != 0) {
errno = error;
if (unlink(pfh->pf_path) == -1)
error = errno;
- if (fcntl(pfh->pf_fd, F_SETLK, &lock) == -1) {
- if (error == 0)
- error = errno;
- }
if (close(pfh->pf_fd) == -1) {
if (error == 0)
error = errno;