23#ifdef HAVE_SYS_TYPES_H
54 return (off_t) _lseeki64(fd, 0, SEEK_CUR);
56 return (off_t) lseek(fd, 0, SEEK_CUR);
67 return _lseeki64(fd, 0, SEEK_END) < 0 ? -1 : 0;
69 off_t rc = lseek(fd, 0, SEEK_END) < 0 ? -1 : 0;
73 if (rc < 0 && errno == ESPIPE)
76 return (rc < 0) ? -1 : 0;
86 return _lseeki64(fd, pos, SEEK_SET) < 0 ? -1 : 0;
88 return lseek(fd, pos, SEEK_SET) < 0 ? -1 : 0;
103 return _chsize(fd, 0);
105 return ftruncate(fd, 0);
114 raw_assert(count < SSIZE_MAX);
116 while (written < count) {
117 ssize_t result = write(fd, buf+written, count-written);
125#if defined(HAVE_PIPE2) && defined(O_CLOEXEC)
127tor_pipe_cloexec(
int pipefd[2])
129 return pipe2(pipefd, O_CLOEXEC);
131#elif defined(HAVE_PIPE) && defined(FD_CLOEXEC)
133tor_pipe_cloexec(
int pipefd[2])
138 if (fcntl(pipefd[0], F_SETFD, FD_CLOEXEC)) {
141 if (fcntl(pipefd[1], F_SETFD, FD_CLOEXEC)) {
int tor_fd_seekend(int fd)
off_t tor_fd_getpos(int fd)
int write_all_to_fd_minimal(int fd, const char *buf, size_t count)
int tor_ftruncate(int fd)
int tor_fd_setpos(int fd, off_t pos)
Integer definitions used throughout Tor.