Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Linux (and Unix) permit files to have holes in them. A hole can be created by seeking beyond the end of the file and

Linux (and Unix) permit files to have  lseek (rfd, 130, SEEK_SET) ; read (rfd, buffer, 40); What will the read return, and what (if anything) will

Linux (and Unix) permit files to have "holes" in them. A "hole" can be created by seeking beyond the end of the file and writing data there. Consider the following code. Assume all system calls are successful, and BUFSIZE is sufficiently large. (Look up any unfamiliar functions using the man command on your VM.) char buffer [BUFSIZE]; int fd = open("fooey",0_WRONLY | O_CREAT|O_TRUNC,0777); strcpy (buffer, "First data"); write(fd, buffer, strlen(buffer)); 1seek (fd, 90, SEEK_SET); strcpy (buffer, "Second data"); write(fd, buffer, strlen(buffer)); 1seek (fd, 100, SEEK_END); strpcy (buffer, "Third data"); write(fd, buffer, strlen(buffer)); close(fd); a. What is the size of the file at the end of this section of code? b. Describe the contents of the file say exactly what byte offsets contain actual data, and what offsets constitute "holes". c. Why might holey files be useful? d. Suppose, after the above sequence of writes, the same program opens the file for reading and then does: lseek (rfd, 130, SEEK_SET) ; read (rfd, buffer, 40); What will the read return, and what (if anything) will be placed in buffer?

Step by Step Solution

3.47 Rating (150 Votes )

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

Accounting Information Systems

Authors: George H. Bodnar, William S. Hopwood

11th Edition

0132871939, 978-0132871938

More Books

Students also viewed these Programming questions

Question

List the four types of master records that are used in SAP ERP.

Answered: 1 week ago