Skip to Main Content

Infrastructure Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

kernel module code to get current and parent process information

ilanschJun 7 2017 — edited Jun 8 2017

In solaris 11.0 kernel module driver, I need to get the parent process id and start time, and continue doing it - climb up the process tree this way.

in Linux kernel I have struct_task contains process id, start time.

What is equivelant to struct_task, and how I can get it within process context ?

Thanks

I saw something like it in userspace code. but "open" cannot be used in kernel space..

    char psfile[64];

    pid_t pid;

    int fd;

    psinfo_t psinfo;

    pid = getpid();

    sprintf(psfile, "/proc/%d/psinfo", pid);

    if ((fd = open(psfile, O_RDONLY)) >= 0) {

    if (read(fd, &psinfo, sizeof(psinfo_t)) != -1) {

    printf("Pid: %ld\n", psinfo.pr_pid);

    printf("Up Start: (%ld, %ld)\n", psinfo.pr_start.tv_sec,

    psinfo.pr_start.tv_nsec);

    printf("Command: %s\n", psinfo.pr_fname);

    return 0;

    }

    } else {

    perror("Open psfino");

    }

the whole concept of /proc/procid/psinfo is to allow userspace processes to read kernel data. Why do i need to get the data from /proc/procid/psinfo if im on kernel space, this is disk IO...

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 6 2017
Added on Jun 7 2017
2 comments
1,149 views