Answered step by step
Verified Expert Solution
Question
1 Approved Answer
4. [20 points] Unix L'O and file operations [10 points] Suppose the following code is executed correctly without generating any errors, and parent's PID is
4. [20 points] Unix L'O and file operations [10 points] Suppose the following code is executed correctly without generating any errors, and parent's PID is 7 while child's PID is 8 a. fprintf (stdout, forint f (stderr, fprintf (stdout, forint f (stderr, fprintf (stdout, fork(); fprintf(stdout, return 0; "%d: "%d: "%d: "%d: "d: a ", a has been written b ", b has been written c", getpid)) getpid()); getpid () getpid()); getpid)) ", ", "%d: all done ! ", getpid()); Give a possible output for the above program. b. [10 points] Consider the given INODE structure and assume that block size is 8K bytes and pointers are 4 bytes. So each block has numPtr = 8*1024/4 pointers! You are asked to implement char *get blk n di (struct inode *myinode, int n) ; which returns the address of the n" double indirect (di) data block (if it exists); otherwise, it returns NULL. For the first di data block (if exists), n is 0 . When n is 0, return myinode->d [ 0] [ 0 ] ; For the last di data block (if exists), nis num ptr*u ptr-1. In this case, return myinode->di [num ptr-1] [num ptr-1 Note that direct or ary indirect levels might be partially filled with blocks! So fthere is no more block or level the corresponding pointer will contain NULL char *get _blk n di (struct inode *myinode, int n) int i, ji int count-0 int num tr = 8 * 1024 / 4; if (n num ptr*num ptr-1) return NULL court dp data tirdredt data
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started