Home
last modified time | relevance | path

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

123456

/bionic/tests/
Dfdsan_test.cpp53 int fd = open("/dev/null", O_RDONLY); in TEST_F() local
54 ASSERT_EQ(0, close(fd)); in TEST_F()
60 int fd = open("/dev/null", O_RDONLY); in TEST_F() local
61 ASSERT_EQ(0, android_fdsan_close_with_tag(fd, 0)); in TEST_F()
67 int fd = open("/dev/null", O_RDONLY); in TEST_F() local
68 EXPECT_FDSAN_DEATH(android_fdsan_close_with_tag(fd, 0xdeadbeef), "actually unowned"); in TEST_F()
74 int fd = open("/dev/null", O_RDONLY); in TEST_F() local
75 EXPECT_FDSAN_DEATH(android_fdsan_exchange_owner_tag(fd, 0xbadc0de, 0xdeadbeef), in TEST_F()
82 int fd = open("/dev/null", O_RDONLY); in TEST_F() local
83 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.cpp35 int fd = open("/proc/version", O_RDONLY); in TEST() local
36 ASSERT_TRUE(fd != -1); in TEST()
38 int flags = fcntl(fd, F_GETFD); in TEST()
42 int rc = fcntl(fd, F_SETFD, FD_CLOEXEC); in TEST()
45 flags = fcntl(fd, F_GETFD); in TEST()
49 close(fd); in TEST()
53 int fd; in TEST() local
55 fd = open("/proc/version", O_RDONLY); in TEST()
56 ASSERT_TRUE(fd != -1); in TEST()
57 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()
Dunistd_test.cpp176 ASSERT_EQ(0, close(tf.fd)); in TEST()
186 ASSERT_EQ(0, close(tf.fd)); in TEST()
196 ASSERT_EQ(0, ftruncate(tf.fd, 123)); in TEST()
197 ASSERT_EQ(0, close(tf.fd)); in TEST()
206 ASSERT_EQ(0, ftruncate64(tf.fd, 123)); in TEST()
207 ASSERT_EQ(0, close(tf.fd)); in TEST()
217 ASSERT_EQ(-1, ftruncate(tf.fd, -123)); in TEST()
236 int fd = open("/proc/version", O_RDONLY); in TEST() local
237 ASSERT_TRUE(fd != -1); in TEST()
240 ASSERT_EQ(5, read(fd, buf, 5)); in TEST()
[all …]
Dsys_epoll_test.cpp84 int fd; in TEST() local
85 fd = epoll_create(1); in TEST()
86 AssertCloseOnExec(fd, false); in TEST()
87 close(fd); in TEST()
89 fd = epoll_create1(0); in TEST()
90 AssertCloseOnExec(fd, false); in TEST()
91 close(fd); in TEST()
93 fd = epoll_create1(EPOLL_CLOEXEC); in TEST()
94 AssertCloseOnExec(fd, true); in TEST()
95 close(fd); in TEST()
Dstdlib_test.cpp51 if (fd == -1) { in GenericTemporaryFile()
57 close(fd); in ~GenericTemporaryFile()
61 int fd; member in GenericTemporaryFile
69 fd = mk_fn_(path); in init()
387 android::base::unique_fd fd(open(A_path.c_str(), O_PATH)); in TEST() local
388 ASSERT_NE(fd, -1); in TEST()
400 fd.get()); in TEST()
459 AssertCloseOnExec(tf.fd, true); in TEST()
464 AssertCloseOnExec(tf.fd, true); in TEST()
470 ASSERT_EQ(0, fstat64(tf.fd, &sb)); 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 …]
Dfdtrack_test.cpp49 fprintf(stderr, " event %zu: fd %d created by %s\n", index, event.fd, in DumpEvent()
52 fprintf(stderr, " event %zu: fd %d closed\n", index, event.fd); in DumpEvent()
91 if (event.fd == events[j].fd) { in FdtrackRun()
123 static int fd = open("/dev/null", O_WRONLY | O_CLOEXEC); in TEST() local
124 ASSERT_NE(-1, fd); in TEST()
126 auto events = FdtrackRun([]() { close(fd); }); in TEST()
128 ASSERT_EQ(fd, events[0].fd); in TEST()
156 ASSERT_EQ(fd1, events[0].fd); in TEST()
160 ASSERT_EQ(fd3, events[1].fd); in TEST()
169 void SetFdResult(std::vector<int>* output, int fd) { in SetFdResult() argument
[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/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
85 #define FD_CLR(fd, set) __FD_CLR_chk(fd, set, __bos(set)) argument
87 #define FD_SET(fd, set) __FD_SET_chk(fd, set, __bos(set)) argument
89 #define FD_ISSET(fd, set) __FD_ISSET_chk(fd, set, __bos(set)) argument
94 #define FD_CLR(fd, set) __FD_CLR(fd, set) argument
96 #define FD_SET(fd, set) __FD_SET(fd, set) argument
[all …]
/bionic/libc/bionic/
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 …]
Dlegacy_32_bit_support.cpp53 off64_t lseek64(int fd, off64_t off, int whence) { in lseek64() argument
57 if (__llseek(fd, off_hi, off_lo, &result, whence) < 0) { in lseek64()
64 ssize_t pread(int fd, void* buf, size_t byte_count, off_t offset) { in pread() argument
65 return pread64(fd, buf, byte_count, static_cast<off64_t>(offset)); in pread()
69 ssize_t pwrite(int fd, const void* buf, size_t byte_count, off_t offset) { in pwrite() argument
70 return pwrite64(fd, buf, byte_count, static_cast<off64_t>(offset)); in pwrite()
77 ssize_t preadv(int fd, const struct iovec* ios, int count, off_t offset) { in preadv() argument
78 return preadv64(fd, ios, count, offset); in preadv()
80 ssize_t preadv64(int fd, const struct iovec* ios, int count, off64_t offset) { in preadv64() argument
81 return __preadv64(fd, ios, count, offset, offset >> 32); in preadv64()
[all …]
Dtmpfile.cpp44 static FILE* __fd_to_fp(int fd) { in __fd_to_fp() argument
45 FILE* fp = fdopen(fd, "w+"); in __fd_to_fp()
49 close(fd); in __fd_to_fp()
59 int fd = mkstemp(path); in __tmpfile_dir_legacy() local
60 if (fd == -1) { in __tmpfile_dir_legacy()
72 if (fstat(fd, &sb) == -1) { in __tmpfile_dir_legacy()
74 close(fd); in __tmpfile_dir_legacy()
78 return __fd_to_fp(fd); in __tmpfile_dir_legacy()
82 int fd = open(tmp_dir, O_TMPFILE | O_RDWR, S_IRUSR | S_IWUSR); in __tmpfile_dir() local
83 if (fd == -1) return __tmpfile_dir_legacy(tmp_dir); in __tmpfile_dir()
[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()
248 int android_fdsan_close_with_tag(int fd, uint64_t expected_tag) { in android_fdsan_close_with_tag() argument
250 return __close(fd); in android_fdsan_close_with_tag()
253 FDTRACK_CLOSE(fd); in android_fdsan_close_with_tag()
254 FdEntry* fde = GetFdEntry(fd); in android_fdsan_close_with_tag()
256 return __close(fd); in android_fdsan_close_with_tag()
269 fd, expected_type, expected_owner, actual_type, actual_owner); in android_fdsan_close_with_tag()
[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()
Dspawn.cpp53 int fd; member
61 fd = open(path, flags, mode); in Do()
62 if (fd == -1) _exit(127); in Do()
64 if (fd != new_fd) { in Do()
65 if (dup2(fd, new_fd) == -1) _exit(127); in Do()
66 close(fd); in Do()
70 close(fd); in Do()
72 if (dup2(fd, new_fd) == -1) _exit(127); in Do()
294 int fd, in posix_spawn_add_file_action() argument
314 action->fd = fd; in posix_spawn_add_file_action()
[all …]
Djemalloc_wrapper.cpp144 int fd = fileno(fp); in je_malloc_info() local
145 MallocXmlElem root(fd, "malloc", "version=\"jemalloc-1\""); in je_malloc_info()
151 MallocXmlElem arena_elem(fd, "heap", "nr=\"%d\"", i); in je_malloc_info()
153 MallocXmlElem(fd, "allocated-large").Contents("%zu", mi.ordblks); in je_malloc_info()
154 MallocXmlElem(fd, "allocated-huge").Contents("%zu", mi.uordblks); in je_malloc_info()
155 MallocXmlElem(fd, "allocated-bins").Contents("%zu", mi.fsmblks); in je_malloc_info()
161 MallocXmlElem bin_elem(fd, "bin", "nr=\"%d\"", j); in je_malloc_info()
162 MallocXmlElem(fd, "allocated").Contents("%zu", mi.ordblks); in je_malloc_info()
163 MallocXmlElem(fd, "nmalloc").Contents("%zu", mi.uordblks); in je_malloc_info()
164 MallocXmlElem(fd, "ndalloc").Contents("%zu", mi.fordblks); in je_malloc_info()
[all …]
/bionic/libfdtrack/
Dfdtrack.cpp52 using fdtrack_callback_t = bool (*)(int fd, const char* const* function_names,
91 FdEntry* GetFdEntry(int fd) { in GetFdEntry() argument
92 if (fd >= 0 && fd < static_cast<int>(kFdTableSize)) { in GetFdEntry()
93 return &stack_traces[fd]; in GetFdEntry()
100 if (FdEntry* entry = GetFdEntry(event->fd); entry) { in fd_hook()
106 if (FdEntry* entry = GetFdEntry(event->fd); entry) { in fd_hook()
116 for (int fd = 0; fd < static_cast<int>(stack_traces.size()); ++fd) { in fdtrack_iterate() local
119 FdEntry* entry = GetFdEntry(fd); in fdtrack_iterate()
125 async_safe_format_log(ANDROID_LOG_WARN, "fdtrack", "fd %d locked, skipping", fd); in fdtrack_iterate()
133 async_safe_format_log(ANDROID_LOG_WARN, "fdtrack", "fd %d missing frames: size = %zu", fd, in fdtrack_iterate()
[all …]
/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, 0)) != -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/fortify/
Dunistd.h88 ssize_t pread(int fd, void* const __pass_object_size0 buf, size_t count, off_t offset) in pread() argument
96 return __PREAD_PREFIX(chk)(fd, buf, count, offset, bos); in pread()
99 return __PREAD_PREFIX(real)(fd, buf, count, offset); in pread()
104 ssize_t pread64(int fd, void* const __pass_object_size0 buf, size_t count, off64_t offset) in pread64() argument
112 return __pread64_chk(fd, buf, count, offset, bos); in pread64()
115 return __pread64_real(fd, buf, count, offset); in pread64()
120 ssize_t pwrite(int fd, const void* const __pass_object_size0 buf, size_t count, off_t offset) in pwrite() argument
128 return __PWRITE_PREFIX(chk)(fd, buf, count, offset, bos); in pwrite()
131 return __PWRITE_PREFIX(real)(fd, buf, count, offset); in pwrite()
136 ssize_t pwrite64(int fd, const void* const __pass_object_size0 buf, size_t count, off64_t offset) in pwrite64() argument
[all …]

123456