Fix time modification on truncate()
POSIX truncate specification says "Upon successful completion, if the *file size is changed*, this function shall mark for update the st_ctime and st_mtime fields of the file." This patch prevents changing of the date fields when the size stays the same.
This commit is contained in:
committed by
Thomas Veerman
parent
902e0e27e0
commit
255ae85b1e
@@ -204,6 +204,15 @@ void test16a()
|
||||
if (unlink("T16.i1") != 0) e(84);
|
||||
if (unlink("T16.j") != 0) e(85);
|
||||
if (unlink("T16.k") != 0) e(86);
|
||||
|
||||
/* Test the times for truncate. */
|
||||
if (system("echo 1 > T16.l") != 0) e(87);
|
||||
stat("T16.l", &s);
|
||||
get_times("T16.l", &a, &c, &m);
|
||||
sleep(1);
|
||||
truncate("T16.l", s.st_size);
|
||||
get_times("T16.l", &ta, &tc, &tm);
|
||||
if (a != ta || c != tc || m != tm) e(88);
|
||||
}
|
||||
|
||||
void get_times(name, a, c, m)
|
||||
|
||||
Reference in New Issue
Block a user