Some notes on HW6
- Boy did I find a way to make grading homework hard.
- Please read what you write. Make sure it is a good explanation.
- if (argv[1] == "-a") is not a valid comparison.
- 4-1
- If you are going to copy a command, make sure that you behave like the command.
- ls | tee foo
- Print the result to the file foo, after opening it with O_TRUNC
- and to the screen.
- Your program should do this as well, but also handle
ls | tee -a foo which should open foo with O_APPEND
- 4-2
- I do not like the way the simple solution is working, I think we might have a file system covering for our mistakes on this one. I will experiment and get back to you on this one.
- 5-2
- You really should demonstrate what happens if a second seek and write is performed. Was the O_APPEND effective only for the first write or for all writes?
- 5-3
- From the man page: "The file is opened in append mode. Before each write(2), the file offset is positioned at the end of the file, as if with lseek(2). O_APPEND may lead to corrupted files on NFS filesys- tems if more than one process appends data to a file at once. This is because NFS does not support appending to a file, so the client kernel has to simulate it, which can't be done without a race condition. "
- I am fairly sure your files are on an nfs mounted file system, you probably want to do your experiments in /tmp
- But make sure you remove those files when you are done.
- I would add another command line argument, a character, the data your program should write, then you can see which process has written what, and even if some of the data is missing. This would be quite informative.
- If you are going to test a concept, use as much common code as possible. Many of you had errors in your code which created different experiments.
- If the question states that you should see a difference and you don't, you should question your results/code.