Computers and Technology

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();
}

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 11:30, leapfroggiez
Auser is given read permission to a file stored on an ntfs-formatted volume. the file is then copied to a folder on the same ntfs-formatted volume where the user has been given full control permission for that folder. when the user logs on to the computer holding the file and accesses its new location via a drive letter, what is the user's effective permission to the file? a. read b. full control c. no access d. modify e. none of the above
Answers: 1
image
Computers and Technology, 24.06.2019 04:30, andrespacheco5888
Which of the following terms refers to a collection of different types of software that share the goal of infiltrating a computer and making it do something? a- malware b- virus c- spyware d- trojan horse
Answers: 2
image
Computers and Technology, 24.06.2019 16:30, laureanogabriel
What is the item which could be matched with a statement below? software installed on a computer that produces pop-up ads using your browser an example of social engineering malware loads itself before the os boot is complete type of spyware that tracks your keystrokes, including passwords windows key + l the practice of tricking people into giving out private information or allowing unsafe programs into the network or computer when someone who is unauthorized follows the employee through a secured entrance to a room or building a type of malware that tricks you into opening it by substituting itself for a legitimate program a computer that has been hacked, and the hacker is using the computer to run repetitive software in the background without the user's knowledge an infestation designed to copy itself repeatedly to memory, on drive space, or on a network
Answers: 1
image
Computers and Technology, 24.06.2019 17:00, harlon852
The length of time that a slide appears before automatically advancing to the next slide can be set in the timing group under the transitions tab. transition to this slide group under the transitions tab. timing group in the master slide view. transition to this slide group in the master slide view.
Answers: 1
Do you know the correct answer?
At this point xv6 has no concept of users or groups. You will begin to add this feature to xv6 by ad...

Questions in other subjects:

Konu
Mathematics, 17.09.2019 05:00