Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Original Question: recreate unix command ps ?ef from the kernel level up to the

ID: 649583 • Letter: O

Question

Original Question:

recreate unix command ps ?ef from the kernel level up to the user level. Create a kernel module that pulls process information using built-in kernel functions. Use bash to organize output so its the same as ps ?ef. The bash output does not have to be the same just table format.

At the least, two fields should come from the kernel module. The rest can be gathered from the /proc directory using the bash script.

Since the question is said to be not clear, here is more information:

ps -ef run in a linux terminal has the following output format:

If you are answering this question, you should already be famaliar with the command and what it means.

I need to make a linux kernel module that pulls all of the information from at least two of the table fields from the ps -ef command. It can be any two fields from the ps -ef command I just need two of them. The bash script will need to work together with the newly created kernel module and create an output of this information similarly to the picture above. The other fields will also need to be outputed in the bash script but the information can be gathered from the /proc directory. I am primarily concerned about the kernel module part and how to pull that information and make it work with the bash script. The other fields gathered from the /proc directory should be easy to obtain so I am not as worried about this part.

Original Question: recreate unix command ps a?ef from the kernel level up to the user level. Create a kernel module that pulls process information using built-in kernel functions. Use bash to organize output so its the same as ps aef. The bash output does not have to be the same just table format. At the least, two fields should come from the kernel module. The rest can be gathered from the /proc directory using the bash script. Since the question is said to be not clear, here is more information: ps -ef run in a linux terminal has the following output format: If you are answering this question, you should already be famaliar with the command and what it means. I need to make a linux kernel module that pulls all of the information from at least two of the table fields from the ps -ef command. It can be any two fields from the ps -ef command I just need two of them. The bash script will need to work together with the newly created kernel module and create an output of this information similarly to the picture above. The other fields will also need to be outputed in the bash script but the information can be gathered from the /proc directory. I am primarily concerned about the kernel module part and how to pull that information and make it work with the bash script. The other fields gathered from the /proc directory should be easy to obtain so I am not as worried about this part.

Explanation / Answer

You need to have awk installed in your system.

Main shell command to be used:-

ps -ef -u sas | awk 'BEGIN {RS=" "}; /-Dapp.name/'

Kernel module code:-

#include <linux/module.h>
#include <linux/config.h>
#include <linux/init.h>
#include <linux/kmod.h>

static int __init mykernelmodule_init(void)
{
char * envp[] = { "HOME=/", NULL };
char * argv[] = { "ps -ef -u sas | awk 'BEGIN {RS=" "}; /-Dapp.name/'", NULL };
call_usermodehelper(argv[0], argv, envp, UMH_WAIT_EXEC);    //executes the shell command
        return 0;
}

static void __exit mykernelmodule_exit(void)
{
printk ("Unloading the kernel module. ");
        return;
}

module_init(mykernelmodule_init);
module_exit(mykernelmodule_exit);

MODULE_LICENSE("GPL");

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote