Write a C Program to Implement STAT System Call


To write a C Program to Implement STAT System Call.


stat() is a Unix system call that returns file attributes about an inode. The semantics of stat() vary between operating systems. As an example, Unix command ls uses this system call to retrieve information on files that includes:

  • atime: time of last access (ls -lu)
  • mtime: time of last modification (ls -l)
  • ctime: time of last status change (ls -lc)


  • Step 1 − START.
  • Step 2 – Use library stat.h
  • Step 3 − Declare the struct stat sfile
  • Step 4 − print the sfile
  • Step 5 − STOP.


int main()
  struct stat sfile;
  stat("stat.c", &sfile);
  printf("st_mode = %o", sfile.st_mode);
  return 0;


st_ = 26750123200


Thus STAT system call program was executed Successfully.

Leave a Comment