...
This compliant solution uses a "check, use, check paradigm " pattern to ensure the file that the file opened for reading is the same file that was opened for writing. In this solution, the file is opened using the open() function. If the file is successfully opened, the fstat() function is used to read information about the file into the stat structure. This information is compared with existing information about the file (stored in the dev and ino variables) to improve identification.
...