MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / proc_pid

Function proc_pid

components/dfs/dfs_v2/filesystems/procfs/proc_pid.c:373–433  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

371};
372
373int proc_pid(int pid)
374{
375 char pid_str[64] = {0};
376 struct proc_dentry *dentry;
377
378 rt_snprintf(pid_str, 64, "%d", pid);
379 pid_str[63] = 0;
380
381 dentry = proc_mkdir(pid_str, 0);
382 if (dentry)
383 {
384 struct proc_dentry *ent;
385
386 dentry->pid = pid;
387 for (int j = 0; j < sizeof(pid_dentry_base) / sizeof(struct pid_dentry); j++)
388 {
389 if (S_ISDIR(pid_dentry_base[j].mode))
390 {
391 ent = proc_mkdir_data(pid_dentry_base[j].name, pid_dentry_base[j].mode, dentry,
392 pid_dentry_base[j].fops, pid_dentry_base[j].data);
393 }
394 else if (S_ISLNK(pid_dentry_base[j].mode))
395 {
396 if (pid_dentry_base[j].data == RT_NULL)
397 {
398 pid_dentry_base[j].data = "NULL";
399 }
400
401 ent = proc_symlink(pid_dentry_base[j].name, dentry, pid_dentry_base[j].data);
402 }
403 else
404 {
405 ent = proc_create_data(pid_dentry_base[j].name, pid_dentry_base[j].mode, dentry,
406 pid_dentry_base[j].fops, pid_dentry_base[j].data);
407 }
408
409 if (ent)
410 {
411 if (pid_dentry_base[j].ops)
412 {
413 ent->ops = pid_dentry_base[j].ops;
414 }
415
416 if (pid_dentry_base[j].seq_ops)
417 {
418 ent->seq_ops = pid_dentry_base[j].seq_ops;
419 }
420
421 if (pid_dentry_base[j].single_show)
422 {
423 ent->single_show = pid_dentry_base[j].single_show;
424 }
425
426 proc_release(ent);
427 }
428 }
429 proc_release(dentry);
430 }

Callers 2

lwp_pid_set_lwp_lockedFunction · 0.85
msh_proc_pidFunction · 0.85

Calls 6

rt_snprintfFunction · 0.85
proc_mkdirFunction · 0.85
proc_mkdir_dataFunction · 0.85
proc_symlinkFunction · 0.85
proc_create_dataFunction · 0.85
proc_releaseFunction · 0.85

Tested by

no test coverage detected