Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribedimage text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And Implementation

Authors: Edward Sciore

2nd Edition

3030338355, 978-3030338350

More Books

Students also viewed these Databases questions