Use utimes() instead of the obsolescent utime() for setting file times
- We dont have or care about microsecond precision, but this is the more modern interface ... and on some systems there's an equivalent that allows symlink timestamps to be set, but no such equivalent exists for utime()
This commit is contained in:
parent
d203db9e9b
commit
324e16726c
|
@ -524,7 +524,7 @@ AC_REPLACE_FUNCS(stpcpy stpncpy)
|
|||
AC_CHECK_FUNCS([secure_getenv __secure_getenv])
|
||||
|
||||
AC_CHECK_FUNCS(
|
||||
[mkstemp getcwd basename dirname realpath setenv unsetenv regcomp lchown],
|
||||
[mkstemp getcwd basename dirname realpath setenv unsetenv regcomp lchown utimes],
|
||||
[], [AC_MSG_ERROR([function required by rpm])])
|
||||
|
||||
AC_LIBOBJ(fnmatch)
|
||||
|
|
11
lib/fsm.c
11
lib/fsm.c
|
@ -1450,10 +1450,13 @@ static int fsmChmod(const char *path, mode_t mode)
|
|||
static int fsmUtime(const char *path, time_t mtime)
|
||||
{
|
||||
int rc = 0;
|
||||
struct utimbuf stamp;
|
||||
stamp.actime = mtime;
|
||||
stamp.modtime = mtime;
|
||||
rc = utime(path, &stamp);
|
||||
struct timeval stamps[2] = {
|
||||
{ .tv_sec = mtime, .tv_usec = 0 },
|
||||
{ .tv_sec = mtime, .tv_usec = 0 },
|
||||
};
|
||||
|
||||
rc = utimes(path, stamps);
|
||||
|
||||
if (_fsm_debug)
|
||||
rpmlog(RPMLOG_DEBUG, " %8s (%s, 0x%x) %s\n", __func__,
|
||||
path, (unsigned)mtime, (rc < 0 ? strerror(errno) : ""));
|
||||
|
|
Loading…
Reference in New Issue