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, 22.06.2019 09:50
Assume that you have an sorted array of records. assume that the length of the array (n) is known. give two different methods to search for a specific value in this array. you can use english or pseudo-code for your algorithm. what is the time complexity for each algorithm and why?
Answers: 1
question
Computers and Technology, 23.06.2019 07:50
Most shops require the technician to enter a starting and ending time on the repair order to track the actual time the vehicle was in the shop and closed out by the office. this time is referred to as _ time ? a. comeback b. ro c. cycle d. lead
Answers: 1
question
Computers and Technology, 23.06.2019 21:00
Uget brainliest if accurate mary has been given the responsibility of hiring a person for the position of a software testing officer. which management function would mary achieve this responsibility?
Answers: 1
question
Computers and Technology, 23.06.2019 21:20
In microsoft word, when you highlight existing text you want to replace, you're in              a.  advanced mode.    b.  automatic mode.    c.  basic mode.    d.  typeover mode
Answers: 1
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
Questions on the website: 13722360