Lines Matching refs:info
72 static void print_type(char *type, struct pid_info_t* info) in print_type() argument
77 strlcat(info->path, type, sizeof(info->path)); in print_type()
78 if ((link_dest_size = readlink(info->path, link_dest, sizeof(link_dest)-1)) < 0) { in print_type()
82 snprintf(link_dest, sizeof(link_dest), "%s (readlink: %s)", info->path, strerror(errno)); in print_type()
92 info->cmdline, info->pid, info->user, type, in print_type()
96 info->path[info->parent_length] = '\0'; in print_type()
100 static void print_maps(struct pid_info_t* info) in print_maps() argument
108 strlcat(info->path, "maps", sizeof(info->path)); in print_maps()
110 maps = fopen(info->path, "r"); in print_maps()
121 info->cmdline, info->pid, info->user, "mem", in print_maps()
128 info->path[info->parent_length] = '\0'; in print_maps()
132 static void print_fds(struct pid_info_t* info) in print_fds() argument
135 strlcat(info->path, fd_path, sizeof(info->path)); in print_fds()
137 int previous_length = info->parent_length; in print_fds()
138 info->parent_length += strlen(fd_path); in print_fds()
140 DIR *dir = opendir(info->path); in print_fds()
143 snprintf(msg, sizeof(msg), "%s (opendir: %s)", info->path, strerror(errno)); in print_fds()
145 info->cmdline, info->pid, info->user, "FDS", in print_fds()
155 print_type(de->d_name, info); in print_fds()
160 info->parent_length = previous_length; in print_fds()
161 info->path[info->parent_length] = '\0'; in print_fds()
167 struct pid_info_t info; in lsof_dumpinfo() local
171 info.pid = pid; in lsof_dumpinfo()
172 snprintf(info.path, sizeof(info.path), "/proc/%d/", pid); in lsof_dumpinfo()
173 info.parent_length = strlen(info.path); in lsof_dumpinfo()
176 if (!stat(info.path, &pidstat)) { in lsof_dumpinfo()
179 strlcpy(info.user, pw->pw_name, sizeof(info.user)); in lsof_dumpinfo()
181 snprintf(info.user, USER_DISPLAY_MAX, "%d", (int)pidstat.st_uid); in lsof_dumpinfo()
184 strcpy(info.user, "???"); in lsof_dumpinfo()
188 strlcat(info.path, "cmdline", sizeof(info.path)); in lsof_dumpinfo()
189 fd = open(info.path, O_RDONLY); in lsof_dumpinfo()
191 fprintf(stderr, "Couldn't read %s\n", info.path); in lsof_dumpinfo()
200 fprintf(stderr, "Error reading cmdline: %s: %s\n", info.path, strerror(errno)); in lsof_dumpinfo()
207 strlcpy(info.cmdline, basename(cmdline), sizeof(info.cmdline)); in lsof_dumpinfo()
210 print_type("cwd", &info); in lsof_dumpinfo()
211 print_type("exe", &info); in lsof_dumpinfo()
212 print_type("root", &info); in lsof_dumpinfo()
214 print_fds(&info); in lsof_dumpinfo()
215 print_maps(&info); in lsof_dumpinfo()