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, 23.06.2019 13:00
Which of the following statements is false? a. a class can directly inherit from class object. b. if the class you're inheriting from declares instance variables as private, the inherited class can access those instance variables directly. c. a class's instance variables are normally declared private to enforce good software engineering. d. it's often much more efficient to create a class by inheriting from a similar class than to create the class by writing every line of code the new class requires.
Answers: 3
question
Computers and Technology, 25.06.2019 12:00
Matching 1. many steps descending into a solution 2. the technological process known for its high degree of precision 3. method that allows developers freedom when they are writing software a.)six sigma b.)agile software development organization c.)waterfall method
Answers: 1
question
Computers and Technology, 25.06.2019 16:00
Nasa’s long term goal is for travel in space to be as as travel across the atlantic. however, we are away from that.
Answers: 1
question
Computers and Technology, 25.06.2019 20:40
Write a java program named charsindex to get the index of all the characters of the alphabet. ask user to input a string.the sample output was produced by this string: "the quick brown fox jumps over the lazy dog." sample output:
Answers: 3
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: 13722362