mkntfs.c: Enable microsecond-precision volume creation time.

Previously the creation time was filled in with seconds (obtained using
time(NULL)) but the microsecond part was left zeroed. Fixed by using
gettimeofday when available.
edge
Erik Larsson 2022-12-12 18:51:12 +02:00
parent 71ecccf279
commit e73d481a76
1 changed files with 14 additions and 2 deletions

View File

@ -776,8 +776,20 @@ static ntfs_time mkntfs_time(void)
ts.tv_sec = 0;
ts.tv_nsec = 0;
if (!opts.use_epoch_time)
ts.tv_sec = time(NULL);
if (!opts.use_epoch_time) {
#ifdef HAVE_GETTIMEOFDAY
struct timeval tv = { 0, 0, };
if (!gettimeofday(&tv, NULL)) {
ts.tv_sec = tv.tv_sec;
ts.tv_nsec = tv.tv_usec * 1000L;
}
else
#endif
{
ts.tv_sec = time(NULL);
}
}
return timespec2ntfs(ts);
}