File imap-2007f-utime.patch of Package imap
Index: b/src/osdep/unix/unix.c
===================================================================
--- a/src/osdep/unix/unix.c
+++ b/src/osdep/unix/unix.c
@@ -232,7 +232,7 @@ DRIVER *unix_valid (char *name)
if ((sbuf.st_ctime > sbuf.st_atime) || (sbuf.st_mtime > sbuf.st_atime)) {
tp[0] = sbuf.st_atime; /* yes, preserve atime and mtime */
tp[1] = sbuf.st_mtime;
- utime (file,tp); /* set the times */
+ UTIME (file,tp); /* set the times */
}
}
}
@@ -999,7 +999,7 @@ long unix_copy (MAILSTREAM *stream,char
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 */
+ UTIME (file,tp); /* set the times */
unix_unlock (fd,NIL,&lock); /* unlock and close mailbox */
if (tstream) { /* update last UID if we can */
UNIXLOCAL *local = (UNIXLOCAL *) tstream->local;
@@ -1160,7 +1160,7 @@ long unix_append (MAILSTREAM *stream,cha
ret = NIL; /* return error */
}
else tp[0] = tp[1] - 1; /* set atime to now-1 if successful copy */
- utime (file,tp); /* set the times */
+ UTIME (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);
@@ -1425,7 +1425,8 @@ void unix_unlock (int fd,MAILSTREAM *str
}
else now = 0; /* no time change needed */
/* set the times, note change */
- if (now && !utime (stream->mailbox,tp)) LOCAL->filetime = tp[1];
+ struct utimbuf _tp = { tp[0], tp[1]};
+ if (now && !utime (stream->mailbox,&_tp)) LOCAL->filetime = tp[1];
}
flock (fd,LOCK_UN); /* release flock'ers */
if (!stream) close (fd); /* close the file if no stream */
@@ -2251,7 +2252,8 @@ long unix_rewrite (MAILSTREAM *stream,un
/* 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];
+ struct utimbuf _tp = { tp[0], tp[1]};
+ if (!utime (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)))
Index: b/src/osdep/unix/mbx.c
===================================================================
--- a/src/osdep/unix/mbx.c
+++ b/src/osdep/unix/mbx.c
@@ -302,7 +302,7 @@ int mbx_isvalid (MAILSTREAM **stream,cha
if (sbuf.st_ctime > sbuf.st_atime) {
tp[0] = sbuf.st_atime; /* preserve atime and mtime */
tp[1] = sbuf.st_mtime;
- utime (tmp,tp); /* set the times */
+ UTIME (tmp,tp); /* set the times */
}
}
/* in case INBOX but not mbx format */
@@ -776,7 +776,7 @@ void mbx_flag (MAILSTREAM *stream,char *
stream->user_flags[LOCAL->ffuserflag]) || (oldpid != LOCAL->lastpid))
mbx_update_header (stream);
tp[0] = time (0); /* make sure read comes after all that */
- utime (stream->mailbox,tp);
+ UTIME (stream->mailbox,tp);
}
if (LOCAL->ld >= 0) { /* unlock now */
unlockfd (LOCAL->ld,LOCAL->lock);
@@ -1075,7 +1075,7 @@ long mbx_copy (MAILSTREAM *stream,char *
/* 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 */
+ UTIME (file,tp); /* set the times */
close (fd); /* close the file */
MM_NOCRITICAL (stream); /* release critical */
unlockfd (ld,lock); /* release exclusive parse/append permission */
@@ -1213,7 +1213,7 @@ long mbx_append (MAILSTREAM *stream,char
/* 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 */
+ UTIME (file,tp); /* set the times */
fclose (df); /* close the file */
MM_NOCRITICAL (dstream); /* release critical */
}
@@ -1446,7 +1446,7 @@ long mbx_parse (MAILSTREAM *stream)
time_t tp[2];
tp[0] = time (0);
tp[1] = LOCAL->filetime;
- utime (stream->mailbox,tp);
+ UTIME (stream->mailbox,tp);
}
stream->silent = silent; /* can pass up events now */
mail_exists (stream,nmsgs); /* notify upper level of new mailbox size */
@@ -1814,7 +1814,7 @@ unsigned long mbx_rewrite (MAILSTREAM *s
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);
+ UTIME (stream->mailbox,tp);
unlockfd (ld,lock); /* release exclusive parse/append permission */
/* notify upper level of new mailbox size */
mail_exists (stream,stream->nmsgs);
Index: b/src/osdep/unix/mmdf.c
===================================================================
--- a/src/osdep/unix/mmdf.c
+++ b/src/osdep/unix/mmdf.c
@@ -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 */
+ UTIME (file,tp); /* set the times */
}
}
}
@@ -1131,7 +1131,7 @@ long mmdf_copy (MAILSTREAM *stream,char
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 */
+ UTIME (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,cha
ret = NIL; /* return error */
}
else tp[0] = tp[1] - 1; /* set atime to now-1 if successful copy */
- utime (file,tp); /* set the times */
+ UTIME (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,8 @@ void mmdf_unlock (int fd,MAILSTREAM *str
}
else now = 0; /* no time change needed */
/* set the times, note change */
- if (now && !utime (stream->mailbox,tp)) LOCAL->filetime = tp[1];
+ struct utimbuf _tp = { tp[0], tp[1]};
+ if (now && !utime (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 +2394,8 @@ long mmdf_rewrite (MAILSTREAM *stream,un
/* 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];
+ struct utimbuf _tp = { tp[0], tp[1]};
+ if (!utime (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)))
Index: b/src/osdep/unix/tenex.c
===================================================================
--- a/src/osdep/unix/tenex.c
+++ b/src/osdep/unix/tenex.c
@@ -203,7 +203,7 @@ int tenex_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 */
+ UTIME (file,tp); /* set the times */
}
}
}
@@ -654,7 +654,7 @@ void tenex_flag (MAILSTREAM *stream,char
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);
+ UTIME (stream->mailbox,tp);
}
}
@@ -924,7 +924,7 @@ long tenex_expunge (MAILSTREAM *stream,c
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);
+ UTIME (stream->mailbox,tp);
MM_NOCRITICAL (stream); /* release critical */
/* notify upper level of new mailbox size */
mail_exists (stream,stream->nmsgs);
@@ -1019,7 +1019,7 @@ long tenex_copy (MAILSTREAM *stream,char
/* 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 */
+ UTIME (file,tp); /* set the times */
close (fd); /* close the file */
unlockfd (ld,lock); /* release exclusive parse/append permission */
MM_NOCRITICAL (stream); /* release critical */
@@ -1036,7 +1036,7 @@ long tenex_copy (MAILSTREAM *stream,char
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);
+ UTIME (stream->mailbox,tp);
}
}
if (ret && mail_parameters (NIL,GET_COPYUID,NIL))
@@ -1159,7 +1159,7 @@ long tenex_append (MAILSTREAM *stream,ch
/* 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 */
+ UTIME (file,tp); /* set the times */
fclose (df); /* close the file */
unlockfd (ld,lock); /* release exclusive parse/append permission */
MM_NOCRITICAL (stream); /* release critical */
@@ -1324,7 +1324,7 @@ long tenex_parse (MAILSTREAM *stream)
time_t tp[2];
tp[0] = time (0);
tp[1] = LOCAL->filetime;
- utime (stream->mailbox,tp);
+ UTIME (stream->mailbox,tp);
}
stream->silent = silent; /* can pass up events now */
mail_exists (stream,nmsgs); /* notify upper level of new mailbox size */
@@ -1424,7 +1424,7 @@ void tenex_update_status (MAILSTREAM *st
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);
+ UTIME (stream->mailbox,tp);
}
}
}
Index: b/src/osdep/unix/os_slx.h
===================================================================
--- a/src/osdep/unix/os_slx.h
+++ b/src/osdep/unix/os_slx.h
@@ -62,6 +62,7 @@ extern int safe_flock (int fd,int op);
#define flock safe_flock
+#define UTIME(file,tp) do { struct utimbuf _tp={tp[0],tp[1]}; utime(file, &_tp);} while(0)
#include "env_unix.h"
#include "fs.h"
Index: b/src/osdep/unix/mtx.c
===================================================================
--- a/src/osdep/unix/mtx.c
+++ b/src/osdep/unix/mtx.c
@@ -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 */
+ UTIME (file,tp); /* set the times */
}
}
}
@@ -565,7 +565,7 @@ void mtx_flag (MAILSTREAM *stream,char *
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);
+ UTIME (stream->mailbox,tp);
}
}
@@ -834,7 +834,7 @@ long mtx_expunge (MAILSTREAM *stream,cha
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);
+ UTIME (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 *
/* 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 */
+ UTIME (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 *
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);
+ UTIME (stream->mailbox,tp);
}
}
if (ret && mail_parameters (NIL,GET_COPYUID,NIL))
@@ -1062,7 +1062,7 @@ long mtx_append (MAILSTREAM *stream,char
/* 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 */
+ UTIME (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);
+ UTIME (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 *stre
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);
+ UTIME (stream->mailbox,tp);
}
}
}
Index: b/src/osdep/unix/mh.c
===================================================================
--- a/src/osdep/unix/mh.c
+++ b/src/osdep/unix/mh.c
@@ -1280,5 +1280,5 @@ void mh_setdate (char *file,MESSAGECACHE
time_t tp[2];
tp[0] = time (0); /* atime is now */
tp[1] = mail_longdate (elt); /* modification time */
- utime (file,tp); /* set the times */
+ UTIME (file,tp); /* set the times */
}
Index: b/src/osdep/unix/mx.c
===================================================================
--- a/src/osdep/unix/mx.c
+++ b/src/osdep/unix/mx.c
@@ -1284,5 +1284,5 @@ void mx_setdate (char *file,MESSAGECACHE
time_t tp[2];
tp[0] = time (0); /* atime is now */
tp[1] = mail_longdate (elt); /* modification time */
- utime (file,tp); /* set the times */
+ UTIME (file,tp); /* set the times */
}