subject

At this point xv6 has no concept of users or groups. You will begin to add this feature to xv6 by adding a uid and gidfield to the process structure, where you will track process ownership. These will be of type unsigned int since negative UIDs and GIDs make no sense in this context. Note that when these values are passed into the kernel, they will be taken off the stack as "int"s. There is no issue with this as you will convert them to unsigned ints immediately. It is, however, critical, that the function prototypes in user. h declare values as unsigned as you will see below.
The ppid is the "parent process identifier" or parent PID. The proc structure does not need a ppid field as the parent can, and should, be determined on-the-fly. Look carefully at the existing proc structure in proc. h to see what is needed.
Note: that the init process is a special case as it has no parent. Your code must account for any process whose parent pointer is NULL. For any such pointer, you will display the PPID to be the same as the process PID. Do not modify a parent pointer that is set to NULL; leave it that way as it becomes important in a later project.
You will need to add the following system calls:
uint getuid( void ) // UID of the current process
uint getgid( void ) // GID of the current process
uint getppid( void ) // PPID of the current process
int setuid ( uint ) // set UID
int setgid ( uint ) // set GID
Your kernel code cannot assume that arguments passed into the kernel are valid and so your kernel code must check the values for the correct range. The uid and gid fields in the process structure may only take on values 0 <= value <= 32767. You are required to provide tests that show this bound being enforced by the kernel-side implementation of the system calls.
The following code is a starting point for writing a test program that demonstrates the correct functioning of your new system calls. This example is missing several important tests and fails to check return codes, which is very bad programming. You should fix the shortcomings of this code or write a new test program that properly demonstrates correct functionality for all test cases.
int main ( void )
{
uint uid, gid, ppid;
uid = getuid();
printf( 2 , " Current UID is: %d\n", uid );
printf( 2 , " Setting UID to 100\ n" );
setuid (100);
uid = getuid ();
printf( 2 , " Current UID is: %d\n", uid );
gid = getgid() ;
printf( 2 , " Current GID is: %d\n", gid );
printf( 2 , " Setting GID to 100\ n" );
setuid (100);
gid = getgid();
printf( 2 , " Current GID is: %d\n", gid );
ppid = getppid();
printf( 2 , "My parent process is: %d\n", ppid );
printf( 2 , "Done!\n" );
exit();
}

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 20:50
What does operator overloading allow you to do?
Answers: 2
question
Computers and Technology, 22.06.2019 01:30
What “old fashioned” features of checking accounts is p2p replacing
Answers: 3
question
Computers and Technology, 23.06.2019 00:30
Which one of the following is the most accurate definition of technology? a electronic tools that improve functionality b electronic tools that provide entertainment or practical value c any type of tool that serves a practical function d any type of tool that enhances communication
Answers: 1
question
Computers and Technology, 23.06.2019 08:00
Michael has written an e-mail to his employees that describes a new product special that will be introduced to the customers next week. by taking time to make sure the e-mail is well written, logical, and organized, michael has made sure his message has the characteristics of a) effective communicationb) ineffective communicationc) barriers to communicationd) workplace communication
Answers: 2
You know the right answer?
At this point xv6 has no concept of users or groups. You will begin to add this feature to xv6 by ad...
Questions
question
Mathematics, 18.12.2020 06:50
question
Mathematics, 18.12.2020 06:50
question
Mathematics, 18.12.2020 06:50
question
Mathematics, 18.12.2020 06:50
question
Mathematics, 18.12.2020 06:50
question
History, 18.12.2020 06:50
question
Health, 18.12.2020 06:50
question
History, 18.12.2020 06:50
Questions on the website: 13722359