Question: Write a program, analogous to the Unix/Linux cat command, that uses mmap() and write() system calls (instead of read() or write() ) to copy a

Write a program, analogous to the Unix/Linux cat command, that uses mmap() and write() system calls (instead of read() or write() ) to copy a source file to the screen. Use fstat() to obtain the size of the input file which can be used to size the required memory mapping.

The statement to write the file contents to STDOUT is

write (STDOUT_FILENO, addr, sb.st_size);

where

addr is the start of the mapping, gotten from mmap() and,

sb.st_size is the size of the mapping returned by fstat() in the

sb struct.

Please show the command line to compile the file and run the code and the screenshots

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!