/bionic/tests/ |
D | eventfd_test.cpp | 28 int fd = eventfd(kInitialValue, EFD_NONBLOCK); in TEST() local 29 ASSERT_NE(-1, fd); in TEST() 32 ASSERT_EQ(0, eventfd_read(fd, &value)); in TEST() 36 ASSERT_EQ(-1, eventfd_read(fd, &value)); in TEST() 40 ASSERT_EQ(0, eventfd_write(fd, 1)); in TEST() 41 ASSERT_EQ(0, eventfd_write(fd, 1)); in TEST() 42 ASSERT_EQ(0, eventfd_write(fd, 1)); in TEST() 44 ASSERT_EQ(0, eventfd_read(fd, &value)); in TEST() 47 close(fd); in TEST() 52 int fd = eventfd(kInitialValue, EFD_CLOEXEC); in TEST() local [all …]
|
D | fdsan_test.cpp | 62 int fd = open("/dev/null", O_RDONLY); in TEST_F() local 63 ASSERT_EQ(0, close(fd)); in TEST_F() 69 int fd = open("/dev/null", O_RDONLY); in TEST_F() local 70 ASSERT_EQ(0, android_fdsan_close_with_tag(fd, 0)); in TEST_F() 76 int fd = open("/dev/null", O_RDONLY); in TEST_F() local 77 EXPECT_FDSAN_DEATH(android_fdsan_close_with_tag(fd, 0xdeadbeef), "actually unowned"); in TEST_F() 83 int fd = open("/dev/null", O_RDONLY); in TEST_F() local 84 EXPECT_FDSAN_DEATH(android_fdsan_exchange_owner_tag(fd, 0xbadc0de, 0xdeadbeef), in TEST_F() 91 int fd = open("/dev/null", O_RDONLY); in TEST_F() local 92 android_fdsan_exchange_owner_tag(fd, 0, 0xdeadbeef); in TEST_F() [all …]
|
D | fcntl_test.cpp | 42 int fd = open("/proc/version", O_RDONLY); in TEST() local 43 ASSERT_TRUE(fd != -1); in TEST() 45 int flags = fcntl(fd, F_GETFD); in TEST() 49 int rc = fcntl(fd, F_SETFD, FD_CLOEXEC); in TEST() 52 flags = fcntl(fd, F_GETFD); in TEST() 56 close(fd); in TEST() 60 int fd; in TEST() local 62 fd = open("/proc/version", O_RDONLY); in TEST() 63 ASSERT_TRUE(fd != -1); in TEST() 64 close(fd); in TEST() [all …]
|
D | sys_xattr_test.cpp | 40 ASSERT_EQ(0, fsetxattr(tf.fd, "user.foo", "bar", 4, 0)); in TEST() 41 ASSERT_EQ(4, fgetxattr(tf.fd, "user.foo", buf, sizeof(buf))); in TEST() 48 ASSERT_EQ(0, fsetxattr(tf.fd, "user.foo", "", 0, 0)); in TEST() 49 ASSERT_EQ(0, fgetxattr(tf.fd, "user.foo", buf, sizeof(buf))); in TEST() 55 ASSERT_EQ(0, fsetxattr(tf.fd, "user.foo", "01234567890123456789", 21, 0)); in TEST() 56 ASSERT_EQ(-1, fgetxattr(tf.fd, "user.foo", buf, sizeof(buf))); in TEST() 72 int fd = open(tf.path, O_PATH); in TEST() local 73 ASSERT_NE(-1, fd); in TEST() 75 int res = fsetxattr(fd, "user.foo", "bar", 4, 0); in TEST() 79 ASSERT_EQ(4, fgetxattr(fd, "user.foo", buf, sizeof(buf))); in TEST() [all …]
|
D | sys_mman_test.cpp | 45 void* map = mmap(nullptr, 100, PROT_READ, MAP_SHARED, tf.fd, 1); in TEST() 52 void* map = mmap64(nullptr, 100, PROT_READ, MAP_SHARED, tf.fd, 1); in TEST() 64 ASSERT_EQ(STR_SSIZE(STRING_MSG), write(tf.fd, STRING_MSG, sizeof(STRING_MSG))); in TEST() 66 void* map = mmap(nullptr, sizeof(STRING_MSG), PROT_READ, MAP_SHARED, tf.fd, 0); in TEST() 78 ASSERT_EQ(STR_SSIZE(INITIAL_MSG), write(tf.fd, INITIAL_MSG, sizeof(INITIAL_MSG))); in TEST() 79 lseek(tf.fd, 0, SEEK_SET); in TEST() 81 void* map = mmap(nullptr, sizeof(STRING_MSG), PROT_WRITE, MAP_SHARED, tf.fd, 0); in TEST() 83 close(tf.fd); in TEST() 89 tf.fd = open(tf.path, O_RDWR); in TEST() 92 ASSERT_EQ(STR_SSIZE(STRING_MSG), read(tf.fd, buf, sizeof(STRING_MSG))); in TEST() [all …]
|
D | sys_sendfile_test.cpp | 29 ASSERT_EQ(5, TEMP_FAILURE_RETRY(write(src_file.fd, "hello", 5))); in TEST() 35 ssize_t rc = sendfile(dst_file.fd, src_file.fd, &offset, count); in TEST() 39 ASSERT_EQ(0, lseek(dst_file.fd, 0, SEEK_SET)); in TEST() 42 ASSERT_EQ(2, TEMP_FAILURE_RETRY(read(dst_file.fd, &buf, 2))); in TEST() 48 ASSERT_EQ(5, TEMP_FAILURE_RETRY(write(src_file.fd, "hello", 5))); in TEST() 54 ssize_t rc = sendfile64(dst_file.fd, src_file.fd, &offset, count); in TEST() 58 ASSERT_EQ(0, lseek(dst_file.fd, 0, SEEK_SET)); in TEST() 61 ASSERT_EQ(2, TEMP_FAILURE_RETRY(read(dst_file.fd, &buf, 2))); in TEST()
|
D | sys_socket_test.cpp | 39 int fd = socket(PF_UNIX, SOCK_SEQPACKET | SOCK_CLOEXEC | SOCK_NONBLOCK, 0); in ConnectFn() local 40 if (fd < 0) { in ConnectFn() 51 if (connect(fd, reinterpret_cast<struct sockaddr*>(&addr), sizeof(addr)) < 0) { in ConnectFn() 55 else if (callback_fn != nullptr && !callback_fn(fd)) { in ConnectFn() 59 close(fd); in ConnectFn() 65 bool (*callback_fn)(int fd), const char* sock_path) { in RunTest() argument 66 int fd = socket(PF_UNIX, SOCK_SEQPACKET, 0); in RunTest() local 67 ASSERT_NE(fd, -1) << strerror(errno); in RunTest() 75 …ASSERT_NE(-1, bind(fd, reinterpret_cast<struct sockaddr*>(&addr), sizeof(addr))) << strerror(errno… in RunTest() 77 ASSERT_NE(-1, listen(fd, 1)) << strerror(errno); in RunTest() [all …]
|
D | sys_uio_test.cpp | 36 ASSERT_EQ(10, writev(tf.fd, ios, 2)); in TEST() 38 ASSERT_EQ(0, lseek(tf.fd, 0, SEEK_SET)); in TEST() 43 ASSERT_EQ(10, readv(tf.fd, ios, 2)); in TEST() 56 ASSERT_EQ(5, write_fn(tf.fd, ios, 1, 5)); in TestPreadVPwriteV() 57 ASSERT_EQ(0, lseek(tf.fd, 0, SEEK_CUR)); in TestPreadVPwriteV() 60 ASSERT_EQ(5, write_fn(tf.fd, ios, 1, 0)); in TestPreadVPwriteV() 61 ASSERT_EQ(0, lseek(tf.fd, 0, SEEK_CUR)); in TestPreadVPwriteV() 63 ASSERT_EQ(5, read_fn(tf.fd, ios, 1, 5)); in TestPreadVPwriteV() 65 ASSERT_EQ(5, read_fn(tf.fd, ios, 1, 0)); in TestPreadVPwriteV() 84 ASSERT_EQ(5, write_fn(tf.fd, ios, 1, 5, 0)) << strerror(errno); in TestPreadV2PwriteV2() [all …]
|
D | unistd_test.cpp | 178 ASSERT_EQ(0, close(tf.fd)); in TEST() 188 ASSERT_EQ(0, close(tf.fd)); in TEST() 198 ASSERT_EQ(0, ftruncate(tf.fd, 123)); in TEST() 199 ASSERT_EQ(0, close(tf.fd)); in TEST() 208 ASSERT_EQ(0, ftruncate64(tf.fd, 123)); in TEST() 209 ASSERT_EQ(0, close(tf.fd)); in TEST() 219 ASSERT_EQ(-1, ftruncate(tf.fd, -123)); in TEST() 238 int fd = open("/proc/version", O_RDONLY); in TEST() local 239 ASSERT_TRUE(fd != -1); in TEST() 242 ASSERT_EQ(5, read(fd, buf, 5)); in TEST() [all …]
|
D | fdtrack_test.cpp | 53 fprintf(stderr, " event %zu: fd %d created by %s\n", index, event.fd, in DumpEvent() 56 fprintf(stderr, " event %zu: fd %d closed\n", index, event.fd); in DumpEvent() 97 if (event.fd == events[j].fd) { in FdtrackRun() 129 static int fd = open("/dev/null", O_WRONLY | O_CLOEXEC); in TEST() local 130 ASSERT_NE(-1, fd); in TEST() 132 auto events = FdtrackRun([]() { close(fd); }); in TEST() 134 ASSERT_EQ(fd, events[0].fd); in TEST() 143 static int fd = open("/dev/null", O_WRONLY | O_CLOEXEC); in TEST() local 144 ASSERT_NE(-1, fd); in TEST() 146 auto events = FdtrackRun([]() { close(fd); }, false); in TEST() [all …]
|
/bionic/libc/bionic/ |
D | preadv_pwritev.cpp | 45 ssize_t preadv(int fd, const struct iovec* ios, int count, off_t offset) { in preadv() argument 46 return preadv64(fd, ios, count, offset); in preadv() 49 ssize_t preadv64(int fd, const struct iovec* ios, int count, off64_t offset) { in preadv64() argument 51 return __preadv64(fd, ios, count, offset, 0); in preadv64() 53 return __preadv64(fd, ios, count, offset, offset >> 32); in preadv64() 57 ssize_t pwritev(int fd, const struct iovec* ios, int count, off_t offset) { in pwritev() argument 58 return pwritev64(fd, ios, count, offset); in pwritev() 61 ssize_t pwritev64(int fd, const struct iovec* ios, int count, off64_t offset) { in pwritev64() argument 63 return __pwritev64(fd, ios, count, offset, 0); in pwritev64() 65 return __pwritev64(fd, ios, count, offset, offset >> 32); in pwritev64() [all …]
|
D | pty.cpp | 54 char* ptsname(int fd) { in ptsname() argument 57 int error = ptsname_r(fd, buf, sizeof(tls.ptsname_buf)); in ptsname() 61 int ptsname_r(int fd, char* buf, size_t len) { in ptsname_r() argument 68 if (ioctl(fd, TIOCGPTN, &pty_num) != 0) { in ptsname_r() 81 char* ttyname(int fd) { in ttyname() argument 84 int error = ttyname_r(fd, buf, sizeof(tls.ttyname_buf)); in ttyname() 88 int ttyname_r(int fd, char* buf, size_t len) { in ttyname_r() argument 94 if (!isatty(fd)) { in ttyname_r() 98 ssize_t count = readlink(FdPath(fd).c_str(), buf, len); in ttyname_r() 110 int unlockpt(int fd) { in unlockpt() argument [all …]
|
D | tmpfile.cpp | 45 static FILE* __fd_to_fp(int fd) { in __fd_to_fp() argument 46 FILE* fp = fdopen(fd, "w+"); in __fd_to_fp() 50 close(fd); in __fd_to_fp() 63 int fd = mkstemp(path); in __tmpfile_dir_legacy() local 64 if (fd == -1) { in __tmpfile_dir_legacy() 76 if (fstat(fd, &sb) == -1) { in __tmpfile_dir_legacy() 78 close(fd); in __tmpfile_dir_legacy() 82 return __fd_to_fp(fd); in __tmpfile_dir_legacy() 94 int fd = open(tmpdir, O_TMPFILE | O_RDWR, S_IRUSR | S_IWUSR); in tmpfile() local 95 if (fd == -1) return __tmpfile_dir_legacy(tmpdir); in tmpfile() [all …]
|
D | fdsan.cpp | 52 extern "C" int __close(int fd); 125 static FdEntry* GetFdEntry(int fd) { in GetFdEntry() argument 126 if (fd < 0) { in GetFdEntry() 130 return GetFdTable().at(fd); in GetFdEntry() 245 int android_fdsan_close_with_tag(int fd, uint64_t expected_tag) { in android_fdsan_close_with_tag() argument 247 return __close(fd); in android_fdsan_close_with_tag() 250 FDTRACK_CLOSE(fd); in android_fdsan_close_with_tag() 251 FdEntry* fde = GetFdEntry(fd); in android_fdsan_close_with_tag() 253 return __close(fd); in android_fdsan_close_with_tag() 266 fd, expected_type, expected_owner, actual_type, actual_owner); in android_fdsan_close_with_tag() [all …]
|
D | sys_epoll.cpp | 52 int epoll_pwait(int fd, epoll_event* events, int max_events, int timeout, const sigset_t* ss) { in epoll_pwait() argument 54 return epoll_pwait64(fd, events, max_events, timeout, set.ptr); in epoll_pwait() 57 int epoll_pwait64(int fd, epoll_event* events, int max_events, int timeout, const sigset64_t* ss) { in epoll_pwait64() argument 58 return __epoll_pwait(fd, events, max_events, timeout, ss, sizeof(*ss)); in epoll_pwait64() 61 int epoll_pwait2(int fd, epoll_event* events, int max_events, const timespec* timeout, in epoll_pwait2() argument 64 return epoll_pwait2_64(fd, events, max_events, timeout, set.ptr); in epoll_pwait2() 67 int epoll_pwait2_64(int fd, epoll_event* events, int max_events, const timespec* timeout, in epoll_pwait2_64() argument 83 return __epoll_pwait2(fd, events, max_events, kts_ptr, ss, sizeof(*ss)); in epoll_pwait2_64() 86 int epoll_wait(int fd, struct epoll_event* events, int max_events, int timeout) { in epoll_wait() argument 87 return epoll_pwait64(fd, events, max_events, timeout, nullptr); in epoll_wait()
|
D | NetdClientDispatch.cpp | 57 int accept4(int fd, sockaddr* addr, socklen_t* addr_length, int flags) { in accept4() argument 58 return FDTRACK_CREATE(__netdClientDispatch.accept4(fd, addr, addr_length, flags)); in accept4() 61 int connect(int fd, const sockaddr* addr, socklen_t addr_length) { in connect() argument 62 return __netdClientDispatch.connect(fd, addr, addr_length); in connect() 65 int sendmmsg(int fd, const struct mmsghdr* msgs, unsigned int msg_count, int flags) { in sendmmsg() argument 66 return __netdClientDispatch.sendmmsg(fd, msgs, msg_count, flags); in sendmmsg() 69 ssize_t sendmsg(int fd, const struct msghdr* msg, int flags) { in sendmsg() argument 70 return __netdClientDispatch.sendmsg(fd, msg, flags); in sendmsg() 73 ssize_t sendto(int fd, const void* buf, size_t n, int flags, in sendto() argument 75 return __netdClientDispatch.sendto(fd, buf, n, flags, dst_addr, dst_addr_length); in sendto()
|
D | execinfo.cpp | 113 ScopedFd fd(memfd_create("backtrace_symbols_fd", MFD_CLOEXEC)); in backtrace_symbols() local 114 if (fd.get() == -1) { in backtrace_symbols() 117 backtrace_symbols_fd(buffer, size, fd.get()); in backtrace_symbols() 120 off_t file_size = lseek(fd.get(), 0, SEEK_END); in backtrace_symbols() 143 lseek(fd.get(), 0, SEEK_SET); in backtrace_symbols() 144 ssize_t num_read = read(fd.get(), cur_string, file_size); in backtrace_symbols() 145 fd.reset(-1); in backtrace_symbols() 170 void backtrace_symbols_fd(void* const* buffer, int size, int fd) { in backtrace_symbols_fd() argument 171 if (size <= 0 || fd < 0) { in backtrace_symbols_fd() 180 write(fd, info.dli_fname, strlen(info.dli_fname)); in backtrace_symbols_fd() [all …]
|
D | spawn.cpp | 79 int fd; member 87 fd = open(path, flags, mode); in Do() 88 if (fd == -1) _exit(127); in Do() 90 if (fd != new_fd) { in Do() 91 if (dup2(fd, new_fd) == -1) _exit(127); in Do() 92 close(fd); in Do() 96 close(fd); in Do() 100 if (fchdir(fd) == -1) _exit(127); in Do() 103 if (fd == new_fd) { in Do() 108 int flags = fcntl(fd, F_GETFD, 0); in Do() [all …]
|
D | lockf.cpp | 35 int lockf64(int fd, int cmd, off64_t length) { in lockf64() argument 46 return fcntl(fd, F_SETLK64, &fl); in lockf64() 51 return fcntl(fd, F_SETLKW64, &fl); in lockf64() 56 return fcntl(fd, F_SETLK64, &fl); in lockf64() 61 if (fcntl(fd, F_GETLK64, &fl) == -1) return -1; in lockf64() 71 int lockf(int fd, int cmd, off_t length) { in lockf() argument 72 return lockf64(fd, cmd, length); in lockf()
|
D | pthread_setname_np.cpp | 65 int fd = __open_task_comm_fd(t, O_RDONLY, "pthread_getname_np"); in pthread_getname_np() local 66 if (fd == -1) return errno; in pthread_getname_np() 68 ssize_t n = TEMP_FAILURE_RETRY(read(fd, buf, buf_size)); in pthread_getname_np() 69 close(fd); in pthread_getname_np() 98 int fd = __open_task_comm_fd(t, O_WRONLY, "pthread_setname_np"); in pthread_setname_np() local 99 if (fd == -1) return errno; in pthread_setname_np() 101 ssize_t n = TEMP_FAILURE_RETRY(write(fd, thread_name, thread_name_len)); in pthread_setname_np() 102 close(fd); in pthread_setname_np()
|
D | posix_fadvise.cpp | 37 int posix_fadvise(int fd, off_t offset, off_t length, int advice) { in posix_fadvise() argument 38 return posix_fadvise64(fd, offset, length, advice); in posix_fadvise() 42 int posix_fadvise64(int fd, off64_t offset, off64_t length, int advice) { in posix_fadvise64() argument 44 return (__arm_fadvise64_64(fd, advice, offset, length) == 0) ? 0 : errno; in posix_fadvise64() 47 int posix_fadvise64(int fd, off64_t offset, off64_t length, int advice) { in posix_fadvise64() argument 49 return (__fadvise64(fd, offset, length, advice) == 0) ? 0 : errno; in posix_fadvise64()
|
/bionic/libc/tzcode/ |
D | bionic.cpp | 134 int fd = TEMP_FAILURE_RETRY(open(path, O_RDONLY | O_CLOEXEC)); in __bionic_open_tzdata_path() local 135 if (fd == -1) { in __bionic_open_tzdata_path() 142 ssize_t bytes_read = TEMP_FAILURE_RETRY(read(fd, &header, sizeof(header))); in __bionic_open_tzdata_path() 146 close(fd); in __bionic_open_tzdata_path() 152 close(fd); in __bionic_open_tzdata_path() 156 if (TEMP_FAILURE_RETRY(lseek(fd, ntohl(header.index_offset), SEEK_SET)) == -1) { in __bionic_open_tzdata_path() 158 close(fd); in __bionic_open_tzdata_path() 165 close(fd); in __bionic_open_tzdata_path() 171 close(fd); in __bionic_open_tzdata_path() 178 close(fd); in __bionic_open_tzdata_path() [all …]
|
/bionic/libc/include/sys/ |
D | select.h | 61 #define __FDELT(fd) ((fd) / NFDBITS) argument 62 #define __FDMASK(fd) (1UL << ((fd) % NFDBITS)) argument 78 #define __FD_CLR(fd, set) (__FDS_BITS(fd_set*,set)[__FDELT(fd)] &= ~__FDMASK(fd)) argument 79 #define __FD_SET(fd, set) (__FDS_BITS(fd_set*,set)[__FDELT(fd)] |= __FDMASK(fd)) argument 80 #define __FD_ISSET(fd, set) ((__FDS_BITS(const fd_set*,set)[__FDELT(fd)] & __FDMASK(fd)) != 0) argument 83 #define FD_CLR(fd, set) __FD_CLR_chk(fd, set, __bos(set)) argument 85 #define FD_SET(fd, set) __FD_SET_chk(fd, set, __bos(set)) argument 87 #define FD_ISSET(fd, set) __FD_ISSET_chk(fd, set, __bos(set)) argument
|
/bionic/libc/upstream-openbsd/lib/libc/gen/ |
D | daemon.c | 39 int fd; in daemon() local 56 if (!noclose && (fd = open(_PATH_DEVNULL, O_RDWR)) != -1) { in daemon() 57 (void)dup2(fd, STDIN_FILENO); in daemon() 58 (void)dup2(fd, STDOUT_FILENO); in daemon() 59 (void)dup2(fd, STDERR_FILENO); in daemon() 60 if (fd > 2) in daemon() 61 (void)close(fd); in daemon()
|
/bionic/libc/include/bits/ |
D | termios_inlines.h | 88 __BIONIC_TERMIOS_INLINE int tcdrain(int fd) { in tcdrain() argument 91 return ioctl(fd, TCSBRK, __BIONIC_CAST(static_cast, unsigned long, 1)); in tcdrain() 94 __BIONIC_TERMIOS_INLINE int tcflow(int fd, int action) { in tcflow() argument 95 return ioctl(fd, TCXONC, __BIONIC_CAST(static_cast, unsigned long, action)); in tcflow() 98 __BIONIC_TERMIOS_INLINE int tcflush(int fd, int queue) { in tcflush() argument 99 return ioctl(fd, TCFLSH, __BIONIC_CAST(static_cast, unsigned long, queue)); in tcflush() 102 __BIONIC_TERMIOS_INLINE int tcgetattr(int fd, struct termios* _Nonnull s) { in tcgetattr() argument 103 return ioctl(fd, TCGETS, s); in tcgetattr() 106 __BIONIC_TERMIOS_INLINE pid_t tcgetsid(int fd) { in tcgetsid() argument 108 return (ioctl(fd, TIOCGSID, &sid) == -1) ? -1 : sid; in tcgetsid() [all …]
|