blob: 1ef1718c77db670c17d1925ea44c9f875141c6fc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
/* ISC license. */
#include <string.h>
#include <skalibs/strerr.h>
#include <skalibs/djbunix.h>
#include <skalibs/unix-transactional.h>
#include "s6f.h"
int s6f_lock (char const *stmpdir, int w)
{
int fdstmp = s6f_confdir_open(stmpdir, 1) ;
int fd = openc_truncat(fdstmp, "lock") ;
if (fd == -1) strerr_diefu4sys(111, "open ", stmpdir, "/lock", " for writing") ;
fd_close(fdstmp) ;
if (fd_lock(fd, w, 0) < 1)
strerr_diefu3sys(111, "lock ", stmpdir, "/lock") ;
return fd ;
}
|