Blame


1 01b7ba6b 2019-03-11 stsp /*
2 01b7ba6b 2019-03-11 stsp * Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
3 01b7ba6b 2019-03-11 stsp *
4 01b7ba6b 2019-03-11 stsp * Permission to use, copy, modify, and distribute this software for any
5 01b7ba6b 2019-03-11 stsp * purpose with or without fee is hereby granted, provided that the above
6 01b7ba6b 2019-03-11 stsp * copyright notice and this permission notice appear in all copies.
7 01b7ba6b 2019-03-11 stsp *
8 01b7ba6b 2019-03-11 stsp * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 01b7ba6b 2019-03-11 stsp * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 01b7ba6b 2019-03-11 stsp * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 01b7ba6b 2019-03-11 stsp * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 01b7ba6b 2019-03-11 stsp * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 01b7ba6b 2019-03-11 stsp * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 01b7ba6b 2019-03-11 stsp * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 01b7ba6b 2019-03-11 stsp */
16 01b7ba6b 2019-03-11 stsp
17 01b7ba6b 2019-03-11 stsp /*
18 01b7ba6b 2019-03-11 stsp * Git-compatible lock file implementation. Lock files are used to
19 5e91dae4 2022-08-30 stsp * ensure exclusive access when files in a Git repository are modified.
20 01b7ba6b 2019-03-11 stsp */
21 01b7ba6b 2019-03-11 stsp
22 01b7ba6b 2019-03-11 stsp #define GOT_LOCKFILE_SUFFIX ".lock"
23 01b7ba6b 2019-03-11 stsp
24 01b7ba6b 2019-03-11 stsp struct got_lockfile {
25 01b7ba6b 2019-03-11 stsp char *path;
26 01b7ba6b 2019-03-11 stsp char *locked_path;
27 01b7ba6b 2019-03-11 stsp int fd;
28 01b7ba6b 2019-03-11 stsp };
29 01b7ba6b 2019-03-11 stsp
30 5345b4c7 2021-07-06 stsp const struct got_error *got_lockfile_lock(struct got_lockfile **,
31 5345b4c7 2021-07-06 stsp const char *, int);
32 5345b4c7 2021-07-06 stsp const struct got_error *got_lockfile_unlock(struct got_lockfile *, int);