line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
/* |
2
|
|
|
|
|
|
|
* Copyright (C) the libgit2 contributors. All rights reserved. |
3
|
|
|
|
|
|
|
* |
4
|
|
|
|
|
|
|
* This file is part of libgit2, distributed under the GNU GPL v2 with |
5
|
|
|
|
|
|
|
* a Linking Exception. For full terms see the included COPYING file. |
6
|
|
|
|
|
|
|
*/ |
7
|
|
|
|
|
|
|
#ifndef INCLUDE_unix_posix_h__ |
8
|
|
|
|
|
|
|
#define INCLUDE_unix_posix_h__ |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
#include "git2_util.h" |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
#include |
13
|
|
|
|
|
|
|
#include |
14
|
|
|
|
|
|
|
#include |
15
|
|
|
|
|
|
|
#include |
16
|
|
|
|
|
|
|
#include |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
typedef int GIT_SOCKET; |
19
|
|
|
|
|
|
|
#define INVALID_SOCKET -1 |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
#define p_lseek(f,n,w) lseek(f, n, w) |
22
|
|
|
|
|
|
|
#define p_fstat(f,b) fstat(f, b) |
23
|
|
|
|
|
|
|
#define p_lstat(p,b) lstat(p,b) |
24
|
|
|
|
|
|
|
#define p_stat(p,b) stat(p, b) |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
#if defined(GIT_USE_STAT_MTIMESPEC) |
27
|
|
|
|
|
|
|
# define st_atime_nsec st_atimespec.tv_nsec |
28
|
|
|
|
|
|
|
# define st_mtime_nsec st_mtimespec.tv_nsec |
29
|
|
|
|
|
|
|
# define st_ctime_nsec st_ctimespec.tv_nsec |
30
|
|
|
|
|
|
|
#elif defined(GIT_USE_STAT_MTIM) |
31
|
|
|
|
|
|
|
# define st_atime_nsec st_atim.tv_nsec |
32
|
|
|
|
|
|
|
# define st_mtime_nsec st_mtim.tv_nsec |
33
|
|
|
|
|
|
|
# define st_ctime_nsec st_ctim.tv_nsec |
34
|
|
|
|
|
|
|
#elif !defined(GIT_USE_STAT_MTIME_NSEC) && defined(GIT_USE_NSEC) |
35
|
|
|
|
|
|
|
# error GIT_USE_NSEC defined but unknown struct stat nanosecond type |
36
|
|
|
|
|
|
|
#endif |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
#define p_utimes(f, t) utimes(f, t) |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
#define p_readlink(a, b, c) readlink(a, b, c) |
41
|
|
|
|
|
|
|
#define p_symlink(o,n) symlink(o, n) |
42
|
|
|
|
|
|
|
#define p_link(o,n) link(o, n) |
43
|
|
|
|
|
|
|
#define p_unlink(p) unlink(p) |
44
|
|
|
|
|
|
|
#define p_mkdir(p,m) mkdir(p, m) |
45
|
|
|
|
|
|
|
extern char *p_realpath(const char *, char *); |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
GIT_INLINE(int) p_fsync(int fd) |
48
|
|
|
|
|
|
|
{ |
49
|
0
|
|
|
|
|
|
p_fsync__cnt++; |
50
|
0
|
|
|
|
|
|
return fsync(fd); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
#define p_recv(s,b,l,f) recv(s,b,l,f) |
54
|
|
|
|
|
|
|
#define p_send(s,b,l,f) send(s,b,l,f) |
55
|
|
|
|
|
|
|
#define p_inet_pton(a, b, c) inet_pton(a, b, c) |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
#define p_strcasecmp(s1, s2) strcasecmp(s1, s2) |
58
|
|
|
|
|
|
|
#define p_strncasecmp(s1, s2, c) strncasecmp(s1, s2, c) |
59
|
|
|
|
|
|
|
#define p_vsnprintf(b, c, f, a) vsnprintf(b, c, f, a) |
60
|
|
|
|
|
|
|
#define p_snprintf snprintf |
61
|
|
|
|
|
|
|
#define p_chdir(p) chdir(p) |
62
|
|
|
|
|
|
|
#define p_rmdir(p) rmdir(p) |
63
|
|
|
|
|
|
|
#define p_access(p,m) access(p,m) |
64
|
|
|
|
|
|
|
#define p_ftruncate(fd, sz) ftruncate(fd, sz) |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
/* |
67
|
|
|
|
|
|
|
* Pre-Android 5 did not implement a virtual filesystem atop FAT |
68
|
|
|
|
|
|
|
* partitions for Unix permissions, which causes chmod to fail. However, |
69
|
|
|
|
|
|
|
* Unix permissions have no effect on Android anyway as file permissions |
70
|
|
|
|
|
|
|
* are not actually managed this way, so treating it as a no-op across |
71
|
|
|
|
|
|
|
* all Android is safe. |
72
|
|
|
|
|
|
|
*/ |
73
|
|
|
|
|
|
|
#ifdef __ANDROID__ |
74
|
|
|
|
|
|
|
# define p_chmod(p,m) 0 |
75
|
|
|
|
|
|
|
#else |
76
|
|
|
|
|
|
|
# define p_chmod(p,m) chmod(p, m) |
77
|
|
|
|
|
|
|
#endif |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
/* see win32/posix.h for explanation about why this exists */ |
80
|
|
|
|
|
|
|
#define p_lstat_posixly(p,b) lstat(p,b) |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
#define p_localtime_r(c, r) localtime_r(c, r) |
83
|
|
|
|
|
|
|
#define p_gmtime_r(c, r) gmtime_r(c, r) |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
#define p_timeval timeval |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
#ifdef GIT_USE_FUTIMENS |
88
|
|
|
|
|
|
|
GIT_INLINE(int) p_futimes(int f, const struct p_timeval t[2]) |
89
|
|
|
|
|
|
|
{ |
90
|
|
|
|
|
|
|
struct timespec s[2]; |
91
|
|
|
|
|
|
|
s[0].tv_sec = t[0].tv_sec; |
92
|
|
|
|
|
|
|
s[0].tv_nsec = t[0].tv_usec * 1000; |
93
|
|
|
|
|
|
|
s[1].tv_sec = t[1].tv_sec; |
94
|
|
|
|
|
|
|
s[1].tv_nsec = t[1].tv_usec * 1000; |
95
|
|
|
|
|
|
|
return futimens(f, s); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
#else |
98
|
|
|
|
|
|
|
# define p_futimes futimes |
99
|
|
|
|
|
|
|
#endif |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
#define p_pread(f, d, s, o) pread(f, d, s, o) |
102
|
|
|
|
|
|
|
#define p_pwrite(f, d, s, o) pwrite(f, d, s, o) |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
#endif |