2

What is the use of the stat.h header in cat.c?

Here you have the cat.c

https://github.com/mit-pdos/xv6-riscv/blob/riscv/user/cat.c

Here you have the stat.h

https://github.com/mit-pdos/xv6-riscv/blob/riscv/kernel/stat.h

I do not see any direct use of the stat struct in the cat.c so I wonder if there is an indirect one.

pav
  • 47
  • 4

1 Answers1

2

It was added in this commit probably because user.h uses the struct stat * datatype

kirjosieppo
  • 617
  • 3
  • 16
  • Thanks, I'm learning c along xv6 .... so probably this is more a c question then xv6 .. but why the include statement is then not in the user.h file? – pav Dec 19 '21 at 15:35
  • 1
    https://stackoverflow.com/q/7553750/17635987 is perhaps relevant here. – kirjosieppo Dec 19 '21 at 15:52
  • I see, that' way people can define their stat without need to change user.h... the downside is that you need to bring it around stat.h with user.h even when as in this case you do not need the fstat which is where stat.h is needed. – pav Dec 19 '21 at 18:35