/system/core/adb/ |
D | adb_client.cpp | 49 static bool ReadProtocolString(int fd, std::string* s, std::string* error) { in ReadProtocolString() argument 51 if (!ReadFdExactly(fd, buf, 4)) { in ReadProtocolString() 59 if (!ReadFdExactly(fd, &(*s)[0], len)) { in ReadProtocolString() 113 static int switch_socket_transport(int fd, std::string* error) { in switch_socket_transport() argument 138 if (!SendProtocolString(fd, service)) { in switch_socket_transport() 140 adb_close(fd); in switch_socket_transport() 145 if (!adb_status(fd, error)) { in switch_socket_transport() 146 adb_close(fd); in switch_socket_transport() 154 bool adb_status(int fd, std::string* error) { in adb_status() argument 156 if (!ReadFdExactly(fd, buf, 4)) { in adb_status() [all …]
|
D | adb_io.cpp | 29 bool SendProtocolString(int fd, const std::string& s) { in SendProtocolString() argument 35 return WriteFdFmt(fd, "%04x", length) && WriteFdExactly(fd, s); in SendProtocolString() 38 bool SendOkay(int fd) { in SendOkay() argument 39 return WriteFdExactly(fd, "OKAY", 4); in SendOkay() 42 bool SendFail(int fd, const std::string& reason) { in SendFail() argument 43 return WriteFdExactly(fd, "FAIL", 4) && SendProtocolString(fd, reason); in SendFail() 46 bool ReadFdExactly(int fd, void* buf, size_t len) { in ReadFdExactly() argument 51 D("readx: fd=%d wanted=%zu\n", fd, len); in ReadFdExactly() 53 int r = adb_read(fd, p, len); in ReadFdExactly() 58 D("readx: fd=%d error %d: %s\n", fd, errno, strerror(errno)); in ReadFdExactly() [all …]
|
D | adb_io_test.cpp | 36 if (fd == -1) { in TemporaryFile() 42 close(fd); in ~TemporaryFile() 46 int fd; member in TemporaryFile 52 fd = mkstemp(filename); in init() 59 ASSERT_NE(-1, tf.fd); in TEST() 61 ASSERT_TRUE(android::base::WriteStringToFd(expected, tf.fd)) << strerror(errno); in TEST() 62 ASSERT_EQ(0, lseek(tf.fd, SEEK_SET, 0)); in TEST() 66 ASSERT_TRUE(ReadFdExactly(tf.fd, buf, sizeof(buf) - 1)) << strerror(errno); in TEST() 73 ASSERT_NE(-1, tf.fd); in TEST() 75 ASSERT_TRUE(android::base::WriteStringToFd(expected, tf.fd)) << strerror(errno); in TEST() [all …]
|
D | set_verity_enable_state_service.cpp | 44 static int get_target_device_size(int fd, const char *blk_device, in get_target_device_size() argument 55 WriteFdFmt(fd, "Error opening block device (%s)\n", strerror(errno)); in get_target_device_size() 60 WriteFdFmt(fd, "Error seeking to superblock\n"); in get_target_device_size() 66 WriteFdFmt(fd, "Error reading superblock\n"); in get_target_device_size() 79 static int set_verity_enabled_state(int fd, const char *block_device, in set_verity_enabled_state() argument 90 WriteFdFmt(fd, "Could not make block device %s writable (%s).\n", in set_verity_enabled_state() 97 WriteFdFmt(fd, "Could not open block device %s (%s).\n", block_device, strerror(errno)); in set_verity_enabled_state() 98 WriteFdFmt(fd, "Maybe run adb remount?\n"); in set_verity_enabled_state() 103 if (get_target_device_size(fd, (char*)block_device, &device_length) < 0) { in set_verity_enabled_state() 104 WriteFdFmt(fd, "Could not get target device size.\n"); in set_verity_enabled_state() [all …]
|
D | remount_service.cpp | 54 int fd = unix_open(dev.c_str(), O_RDONLY | O_CLOEXEC); in make_block_device_writable() local 55 if (fd == -1) { in make_block_device_writable() 60 bool result = (ioctl(fd, BLKROSET, &OFF) != -1); in make_block_device_writable() 61 adb_close(fd); in make_block_device_writable() 65 static bool remount_partition(int fd, const char* dir) { in remount_partition() argument 74 WriteFdFmt(fd, "remount of %s failed; couldn't make block device %s writable: %s\n", in remount_partition() 79 WriteFdFmt(fd, "remount of %s failed: %s\n", dir, strerror(errno)); in remount_partition() 85 void remount_service(int fd, void* cookie) { in remount_service() argument 87 WriteFdExactly(fd, "Not running as root. Try \"adb root\" first.\n"); in remount_service() 88 adb_close(fd); in remount_service() [all …]
|
D | sysdeps.h | 102 static __inline__ void close_on_exec(int fd) in close_on_exec() argument 136 extern int adb_read(int fd, void* buf, int len); 137 extern int adb_write(int fd, const void* buf, int len); 138 extern int adb_lseek(int fd, int pos, int where); 139 extern int adb_shutdown(int fd); 140 extern int adb_close(int fd); 142 static __inline__ int unix_close(int fd) in unix_close() argument 144 return close(fd); in unix_close() 149 extern int unix_read(int fd, void* buf, size_t len); 154 static __inline__ int unix_write(int fd, const void* buf, size_t len) in unix_write() argument [all …]
|
D | console.cpp | 8 int fd, port; in connect_to_console() local 18 fd = socket_loopback_client( port, SOCK_STREAM ); in connect_to_console() 19 if (fd < 0) { in connect_to_console() 23 return fd; in connect_to_console() 29 int fd, nn; in adb_send_emulator_command() local 31 fd = connect_to_console(); in adb_send_emulator_command() 32 if (fd < 0) in adb_send_emulator_command() 38 adb_write( fd, argv[nn], strlen(argv[nn]) ); in adb_send_emulator_command() 39 adb_write( fd, (nn == argc-1) ? "\n" : " ", 1 ); in adb_send_emulator_command() 41 adb_write( fd, QUIT, sizeof(QUIT)-1 ); in adb_send_emulator_command() [all …]
|
D | services.cpp | 50 void (*func)(int fd, void *cookie); 51 int fd; member 59 sti->func(sti->fd, sti->cookie); in service_bootstrap_func() 66 void restart_root_service(int fd, void *cookie) { in restart_root_service() argument 68 WriteFdExactly(fd, "adbd is already running as root\n"); in restart_root_service() 69 adb_close(fd); in restart_root_service() 74 WriteFdExactly(fd, "adbd cannot run as root in production builds\n"); in restart_root_service() 75 adb_close(fd); in restart_root_service() 80 WriteFdExactly(fd, "restarting adbd as root\n"); in restart_root_service() 81 adb_close(fd); in restart_root_service() [all …]
|
D | transport_local.cpp | 93 int fd = -1; in local_connect_arbitrary_ports() local 98 fd = socket_network_client(host, adb_port, SOCK_STREAM); in local_connect_arbitrary_ports() 101 if (fd < 0) { in local_connect_arbitrary_ports() 102 fd = socket_loopback_client(adb_port, SOCK_STREAM); in local_connect_arbitrary_ports() 105 if (fd >= 0) { in local_connect_arbitrary_ports() 106 D("client: connected on remote on fd %d\n", fd); in local_connect_arbitrary_ports() 107 close_on_exec(fd); in local_connect_arbitrary_ports() 108 disable_tcp_nagle(fd); in local_connect_arbitrary_ports() 110 register_socket_transport(fd, serial.c_str(), adb_port, 1); in local_connect_arbitrary_ports() 137 int serverfd, fd; in server_socket_thread() local [all …]
|
D | fdevent.cpp | 63 fprintf(stderr,"FDE #%03d %c%c%c %s\n", fde->fd, in dump_fde() 84 static void fdevent_subproc_event_func(int fd, unsigned events, void *userdata); 89 .fd = -1, 130 if(epoll_ctl(epoll_fd, EPOLL_CTL_ADD, fde->fd, &ev)) { in fdevent_connect() 150 epoll_ctl(epoll_fd, EPOLL_CTL_DEL, fde->fd, &ev); in fdevent_disconnect() 176 if(epoll_ctl(epoll_fd, EPOLL_CTL_MOD, fde->fd, &ev)) { in fdevent_update() 181 if(epoll_ctl(epoll_fd, EPOLL_CTL_DEL, fde->fd, &ev)) { in fdevent_update() 191 if(epoll_ctl(epoll_fd, EPOLL_CTL_ADD, fde->fd, &ev)) { in fdevent_update() 257 if(fde->fd >= select_n) { in fdevent_connect() 258 select_n = fde->fd + 1; in fdevent_connect() [all …]
|
D | file_sync_service.cpp | 181 int fd; in handle_send_file() local 183 fd = adb_open_mode(path, O_WRONLY | O_CREAT | O_EXCL | O_CLOEXEC, mode); in handle_send_file() 184 if(fd < 0 && errno == ENOENT) { in handle_send_file() 188 fd = -1; in handle_send_file() 190 fd = adb_open_mode(path, O_WRONLY | O_CREAT | O_EXCL | O_CLOEXEC, mode); in handle_send_file() 193 if(fd < 0 && errno == EEXIST) { in handle_send_file() 194 fd = adb_open_mode(path, O_WRONLY | O_CLOEXEC, mode); in handle_send_file() 196 if(fd < 0) { in handle_send_file() 199 fd = -1; in handle_send_file() 201 if(fchown(fd, uid, gid) != 0) { in handle_send_file() [all …]
|
D | file_sync_client.cpp | 82 void sync_quit(int fd) in sync_quit() argument 89 WriteFdExactly(fd, &msg.req, sizeof(msg.req)); in sync_quit() 94 int sync_ls(int fd, const char *path, sync_ls_cb func, void *cookie) in sync_ls() argument 106 if(!WriteFdExactly(fd, &msg.req, sizeof(msg.req)) || in sync_ls() 107 !WriteFdExactly(fd, path, len)) { in sync_ls() 112 if(!ReadFdExactly(fd, &msg.dent, sizeof(msg.dent))) break; in sync_ls() 119 if(!ReadFdExactly(fd, buf, len)) break; in sync_ls() 129 adb_close(fd); in sync_ls() 141 int sync_readtime(int fd, const char *path, unsigned int *timestamp, in sync_readtime() argument 150 if(!WriteFdExactly(fd, &msg.req, sizeof(msg.req)) || in sync_readtime() [all …]
|
D | adb_io.h | 25 bool SendOkay(int fd); 28 bool SendFail(int fd, const std::string& reason); 31 bool SendProtocolString(int fd, const std::string& s); 41 bool ReadFdExactly(int fd, void *buf, size_t len); 50 bool WriteFdExactly(int fd, const void* buf, size_t len); 53 bool WriteFdExactly(int fd, const char* s); 54 bool WriteFdExactly(int fd, const std::string& s); 57 bool WriteFdFmt(int fd, const char* fmt, ...) __attribute__((__format__(__printf__, 2, 3)));
|
/system/core/libion/ |
D | ion.c | 36 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 …]
|
D | ion_test.c | 41 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/core/libcutils/ |
D | ashmem-dev.c | 44 int fd, ret; in ashmem_create_region() local 46 fd = open(ASHMEM_DEVICE, O_RDWR); in ashmem_create_region() 47 if (fd < 0) in ashmem_create_region() 48 return fd; in ashmem_create_region() 54 ret = ioctl(fd, ASHMEM_SET_NAME, buf); in ashmem_create_region() 59 ret = ioctl(fd, ASHMEM_SET_SIZE, size); in ashmem_create_region() 63 return fd; in ashmem_create_region() 66 close(fd); in ashmem_create_region() 70 int ashmem_set_prot_region(int fd, int prot) in ashmem_set_prot_region() argument 72 return ioctl(fd, ASHMEM_SET_PROT_MASK, prot); in ashmem_set_prot_region() [all …]
|
D | ashmem-host.c | 45 int fd = mkstemp(template); in ashmem_create_region() local 46 if (fd != -1 && TEMP_FAILURE_RETRY(ftruncate(fd, size)) != -1 && unlink(template) != -1) { in ashmem_create_region() 47 return fd; in ashmem_create_region() 49 close(fd); in ashmem_create_region() 53 int ashmem_set_prot_region(int fd __unused, int prot __unused) in ashmem_set_prot_region() 58 int ashmem_pin_region(int fd __unused, size_t offset __unused, size_t len __unused) in ashmem_pin_region() 63 int ashmem_unpin_region(int fd __unused, size_t offset __unused, size_t len __unused) in ashmem_unpin_region() 68 int ashmem_get_size_region(int fd) in ashmem_get_size_region() argument 71 int result = fstat(fd, &buf); in ashmem_get_size_region()
|
/system/vold/ |
D | Loop.cpp | 43 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() 106 close(fd); in lookupActive() 131 int fd; in create() local 171 if ((fd = open(filename, O_RDWR | O_CLOEXEC)) < 0) { in create() [all …]
|
D | Devmapper.cpp | 57 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/base/ |
D | file.cpp | 34 bool ReadFdToString(int fd, std::string* content) { in ReadFdToString() argument 39 while ((n = TEMP_FAILURE_RETRY(read(fd, &buf[0], sizeof(buf)))) > 0) { in ReadFdToString() 48 int fd = in ReadFileToString() local 50 if (fd == -1) { in ReadFileToString() 53 bool result = ReadFdToString(fd, content); in ReadFileToString() 54 close(fd); in ReadFileToString() 58 bool WriteStringToFd(const std::string& content, int fd) { in WriteStringToFd() argument 62 ssize_t n = TEMP_FAILURE_RETRY(write(fd, p, left)); in WriteStringToFd() 83 int fd = TEMP_FAILURE_RETRY( in WriteStringToFile() local 86 if (fd == -1) { in WriteStringToFile() [all …]
|
/system/bt/osi/src/ |
D | semaphore.c | 38 int fd; member 44 ret->fd = eventfd(value, EFD_SEMAPHORE); in semaphore_new() 45 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 = TEMP_FAILURE_RETRY(fcntl(semaphore->fd, F_GETFL)); in semaphore_try_wait() 81 if (TEMP_FAILURE_RETRY(fcntl(semaphore->fd, F_SETFL, flags | O_NONBLOCK)) == -1) { in semaphore_try_wait() [all …]
|
D | socket.c | 41 int fd; member 58 ret->fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); in socket_new() 59 if (ret->fd == INVALID_FD) { in socket_new() 65 if (setsockopt(ret->fd, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(enable)) == -1) { in socket_new() 74 close(ret->fd); in socket_new() 79 socket_t *socket_new_from_fd(int fd) { in socket_new_from_fd() argument 80 assert(fd != INVALID_FD); in socket_new_from_fd() 88 ret->fd = fd; in socket_new_from_fd() 97 close(socket->fd); in socket_free() 108 if (bind(socket->fd, (struct sockaddr *)&addr, sizeof(addr)) == -1) { in socket_listen() [all …]
|
/system/extras/ext4_utils/ |
D | ext4fixup.c | 86 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/core/init/ |
D | util.cpp | 95 int fd, ret; in create_socket() local 101 fd = socket(PF_UNIX, type, 0); in create_socket() 102 if (fd < 0) { in create_socket() 128 ret = bind(fd, (struct sockaddr *) &addr, sizeof (addr)); in create_socket() 143 return fd; in create_socket() 148 close(fd); in create_socket() 155 int fd = TEMP_FAILURE_RETRY(open(path, O_RDONLY|O_NOFOLLOW|O_CLOEXEC)); in read_file() local 156 if (fd == -1) { in read_file() 163 if (fstat(fd, &sb) == -1) { in read_file() 172 bool okay = android::base::ReadFdToString(fd, content); in read_file() [all …]
|
/system/extras/tests/iptables/qtaguid/ |
D | socketTag.cpp | 42 SockInfo() : fd(-1), addr(NULL) {}; in SockInfo() 45 int fd; member in android::SockInfo 102 fd = socket(AF_INET, SOCK_STREAM, 0); in setup() 103 if (fd < 0) { in setup() 107 if (doCtrlCommand("t %d %" PRIu64, fd, tag) < 0) { in setup() 109 close(fd); in setup() 114 close(fd); in setup() 117 if (doCtrlCommand("u %d", fd) < 0) { in setup() 119 close(fd); in setup() 268 EXPECT_GE(doCtrlCommand("t %d %" PRIu64 " %u", sock0.fd, tag , fake_uid2), 0) in TEST_F() [all …]
|