/system/core/libcutils/ |
D | ashmem-dev.cpp | 163 android::base::unique_fd fd( in __has_memfd_support() local 165 if (fd == -1) { in __has_memfd_support() 170 if (fcntl(fd, F_ADD_SEALS, F_SEAL_FUTURE_WRITE) == -1) { in __has_memfd_support() 211 int fd = TEMP_FAILURE_RETRY(open(ashmem_device_path.c_str(), O_RDWR | O_CLOEXEC)); in __ashmem_open_locked() local 214 if (fd < 0) { in __ashmem_open_locked() 215 fd = TEMP_FAILURE_RETRY(open("/dev/ashmem", O_RDWR | O_CLOEXEC)); in __ashmem_open_locked() 218 if (fd < 0) { in __ashmem_open_locked() 219 return fd; in __ashmem_open_locked() 223 int ret = TEMP_FAILURE_RETRY(fstat(fd, &st)); in __ashmem_open_locked() 226 close(fd); in __ashmem_open_locked() [all …]
|
D | ashmem_test.cpp | 32 void TestCreateRegion(size_t size, unique_fd &fd, int prot) { in TestCreateRegion() argument 33 fd = unique_fd(ashmem_create_region(nullptr, size)); in TestCreateRegion() 34 ASSERT_TRUE(fd >= 0); in TestCreateRegion() 35 ASSERT_TRUE(ashmem_valid(fd)); in TestCreateRegion() 36 ASSERT_EQ(size, static_cast<size_t>(ashmem_get_size_region(fd))); in TestCreateRegion() 37 ASSERT_EQ(0, ashmem_set_prot_region(fd, prot)); in TestCreateRegion() 40 void TestMmap(const unique_fd& fd, size_t size, int prot, void** region, off_t off = 0) { in TestMmap() argument 41 ASSERT_TRUE(fd >= 0); in TestMmap() 42 ASSERT_TRUE(ashmem_valid(fd)); in TestMmap() 43 *region = mmap(nullptr, size, prot, MAP_SHARED, fd, off); in TestMmap() [all …]
|
D | ashmem-host.cpp | 37 static bool ashmem_validate_stat(int fd, struct stat* buf) { in ashmem_validate_stat() argument 38 int result = fstat(fd, buf); in ashmem_validate_stat() 55 int ashmem_valid(int fd) { in ashmem_valid() argument 57 return ashmem_validate_stat(fd, &buf); in ashmem_valid() 63 int fd = mkstemp(pattern); in ashmem_create_region() local 64 if (fd == -1) return -1; in ashmem_create_region() 68 if (TEMP_FAILURE_RETRY(ftruncate(fd, size)) == -1) { in ashmem_create_region() 69 close(fd); in ashmem_create_region() 73 return fd; in ashmem_create_region() 88 int ashmem_get_size_region(int fd) in ashmem_get_size_region() argument [all …]
|
D | android_get_control_file.cpp | 67 long fd = strtol(val, NULL, 10); in __android_get_control_from_env() local 71 if ((fd < 0) || (fd > INT_MAX)) return -1; in __android_get_control_from_env() 74 if (TEMP_FAILURE_RETRY(fcntl(fd, F_GETFD)) < 0) return -1; in __android_get_control_from_env() 76 return static_cast<int>(fd); in __android_get_control_from_env() 84 auto fd = __android_get_control_from_env(ANDROID_FILE_ENV_PREFIX, path); in android_get_control_file() local 85 if (fd < 0) { in android_get_control_file() 86 fd = __android_get_control_from_env(ANDROID_FILE_ENV_PREFIX, given_path.c_str()); in android_get_control_file() 87 if (fd < 0) return fd; in android_get_control_file() 91 auto proc = android::base::StringPrintf("/proc/self/fd/%d", fd); in android_get_control_file() 98 return fd; in android_get_control_file()
|
/system/memory/libion/ |
D | ion.c | 44 int ion_is_legacy(int fd) { in ion_is_legacy() argument 51 int err = ion_free(fd, (ion_user_handle_t)NULL); in ion_is_legacy() 59 int fd = open("/dev/ion", O_RDONLY | O_CLOEXEC); in ion_open() local 60 if (fd < 0) ALOGE("open /dev/ion failed: %s", strerror(errno)); in ion_open() 62 return fd; in ion_open() 65 int ion_close(int fd) { in ion_close() argument 66 int ret = close(fd); in ion_close() 71 static int ion_ioctl(int fd, int req, void* arg) { in ion_ioctl() argument 72 int ret = ioctl(fd, req, arg); in ion_ioctl() 80 int ion_is_using_modular_heaps(int fd) { in ion_is_using_modular_heaps() argument [all …]
|
/system/core/adb/ |
D | adb_io.cpp | 37 bool SendProtocolString(borrowed_fd fd, std::string_view s) { in SendProtocolString() argument 47 return WriteFdExactly(fd, str); in SendProtocolString() 50 bool ReadProtocolString(borrowed_fd fd, std::string* s, std::string* error) { in ReadProtocolString() argument 52 if (!ReadFdExactly(fd, buf, 4)) { in ReadProtocolString() 60 if (!ReadFdExactly(fd, &(*s)[0], len)) { in ReadProtocolString() 68 bool SendOkay(borrowed_fd fd) { in SendOkay() argument 69 return WriteFdExactly(fd, "OKAY", 4); in SendOkay() 72 bool SendFail(borrowed_fd fd, std::string_view reason) { in SendFail() argument 73 return WriteFdExactly(fd, "FAIL", 4) && SendProtocolString(fd, reason); in SendFail() 76 bool ReadFdExactly(borrowed_fd fd, void* buf, size_t len) { in ReadFdExactly() argument [all …]
|
D | adb_io_test.cpp | 48 ASSERT_NE(-1, tf.fd); in POSIX_TEST() 50 ASSERT_TRUE(android::base::WriteStringToFd(expected, tf.fd)) << strerror(errno); in POSIX_TEST() 51 ASSERT_EQ(0, lseek(tf.fd, 0, SEEK_SET)); in POSIX_TEST() 55 ASSERT_TRUE(ReadFdExactly(tf.fd, buf, sizeof(buf) - 1)) << strerror(errno); in POSIX_TEST() 62 ASSERT_NE(-1, tf.fd); in POSIX_TEST() 64 ASSERT_TRUE(android::base::WriteStringToFd(expected, tf.fd)) << strerror(errno); in POSIX_TEST() 65 ASSERT_EQ(0, lseek(tf.fd, 0, SEEK_SET)); in POSIX_TEST() 69 ASSERT_FALSE(ReadFdExactly(tf.fd, buf, sizeof(buf))); in POSIX_TEST() 76 ASSERT_NE(-1, tf.fd); in POSIX_TEST() 78 ASSERT_TRUE(android::base::WriteStringToFd(input, tf.fd)) << strerror(errno); in POSIX_TEST() [all …]
|
D | sysdeps.h | 85 static inline void close_on_exec(borrowed_fd fd) { in close_on_exec() argument 102 extern int adb_read(borrowed_fd fd, void* buf, int len); 103 extern int adb_pread(borrowed_fd fd, void* buf, int len, off64_t offset); 104 extern int adb_write(borrowed_fd fd, const void* buf, int len); 105 extern int adb_pwrite(borrowed_fd fd, const void* buf, int len, off64_t offset); 106 extern int64_t adb_lseek(borrowed_fd fd, int64_t pos, int where); 107 extern int adb_shutdown(borrowed_fd fd, int direction = SHUT_RDWR); 108 extern int adb_close(int fd); 110 extern HANDLE adb_get_os_handle(borrowed_fd fd); 116 static inline int unix_close(int fd) { in unix_close() argument [all …]
|
D | adb_io.h | 28 bool SendOkay(borrowed_fd fd); 31 bool SendFail(borrowed_fd fd, std::string_view reason); 34 bool SendProtocolString(borrowed_fd fd, std::string_view s); 37 bool ReadProtocolString(borrowed_fd fd, std::string* s, std::string* error); 45 bool ReadFdExactly(borrowed_fd fd, void* buf, size_t len); 63 bool ReadOrderlyShutdown(borrowed_fd fd); 70 bool WriteFdExactly(borrowed_fd fd, const void* buf, size_t len); 73 bool WriteFdExactly(borrowed_fd fd, const char* s); 74 bool WriteFdExactly(borrowed_fd fd, const std::string& s); 77 bool WriteFdFmt(borrowed_fd fd, const char* fmt, ...) __attribute__((__format__(__printf__, 2, 3)));
|
/system/netd/server/ |
D | OffloadUtils.h | 51 const int fd = bpf::mapRetrieveRW(CLAT_EGRESS_MAP_PATH); in getClatEgressMapFd() local 52 return (fd == -1) ? -errno : fd; in getClatEgressMapFd() 56 const int fd = bpf::retrieveProgram(with_ethernet_header ? CLAT_EGRESS_PROG_ETHER_PATH in getClatEgressProgFd() local 58 return (fd == -1) ? -errno : fd; in getClatEgressProgFd() 62 const int fd = bpf::mapRetrieveRW(CLAT_INGRESS_MAP_PATH); in getClatIngressMapFd() local 63 return (fd == -1) ? -errno : fd; in getClatIngressMapFd() 67 const int fd = bpf::retrieveProgram(with_ethernet_header ? CLAT_INGRESS_PROG_ETHER_PATH in getClatIngressProgFd() local 69 return (fd == -1) ? -errno : fd; in getClatIngressProgFd() 73 const int fd = bpf::mapRetrieveRW(TETHER_INGRESS_MAP_PATH); in getTetherIngressMapFd() local 74 return (fd == -1) ? -errno : fd; in getTetherIngressMapFd() [all …]
|
D | OffloadUtilsTest.cpp | 104 int fd = getClatEgressMapFd(); in TEST_F() local 105 ASSERT_GE(fd, 3); // 0,1,2 - stdin/out/err, thus fd >= 3 in TEST_F() 106 EXPECT_EQ(FD_CLOEXEC, fcntl(fd, F_GETFD)); in TEST_F() 107 close(fd); in TEST_F() 113 int fd = getClatEgressProgFd(RAWIP); in TEST_F() local 114 ASSERT_GE(fd, 3); in TEST_F() 115 EXPECT_EQ(FD_CLOEXEC, fcntl(fd, F_GETFD)); in TEST_F() 116 close(fd); in TEST_F() 122 int fd = getClatEgressProgFd(ETHER); in TEST_F() local 123 ASSERT_GE(fd, 3); in TEST_F() [all …]
|
/system/extras/boot_control_copy/ |
D | bootinfo.cpp | 51 int fd; in boot_info_open_partition() local 93 fd = open(path, flags); in boot_info_open_partition() 97 if (fd != -1 && out_size != NULL) { in boot_info_open_partition() 98 if (ioctl(fd, BLKGETSIZE64, out_size) != 0) { in boot_info_open_partition() 99 close(fd); in boot_info_open_partition() 104 return fd; in boot_info_open_partition() 125 int fd; in boot_info_load() local 129 fd = boot_info_open_partition("misc", NULL, O_RDONLY); in boot_info_load() 130 if (fd == -1) in boot_info_load() 132 if (lseek(fd, BOOTINFO_OFFSET, SEEK_SET) != BOOTINFO_OFFSET) { in boot_info_load() [all …]
|
/system/memory/libion/include/ion/ |
D | ion.h | 32 int ion_close(int fd); 33 int ion_alloc(int fd, size_t len, size_t align, unsigned int heap_mask, 35 int ion_alloc_fd(int fd, size_t len, size_t align, unsigned int heap_mask, 37 int ion_sync_fd(int fd, int handle_fd); 38 int ion_free(int fd, ion_user_handle_t handle); 39 int ion_map(int fd, ion_user_handle_t handle, size_t length, int prot, 41 int ion_share(int fd, ion_user_handle_t handle, int *share_fd); 42 int ion_import(int fd, int share_fd, ion_user_handle_t *handle); 48 int ion_query_heap_cnt(int fd, int* cnt); 49 int ion_query_get_heaps(int fd, int cnt, void* buffers); [all …]
|
/system/core/adb/daemon/ |
D | restart_service.cpp | 31 void restart_root_service(unique_fd fd) { in restart_root_service() argument 33 WriteFdExactly(fd.get(), "adbd is already running as root\n"); in restart_root_service() 37 WriteFdExactly(fd.get(), "adbd cannot run as root in production builds\n"); in restart_root_service() 43 WriteFdExactly(fd.get(), "restarting adbd as root\n"); in restart_root_service() 46 void restart_unroot_service(unique_fd fd) { in restart_unroot_service() argument 48 WriteFdExactly(fd.get(), "adbd not running as root\n"); in restart_unroot_service() 54 WriteFdExactly(fd.get(), "restarting adbd as non root\n"); in restart_unroot_service() 57 void restart_tcp_service(unique_fd fd, int port) { in restart_tcp_service() argument 59 WriteFdFmt(fd.get(), "invalid port %d\n", port); in restart_tcp_service() 65 WriteFdFmt(fd.get(), "restarting in TCP mode port: %d\n", port); in restart_tcp_service() [all …]
|
/system/core/qemu_pipe/ |
D | qemu_pipe.cpp | 43 int fd = TEMP_FAILURE_RETRY(open("/dev/qemu_pipe", O_RDWR)); in qemu_pipe_open() local 44 if (fd < 0) { in qemu_pipe_open() 52 if (WriteFully(fd, pipeName, pipeNameLen + 1U)) { in qemu_pipe_open() 53 return fd; in qemu_pipe_open() 60 if (WriteFully(fd, pipe_prefix, strlen(pipe_prefix)) && in qemu_pipe_open() 61 WriteFully(fd, pipeName, pipeNameLen + 1U)) { in qemu_pipe_open() 62 return fd; in qemu_pipe_open() 66 close(fd); in qemu_pipe_open() 70 int qemu_pipe_frame_send(int fd, const void* buff, size_t len) { in qemu_pipe_frame_send() argument 73 if (!WriteFully(fd, header, 4)) { in qemu_pipe_frame_send() [all …]
|
/system/bt/osi/src/ |
D | semaphore.cc | 40 int fd; member 45 ret->fd = eventfd(value, EFD_SEMAPHORE); in semaphore_new() 46 if (ret->fd == INVALID_FD) { in semaphore_new() 57 if (semaphore->fd != INVALID_FD) close(semaphore->fd); in semaphore_free() 63 CHECK(semaphore->fd != INVALID_FD); in semaphore_wait() 66 if (eventfd_read(semaphore->fd, &value) == -1) in semaphore_wait() 72 CHECK(semaphore->fd != INVALID_FD); in semaphore_try_wait() 74 int flags = fcntl(semaphore->fd, F_GETFL); in semaphore_try_wait() 80 if (fcntl(semaphore->fd, F_SETFL, flags | O_NONBLOCK) == -1) { in semaphore_try_wait() 88 if (eventfd_read(semaphore->fd, &value) == -1) rc = false; in semaphore_try_wait() [all …]
|
D | socket.cc | 41 int fd; member 55 ret->fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); in socket_new() 56 if (ret->fd == INVALID_FD) { in socket_new() 61 if (setsockopt(ret->fd, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(enable)) == in socket_new() 70 if (ret) close(ret->fd); in socket_new() 75 socket_t* socket_new_from_fd(int fd) { in socket_new_from_fd() argument 76 CHECK(fd != INVALID_FD); in socket_new_from_fd() 80 ret->fd = fd; in socket_new_from_fd() 88 close(socket->fd); in socket_free() 99 if (bind(socket->fd, (struct sockaddr*)&addr, sizeof(addr)) == -1) { in socket_listen() [all …]
|
/system/core/fs_mgr/liblp/ |
D | io_test.cpp | 52 unique_fd fd(syscall(__NR_memfd_create, "fake_disk", MFD_ALLOW_SEALING)); in CreateFakeDisk() local 53 if (fd < 0) { in CreateFakeDisk() 57 if (ftruncate(fd, size) < 0) { in CreateFakeDisk() 63 if (fcntl(fd, F_ADD_SEALS, F_SEAL_GROW | F_SEAL_SHRINK) < 0) { in CreateFakeDisk() 70 if (!android::base::WriteFully(fd, buffer.get(), size)) { in CreateFakeDisk() 73 return fd; in CreateFakeDisk() 90 explicit DefaultPartitionOpener(int fd) in DefaultPartitionOpener() argument 91 : TestPartitionOpener({{"super", fd}}, {{"super", kSuperInfo}}) {} in DefaultPartitionOpener() 108 unique_fd fd = CreateFakeDisk(); in CreateFlashedDisk() local 109 if (fd < 0) { in CreateFlashedDisk() [all …]
|
/system/memory/lmkd/libpsi/ |
D | psi.cpp | 38 int fd; in init_psi_monitor() local 42 fd = TEMP_FAILURE_RETRY(open(PSI_MON_FILE_MEMORY, O_WRONLY | O_CLOEXEC)); in init_psi_monitor() 43 if (fd < 0) { in init_psi_monitor() 67 res = TEMP_FAILURE_RETRY(write(fd, buf, strlen(buf) + 1)); in init_psi_monitor() 74 return fd; in init_psi_monitor() 77 close(fd); in init_psi_monitor() 81 int register_psi_monitor(int epollfd, int fd, void* data) { in register_psi_monitor() argument 87 res = epoll_ctl(epollfd, EPOLL_CTL_ADD, fd, &epev); in register_psi_monitor() 94 int unregister_psi_monitor(int epollfd, int fd) { in unregister_psi_monitor() argument 95 return epoll_ctl(epollfd, EPOLL_CTL_DEL, fd, NULL); in unregister_psi_monitor() [all …]
|
/system/core/adb/client/ |
D | adb_client.cpp | 76 static std::optional<TransportId> switch_socket_transport(int fd, std::string* error) { in switch_socket_transport() argument 109 if (!SendProtocolString(fd, service)) { in switch_socket_transport() 116 if (!adb_status(fd, error)) { in switch_socket_transport() 122 if (!ReadFdExactly(fd, &result, sizeof(result))) { in switch_socket_transport() 132 bool adb_status(borrowed_fd fd, std::string* error) { in adb_status() argument 134 if (!ReadFdExactly(fd, buf, 4)) { in adb_status() 149 ReadProtocolString(fd, error, error); in adb_status() 162 unique_fd fd; in _adb_connect() local 163 if (!socket_spec_connect(&fd, __adb_server_socket_spec, nullptr, nullptr, &reason)) { in _adb_connect() 170 std::optional<TransportId> transport_result = switch_socket_transport(fd.get(), error); in _adb_connect() [all …]
|
D | incremental_utils.cpp | 66 static inline int32_t read_int32(borrowed_fd fd) { in read_int32() argument 68 return ReadFdExactly(fd, &result, sizeof(result)) ? result : -1; in read_int32() 71 static inline int32_t skip_int(borrowed_fd fd) { in skip_int() argument 72 return adb_lseek(fd, 4, SEEK_CUR); in skip_int() 75 static inline void append_int(borrowed_fd fd, std::vector<char>* bytes) { in append_int() argument 76 int32_t le_val = read_int32(fd); in append_int() 82 static inline void append_bytes_with_size(borrowed_fd fd, std::vector<char>* bytes) { in append_bytes_with_size() argument 83 int32_t le_size = read_int32(fd); in append_bytes_with_size() 91 ReadFdExactly(fd, bytes->data() + old_size + sizeof(le_size), size); in append_bytes_with_size() 94 static inline int32_t skip_bytes_with_size(borrowed_fd fd) { in skip_bytes_with_size() argument [all …]
|
/system/core/trusty/libtrusty/ |
D | trusty.c | 34 int fd; in tipc_connect() local 37 fd = open(dev_name, O_RDWR); in tipc_connect() 38 if (fd < 0) { in tipc_connect() 45 rc = ioctl(fd, TIPC_IOC_CONNECT, srv_name); in tipc_connect() 50 close(fd); in tipc_connect() 54 ALOGV("%s: connected to \"%s\" fd %d\n", __func__, srv_name, fd); in tipc_connect() 55 return fd; in tipc_connect() 58 void tipc_close(int fd) in tipc_close() argument 60 close(fd); in tipc_close()
|
/system/core/trusty/libtrusty/tipc-test/ |
D | tipc_test.c | 194 int fd; in connect_foo() local 201 fd = tipc_connect(dev_name, "foo"); in connect_foo() 202 if (fd >= 0) { in connect_foo() 205 tipc_close(fd); in connect_foo() 220 int fd; in closer1_test() local 227 fd = tipc_connect(dev_name, closer1_name); in closer1_test() 228 if (fd < 0) { in closer1_test() 236 tipc_close(fd); in closer1_test() 249 int fd; in closer2_test() local 256 fd = tipc_connect(dev_name, closer2_name); in closer2_test() [all …]
|
/system/bt/test/suite/rfcomm/ |
D | rfcomm_unittest.cc | 32 int fd = -1; in TEST_F() local 37 &HFP_UUID, 0, &fd, 0, getuid()); in TEST_F() 40 EXPECT_TRUE(fd != -1) << "Error creating RFCOMM socket: invalid fd"; in TEST_F() 44 len = read(fd, &channel, sizeof(channel)); in TEST_F() 47 len = read(fd, &signal, sizeof(signal)); in TEST_F() 57 len = write(fd, HANDSHAKE_COMMAND, sizeof(HANDSHAKE_COMMAND)); in TEST_F() 62 len = read(fd, response, sizeof(response)); in TEST_F() 65 close(fd); in TEST_F() 73 int fd = -1; in TEST_F() local 78 &HFP_UUID, 0, &fd, 0, getuid()); in TEST_F() [all …]
|
/system/security/identity/ |
D | Util.cpp | 51 int fd = open(path.c_str(), O_RDONLY); in fileGetContents() local 52 if (fd == -1) { in fileGetContents() 58 if (fstat(fd, &statbuf) != 0) { in fileGetContents() 60 close(fd); in fileGetContents() 69 ssize_t numRead = TEMP_FAILURE_RETRY(read(fd, p, remaining)); in fileGetContents() 72 close(fd); in fileGetContents() 78 close(fd); in fileGetContents() 85 int fd; in fileSetContents() local 94 fd = mkstemp(tempName); in fileSetContents() 95 if (fd == -1) { in fileSetContents() [all …]
|