183 if (result >= 0) { 184 *pbytes = n; 185 return 1; 186 } 187 } else if (S_ISREG(mode)) { 188 size = buf64.st_size; 189 } 190 } 191 192 if ((current = lseek64(fd, 0, SEEK_CUR)) == -1) { 193 return 0; 194 } 195 196 if (size < current) { 197 if ((size = lseek64(fd, 0, SEEK_END)) == -1) 198 return 0; 199 else if (lseek64(fd, current, SEEK_SET) == -1) 200 return 0; 201 } 202 203 if (size >= current) { 204 *pbytes = size - current; 205 return 1; 206 } else { 207 return 0; 208 } 209 } 210 211 jint 212 handleSetLength(FD fd, jlong length) 213 { 214 int result; 215 RESTARTABLE(ftruncate64(fd, length), result); 216 return result; 217 } 218 219 size_t 220 getLastErrorString(char *buf, size_t len) 221 { 222 if (errno == 0 || len < 1) return 0; 223 224 const char *err = strerror(errno); 225 size_t n = strlen(err); 226 if (n >= len) 227 n = len - 1; 228 | 183 if (result >= 0) { 184 *pbytes = n; 185 return 1; 186 } 187 } else if (S_ISREG(mode)) { 188 size = buf64.st_size; 189 } 190 } 191 192 if ((current = lseek64(fd, 0, SEEK_CUR)) == -1) { 193 return 0; 194 } 195 196 if (size < current) { 197 if ((size = lseek64(fd, 0, SEEK_END)) == -1) 198 return 0; 199 else if (lseek64(fd, current, SEEK_SET) == -1) 200 return 0; 201 } 202 203 *pbytes = size - current; 204 return 1; 205 } 206 207 jint 208 handleSetLength(FD fd, jlong length) 209 { 210 int result; 211 RESTARTABLE(ftruncate64(fd, length), result); 212 return result; 213 } 214 215 size_t 216 getLastErrorString(char *buf, size_t len) 217 { 218 if (errno == 0 || len < 1) return 0; 219 220 const char *err = strerror(errno); 221 size_t n = strlen(err); 222 if (n >= len) 223 n = len - 1; 224 |