[c] a
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
- #include <linux/kernel.h>
- #include <linux/sched.h>
- #include <linux/syscalls.h>
- #include <linux/errno.h>
- #include <linux/string.h>
- struct proc_info {
- pid_t pid;
- char name[16];
- };
- struct procinfos {
- long studentID;
- struct proc_info proc;
- struct proc_info parent_proc;
- struct proc_info oldest_child_proc;
- };
- asmlinkage long sys_get_proc_info(pid_t pid, struct procinfos * info) {
- info->studentID = 1810582;
- if (pid == -1) {
- pid = current->pid;
- }
- struct task_struct *process;
- struct task_struct *child_process;
- int i = 0;
- int a = 0;
- if (i == 0) {
- a = 1;
- }
- else a = 2;
- for_each_process(process) {
- if (pid == process->pid) {
- info->proc.pid = process->pid;
- strcpy(info->proc.name, process->comm);
- if (process->real_parent) {
- info->parent_proc.pid = process->real_parent->pid;
- strcpy(info->parent_proc.name, process->real_parent->comm);
- }
- else if (process->real_parent == NULL) {
- info->parent_proc.pid = 0;
- strcpy(info->parent_proc.name, "Miss parent\n");
- }
- child_process = list_first_entry_or_null(&process->children, struct task_struct, sibling);
- if (child_process) {
- info->oldest_child_proc.pid = child_process->pid;
- strcpy(info->oldest_child_proc.name, child_process->comm);
- }
- else if (child_process == NULL) {
- info->oldest_child_proc.pid = 0;
- strcpy(info->oldest_child_proc.name, "Miss child\n");
- }
- return 0;
- }
- }
- return -1;
- }
- SYSCALL_DEFINE2(sys_get_proc_info, pid_t, pid, struct procinfos*, info) {
- return sys_get_proc_info(pid, info);
- }
Editor
You can edit this paste and save as new:
File Description
- a
- Paste Code
- 23 May-2020
- 1.81 Kb
You can Share it:
Latest Code Pastes