-
Notifications
You must be signed in to change notification settings - Fork 5
/
linux.h
79 lines (63 loc) · 2.76 KB
/
linux.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/***************************************************************************/
/* Copyright (C) 2006-2011 Brice Arnould. */
/* */
/* This file is part of ShaKe. */
/* */
/* ShaKe is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License, or */
/* (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/***************************************************************************/
#ifndef LINUX_H
# define LINUX_H
# define _GNU_SOURCE
# include <getopt.h> // getopt_long()
# include <alloca.h> // alloca()
# include <stdbool.h> // bool
# include <stdio.h> // getline, asprintf
# include <sys/time.h> // struct timeval
# include "judge.h"
# define OS_RESERVED_SIGNAL 16
/* Called once, perform OS-specific tasks.
*/
int os_specific_setup (const char *tempfile);
/* Get a write lock on the file.
* We get a write lock even when a read lock would be enough to detect
* earlier access contention.
*/
int readlock_file (int fd, const char *filename);
/* Release our locks on the file
* Return -1 if we do not own the lock.
*/
int unlock_file (int fd);
/* Promote a read lock to a write lock.
* Return -1 if we no longer owned the lock.
*/
int readlock_to_writelock (int fd);
/* Return true if fd is locked, else false
*/
bool is_locked (int fd);
/* Declares the glibc function
*/
int futimes (int fd, const struct timeval tv[2]);
/* Set the shake_ptime field and ctime of the file to the actual date.
*/
int set_ptime (int fd);
/* Get the ptime of the file, -1 if that failed
*/
time_t get_ptime (int fd);
/* This function is mainly a wrapper around ioctl()s.
* It updates a->{blocks, crumbc, fragc, start and end}
* with just a bit of undocumented black magic.
* It can only be called after investigate().
*/
int get_testimony (struct accused *a, struct law *l);
#endif