Home
last modified time | relevance | path

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

12345678910>>...28

/system/core/adb/
Dadb_client.cpp72 static int switch_socket_transport(int fd, std::string* error) { in switch_socket_transport() argument
97 if (!SendProtocolString(fd, service)) { in switch_socket_transport()
99 adb_close(fd); in switch_socket_transport()
104 if (!adb_status(fd, error)) { in switch_socket_transport()
105 adb_close(fd); in switch_socket_transport()
113 bool adb_status(int fd, std::string* error) { in adb_status() argument
115 if (!ReadFdExactly(fd, buf, 4)) { in adb_status()
130 ReadProtocolString(fd, error, error); in adb_status()
142 int fd; in _adb_connect() local
145 fd = network_connect(__adb_server_name, __adb_server_port, SOCK_STREAM, 0, &reason); in _adb_connect()
[all …]
Dadb_io.cpp30 bool SendProtocolString(int fd, const std::string& s) { in SendProtocolString() argument
39 return WriteFdFmt(fd, "%04x%.*s", length, length, s.c_str()); in SendProtocolString()
42 bool ReadProtocolString(int fd, std::string* s, std::string* error) { in ReadProtocolString() argument
44 if (!ReadFdExactly(fd, buf, 4)) { in ReadProtocolString()
52 if (!ReadFdExactly(fd, &(*s)[0], len)) { in ReadProtocolString()
60 bool SendOkay(int fd) { in SendOkay() argument
61 return WriteFdExactly(fd, "OKAY", 4); in SendOkay()
64 bool SendFail(int fd, const std::string& reason) { in SendFail() argument
65 return WriteFdExactly(fd, "FAIL", 4) && SendProtocolString(fd, reason); in SendFail()
68 bool ReadFdExactly(int fd, void* buf, size_t len) { in ReadFdExactly() argument
[all …]
Dadb_io_test.cpp43 ASSERT_NE(-1, tf.fd); in TEST()
45 ASSERT_TRUE(android::base::WriteStringToFd(expected, tf.fd)) << strerror(errno); in TEST()
46 ASSERT_EQ(0, lseek(tf.fd, 0, SEEK_SET)); in TEST()
50 ASSERT_TRUE(ReadFdExactly(tf.fd, buf, sizeof(buf) - 1)) << strerror(errno); in TEST()
57 ASSERT_NE(-1, tf.fd); in TEST()
59 ASSERT_TRUE(android::base::WriteStringToFd(expected, tf.fd)) << strerror(errno); in TEST()
60 ASSERT_EQ(0, lseek(tf.fd, 0, SEEK_SET)); in TEST()
64 ASSERT_FALSE(ReadFdExactly(tf.fd, buf, sizeof(buf))); in TEST()
71 ASSERT_NE(-1, tf.fd); in TEST()
73 ASSERT_TRUE(android::base::WriteStringToFd(input, tf.fd)) << strerror(errno); in TEST()
[all …]
Dtransport_local.cpp99 int fd = -1; in local_connect_arbitrary_ports() local
108 fd = network_connect(host, adb_port, SOCK_STREAM, 0, error); in local_connect_arbitrary_ports()
111 if (fd < 0) { in local_connect_arbitrary_ports()
112 fd = network_loopback_client(adb_port, SOCK_STREAM, error); in local_connect_arbitrary_ports()
115 if (fd >= 0) { in local_connect_arbitrary_ports()
116 D("client: connected on remote on fd %d", fd); in local_connect_arbitrary_ports()
117 close_on_exec(fd); in local_connect_arbitrary_ports()
118 disable_tcp_nagle(fd); in local_connect_arbitrary_ports()
120 if (register_socket_transport(fd, serial.c_str(), adb_port, 1) == 0) { in local_connect_arbitrary_ports()
123 adb_close(fd); in local_connect_arbitrary_ports()
[all …]
Dset_verity_enable_state_service.cpp46 static int set_verity_enabled_state(int fd, const char *block_device, in set_verity_enabled_state() argument
50 WriteFdFmt(fd, "Could not make block device %s writable (%s).\n", in set_verity_enabled_state()
58 WriteFdFmt(fd, "Could not open block device %s (%s).\n", block_device, strerror(errno)); in set_verity_enabled_state()
59 WriteFdFmt(fd, "Maybe run adb root?\n"); in set_verity_enabled_state()
66 WriteFdFmt(fd, "Couldn't find verity metadata!\n"); in set_verity_enabled_state()
71 WriteFdFmt(fd, "Verity already disabled on %s\n", mount_point); in set_verity_enabled_state()
76 WriteFdFmt(fd, "Verity already enabled on %s\n", mount_point); in set_verity_enabled_state()
81 WriteFdFmt(fd, "Could not set verity %s flag on device %s with error %s\n", in set_verity_enabled_state()
87 WriteFdFmt(fd, "Verity %s on %s\n", enable ? "enabled" : "disabled", mount_point); in set_verity_enabled_state()
91 void set_verity_enabled_state_service(int fd, void* cookie) in set_verity_enabled_state_service() argument
[all …]
Dremount_service.cpp78 int fd = unix_open(dev.c_str(), O_RDONLY | O_CLOEXEC); in make_block_device_writable() local
79 if (fd == -1) { in make_block_device_writable()
84 bool result = (ioctl(fd, BLKROSET, &OFF) != -1); in make_block_device_writable()
85 unix_close(fd); in make_block_device_writable()
89 static bool remount_partition(int fd, const char* dir) { in remount_partition() argument
98 WriteFdFmt(fd, "remount of %s failed; couldn't make block device %s writable: %s\n", in remount_partition()
103 WriteFdFmt(fd, "remount of %s failed: %s\n", dir, strerror(errno)); in remount_partition()
109 void remount_service(int fd, void* cookie) { in remount_service() argument
111 WriteFdExactly(fd, "Not running as root. Try \"adb root\" first.\n"); in remount_service()
112 adb_close(fd); in remount_service()
[all …]
Dservices.cpp56 void (*func)(int fd, void *cookie);
57 int fd; member
63 adb_thread_setname(android::base::StringPrintf("service %d", sti->fd)); in service_bootstrap_func()
64 sti->func(sti->fd, sti->cookie); in service_bootstrap_func()
70 void restart_root_service(int fd, void *cookie) { in restart_root_service() argument
72 WriteFdExactly(fd, "adbd is already running as root\n"); in restart_root_service()
73 adb_close(fd); in restart_root_service()
78 WriteFdExactly(fd, "adbd cannot run as root in production builds\n"); in restart_root_service()
79 adb_close(fd); in restart_root_service()
84 WriteFdExactly(fd, "restarting adbd as root\n"); in restart_root_service()
[all …]
Dadb_io.h25 bool SendOkay(int fd);
28 bool SendFail(int fd, const std::string& reason);
31 bool SendProtocolString(int fd, const std::string& s);
34 bool ReadProtocolString(int fd, std::string* s, std::string* error);
42 bool ReadFdExactly(int fd, void* buf, size_t len);
60 bool ReadOrderlyShutdown(int fd);
67 bool WriteFdExactly(int fd, const void* buf, size_t len);
70 bool WriteFdExactly(int fd, const char* s);
71 bool WriteFdExactly(int fd, const std::string& s);
74 bool WriteFdFmt(int fd, const char* fmt, ...) __attribute__((__format__(__printf__, 2, 3)));
Dshell_service.cpp113 int fd = adb_open("/proc/self/oom_score_adj", O_WRONLY | O_CLOEXEC); in init_subproc_child() local
114 if (fd >= 0) { in init_subproc_child()
115 adb_write(fd, "0", 1); in init_subproc_child()
116 adb_close(fd); in init_subproc_child()
123 std::string ReadAll(int fd) { in ReadAll() argument
128 int bytes = adb_read(fd, buffer, sizeof(buffer)); in ReadAll()
290 int fd; in ForkAndExec() local
291 pid_ = forkpty(&fd, pts_name, nullptr, nullptr); in ForkAndExec()
293 stdinout_sfd_.Reset(fd); in ForkAndExec()
324 dup2(child_stdinout_sfd.fd(), STDIN_FILENO); in ForkAndExec()
[all …]
Dsysdeps.h197 static __inline__ void close_on_exec(int fd) in close_on_exec() argument
217 extern int adb_read(int fd, void* buf, int len);
218 extern int adb_write(int fd, const void* buf, int len);
219 extern int adb_lseek(int fd, int pos, int where);
220 extern int adb_shutdown(int fd);
221 extern int adb_close(int fd);
224 static __inline__ int unix_close(int fd) in unix_close() argument
226 return close(fd); in unix_close()
232 extern int unix_read_interruptible(int fd, void* buf, size_t len);
235 static __inline__ int unix_read(int fd, void* buf, size_t len) { in unix_read() argument
[all …]
/system/core/libcutils/
Dashmem-dev.c54 int fd = TEMP_FAILURE_RETRY(open(ASHMEM_DEVICE, O_RDWR)); in __ashmem_open_locked() local
55 if (fd < 0) { in __ashmem_open_locked()
56 return fd; in __ashmem_open_locked()
59 ret = TEMP_FAILURE_RETRY(fstat(fd, &st)); in __ashmem_open_locked()
62 close(fd); in __ashmem_open_locked()
67 close(fd); in __ashmem_open_locked()
73 return fd; in __ashmem_open_locked()
78 int fd; in __ashmem_open() local
81 fd = __ashmem_open_locked(); in __ashmem_open()
84 return fd; in __ashmem_open()
[all …]
Dashmem-host.c45 int fd = mkstemp(template); in ashmem_create_region() local
46 if (fd == -1) return -1; in ashmem_create_region()
50 if (TEMP_FAILURE_RETRY(ftruncate(fd, size)) == -1) { in ashmem_create_region()
51 close(fd); in ashmem_create_region()
55 return fd; in ashmem_create_region()
58 int ashmem_set_prot_region(int fd __unused, int prot __unused) in ashmem_set_prot_region()
63 int ashmem_pin_region(int fd __unused, size_t offset __unused, size_t len __unused) in ashmem_pin_region()
68 int ashmem_unpin_region(int fd __unused, size_t offset __unused, size_t len __unused) in ashmem_unpin_region()
73 int ashmem_get_size_region(int fd) in ashmem_get_size_region() argument
76 int result = fstat(fd, &buf); in ashmem_get_size_region()
/system/core/libion/
Dion.c36 int fd = open("/dev/ion", O_RDWR); in ion_open() local
37 if (fd < 0) in ion_open()
39 return fd; in ion_open()
42 int ion_close(int fd) in ion_close() argument
44 int ret = close(fd); in ion_close()
50 static int ion_ioctl(int fd, int req, void *arg) in ion_ioctl() argument
52 int ret = ioctl(fd, req, arg); in ion_ioctl()
61 int ion_alloc(int fd, size_t len, size_t align, unsigned int heap_mask, in ion_alloc() argument
75 ret = ion_ioctl(fd, ION_IOC_ALLOC, &data); in ion_alloc()
82 int ion_free(int fd, ion_user_handle_t handle) in ion_free() 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/vold/
DLoop.cpp43 int fd; in dumpState() local
52 if ((fd = open(filename, O_RDWR | O_CLOEXEC)) < 0) { in dumpState()
61 rc = ioctl(fd, LOOP_GET_STATUS64, &li); in dumpState()
62 close(fd); in dumpState()
85 int fd; in lookupActive() local
96 if ((fd = open(filename, O_RDWR | O_CLOEXEC)) < 0) { in lookupActive()
105 rc = ioctl(fd, LOOP_GET_STATUS64, &li); in lookupActive()
107 close(fd); in lookupActive()
110 close(fd); in lookupActive()
132 int fd; in create() local
[all …]
DDevmapper.cpp57 int fd; in dumpState() local
58 if ((fd = open("/dev/device-mapper", O_RDWR | O_CLOEXEC)) < 0) { in dumpState()
68 if (ioctl(fd, DM_LIST_DEVICES, io)) { in dumpState()
72 close(fd); in dumpState()
80 close(fd); in dumpState()
91 if (ioctl(fd, DM_DEV_STATUS, io2)) { in dumpState()
113 close(fd); in dumpState()
140 int fd; in lookupActive() local
141 if ((fd = open("/dev/device-mapper", O_RDWR | O_CLOEXEC)) < 0) { in lookupActive()
150 if (ioctl(fd, DM_DEV_STATUS, io)) { in lookupActive()
[all …]
/system/core/trusty/libtrusty/tipc-test/
Dtipc_test.c191 int fd; in connect_foo() local
198 fd = tipc_connect(dev_name, "foo"); in connect_foo()
199 if (fd >= 0) { in connect_foo()
202 tipc_close(fd); in connect_foo()
217 int fd; in closer1_test() local
224 fd = tipc_connect(dev_name, closer1_name); in closer1_test()
225 if (fd < 0) { in closer1_test()
233 tipc_close(fd); in closer1_test()
246 int fd; in closer2_test() local
253 fd = tipc_connect(dev_name, closer2_name); in closer2_test()
[all …]
/system/extras/boot_control_copy/
Dbootinfo.c59 int fd; in boot_info_open_partition() local
105 fd = open(path, flags); in boot_info_open_partition()
109 if (fd != -1 && out_size != NULL) { in boot_info_open_partition()
110 if (ioctl(fd, BLKGETSIZE64, out_size) != 0) { in boot_info_open_partition()
111 close(fd); in boot_info_open_partition()
116 return fd; in boot_info_open_partition()
128 int fd; in boot_info_load() local
132 fd = boot_info_open_partition("misc", NULL, O_RDONLY); in boot_info_load()
133 if (fd == -1) in boot_info_load()
135 if (lseek(fd, BOOTINFO_OFFSET, SEEK_SET) != BOOTINFO_OFFSET) { in boot_info_load()
[all …]
/system/extras/ext4_utils/
Dext4fixup.c86 static int get_fs_fixup_state(int fd) in get_fs_fixup_state() argument
95 lseek64(fd, 0, SEEK_SET); in get_fs_fixup_state()
96 len = read(fd, &magic, sizeof(magic)); in get_fs_fixup_state()
117 static int set_fs_fixup_state(int fd, int state) in set_fs_fixup_state() argument
144 lseek64(fd, 0, SEEK_SET); in set_fs_fixup_state()
145 len = write(fd, &magic, sizeof(magic)); in set_fs_fixup_state()
150 read_sb(fd, &sb); in set_fs_fixup_state()
160 write_sb(fd, 1024, &sb); in set_fs_fixup_state()
166 static int read_inode(int fd, unsigned int inum, struct ext4_inode *inode) in read_inode() argument
178 if (lseek64(fd, inode_offset, SEEK_SET) < 0) { in read_inode()
[all …]
/system/bt/osi/src/
Dsemaphore.c40 int fd; member
45 ret->fd = eventfd(value, EFD_SEMAPHORE); in semaphore_new()
46 if (ret->fd == INVALID_FD) { in semaphore_new()
58 if (semaphore->fd != INVALID_FD) in semaphore_free()
59 close(semaphore->fd); in semaphore_free()
65 assert(semaphore->fd != INVALID_FD); in semaphore_wait()
68 if (eventfd_read(semaphore->fd, &value) == -1) in semaphore_wait()
74 assert(semaphore->fd != INVALID_FD); in semaphore_try_wait()
76 int flags = fcntl(semaphore->fd, F_GETFL); in semaphore_try_wait()
81 if (fcntl(semaphore->fd, F_SETFL, flags | O_NONBLOCK) == -1) { in semaphore_try_wait()
[all …]
Dsocket.c41 int fd; member
54 ret->fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); in socket_new()
55 if (ret->fd == INVALID_FD) { in socket_new()
61 if (setsockopt(ret->fd, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(enable)) == -1) { in socket_new()
70 close(ret->fd); in socket_new()
75 socket_t *socket_new_from_fd(int fd) { in socket_new_from_fd() argument
76 assert(fd != INVALID_FD); in socket_new_from_fd()
80 ret->fd = fd; in socket_new_from_fd()
89 close(socket->fd); in socket_free()
100 if (bind(socket->fd, (struct sockaddr *)&addr, sizeof(addr)) == -1) { in socket_listen()
[all …]
/system/core/base/
Dfile.cpp38 bool ReadFdToString(int fd, std::string* content) { in ReadFdToString() argument
43 while ((n = TEMP_FAILURE_RETRY(read(fd, &buf[0], sizeof(buf)))) > 0) { in ReadFdToString()
52 int fd = TEMP_FAILURE_RETRY(open(path.c_str(), O_RDONLY | O_CLOEXEC | O_NOFOLLOW | O_BINARY)); in ReadFileToString() local
53 if (fd == -1) { in ReadFileToString()
56 bool result = ReadFdToString(fd, content); in ReadFileToString()
57 close(fd); in ReadFileToString()
61 bool WriteStringToFd(const std::string& content, int fd) { in WriteStringToFd() argument
65 ssize_t n = TEMP_FAILURE_RETRY(write(fd, p, left)); in WriteStringToFd()
87 int fd = TEMP_FAILURE_RETRY(open(path.c_str(), flags, mode)); in WriteStringToFile() local
88 if (fd == -1) { in WriteStringToFile()
[all …]
/system/core/trusty/libtrusty/
Dtrusty.c32 int fd; in tipc_connect() local
35 fd = open(dev_name, O_RDWR); in tipc_connect()
36 if (fd < 0) { in tipc_connect()
43 rc = ioctl(fd, TIPC_IOC_CONNECT, srv_name); in tipc_connect()
48 close(fd); in tipc_connect()
52 ALOGV("%s: connected to \"%s\" fd %d\n", __func__, srv_name, fd); in tipc_connect()
53 return fd; in tipc_connect()
56 void tipc_close(int fd) in tipc_close() argument
58 close(fd); in tipc_close()
/system/update_engine/
Dtest_http_server.cc83 bool ParseRequest(int fd, HttpRequest* request) { in ParseRequest() argument
87 ssize_t r = read(fd, buf, sizeof(buf)); in ParseRequest()
160 ssize_t WriteString(int fd, const string& str) { in WriteString() argument
166 ssize_t written = write(fd, data, remaining_size); in WriteString()
180 ssize_t WriteHeaders(int fd, const off_t start_offset, const off_t end_offset, in WriteHeaders() argument
184 ret = WriteString(fd, in WriteHeaders()
199 ret = WriteString(fd, in WriteHeaders()
210 ret = WriteString(fd, string("Content-Length: ") + Itoa(content_length) + in WriteHeaders()
222 size_t WritePayload(int fd, const off_t start_offset, const off_t end_offset, in WritePayload() argument
248 ssize_t ret = WriteString(fd, partial); in WritePayload()
[all …]
/system/connectivity/shill/
Dfile_io.cc41 ssize_t FileIO::Write(int fd, const void* buf, size_t count) { in Write() argument
42 return HANDLE_EINTR(write(fd, buf, count)); in Write()
45 ssize_t FileIO::Read(int fd, void* buf, size_t count) { in Read() argument
46 return HANDLE_EINTR(read(fd, buf, count)); in Read()
49 int FileIO::Close(int fd) { in Close() argument
50 return IGNORE_EINTR(close(fd)); in Close()
53 int FileIO::SetFdNonBlocking(int fd) { in SetFdNonBlocking() argument
54 const int flags = HANDLE_EINTR(fcntl(fd, F_GETFL)) | O_NONBLOCK; in SetFdNonBlocking()
55 return HANDLE_EINTR(fcntl(fd, F_SETFL, flags)); in SetFdNonBlocking()

12345678910>>...28