FAT | RFS | XFS
fstat_set()
PROTOTYPE
#include <posix.h>
int fstat_set(int fid, struct stat *info);
DESCRIPTION
fstat_set() is a non-standard routine that sets the data access and modification timestamps and mode for the open file referenced by fid. info points to a stat structure, defined in “posix.h”, whose st_atime, st_mtime, and st_mode fields contain the new values.
The caller must own the file or be the superuser (UID == 0).
If successful, fstat_set() returns 0. Otherwise, it sets errno and returns -1.
ERROR CODES
| EBADF | fid is not the descriptor of an open file. |
| EFAULT | info equals NULL. |
| EINVAL | Bits outside of S_ALL are set in the info st_mode field. |
| EPERM | The caller is not the file’s owner (per FsGetId()). |
| EROFS | The volume is read-only. |
EXAMPLE
struct tm ftime;
struct stat info;
/*-----------------------------------------------------------------*/
/* Set file's mode and set atime/mtime ro Apr 11, 2008, 17:19:12. */
/*-----------------------------------------------------------------*/
ftime.tm_sec = 12; // seconds after the minute (from 0)
ftime.tm_min = 19; // minutes after the hour (from 0)
ftime.tm_hour = 17; // hour of the day (from 0)
ftime.tm_mday = 11; // day of the month (from 1)
ftime.tm_mon = 3; // month of the year (from 0)
ftime.tm_year = 2008 - 1900; // years since 1900 (from 0)
ftime.tm_isdst = -1; // daylight saving time flag
info.st_atime = info.st_mtime = mktime(&ftime);
info.st_mode = S_IRUSR | S_IWUSR | S_IXUSR; // user RWX permission
if (fstat_set(fid, &info))
return -1;