Chapter 15 exercises

@rmascarenhas  done! :smile: 
I don't think that's the case, since all the data `stat(2)` returns is obtained from the i-node, and hence it is not necessary to actually open the file.

I wrote up a simple program that just calls `stat(2)` and then ran `strace` on it to verify:

~~~console
renato on earth in ~/code/personal/lpi at branch master $ 
% cat t_stat.c 
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

#include <stdio.h>

int
main(int argc, char *argv[]) {
  struct stat s;

  if (argc != 2) {
    return 1;
  }

  if (stat(argv[1], &s) == -1) {
    perror("stat");
    return 1;
  }

  return 0;
}

renato on earth in ~/code/personal/lpi at branch master $ 
% strace ./t_stat README.md 
execve("./t_stat", ["./t_stat", "README.md"], [/* 49 vars */]) = 0
# snip
stat("README.md", {st_mode=S_IFREG|0600, st_size=355, ...}) = 0
exit_group(0)                           = ?
~~~

Apart from the noise of opening and reading the header files (which I didn't include), we can see that just the `stat(2)` call was triggered.