GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — add proc_pid_status · magicjva/SKRoot-linuxKernelRoot@2b3b6b4

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • find_kernel_func
    • Linux内核源码摘录.cpp
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎find_kernel_func/Linux内核源码摘录.cpp‎

Copy file name to clipboardExpand all lines: find_kernel_func/Linux内核源码摘录.cpp
+118-1Lines changed: 118 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1682,4 +1682,121 @@ static int __ref kernel_init(void *unused)
16821682

16831683
panic("No working init found. Try passing init= option to kernel. "
16841684
"See Linux Documentation/admin-guide/init.rst for guidance.");
1685-
}
1685+
}
1686+
1687+
const struct cred *get_task_cred(struct task_struct *task)
1688+
{
1689+
const struct cred *cred;
1690+
1691+
rcu_read_lock();
1692+
1693+
do {
1694+
cred = __task_cred((task));
1695+
BUG_ON(!cred);
1696+
} while (!get_cred_rcu(cred));
1697+
1698+
rcu_read_unlock();
1699+
return cred;
1700+
}
1701+
EXPORT_SYMBOL(get_task_cred);
1702+
static inline void task_state(struct seq_file *m, struct pid_namespace *ns,
1703+
struct pid *pid, struct task_struct *p)
1704+
{
1705+
struct user_namespace *user_ns = seq_user_ns(m);
1706+
struct group_info *group_info;
1707+
int g, umask = -1;
1708+
struct task_struct *tracer;
1709+
const struct cred *cred;
1710+
pid_t ppid, tpid = 0, tgid, ngid;
1711+
unsigned int max_fds = 0;
1712+
1713+
rcu_read_lock();
1714+
ppid = pid_alive(p) ?
1715+
task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0;
1716+
1717+
tracer = ptrace_parent(p);
1718+
if (tracer)
1719+
tpid = task_pid_nr_ns(tracer, ns);
1720+
1721+
tgid = task_tgid_nr_ns(p, ns);
1722+
ngid = task_numa_group_id(p);
1723+
cred = get_task_cred(p);
1724+
1725+
task_lock(p);
1726+
if (p->fs)
1727+
umask = p->fs->umask;
1728+
if (p->files)
1729+
max_fds = files_fdtable(p->files)->max_fds;
1730+
task_unlock(p);
1731+
rcu_read_unlock();
1732+
1733+
if (umask >= 0)
1734+
seq_printf(m, "Umask:\t%#04o\n", umask);
1735+
seq_puts(m, "State:\t");
1736+
seq_puts(m, get_task_state(p));
1737+
1738+
seq_put_decimal_ull(m, "\nTgid:\t", tgid);
1739+
seq_put_decimal_ull(m, "\nNgid:\t", ngid);
1740+
seq_put_decimal_ull(m, "\nPid:\t", pid_nr_ns(pid, ns));
1741+
seq_put_decimal_ull(m, "\nPPid:\t", ppid);
1742+
seq_put_decimal_ull(m, "\nTracerPid:\t", tpid);
1743+
seq_put_decimal_ull(m, "\nUid:\t", from_kuid_munged(user_ns, cred->uid));
1744+
seq_put_decimal_ull(m, "\t", from_kuid_munged(user_ns, cred->euid));
1745+
seq_put_decimal_ull(m, "\t", from_kuid_munged(user_ns, cred->suid));
1746+
seq_put_decimal_ull(m, "\t", from_kuid_munged(user_ns, cred->fsuid));
1747+
seq_put_decimal_ull(m, "\nGid:\t", from_kgid_munged(user_ns, cred->gid));
1748+
seq_put_decimal_ull(m, "\t", from_kgid_munged(user_ns, cred->egid));
1749+
seq_put_decimal_ull(m, "\t", from_kgid_munged(user_ns, cred->sgid));
1750+
seq_put_decimal_ull(m, "\t", from_kgid_munged(user_ns, cred->fsgid));
1751+
seq_put_decimal_ull(m, "\nFDSize:\t", max_fds);
1752+
1753+
seq_puts(m, "\nGroups:\t");
1754+
group_info = cred->group_info;
1755+
for (g = 0; g < group_info->ngroups; g++)
1756+
seq_put_decimal_ull(m, g ? " " : "",
1757+
from_kgid_munged(user_ns, group_info->gid[g]));
1758+
put_cred(cred);
1759+
/* Trailing space shouldn't have been added in the first place. */
1760+
seq_putc(m, ' ');
1761+
1762+
#ifdef CONFIG_PID_NS
1763+
seq_puts(m, "\nNStgid:");
1764+
for (g = ns->level; g <= pid->level; g++)
1765+
seq_put_decimal_ull(m, "\t", task_tgid_nr_ns(p, pid->numbers[g].ns));
1766+
seq_puts(m, "\nNSpid:");
1767+
for (g = ns->level; g <= pid->level; g++)
1768+
seq_put_decimal_ull(m, "\t", task_pid_nr_ns(p, pid->numbers[g].ns));
1769+
seq_puts(m, "\nNSpgid:");
1770+
for (g = ns->level; g <= pid->level; g++)
1771+
seq_put_decimal_ull(m, "\t", task_pgrp_nr_ns(p, pid->numbers[g].ns));
1772+
seq_puts(m, "\nNSsid:");
1773+
for (g = ns->level; g <= pid->level; g++)
1774+
seq_put_decimal_ull(m, "\t", task_session_nr_ns(p, pid->numbers[g].ns));
1775+
#endif
1776+
seq_putc(m, '\n');
1777+
}
1778+
int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
1779+
struct pid *pid, struct task_struct *task)
1780+
{
1781+
struct mm_struct *mm = get_task_mm(task);
1782+
1783+
seq_puts(m, "Name:\t");
1784+
proc_task_name(m, task, true);
1785+
seq_putc(m, '\n');
1786+
1787+
task_state(m, ns, pid, task);
1788+
1789+
if (mm) {
1790+
task_mem(m, mm);
1791+
task_core_dumping(m, mm);
1792+
task_thp_status(m, mm);
1793+
mmput(mm);
1794+
}
1795+
task_sig(m, task);
1796+
task_cap(m, task);
1797+
task_seccomp(m, task);
1798+
task_cpus_allowed(m, task);
1799+
cpuset_task_status_allowed(m, task);
1800+
task_context_switch_counts(m, task);
1801+
return 0;
1802+
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.