110 likes | 122 Views
This project involves implementing three main parts - message passing, input/output redirection, and users/permissions. It requires working with message queues, implementing circular queues for message passing, managing input/output redirection, and handling permissions for processes.
E N D
Project 6 • Requires working project 5 • Three main parts • Message passing • Input/Output redirection • Users/Permissions
Message Passing • Create with MessageQueueCreate(char *name) • If no message queue with name, create • Otherwise, grant access to existing • Use existing Read/Write/Close (new filesystem FS_TYPE_IPC) • vfs.c Read example: • If (PFAT) do what it does now • Else If (GOSFS) GOSFS_Read() • Else if (IPC) Message_Queue_Read() • You implement Message_Queue_Read • Read from empty blocks a process • Write to full blocks a process
Message Passing • size = 4 • Implement as circular queue
Input/Output Redirection • Change Spawn_Program(char *program) to Spawn_Program(char *program, int stdin, int stdout) • For every process file descriptor 0 is input • For every process file descriptor 1 is output • Make sure supplied file descriptors are valid
FS_TYPE_CONSOLE • Console is a new file type in vsf • vfs.c Read • If (CONSOLE) Get_Key • vsf.c Write • If (CONSOLE) Print() • Modify Print_String to call Write(1) • Allows output redirection automatically
Redirection Example • Parent process • int fd = Open(“/d/output”); • Spawn_Program(“/c/a.exe”, 0, fd); • Close(fd); • Child process (a.exe) • Write(1, “string”); // writes to file fd • Printf(“string”); // writes to file fd
Permissions • Each UserContext has a new field called uid • Indicates user running this process • Superuser is uid 0 • Used to test for GOSFS operations • Open checks permissions requested versus existing • Creating file requires write on parent directory • CreateDirectory requires write on parent directory • Delete requires write to access file/directory • SetAcl requires write access to file/directory • Read, Write, Seek, Stat, and Close do not check rights (checked in Open) • Superuser (uid 0) always has all rights (independent of ACL) • Used to pass permissions to spawned process • More on this later
Modifying UID • SetEffectiveUid(int uid) • Sets the uid to supplied uid for current process • Only sets if current user is superuser (uid == 0) • int GetUid() • Returns current process’ uid
Spawn Modification • New elf.c can spawn a process off GOSFS drive • /d/a.exe will work • How to set spawned process uid? • Copy uid from parent process? • Some processes need more rights than parent • passwd command in UNIX • Use setUid bit in GOSFSFileNode • If setUid bit is 0 • Copy uid from parent process • If setUid bit is 1 • Use acl[0].uid as the process’ uid
GOSFSFileNode Enhancements • aclEntry acl[4] • Table of aclEntries • Each entry contains a uid and permissions • acl[0] is the owner • Set when the file/directory is created set to have full rights • setUid:1; • Indicates whether program should run with permissions of parent process or of file owner
SetAcl • SYS_SET_ACL • SetAcl(char *name, int uid, int permissions) • Permissions can be • O_READ, O_WRITE, O_READ | O_WRITE, 0 • Find file by name • Store permissions for supplied uid • if uid already in acl list – update • if permissions == 0 – erase rights for uid