mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-10 05:03:06 +03:00
* sysdeps/unix/sysv/syscalls.list (time, utime): Correct signatures.
* io/test-utime.c: Test passing NULL as utimbuf* arg.
This commit is contained in:
@@ -22,6 +22,7 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <utime.h>
|
#include <utime.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
@@ -29,6 +30,8 @@ main (int argc, char *argv[])
|
|||||||
char file[L_tmpnam];
|
char file[L_tmpnam];
|
||||||
struct utimbuf ut;
|
struct utimbuf ut;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
struct stat stnow;
|
||||||
|
time_t now1, now2;
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
if (tmpnam (file) == 0)
|
if (tmpnam (file) == 0)
|
||||||
@@ -45,6 +48,7 @@ main (int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
close (fd);
|
close (fd);
|
||||||
|
|
||||||
|
/* Test utime with arg */
|
||||||
ut.actime = 500000000;
|
ut.actime = 500000000;
|
||||||
ut.modtime = 500000001;
|
ut.modtime = 500000001;
|
||||||
if (utime (file, &ut))
|
if (utime (file, &ut))
|
||||||
@@ -61,6 +65,39 @@ main (int argc, char *argv[])
|
|||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Test utime with NULL.
|
||||||
|
Since there's a race condition possible here, we check
|
||||||
|
the time before and after the call to utime. */
|
||||||
|
now1 = time (NULL);
|
||||||
|
if (now1 == (time_t)-1)
|
||||||
|
{
|
||||||
|
perror ("time");
|
||||||
|
remove (file);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (utime (file, NULL))
|
||||||
|
{
|
||||||
|
perror ("utime NULL");
|
||||||
|
remove (file);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
now2 = time (NULL);
|
||||||
|
if (now2 == (time_t)-1)
|
||||||
|
{
|
||||||
|
perror ("time");
|
||||||
|
remove (file);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stat (file, &stnow))
|
||||||
|
{
|
||||||
|
perror ("stat");
|
||||||
|
remove (file);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
remove (file);
|
remove (file);
|
||||||
|
|
||||||
if (st.st_mtime != ut.modtime)
|
if (st.st_mtime != ut.modtime)
|
||||||
@@ -75,6 +112,18 @@ main (int argc, char *argv[])
|
|||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stnow.st_mtime < now1 || stnow.st_mtime > now2)
|
||||||
|
{
|
||||||
|
printf ("modtime %ld <%ld >%ld\n", st.st_mtime, now1, now2);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stnow.st_atime < now1 || stnow.st_atime > now2)
|
||||||
|
{
|
||||||
|
printf ("actime %ld <%ld >%ld\n", st.st_atime, now1, now2);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
puts ("Test succeeded.");
|
puts ("Test succeeded.");
|
||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@ setrlimit - setrlimit i:ip setrlimit
|
|||||||
settimeofday - settimeofday i:PP __settimeofday settimeofday
|
settimeofday - settimeofday i:PP __settimeofday settimeofday
|
||||||
signal - signal i:ii signal
|
signal - signal i:ii signal
|
||||||
stime - stime i:p stime
|
stime - stime i:p stime
|
||||||
time - time i:p time
|
time - time i:P time
|
||||||
times - times i:p __times times
|
times - times i:p __times times
|
||||||
ulimit - ulimit i:ii ulimit
|
ulimit - ulimit i:ii ulimit
|
||||||
utime - utime i:pp utime
|
utime - utime i:sP utime
|
||||||
|
Reference in New Issue
Block a user