HW7
How can we determine whether two paths refer to the same file?
What flag to the
open()system call will create a file if it doesn’t exist already? (See lecture notes and/orman 2 open.)What happens if we try to open a file that does not exist?
What flag truncates a file upon opening?
What happens if we open a file that already exists for writing, without truncating it, and then write bytes to it?
Write a snippet of C code that uses a syscall to open a file called “hello” for writing, creating it if it doesn’t exist, but truncating if it does. Remember to include error checking that exits with
EXIT_FAILUREif the call toopen()fails.