Home
last modified time | relevance | path

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

12345678910>>...39

/system/core/libcutils/
Dashmem-dev.cpp117 android::base::unique_fd fd( in __has_memfd_support() local
119 if (fd == -1) { in __has_memfd_support()
124 if (fcntl(fd, F_ADD_SEALS, F_SEAL_FUTURE_WRITE) == -1) { in __has_memfd_support()
165 int fd = TEMP_FAILURE_RETRY(open(ashmem_device_path.c_str(), O_RDWR | O_CLOEXEC)); in __ashmem_open_locked() local
168 if (fd < 0) { in __ashmem_open_locked()
170 fd = TEMP_FAILURE_RETRY(open("/dev/ashmem", O_RDWR | O_CLOEXEC)); in __ashmem_open_locked()
171 if (fd < 0) { in __ashmem_open_locked()
176 return fd; in __ashmem_open_locked()
180 int ret = TEMP_FAILURE_RETRY(fstat(fd, &st)); in __ashmem_open_locked()
183 close(fd); in __ashmem_open_locked()
[all …]
Dashmem_test.cpp34 void TestCreateRegion(size_t size, unique_fd &fd, int prot) { in TestCreateRegion() argument
35 fd = unique_fd(ashmem_create_region(nullptr, size)); in TestCreateRegion()
36 ASSERT_TRUE(fd >= 0); in TestCreateRegion()
37 ASSERT_TRUE(ashmem_valid(fd)); in TestCreateRegion()
38 ASSERT_EQ(size, static_cast<size_t>(ashmem_get_size_region(fd))); in TestCreateRegion()
39 ASSERT_EQ(0, ashmem_set_prot_region(fd, prot)); in TestCreateRegion()
44 ASSERT_EQ(FD_CLOEXEC, (fcntl(fd, F_GETFD) & FD_CLOEXEC)); in TestCreateRegion()
47 void TestMmap(const unique_fd& fd, size_t size, int prot, void** region, off_t off = 0) { in TestMmap() argument
48 ASSERT_TRUE(fd >= 0); in TestMmap()
49 ASSERT_TRUE(ashmem_valid(fd)); in TestMmap()
[all …]
Dandroid_get_control_file.cpp67 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()
Dashmem-host.cpp37 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 …]
Dload_file.cpp28 int fd; in load_file() local
31 fd = open(fn, O_RDONLY); in load_file()
32 if(fd < 0) return 0; in load_file()
34 sz = lseek(fd, 0, SEEK_END); in load_file()
37 if(lseek(fd, 0, SEEK_SET) != 0) goto oops; in load_file()
42 if(read(fd, data, sz) != sz) goto oops; in load_file()
43 close(fd); in load_file()
50 close(fd); in load_file()
/system/memory/libion/
Dion.c44 int ion_is_legacy(int fd) { in ion_is_legacy() argument
51 int err = ion_free(fd, (ion_user_handle_t)0); 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()
87 int ion_is_using_modular_heaps(int fd) { in ion_is_using_modular_heaps() argument
[all …]
Dion_test.c41 int _ion_alloc_test(int *fd, ion_user_handle_t *handle) in _ion_alloc_test() argument
45 *fd = ion_open(); in _ion_alloc_test()
46 if (*fd < 0) in _ion_alloc_test()
47 return *fd; in _ion_alloc_test()
49 ret = ion_alloc(*fd, len, align, heap_mask, alloc_flags, handle); in _ion_alloc_test()
58 int fd, ret; in ion_alloc_test() local
61 if(_ion_alloc_test(&fd, &handle)) in ion_alloc_test()
64 ret = ion_free(fd, handle); in ion_alloc_test()
69 ion_close(fd); in ion_alloc_test()
75 int fd, map_fd, ret; in ion_map_test() local
[all …]
/system/extras/boot_control_copy/
Dbootinfo.cpp48 int fd; in boot_info_open_partition() local
90 fd = open(path, flags); in boot_info_open_partition()
94 if (fd != -1 && out_size != NULL) { in boot_info_open_partition()
95 if (ioctl(fd, BLKGETSIZE64, out_size) != 0) { in boot_info_open_partition()
96 close(fd); in boot_info_open_partition()
101 return fd; in boot_info_open_partition()
121 int fd; in boot_info_load() local
125 fd = boot_info_open_partition("misc", NULL, O_RDONLY); in boot_info_load()
126 if (fd == -1) return false; in boot_info_load()
127 if (lseek(fd, BOOTINFO_OFFSET, SEEK_SET) != BOOTINFO_OFFSET) { in boot_info_load()
[all …]
/system/core/fs_mgr/libsnapshot/snapuserd/user-space-merge/
Dsnapuserd_server.cpp58 close(watched_fds_[i].fd); in ~UserSnapshotServer()
88 bool UserSnapshotServer::Sendmsg(android::base::borrowed_fd fd, const std::string& msg) { in Sendmsg() argument
89 ssize_t ret = TEMP_FAILURE_RETRY(send(fd.get(), msg.data(), msg.size(), MSG_NOSIGNAL)); in Sendmsg()
102 bool UserSnapshotServer::Recv(android::base::borrowed_fd fd, std::string* data) { in Recv() argument
104 ssize_t rv = TEMP_FAILURE_RETRY(recv(fd.get(), msg, sizeof(msg), 0)); in Recv()
113 bool UserSnapshotServer::Receivemsg(android::base::borrowed_fd fd, const std::string& str) { in Receivemsg() argument
127 return Sendmsg(fd, "fail"); in Receivemsg()
132 return Sendmsg(fd, "fail"); in Receivemsg()
137 return Sendmsg(fd, "fail"); in Receivemsg()
141 return Sendmsg(fd, retval); in Receivemsg()
[all …]
/system/core/fs_mgr/liblp/
Dio_test.cpp56 unique_fd fd(syscall(__NR_memfd_create, "fake_disk", MFD_ALLOW_SEALING)); in CreateFakeDisk() local
57 if (fd < 0) { in CreateFakeDisk()
61 if (ftruncate(fd, size) < 0) { in CreateFakeDisk()
67 if (fcntl(fd, F_ADD_SEALS, F_SEAL_GROW | F_SEAL_SHRINK) < 0) { in CreateFakeDisk()
74 if (!android::base::WriteFully(fd, buffer.get(), size)) { in CreateFakeDisk()
77 return fd; in CreateFakeDisk()
94 explicit DefaultPartitionOpener(int fd) in DefaultPartitionOpener() argument
95 : TestPartitionOpener({{"super", fd}}, {{"super", kSuperInfo}}) {} in DefaultPartitionOpener()
112 unique_fd fd = CreateFakeDisk(); in CreateFlashedDisk() local
113 if (fd < 0) { in CreateFlashedDisk()
[all …]
/system/memory/libion/include/ion/
Dion.h32 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/memory/libdmabufheap/tests/
Ddmabuf_heap_test.c54 int fd = -1, ret = 0; in libdmabufheaptest() local
82 fd = DmabufHeapAllocSystem(bufferAllocator, true /* cpu_access */, len, 0, 0); in libdmabufheaptest()
83 if (fd < 0) { in libdmabufheaptest()
84 printf("DmabufHeapAllocSystem() failed: %d cpu_access: true\n", fd); in libdmabufheaptest()
87 close(fd); in libdmabufheaptest()
89 fd = DmabufHeapAllocSystem(bufferAllocator, false /* cpu_access */, len, 0, 0); in libdmabufheaptest()
90 if (fd < 0) { in libdmabufheaptest()
91 printf("DmabufHeapAllocSystem() failed: %d cpu_access: false\n", fd); in libdmabufheaptest()
94 close(fd); in libdmabufheaptest()
96 fd = DmabufHeapAlloc(bufferAllocator, kDmabufSystemHeapName, len, 0, 0); in libdmabufheaptest()
[all …]
/system/logging/logd/libaudit/
Dlibaudit.cpp36 static int get_ack(int fd) { in get_ack() argument
38 int rc = audit_get_reply(fd, &rep, GET_REPLY_BLOCKING, MSG_PEEK); in get_ack()
44 audit_get_reply(fd, &rep, GET_REPLY_BLOCKING, 0); in get_ack()
65 static int audit_send(int fd, int type, const void* data, size_t size) { in audit_send() argument
78 if (fd < 0) { in audit_send()
105 sendto(fd, &req, req.nlh.nlmsg_len, 0, (struct sockaddr*)&addr, sizeof(addr))); in audit_send()
115 rc = get_ack(fd); in audit_send()
123 int audit_setup(int fd, pid_t pid) { in audit_setup() argument
135 int rc = audit_send(fd, AUDIT_SET, &status, sizeof(status)); in audit_setup()
151 audit_get_reply(fd, &rep, GET_REPLY_NONBLOCKING, 0); in audit_setup()
[all …]
/system/security/identity/
DUtil.cpp51 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 …]
/system/libbase/include/android-base/
Dunique_fd.h65 explicit unique_fd_impl(int fd) { reset(fd); } in unique_fd_impl() argument
72 int fd = s.fd_; variable
74 reset(fd, &s);
129 static auto tag(int fd, void* old_tag, void* new_tag)
130 -> decltype(T::Tag(fd, old_tag, new_tag), void()) {
131 T::Tag(fd, old_tag, new_tag);
141 static auto close(int fd, void* tag_value) -> decltype(T::Close(fd, tag_value), void()) {
142 T::Close(fd, tag_value);
146 static auto close(int fd, void*) -> decltype(T::Close(fd), void()) {
147 T::Close(fd);
[all …]
/system/core/trusty/libtrusty/
Dtrusty.c33 int fd; in tipc_connect() local
36 fd = TEMP_FAILURE_RETRY(open(dev_name, O_RDWR)); in tipc_connect()
37 if (fd < 0) { in tipc_connect()
43 rc = TEMP_FAILURE_RETRY(ioctl(fd, TIPC_IOC_CONNECT, srv_name)); in tipc_connect()
47 close(fd); in tipc_connect()
51 ALOGV("%s: connected to \"%s\" fd %d\n", __func__, srv_name, fd); in tipc_connect()
52 return fd; in tipc_connect()
55 ssize_t tipc_send(int fd, const struct iovec* iov, int iovcnt, struct trusty_shm* shms, in tipc_send() argument
63 int rc = TEMP_FAILURE_RETRY(ioctl(fd, TIPC_IOC_SEND_MSG, &req)); in tipc_send()
71 void tipc_close(int fd) { in tipc_close() argument
[all …]
/system/libbase/
Dabi_compatibility.cpp44 bool ReadFdToString(int fd, std::string* content) { in ReadFdToString() argument
45 return ReadFdToString(borrowed_fd(fd), content); in ReadFdToString()
48 bool WriteStringToFd(const std::string& content, int fd) { in WriteStringToFd() argument
49 return WriteStringToFd(std::string_view(content), borrowed_fd(fd)); in WriteStringToFd()
52 bool WriteStringToFd(const std::string& content, borrowed_fd fd) { in WriteStringToFd() argument
53 return WriteStringToFd(std::string_view(content), fd); in WriteStringToFd()
56 bool ReadFully(int fd, void* data, size_t byte_count) { in ReadFully() argument
57 return ReadFully(borrowed_fd(fd), data, byte_count); in ReadFully()
60 bool ReadFullyAtOffset(int fd, void* data, size_t byte_count, off64_t offset) { in ReadFullyAtOffset() argument
61 return ReadFullyAtOffset(borrowed_fd(fd), data, byte_count, offset); in ReadFullyAtOffset()
[all …]
/system/memory/lmkd/libpsi/
Dpsi.cpp43 int fd; in init_psi_monitor() local
47 fd = TEMP_FAILURE_RETRY(open(psi_resource_file[resource], O_WRONLY | O_CLOEXEC)); in init_psi_monitor()
48 if (fd < 0) { in init_psi_monitor()
72 res = TEMP_FAILURE_RETRY(write(fd, buf, strlen(buf) + 1)); in init_psi_monitor()
79 return fd; in init_psi_monitor()
82 close(fd); in init_psi_monitor()
86 int register_psi_monitor(int epollfd, int fd, void* data) { in register_psi_monitor() argument
92 res = epoll_ctl(epollfd, EPOLL_CTL_ADD, fd, &epev); in register_psi_monitor()
99 int unregister_psi_monitor(int epollfd, int fd) { in unregister_psi_monitor() argument
100 return epoll_ctl(epollfd, EPOLL_CTL_DEL, fd, NULL); in unregister_psi_monitor()
[all …]
/system/update_engine/
Dtest_http_server.cc81 bool ParseRequest(int fd, HttpRequest* request) { in ParseRequest() argument
85 ssize_t r = read(fd, buf, sizeof(buf)); in ParseRequest()
163 ssize_t WriteString(int fd, const string& str) { in WriteString() argument
169 ssize_t written = write(fd, data, remaining_size); in WriteString()
183 ssize_t WriteHeaders(int fd, in WriteHeaders() argument
189 ret = WriteString(fd, in WriteHeaders()
205 fd, in WriteHeaders()
215 fd, string("Content-Length: ") + Itoa(content_length) + EOL EOL); in WriteHeaders()
226 size_t WritePayload(int fd, in WritePayload() argument
255 ssize_t ret = WriteString(fd, partial); in WritePayload()
[all …]
/system/core/trusty/libtrusty/tipc-test/
Dtipc_test.c261 int fd; in connect_foo() local
268 fd = tipc_connect(params->dev_name, "foo"); in connect_foo()
269 if (fd >= 0) { in connect_foo()
271 tipc_close(fd); in connect_foo()
284 int fd; in closer1_test() local
291 fd = tipc_connect(params->dev_name, closer1_name); in closer1_test()
292 if (fd < 0) { in closer1_test()
299 tipc_close(fd); in closer1_test()
311 int fd; in closer2_test() local
318 fd = tipc_connect(params->dev_name, closer2_name); in closer2_test()
[all …]
/system/security/ondevice-signing/
DVerityUtils.cpp60 int* fd = (int*)file; in read_callback() local
61 if (TEMP_FAILURE_RETRY(read(*fd, buf, count)) < 0) return errno ? -errno : -EIO; in read_callback()
65 static Result<std::vector<uint8_t>> createDigest(int fd) { in createDigest() argument
67 int ret = fstat(fd, &filestat); in createDigest()
79 ret = libfsverity_compute_digest(&fd, &read_callback, &params, &digest); in createDigest()
94 unique_fd fd(TEMP_FAILURE_RETRY(open(path.c_str(), O_RDONLY | O_CLOEXEC))); in createDigest() local
95 if (!fd.ok()) { in createDigest()
98 return createDigest(fd.get()); in createDigest()
120 static Result<std::string> measureFsVerity(int fd) { in measureFsVerity() argument
124 if (ioctl(fd, FS_IOC_MEASURE_VERITY, d.get()) != 0) { in measureFsVerity()
[all …]
/system/extras/memory_replay/tests/
DNativeInfoTest.cpp30 ASSERT_TRUE(tmp_file_->fd != -1); in SetUp()
59 write(tmp_file_->fd, smaps_data.c_str(), smaps_data.size())) != -1); in TEST_F()
60 ASSERT_TRUE(lseek(tmp_file_->fd, 0, SEEK_SET) != off_t(-1)); in TEST_F()
64 NativeGetInfo(tmp_file_->fd, &rss_bytes, &va_bytes); in TEST_F()
120 write(tmp_file_->fd, smaps_data.c_str(), smaps_data.size())) != -1); in TEST_F()
121 ASSERT_TRUE(lseek(tmp_file_->fd, 0, SEEK_SET) != off_t(-1)); in TEST_F()
125 NativeGetInfo(tmp_file_->fd, &rss_bytes, &va_bytes); in TEST_F()
181 write(tmp_file_->fd, smaps_data.c_str(), smaps_data.size())) != -1); in TEST_F()
182 ASSERT_TRUE(lseek(tmp_file_->fd, 0, SEEK_SET) != off_t(-1)); in TEST_F()
186 NativeGetInfo(tmp_file_->fd, &rss_bytes, &va_bytes); in TEST_F()
[all …]
/system/core/libutils/include/utils/
DCompat.h32 static inline void* mmap64(void* addr, size_t length, int prot, int flags, int fd, off64_t offset) { in mmap64() argument
33 return mmap(addr, length, prot, flags, fd, offset); in mmap64()
36 static inline off64_t lseek64(int fd, off64_t offset, int whence) { in lseek64() argument
37 return lseek(fd, offset, whence); in lseek64()
40 static inline ssize_t pread64(int fd, void* buf, size_t nbytes, off64_t offset) { in pread64() argument
41 return pread(fd, buf, nbytes, offset); in pread64()
44 static inline ssize_t pwrite64(int fd, const void* buf, size_t nbytes, off64_t offset) { in pwrite64() argument
45 return pwrite(fd, buf, nbytes, offset); in pwrite64()
48 static inline int ftruncate64(int fd, off64_t length) { in ftruncate64() argument
49 return ftruncate(fd, length); in ftruncate64()
/system/update_engine/liburing_cpp/tests/
DBasicTests.cpp63 void Write(int fd, const void* data, const size_t len) { in Write() argument
68 const auto sqe = ring->PrepWrite(fd, buf + i, IO_BATCH_SIZE, i); in Write()
73 ASSERT_TRUE(ring->PrepWrite(fd, buf + i, bytes_remaining, i).IsOk()); in Write()
88 int fd = open("/proc/self/maps", O_RDONLY); in TEST_F() local
90 const auto sqe = ring->PrepRead(fd, buf.data(), buf.size(), 0); in TEST_F()
101 int fd = fileno(fp); in TEST_F() local
103 const auto sqe = ring->PrepWrite(fd, buffer.data(), buffer.size(), 0); in TEST_F()
110 const auto bytes_read = pread(fd, buffer.data(), buffer.size(), 0); in TEST_F()
121 int fd = fileno(fp); in TEST_F() local
123 ASSERT_NO_FATAL_FAILURE(Write(fd, buffer.data(), buffer.size())); in TEST_F()
[all …]
/system/extras/tests/storage/
Dwipe_blkdev.c38 static u64 get_block_device_size(int fd) in get_block_device_size() argument
43 ret = ioctl(fd, BLKGETSIZE64, &size); in get_block_device_size()
51 static int wipe_block_device(int fd, u64 len, int secure) in wipe_block_device() argument
65 ret = ioctl(fd, req, &range); in wipe_block_device()
84 int fd; in main() local
104 fd = open(devname, O_RDWR); in main()
105 if (fd < 0) { in main()
110 if (fstat(fd, &statbuf) < 0) { in main()
120 len = get_block_device_size(fd); in main()
127 ret = wipe_block_device(fd, len, secure); in main()
[all …]

12345678910>>...39