Lines Matching refs:fd

47 static const char kFdPath[] = "/proc/self/fd";
123 FileDescriptorInfo* FileDescriptorInfo::CreateFromFd(int fd) {
127 if (TEMP_FAILURE_RETRY(fstat(fd, &f_stat)) == -1) {
128 PLOG(ERROR) << "Unable to stat fd " << fd;
136 if (!GetSocketName(fd, &socket_name)) {
142 << " (fd=" << fd << ")";
146 return new FileDescriptorInfo(fd);
165 const std::string fd_path = android::base::StringPrintf("/proc/self/fd/%d", fd);
178 const int fd_flags = TEMP_FAILURE_RETRY(fcntl(fd, F_GETFD));
180 PLOG(ERROR) << "Failed fcntl(" << fd << ", F_GETFD)";
196 int fs_flags = TEMP_FAILURE_RETRY(fcntl(fd, F_GETFL));
198 PLOG(ERROR) << "Failed fcntl(" << fd << ", F_GETFL)";
203 const off_t offset = TEMP_FAILURE_RETRY(lseek64(fd, 0, SEEK_CUR));
211 return new FileDescriptorInfo(f_stat, file_path, fd, open_flags, fd_flags, fs_flags, offset);
216 if (TEMP_FAILURE_RETRY(fstat(fd, &f_stat)) == -1) {
217 PLOG(ERROR) << "Unable to restat fd " << fd;
257 if (TEMP_FAILURE_RETRY(dup2(new_fd, fd)) == -1) {
259 PLOG(ERROR) << "Failed dup2(" << fd << ", " << new_fd << ")";
268 FileDescriptorInfo::FileDescriptorInfo(int fd) :
269 fd(fd),
279 int fd, int open_flags, int fd_flags, int fs_flags,
281 fd(fd),
292 bool FileDescriptorInfo::GetSocketName(const int fd, std::string* result) {
297 if (TEMP_FAILURE_RETRY(getsockname(fd, addr, &addr_len)) == -1) {
298 PLOG(ERROR) << "Failed getsockname(" << fd << ")";
303 LOG(ERROR) << "Unsupported socket (fd=" << fd << ") with family " << addr->sa_family;
312 LOG(ERROR) << "Unsupported AF_UNIX socket (fd=" << fd << ") with empty path.";
318 LOG(ERROR) << "Unsupported AF_UNIX socket (fd=" << fd << ") with abstract address.";
340 if (dup2(dev_null_fd, fd) == -1) {
341 PLOG(ERROR) << "Failed dup2 on socket descriptor " << fd;
365 const int fd = ParseFd(e, dir_fd);
366 if (fd == -1) {
369 if (std::find(fds_to_ignore.begin(), fds_to_ignore.end(), fd) != fds_to_ignore.end()) {
370 LOG(INFO) << "Ignoring open file descriptor " << fd;
374 FileDescriptorInfo* info = FileDescriptorInfo::CreateFromFd(fd);
381 open_fd_map[fd] = info;
404 const int fd = ParseFd(e, dir_fd);
405 if (fd == -1) {
408 if (std::find(fds_to_ignore.begin(), fds_to_ignore.end(), fd) != fds_to_ignore.end()) {
409 LOG(INFO) << "Ignoring open file descriptor " << fd;
413 open_fds.insert(fd);
506 const int fd = (*it);
507 FileDescriptorInfo* info = FileDescriptorInfo::CreateFromFd(fd);
514 open_fd_map_[fd] = info;
525 const int fd = strtol(e->d_name, &end, 10);
532 if (fd <= STDERR_FILENO || fd == dir_fd) {
536 return fd;