/src/libgit2/src/util/unix/posix.h
Line | Count | Source (jump to first uncovered line) |
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 <stdio.h> |
13 | | #include <dirent.h> |
14 | | #include <sys/param.h> |
15 | | #include <sys/time.h> |
16 | | #include <sys/stat.h> |
17 | | |
18 | | typedef int GIT_SOCKET; |
19 | 0 | #define INVALID_SOCKET -1 |
20 | | |
21 | 0 | #define p_lseek(f,n,w) lseek(f, n, w) |
22 | 0 | #define p_fstat(f,b) fstat(f, b) |
23 | 0 | #define p_lstat(p,b) lstat(p,b) |
24 | 0 | #define p_stat(p,b) stat(p, b) |
25 | | |
26 | | #if defined(GIT_NSEC_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_NSEC_MTIM) |
31 | | # define st_atime_nsec st_atim.tv_nsec |
32 | 0 | # define st_mtime_nsec st_mtim.tv_nsec |
33 | 0 | # define st_ctime_nsec st_ctim.tv_nsec |
34 | | #elif !defined(GIT_NSEC_MTIME_NSEC) && defined(GIT_NSEC) |
35 | | # error GIT_NSEC defined but unknown struct stat nanosecond type |
36 | | #endif |
37 | | |
38 | 0 | #define p_utimes(f, t) utimes(f, t) |
39 | | |
40 | 0 | #define p_readlink(a, b, c) readlink(a, b, c) |
41 | 0 | #define p_symlink(o,n) symlink(o, n) |
42 | 0 | #define p_link(o,n) link(o, n) |
43 | 0 | #define p_unlink(p) unlink(p) |
44 | 0 | #define p_mkdir(p,m) mkdir(p, m) |
45 | | extern char *p_realpath(const char *, char *); |
46 | | |
47 | | GIT_INLINE(int) p_fsync(int fd) |
48 | 0 | { |
49 | 0 | p_fsync__cnt++; |
50 | 0 | return fsync(fd); |
51 | 0 | } Unexecuted instantiation: midx_fuzzer.c:p_fsync Unexecuted instantiation: fuzzer_utils.c:p_fsync Unexecuted instantiation: errors.c:p_fsync Unexecuted instantiation: hash.c:p_fsync Unexecuted instantiation: runtime.c:p_fsync Unexecuted instantiation: str.c:p_fsync Unexecuted instantiation: thread.c:p_fsync Unexecuted instantiation: util.c:p_fsync Unexecuted instantiation: collisiondetect.c:p_fsync Unexecuted instantiation: sha1.c:p_fsync Unexecuted instantiation: ubc_check.c:p_fsync Unexecuted instantiation: builtin.c:p_fsync Unexecuted instantiation: libgit2.c:p_fsync Unexecuted instantiation: merge_driver.c:p_fsync Unexecuted instantiation: merge_file.c:p_fsync Unexecuted instantiation: midx.c:p_fsync Unexecuted instantiation: mwindow.c:p_fsync Unexecuted instantiation: odb.c:p_fsync Unexecuted instantiation: odb_loose.c:p_fsync Unexecuted instantiation: odb_pack.c:p_fsync Unexecuted instantiation: oid.c:p_fsync Unexecuted instantiation: pack.c:p_fsync Unexecuted instantiation: repository.c:p_fsync Unexecuted instantiation: revparse.c:p_fsync Unexecuted instantiation: revwalk.c:p_fsync Unexecuted instantiation: settings.c:p_fsync Unexecuted instantiation: strarray.c:p_fsync Unexecuted instantiation: mbedtls.c:p_fsync Unexecuted instantiation: openssl.c:p_fsync Unexecuted instantiation: registry.c:p_fsync Unexecuted instantiation: socket.c:p_fsync Unexecuted instantiation: submodule.c:p_fsync Unexecuted instantiation: sysdir.c:p_fsync Unexecuted instantiation: tag.c:p_fsync Unexecuted instantiation: http.c:p_fsync Unexecuted instantiation: httpclient.c:p_fsync Unexecuted instantiation: httpparser.c:p_fsync Unexecuted instantiation: smart_protocol.c:p_fsync Unexecuted instantiation: ssh_libssh2.c:p_fsync Unexecuted instantiation: tree.c:p_fsync Unexecuted instantiation: worktree.c:p_fsync Unexecuted instantiation: alloc.c:p_fsync Unexecuted instantiation: failalloc.c:p_fsync Unexecuted instantiation: stdalloc.c:p_fsync Unexecuted instantiation: date.c:p_fsync Unexecuted instantiation: filebuf.c:p_fsync Unexecuted instantiation: fs_path.c:p_fsync Unexecuted instantiation: futils.c:p_fsync Unexecuted instantiation: net.c:p_fsync Unexecuted instantiation: pool.c:p_fsync Unexecuted instantiation: posix.c:p_fsync Unexecuted instantiation: pqueue.c:p_fsync Unexecuted instantiation: rand.c:p_fsync Unexecuted instantiation: regexp.c:p_fsync Unexecuted instantiation: vector.c:p_fsync Unexecuted instantiation: wildmatch.c:p_fsync Unexecuted instantiation: zstream.c:p_fsync Unexecuted instantiation: map.c:p_fsync Unexecuted instantiation: realpath.c:p_fsync Unexecuted instantiation: annotated_commit.c:p_fsync Unexecuted instantiation: attr.c:p_fsync Unexecuted instantiation: attr_file.c:p_fsync Unexecuted instantiation: attrcache.c:p_fsync Unexecuted instantiation: blob.c:p_fsync Unexecuted instantiation: branch.c:p_fsync Unexecuted instantiation: buf.c:p_fsync Unexecuted instantiation: cache.c:p_fsync Unexecuted instantiation: checkout.c:p_fsync Unexecuted instantiation: clone.c:p_fsync Unexecuted instantiation: commit.c:p_fsync Unexecuted instantiation: commit_graph.c:p_fsync Unexecuted instantiation: commit_list.c:p_fsync Unexecuted instantiation: config.c:p_fsync Unexecuted instantiation: config_cache.c:p_fsync Unexecuted instantiation: config_file.c:p_fsync Unexecuted instantiation: config_list.c:p_fsync Unexecuted instantiation: config_parse.c:p_fsync Unexecuted instantiation: config_snapshot.c:p_fsync Unexecuted instantiation: delta.c:p_fsync Unexecuted instantiation: diff.c:p_fsync Unexecuted instantiation: diff_driver.c:p_fsync Unexecuted instantiation: diff_generate.c:p_fsync Unexecuted instantiation: diff_print.c:p_fsync Unexecuted instantiation: diff_tform.c:p_fsync Unexecuted instantiation: email.c:p_fsync Unexecuted instantiation: filter.c:p_fsync Unexecuted instantiation: grafts.c:p_fsync Unexecuted instantiation: hashsig.c:p_fsync Unexecuted instantiation: ident.c:p_fsync Unexecuted instantiation: index.c:p_fsync Unexecuted instantiation: index_map.c:p_fsync Unexecuted instantiation: indexer.c:p_fsync Unexecuted instantiation: iterator.c:p_fsync Unexecuted instantiation: mailmap.c:p_fsync Unexecuted instantiation: merge.c:p_fsync Unexecuted instantiation: object.c:p_fsync Unexecuted instantiation: object_api.c:p_fsync Unexecuted instantiation: oidarray.c:p_fsync Unexecuted instantiation: pack-objects.c:p_fsync Unexecuted instantiation: parse.c:p_fsync Unexecuted instantiation: patch.c:p_fsync Unexecuted instantiation: patch_generate.c:p_fsync Unexecuted instantiation: path.c:p_fsync Unexecuted instantiation: pathspec.c:p_fsync Unexecuted instantiation: push.c:p_fsync Unexecuted instantiation: refdb.c:p_fsync Unexecuted instantiation: refdb_fs.c:p_fsync Unexecuted instantiation: reflog.c:p_fsync Unexecuted instantiation: refs.c:p_fsync Unexecuted instantiation: refspec.c:p_fsync Unexecuted instantiation: remote.c:p_fsync Unexecuted instantiation: signature.c:p_fsync Unexecuted instantiation: tls.c:p_fsync Unexecuted instantiation: trace.c:p_fsync Unexecuted instantiation: transaction.c:p_fsync Unexecuted instantiation: transport.c:p_fsync Unexecuted instantiation: auth.c:p_fsync Unexecuted instantiation: credential.c:p_fsync Unexecuted instantiation: git.c:p_fsync Unexecuted instantiation: local.c:p_fsync Unexecuted instantiation: smart.c:p_fsync Unexecuted instantiation: smart_pkt.c:p_fsync Unexecuted instantiation: tree-cache.c:p_fsync Unexecuted instantiation: sortedcache.c:p_fsync Unexecuted instantiation: tsort.c:p_fsync Unexecuted instantiation: utf8.c:p_fsync Unexecuted instantiation: varint.c:p_fsync Unexecuted instantiation: crlf.c:p_fsync Unexecuted instantiation: diff_file.c:p_fsync Unexecuted instantiation: diff_stats.c:p_fsync Unexecuted instantiation: diff_xdiff.c:p_fsync Unexecuted instantiation: fetch.c:p_fsync Unexecuted instantiation: fetchhead.c:p_fsync Unexecuted instantiation: graph.c:p_fsync Unexecuted instantiation: ignore.c:p_fsync Unexecuted instantiation: proxy.c:p_fsync |
52 | | |
53 | 0 | #define p_recv(s,b,l,f) recv(s,b,l,f) |
54 | 0 | #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 | 1.76k | #define p_vsnprintf(b, c, f, a) vsnprintf(b, c, f, a) |
58 | 0 | #define p_snprintf snprintf |
59 | | #define p_chdir(p) chdir(p) |
60 | 0 | #define p_rmdir(p) rmdir(p) |
61 | 0 | #define p_access(p,m) access(p,m) |
62 | | #define p_ftruncate(fd, sz) ftruncate(fd, sz) |
63 | | |
64 | | /* |
65 | | * Pre-Android 5 did not implement a virtual filesystem atop FAT |
66 | | * partitions for Unix permissions, which causes chmod to fail. However, |
67 | | * Unix permissions have no effect on Android anyway as file permissions |
68 | | * are not actually managed this way, so treating it as a no-op across |
69 | | * all Android is safe. |
70 | | */ |
71 | | #ifdef __ANDROID__ |
72 | | # define p_chmod(p,m) 0 |
73 | | #else |
74 | 0 | # define p_chmod(p,m) chmod(p, m) |
75 | | #endif |
76 | | |
77 | | /* see win32/posix.h for explanation about why this exists */ |
78 | 0 | #define p_lstat_posixly(p,b) lstat(p,b) |
79 | | |
80 | 0 | #define p_localtime_r(c, r) localtime_r(c, r) |
81 | 0 | #define p_gmtime_r(c, r) gmtime_r(c, r) |
82 | | |
83 | | #define p_timeval timeval |
84 | | |
85 | | #ifdef GIT_FUTIMENS |
86 | | GIT_INLINE(int) p_futimes(int f, const struct p_timeval t[2]) |
87 | 0 | { |
88 | 0 | struct timespec s[2]; |
89 | 0 | s[0].tv_sec = t[0].tv_sec; |
90 | 0 | s[0].tv_nsec = t[0].tv_usec * 1000; |
91 | 0 | s[1].tv_sec = t[1].tv_sec; |
92 | 0 | s[1].tv_nsec = t[1].tv_usec * 1000; |
93 | 0 | return futimens(f, s); |
94 | 0 | } Unexecuted instantiation: midx_fuzzer.c:p_futimes Unexecuted instantiation: fuzzer_utils.c:p_futimes Unexecuted instantiation: errors.c:p_futimes Unexecuted instantiation: hash.c:p_futimes Unexecuted instantiation: runtime.c:p_futimes Unexecuted instantiation: str.c:p_futimes Unexecuted instantiation: thread.c:p_futimes Unexecuted instantiation: util.c:p_futimes Unexecuted instantiation: collisiondetect.c:p_futimes Unexecuted instantiation: sha1.c:p_futimes Unexecuted instantiation: ubc_check.c:p_futimes Unexecuted instantiation: builtin.c:p_futimes Unexecuted instantiation: libgit2.c:p_futimes Unexecuted instantiation: merge_driver.c:p_futimes Unexecuted instantiation: merge_file.c:p_futimes Unexecuted instantiation: midx.c:p_futimes Unexecuted instantiation: mwindow.c:p_futimes Unexecuted instantiation: odb.c:p_futimes Unexecuted instantiation: odb_loose.c:p_futimes Unexecuted instantiation: odb_pack.c:p_futimes Unexecuted instantiation: oid.c:p_futimes Unexecuted instantiation: pack.c:p_futimes Unexecuted instantiation: repository.c:p_futimes Unexecuted instantiation: revparse.c:p_futimes Unexecuted instantiation: revwalk.c:p_futimes Unexecuted instantiation: settings.c:p_futimes Unexecuted instantiation: strarray.c:p_futimes Unexecuted instantiation: mbedtls.c:p_futimes Unexecuted instantiation: openssl.c:p_futimes Unexecuted instantiation: registry.c:p_futimes Unexecuted instantiation: socket.c:p_futimes Unexecuted instantiation: submodule.c:p_futimes Unexecuted instantiation: sysdir.c:p_futimes Unexecuted instantiation: tag.c:p_futimes Unexecuted instantiation: http.c:p_futimes Unexecuted instantiation: httpclient.c:p_futimes Unexecuted instantiation: httpparser.c:p_futimes Unexecuted instantiation: smart_protocol.c:p_futimes Unexecuted instantiation: ssh_libssh2.c:p_futimes Unexecuted instantiation: tree.c:p_futimes Unexecuted instantiation: worktree.c:p_futimes Unexecuted instantiation: alloc.c:p_futimes Unexecuted instantiation: failalloc.c:p_futimes Unexecuted instantiation: stdalloc.c:p_futimes Unexecuted instantiation: date.c:p_futimes Unexecuted instantiation: filebuf.c:p_futimes Unexecuted instantiation: fs_path.c:p_futimes Unexecuted instantiation: futils.c:p_futimes Unexecuted instantiation: net.c:p_futimes Unexecuted instantiation: pool.c:p_futimes Unexecuted instantiation: posix.c:p_futimes Unexecuted instantiation: pqueue.c:p_futimes Unexecuted instantiation: rand.c:p_futimes Unexecuted instantiation: regexp.c:p_futimes Unexecuted instantiation: vector.c:p_futimes Unexecuted instantiation: wildmatch.c:p_futimes Unexecuted instantiation: zstream.c:p_futimes Unexecuted instantiation: map.c:p_futimes Unexecuted instantiation: realpath.c:p_futimes Unexecuted instantiation: annotated_commit.c:p_futimes Unexecuted instantiation: attr.c:p_futimes Unexecuted instantiation: attr_file.c:p_futimes Unexecuted instantiation: attrcache.c:p_futimes Unexecuted instantiation: blob.c:p_futimes Unexecuted instantiation: branch.c:p_futimes Unexecuted instantiation: buf.c:p_futimes Unexecuted instantiation: cache.c:p_futimes Unexecuted instantiation: checkout.c:p_futimes Unexecuted instantiation: clone.c:p_futimes Unexecuted instantiation: commit.c:p_futimes Unexecuted instantiation: commit_graph.c:p_futimes Unexecuted instantiation: commit_list.c:p_futimes Unexecuted instantiation: config.c:p_futimes Unexecuted instantiation: config_cache.c:p_futimes Unexecuted instantiation: config_file.c:p_futimes Unexecuted instantiation: config_list.c:p_futimes Unexecuted instantiation: config_parse.c:p_futimes Unexecuted instantiation: config_snapshot.c:p_futimes Unexecuted instantiation: delta.c:p_futimes Unexecuted instantiation: diff.c:p_futimes Unexecuted instantiation: diff_driver.c:p_futimes Unexecuted instantiation: diff_generate.c:p_futimes Unexecuted instantiation: diff_print.c:p_futimes Unexecuted instantiation: diff_tform.c:p_futimes Unexecuted instantiation: email.c:p_futimes Unexecuted instantiation: filter.c:p_futimes Unexecuted instantiation: grafts.c:p_futimes Unexecuted instantiation: hashsig.c:p_futimes Unexecuted instantiation: ident.c:p_futimes Unexecuted instantiation: index.c:p_futimes Unexecuted instantiation: index_map.c:p_futimes Unexecuted instantiation: indexer.c:p_futimes Unexecuted instantiation: iterator.c:p_futimes Unexecuted instantiation: mailmap.c:p_futimes Unexecuted instantiation: merge.c:p_futimes Unexecuted instantiation: object.c:p_futimes Unexecuted instantiation: object_api.c:p_futimes Unexecuted instantiation: oidarray.c:p_futimes Unexecuted instantiation: pack-objects.c:p_futimes Unexecuted instantiation: parse.c:p_futimes Unexecuted instantiation: patch.c:p_futimes Unexecuted instantiation: patch_generate.c:p_futimes Unexecuted instantiation: path.c:p_futimes Unexecuted instantiation: pathspec.c:p_futimes Unexecuted instantiation: push.c:p_futimes Unexecuted instantiation: refdb.c:p_futimes Unexecuted instantiation: refdb_fs.c:p_futimes Unexecuted instantiation: reflog.c:p_futimes Unexecuted instantiation: refs.c:p_futimes Unexecuted instantiation: refspec.c:p_futimes Unexecuted instantiation: remote.c:p_futimes Unexecuted instantiation: signature.c:p_futimes Unexecuted instantiation: tls.c:p_futimes Unexecuted instantiation: trace.c:p_futimes Unexecuted instantiation: transaction.c:p_futimes Unexecuted instantiation: transport.c:p_futimes Unexecuted instantiation: auth.c:p_futimes Unexecuted instantiation: credential.c:p_futimes Unexecuted instantiation: git.c:p_futimes Unexecuted instantiation: local.c:p_futimes Unexecuted instantiation: smart.c:p_futimes Unexecuted instantiation: smart_pkt.c:p_futimes Unexecuted instantiation: tree-cache.c:p_futimes Unexecuted instantiation: sortedcache.c:p_futimes Unexecuted instantiation: tsort.c:p_futimes Unexecuted instantiation: utf8.c:p_futimes Unexecuted instantiation: varint.c:p_futimes Unexecuted instantiation: crlf.c:p_futimes Unexecuted instantiation: diff_file.c:p_futimes Unexecuted instantiation: diff_stats.c:p_futimes Unexecuted instantiation: diff_xdiff.c:p_futimes Unexecuted instantiation: fetch.c:p_futimes Unexecuted instantiation: fetchhead.c:p_futimes Unexecuted instantiation: graph.c:p_futimes Unexecuted instantiation: ignore.c:p_futimes Unexecuted instantiation: proxy.c:p_futimes |
95 | | #else |
96 | | # define p_futimes futimes |
97 | | #endif |
98 | | |
99 | 0 | #define p_pread(f, d, s, o) pread(f, d, s, o) |
100 | | #define p_pwrite(f, d, s, o) pwrite(f, d, s, o) |
101 | | |
102 | | #endif |