Fix utime() usage for modern glibc

This commit is contained in:
2025-12-14 11:48:10 +01:00
parent cab1094665
commit f7567c5512
6 changed files with 53 additions and 32 deletions

View File

@@ -379,7 +379,7 @@ long mmdf_isvalid (char *name,char *tmp)
if ((sbuf.st_ctime > sbuf.st_atime) || (sbuf.st_mtime > sbuf.st_atime)) {
tp[0] = sbuf.st_atime; /* preserve atime and mtime */
tp[1] = sbuf.st_mtime;
utime (file,tp); /* set the times */
set_utime_from_tp(file,tp); /* set the times */
}
}
}
@@ -1131,7 +1131,7 @@ long mmdf_copy (MAILSTREAM *stream,char *sequence,char *mailbox,long options)
else tp[0] = /* else preserve \Marked status */
((sbuf.st_ctime > sbuf.st_atime) || (sbuf.st_mtime > sbuf.st_atime)) ?
sbuf.st_atime : tp[1];
utime (file,tp); /* set the times */
set_utime_from_tp(file,tp); /* set the times */
mmdf_unlock (fd,NIL,&lock); /* unlock and close mailbox */
if (tstream) { /* update last UID if we can */
MMDFLOCAL *local = (MMDFLOCAL *) tstream->local;
@@ -1292,7 +1292,7 @@ long mmdf_append (MAILSTREAM *stream,char *mailbox,append_t af,void *data)
ret = NIL; /* return error */
}
else tp[0] = tp[1] - 1; /* set atime to now-1 if successful copy */
utime (file,tp); /* set the times */
set_utime_from_tp(file,tp); /* set the times */
fclose (sf); /* done with scratch file */
/* force UIDVALIDITY assignment now */
if (tstream && !tstream->uid_validity) tstream->uid_validity = time (0);
@@ -1550,7 +1550,7 @@ void mmdf_unlock (int fd,MAILSTREAM *stream,DOTLOCK *lock)
}
else now = 0; /* no time change needed */
/* set the times, note change */
if (now && !utime (stream->mailbox,tp)) LOCAL->filetime = tp[1];
if (now && !set_utime_from_tp(stream->mailbox,tp)) LOCAL->filetime = tp[1];
}
flock (fd,LOCK_UN); /* release flock'ers */
if (!stream) close (fd); /* close the file if no stream */
@@ -2393,7 +2393,7 @@ long mmdf_rewrite (MAILSTREAM *stream,unsigned long *nexp,DOTLOCK *lock,
/* set atime to now, mtime a second earlier */
tp[1] = (tp[0] = time (0)) - 1;
/* set the times, note change */
if (!utime (stream->mailbox,tp)) LOCAL->filetime = tp[1];
if (!set_utime_from_tp(stream->mailbox,tp)) LOCAL->filetime = tp[1];
close (LOCAL->fd); /* close and reopen file */
if ((LOCAL->fd = open (stream->mailbox,O_RDWR,
(long) mail_parameters (NIL,GET_MBXPROTECTION,NIL)))