Home
last modified time | relevance | path

Searched refs:fd (Results 1 – 25 of 162) sorted by relevance

1234567

/bionic/tests/
Dfdsan_test.cpp63 int fd = open("/dev/null", O_RDONLY); in TEST_F() local
64 ASSERT_EQ(0, close(fd)); in TEST_F()
70 int fd = open("/dev/null", O_RDONLY); in TEST_F() local
71 ASSERT_EQ(0, android_fdsan_close_with_tag(fd, 0)); in TEST_F()
77 int fd = open("/dev/null", O_RDONLY); in TEST_F() local
78 EXPECT_FDSAN_DEATH(android_fdsan_close_with_tag(fd, 0xdeadbeef), "actually unowned"); in TEST_F()
84 int fd = open("/dev/null", O_RDONLY); in TEST_F() local
85 EXPECT_FDSAN_DEATH(android_fdsan_exchange_owner_tag(fd, 0xbadc0de, 0xdeadbeef), in TEST_F()
92 int fd = open("/dev/null", O_RDONLY); in TEST_F() local
93 android_fdsan_exchange_owner_tag(fd, 0, 0xdeadbeef); in TEST_F()
[all …]
Deventfd_test.cpp28 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 …]
Dfcntl_test.cpp40 int fd = open("/proc/version", O_RDONLY); in TEST() local
41 ASSERT_TRUE(fd != -1); in TEST()
43 int flags = fcntl(fd, F_GETFD); in TEST()
47 int rc = fcntl(fd, F_SETFD, FD_CLOEXEC); in TEST()
50 flags = fcntl(fd, F_GETFD); in TEST()
54 close(fd); in TEST()
58 int fd; in TEST() local
60 fd = open("/proc/version", O_RDONLY); in TEST()
61 ASSERT_TRUE(fd != -1); in TEST()
62 close(fd); in TEST()
[all …]
Dsys_mman_test.cpp41 void* map = mmap(nullptr, 100, PROT_READ, MAP_SHARED, tf.fd, 1); in TEST()
48 void* map = mmap64(nullptr, 100, PROT_READ, MAP_SHARED, tf.fd, 1); in TEST()
60 ASSERT_EQ(STR_SSIZE(STRING_MSG), write(tf.fd, STRING_MSG, sizeof(STRING_MSG))); in TEST()
62 void* map = mmap(nullptr, sizeof(STRING_MSG), PROT_READ, MAP_SHARED, tf.fd, 0); in TEST()
74 ASSERT_EQ(STR_SSIZE(INITIAL_MSG), write(tf.fd, INITIAL_MSG, sizeof(INITIAL_MSG))); in TEST()
75 lseek(tf.fd, 0, SEEK_SET); in TEST()
77 void* map = mmap(nullptr, sizeof(STRING_MSG), PROT_WRITE, MAP_SHARED, tf.fd, 0); in TEST()
79 close(tf.fd); in TEST()
85 tf.fd = open(tf.path, O_RDWR); in TEST()
88 ASSERT_EQ(STR_SSIZE(STRING_MSG), read(tf.fd, buf, sizeof(STRING_MSG))); in TEST()
[all …]
Dsys_xattr_test.cpp38 ASSERT_EQ(0, fsetxattr(tf.fd, "user.foo", "bar", 4, 0)); in TEST()
39 ASSERT_EQ(4, fgetxattr(tf.fd, "user.foo", buf, sizeof(buf))); in TEST()
46 ASSERT_EQ(0, fsetxattr(tf.fd, "user.foo", "", 0, 0)); in TEST()
47 ASSERT_EQ(0, fgetxattr(tf.fd, "user.foo", buf, sizeof(buf))); in TEST()
53 ASSERT_EQ(0, fsetxattr(tf.fd, "user.foo", "01234567890123456789", 21, 0)); in TEST()
54 ASSERT_EQ(-1, fgetxattr(tf.fd, "user.foo", buf, sizeof(buf))); in TEST()
70 int fd = open(tf.path, O_PATH); in TEST() local
71 ASSERT_NE(-1, fd); in TEST()
73 int res = fsetxattr(fd, "user.foo", "bar", 4, 0); in TEST()
77 ASSERT_EQ(4, fgetxattr(fd, "user.foo", buf, sizeof(buf))); in TEST()
[all …]
Dsys_socket_test.cpp39 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 …]
Dsys_sendfile_test.cpp29 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()
Dsys_uio_test.cpp34 ASSERT_EQ(10, writev(tf.fd, ios, 2)); in TEST()
36 ASSERT_EQ(0, lseek(tf.fd, 0, SEEK_SET)); in TEST()
41 ASSERT_EQ(10, readv(tf.fd, ios, 2)); in TEST()
54 ASSERT_EQ(5, write_fn(tf.fd, ios, 1, 5)); in TestPreadVPwriteV()
55 ASSERT_EQ(0, lseek(tf.fd, 0, SEEK_CUR)); in TestPreadVPwriteV()
58 ASSERT_EQ(5, write_fn(tf.fd, ios, 1, 0)); in TestPreadVPwriteV()
59 ASSERT_EQ(0, lseek(tf.fd, 0, SEEK_CUR)); in TestPreadVPwriteV()
61 ASSERT_EQ(5, read_fn(tf.fd, ios, 1, 5)); in TestPreadVPwriteV()
63 ASSERT_EQ(5, read_fn(tf.fd, ios, 1, 0)); in TestPreadVPwriteV()
82 ASSERT_EQ(5, write_fn(tf.fd, ios, 1, 5, 0)) << strerror(errno); in TestPreadV2PwriteV2()
[all …]
Dsys_epoll_test.cpp84 int fd; in TEST() local
85 fd = epoll_create(1); in TEST()
86 ASSERT_FALSE(CloseOnExec(fd)); in TEST()
87 close(fd); in TEST()
89 fd = epoll_create1(0); in TEST()
90 ASSERT_FALSE(CloseOnExec(fd)); in TEST()
91 close(fd); in TEST()
93 fd = epoll_create1(EPOLL_CLOEXEC); in TEST()
94 ASSERT_TRUE(CloseOnExec(fd)); in TEST()
95 close(fd); in TEST()
Dunistd_test.cpp178 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 …]
Dfdtrack_test.cpp51 fprintf(stderr, " event %zu: fd %d created by %s\n", index, event.fd, in DumpEvent()
54 fprintf(stderr, " event %zu: fd %d closed\n", index, event.fd); in DumpEvent()
95 if (event.fd == events[j].fd) { in FdtrackRun()
127 static int fd = open("/dev/null", O_WRONLY | O_CLOEXEC); in TEST() local
128 ASSERT_NE(-1, fd); in TEST()
130 auto events = FdtrackRun([]() { close(fd); }); in TEST()
132 ASSERT_EQ(fd, events[0].fd); in TEST()
141 static int fd = open("/dev/null", O_WRONLY | O_CLOEXEC); in TEST() local
142 ASSERT_NE(-1, fd); in TEST()
144 auto events = FdtrackRun([]() { close(fd); }, false); in TEST()
[all …]
Dsys_select_test.cpp52 static void DelayedWrite(int* pid, int* fd) { in DelayedWrite() argument
66 *fd = fds[0]; in DelayedWrite()
69 static void DelayedWriteCleanup(int pid, int fd) { in DelayedWriteCleanup() argument
71 ASSERT_EQ(static_cast<ssize_t>(sizeof(DELAY_MSG)), read(fd, buf, sizeof(DELAY_MSG))); in DelayedWriteCleanup()
115 int pid, fd; in TEST() local
116 DelayedWrite(&pid, &fd); in TEST()
119 FD_SET(fd, &r); in TEST()
120 ASSERT_EQ(1, select(fd+1, &r, nullptr, nullptr, &tv)); in TEST()
125 DelayedWriteCleanup(pid, fd); in TEST()
170 int pid, fd; in TEST() local
[all …]
/bionic/libc/tzcode/
Dbionic.cpp115 int fd = TEMP_FAILURE_RETRY(open(path, O_RDONLY | O_CLOEXEC)); in __bionic_open_tzdata_path() local
116 if (fd == -1) { in __bionic_open_tzdata_path()
123 ssize_t bytes_read = TEMP_FAILURE_RETRY(read(fd, &header, sizeof(header))); in __bionic_open_tzdata_path()
127 close(fd); in __bionic_open_tzdata_path()
133 close(fd); in __bionic_open_tzdata_path()
137 if (TEMP_FAILURE_RETRY(lseek(fd, ntohl(header.index_offset), SEEK_SET)) == -1) { in __bionic_open_tzdata_path()
139 close(fd); in __bionic_open_tzdata_path()
146 close(fd); in __bionic_open_tzdata_path()
152 close(fd); in __bionic_open_tzdata_path()
159 close(fd); in __bionic_open_tzdata_path()
[all …]
/bionic/libc/bionic/
Dpreadv_pwritev.cpp45 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 …]
Dpty.cpp54 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 …]
Dtmpfile.cpp45 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 …]
Dfdsan.cpp51 extern "C" int __close(int fd);
124 static FdEntry* GetFdEntry(int fd) { in GetFdEntry() argument
125 if (fd < 0) { in GetFdEntry()
129 return GetFdTable().at(fd); in GetFdEntry()
242 int android_fdsan_close_with_tag(int fd, uint64_t expected_tag) { in android_fdsan_close_with_tag() argument
244 return __close(fd); in android_fdsan_close_with_tag()
247 FDTRACK_CLOSE(fd); in android_fdsan_close_with_tag()
248 FdEntry* fde = GetFdEntry(fd); in android_fdsan_close_with_tag()
250 return __close(fd); in android_fdsan_close_with_tag()
263 fd, expected_type, expected_owner, actual_type, actual_owner); in android_fdsan_close_with_tag()
[all …]
Dexecinfo.cpp108 ScopedFd fd(memfd_create("backtrace_symbols_fd", MFD_CLOEXEC)); in backtrace_symbols() local
109 if (fd.get() == -1) { in backtrace_symbols()
112 backtrace_symbols_fd(buffer, size, fd.get()); in backtrace_symbols()
115 off_t file_size = lseek(fd.get(), 0, SEEK_END); in backtrace_symbols()
138 lseek(fd.get(), 0, SEEK_SET); in backtrace_symbols()
139 ssize_t num_read = read(fd.get(), cur_string, file_size); in backtrace_symbols()
140 fd.reset(-1); in backtrace_symbols()
165 void backtrace_symbols_fd(void* const* buffer, int size, int fd) { in backtrace_symbols_fd() argument
166 if (size <= 0 || fd < 0) { in backtrace_symbols_fd()
175 write(fd, info.dli_fname, strlen(info.dli_fname)); in backtrace_symbols_fd()
[all …]
Dspawn.cpp80 int fd; member
88 fd = open(path, flags, mode); in Do()
89 if (fd == -1) _exit(127); in Do()
91 if (fd != new_fd) { in Do()
92 if (dup2(fd, new_fd) == -1) _exit(127); in Do()
93 close(fd); in Do()
97 close(fd); in Do()
101 if (fchdir(fd) == -1) _exit(127); in Do()
104 if (fd == new_fd) { in Do()
109 int flags = fcntl(fd, F_GETFD, 0); in Do()
[all …]
DNetdClientDispatch.cpp57 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()
Dpthread_setname_np.cpp65 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()
Dlockf.cpp35 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()
/bionic/libc/include/sys/
Dselect.h61 #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/include/bits/
Dtermios_inlines.h88 __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* 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 …]
/bionic/libc/upstream-openbsd/lib/libc/gen/
Ddaemon.c39 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()

1234567