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

@@ -196,7 +196,7 @@ int mtx_isvalid (char *name,char *tmp)
if (sbuf.st_ctime > 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 */
}
}
}
@@ -565,7 +565,7 @@ void mtx_flag (MAILSTREAM *stream,char *sequence,char *flag,long flags)
fstat (LOCAL->fd,&sbuf); /* get current write time */
tp[1] = LOCAL->filetime = sbuf.st_mtime;
tp[0] = time (0); /* make sure read comes after all that */
utime (stream->mailbox,tp);
set_utime_from_tp(stream->mailbox,tp);
}
}
@@ -834,7 +834,7 @@ long mtx_expunge (MAILSTREAM *stream,char *sequence,long options)
fstat (LOCAL->fd,&sbuf); /* get new write time */
tp[1] = LOCAL->filetime = sbuf.st_mtime;
tp[0] = time (0); /* reset atime to now */
utime (stream->mailbox,tp);
set_utime_from_tp(stream->mailbox,tp);
MM_NOCRITICAL (stream); /* release critical */
/* notify upper level of new mailbox size */
mail_exists (stream,stream->nmsgs);
@@ -929,7 +929,7 @@ long mtx_copy (MAILSTREAM *stream,char *sequence,char *mailbox,long options)
/* else preserve \Marked status */
else tp[0] = (sbuf.st_ctime > sbuf.st_atime) ? sbuf.st_atime : time(0);
tp[1] = sbuf.st_mtime; /* preserve mtime */
utime (file,tp); /* set the times */
set_utime_from_tp(file,tp); /* set the times */
close (fd); /* close the file */
unlockfd (ld,lock); /* release exclusive parse/append permission */
MM_NOCRITICAL (stream); /* release critical */
@@ -946,7 +946,7 @@ long mtx_copy (MAILSTREAM *stream,char *sequence,char *mailbox,long options)
fstat (LOCAL->fd,&sbuf); /* get current write time */
tp[1] = LOCAL->filetime = sbuf.st_mtime;
tp[0] = time (0); /* make sure atime remains greater */
utime (stream->mailbox,tp);
set_utime_from_tp(stream->mailbox,tp);
}
}
if (ret && mail_parameters (NIL,GET_COPYUID,NIL))
@@ -1062,7 +1062,7 @@ long mtx_append (MAILSTREAM *stream,char *mailbox,append_t af,void *data)
/* else preserve \Marked status */
else tp[0] = (sbuf.st_ctime > sbuf.st_atime) ? sbuf.st_atime : time(0);
tp[1] = sbuf.st_mtime; /* preserve mtime */
utime (file,tp); /* set the times */
set_utime_from_tp(file,tp); /* set the times */
fclose (df); /* close the file */
unlockfd (ld,lock); /* release exclusive parse/append permission */
MM_NOCRITICAL (stream); /* release critical */
@@ -1212,7 +1212,7 @@ long mtx_parse (MAILSTREAM *stream)
time_t tp[2];
tp[0] = time (0);
tp[1] = LOCAL->filetime;
utime (stream->mailbox,tp);
set_utime_from_tp(stream->mailbox,tp);
}
stream->silent = silent; /* can pass up events now */
mail_exists (stream,nmsgs); /* notify upper level of new mailbox size */
@@ -1312,7 +1312,7 @@ void mtx_update_status (MAILSTREAM *stream,unsigned long msgno,long syncflag)
fstat (LOCAL->fd,&sbuf); /* get new write time */
tp[1] = LOCAL->filetime = sbuf.st_mtime;
tp[0] = time (0); /* make sure read is later */
utime (stream->mailbox,tp);
set_utime_from_tp(stream->mailbox,tp);
}
}
}