-
Notifications
You must be signed in to change notification settings - Fork 165
Expand file tree
/
Copy pathutils.h
More file actions
62 lines (42 loc) · 1.67 KB
/
utils.h
File metadata and controls
62 lines (42 loc) · 1.67 KB
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
#ifndef HEADER_UTILS_H
#define HEADER_UTILS_H
#include <stdio.h> /* For type FILE. */
#include <sys/time.h> /* For struct timeval. */
#include <stdint.h> /* For type uint64_t. */
#include <argp.h> /* For struct argp_state. */
#define GIGABYTES (1024 * 1024 * 1024)
void adjust_dev_path(const char **dev_path);
int get_block_size(const char *path);
/* Return true if @filename matches the regex /^[0-9]+\.h2w$/ */
int is_my_file(const char *filename);
/* Caller must free(3) the returned pointer. */
char *full_fn_from_number(const char **filename, const char *path, long num);
const long *ls_my_files(const char *path, long start_at, long end_at);
static inline uint64_t random_number(uint64_t prv_number)
{
return prv_number * 4294967311ULL + 17;
}
long arg_to_long(const struct argp_state *state, const char *arg);
#if __APPLE__ && __MACH__
#include <unistd.h> /* For type off_t. */
#define POSIX_FADV_SEQUENTIAL 2 /* Expect sequential page references. */
#define POSIX_FADV_DONTNEED 4 /* Don't need these pages. */
int fdatasync(int fd);
int posix_fadvise(int fd, off_t offset, off_t len, int advice);
#endif /* Apple Macintosh */
#ifdef __FreeBSD__
#define fdatasync(fd) fsync(fd)
#endif
#ifdef __OpenBSD__
#define POSIX_FADV_SEQUENTIAL 2 /* Expect sequential page references. */
#define POSIX_FADV_DONTNEED 4 /* Don't need these pages. */
/*
* OpenBSD doesn't have posix_fadvise() (...).
* There is some code [in F3] to emulate posix_fadvise for MacOS
* but it uses various fcntl(2) commands that we don't have [in OpenBSD].
*
* -- Stuart Henderson, OpenBSD developer
*/
#define posix_fadvise(fd, offset, len, advice) (0)
#endif /* OpenBSD */
#endif /* HEADER_UTILS_H */