You will implement two different versions of a file copy utility, one using read()/write() operations and one using mmap(). You are only allowed to use the following system calls: open(), close(), read(), write(), lseek(), mmap(), munmap(), stat(), lstat(), fstat(). You may also use fprintf() to report errors, and getenv() to read environment variables. Specifically, if the environment variable X_MY_COPY is set to READ+WRITE then your program should use read()/write() to copy the file. If it is set to MMAP, your program should use mmap(). If it is not set, or set to some other value, your program should report an error and exit. Your program should take two arguments, a source pathname and a destination pathname, e.g., mycopy /tmp/foo bar
At the end of the copy operation (regardless of which type it was), print some diagnostics (e.g., number of bytes copies, elapsed time, anything else you think might be useful or interesting); you can use appropriate system calls (e.g., time()) to retrieve the relevant information.
Additionally, if the user specifies the -r command-line flag, you should remove the source file if the copy has been successful. (You can use the unlink() system call for that.)