0

I was given a assignment to run strace command on by hello world program and see the output, and I don't understand one thing in fstat system call.

I got to know that fstat system call should have stat buff as second argument, but here we are passing mode and size as arguments, how can this happen? and how did fstat got to know file stze?

fstat(3, {st_mode=S_IFREG|0755, st_size=2066504, ...}) = 0 
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
red0ct
  • 4,840
  • 3
  • 17
  • 44
Ellanti Kishore
  • 104
  • 1
  • 9
  • 2
    You're not passing those arguments, you're passing a pointer to a `struct stat` and the kernel is filling its fields. The strace output doesn't mark the input and output arguments differently. –  Aug 29 '19 at 14:46
  • Thanks @mosvy, it helped – Ellanti Kishore Sep 02 '19 at 22:52

0 Answers0