...
It is necessary to call the fstat() function on an already opened file, rather than calling stat() on a file name followed by open() to ensure the file for which the information is being collected is the same file that is opened. See FIO01-AC. Be careful using functions that use file names for identification for more information on avoiding race conditions resulting from the use of file names for identification.
...