this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

More fcntl() commands supported

+95
+78
src/libSystem/kernel-bsd/fcntl.cpp
··· 66 66 ((char*) arg)[rv] = 0; 67 67 return 0; 68 68 } 69 + case DARWIN_F_PREALLOCATE: 70 + { 71 + __darwin_fallocate* fa = static_cast<__darwin_fallocate*>(arg); 72 + fa->allocated = 0; 73 + 74 + // We disregard fa->flags, it's not supported on Linux 75 + 76 + if (fa->mode == DARWIN_F_PEOFPOSMODE) // like SEEK_END 77 + { 78 + struct stat st; 79 + if (fstat(fd, &st) == -1) 80 + { 81 + errnoOut(); 82 + return -1; 83 + } 84 + fa->offset += st.st_size; 85 + } 86 + else if (fa->mode == DARWIN_F_VOLPOSMODE) // like SEEK_CUR 87 + { 88 + fa->offset += lseek(fd, 0, SEEK_CUR); 89 + } 90 + else 91 + { 92 + errno = DARWIN_EINVAL; 93 + return -1; 94 + } 95 + 96 + int err = posix_fallocate(fd, fa->offset, fa->length); 97 + if (err) // doesn't use errno! 98 + { 99 + errno = errnoLinuxToDarwin(err); 100 + return -1; 101 + } 102 + else 103 + { 104 + fa->allocated = fa->length; 105 + return 0; 106 + } 107 + } 108 + case DARWIN_F_SETSIZE: 109 + { 110 + uint64_t size = uint64_t(arg); 111 + 112 + // Not identical to what F_SETSIZE is supposed to do 113 + // but it's the best we can do. 114 + if (ftruncate(fd, size) == -1) 115 + { 116 + errnoOut(); 117 + return -1; 118 + } 119 + return 0; 120 + } 121 + case DARWIN_F_RDADVISE: 122 + { 123 + const __darwin_rdadvise* adv = static_cast<__darwin_rdadvise*>(arg); 124 + int err = posix_fadvise(fd, adv->offset, adv->count, POSIX_FADV_WILLNEED); 125 + 126 + if (err) // doesn't use errno! 127 + { 128 + errno = errnoLinuxToDarwin(err); 129 + return -1; 130 + } 131 + else 132 + return 0; 133 + } 134 + case DARWIN_F_RDAHEAD: 135 + { 136 + int advice = (arg) ? POSIX_FADV_NORMAL : POSIX_FADV_RANDOM; 137 + int err = posix_fadvise(fd, 0, 1, advice); // on Linux, the offset and length doesn't matter for these advices 138 + 139 + if (err) // doesn't use errno! 140 + { 141 + errno = errnoLinuxToDarwin(err); 142 + return -1; 143 + } 144 + else 145 + return 0; 146 + } 69 147 // TODO: other values 70 148 71 149 default:
+17
src/libSystem/kernel-bsd/fcntl.h
··· 28 28 #define DARWIN_F_UNLCK 2 29 29 #define DARWIN_F_WRLCK 3 30 30 31 + #define DARWIN_F_PEOFPOSMODE 3 32 + #define DARWIN_F_VOLPOSMODE 4 33 + 31 34 struct __darwin_flock 32 35 { 33 36 int64_t l_start; ··· 35 38 pid_t l_pid; 36 39 short l_type; 37 40 short l_whence; 41 + }; 42 + 43 + struct __darwin_fallocate 44 + { 45 + uint32_t flags; 46 + int mode; 47 + uint64_t offset, length; 48 + uint64_t allocated; 49 + }; 50 + 51 + struct __darwin_rdadvise 52 + { 53 + uint64_t offset; 54 + int count; 38 55 }; 39 56 40 57 #ifdef __cplusplus