Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 919252
Collapse All | Expand All

(-)a/src/osdep/unix/mbx.c (-26 / +26 lines)
Lines 209-215 Link Here
209
  off_t pos;
209
  off_t pos;
210
  char c,*s,*t,hdr[HDRSIZE];
210
  char c,*s,*t,hdr[HDRSIZE];
211
  struct stat sbuf;
211
  struct stat sbuf;
212
  time_t tp[2];
212
  struct utimbuf tp;
213
  int error = EINVAL;		/* assume invalid argument */
213
  int error = EINVAL;		/* assume invalid argument */
214
  if (ld) *ld = -1;		/* initially no lock */
214
  if (ld) *ld = -1;		/* initially no lock */
215
  if ((s = mbx_file (tmp,name)) && !stat (s,&sbuf) &&
215
  if ((s = mbx_file (tmp,name)) && !stat (s,&sbuf) &&
Lines 298-306 Link Here
298
    else lseek (fd,0,L_SET);	/* else rewind to start */
298
    else lseek (fd,0,L_SET);	/* else rewind to start */
299
				/* \Marked status? */
299
				/* \Marked status? */
300
    if (sbuf.st_ctime > sbuf.st_atime) {
300
    if (sbuf.st_ctime > sbuf.st_atime) {
301
      tp[0] = sbuf.st_atime;	/* preserve atime and mtime */
301
      tp.actime = sbuf.st_atime;	/* preserve atime and mtime */
302
      tp[1] = sbuf.st_mtime;
302
      tp.modtime = sbuf.st_mtime;
303
      utime (tmp,tp);		/* set the times */
303
      utime (tmp,&tp);		/* set the times */
304
    }
304
    }
305
  }
305
  }
306
				/* in case INBOX but not mbx format */
306
				/* in case INBOX but not mbx format */
Lines 759-780 Link Here
759
759
760
void mbx_flag (MAILSTREAM *stream,char *sequence,char *flag,long flags)
760
void mbx_flag (MAILSTREAM *stream,char *sequence,char *flag,long flags)
761
{
761
{
762
  time_t tp[2];
762
  struct utimbuf tp;
763
  struct stat sbuf;
763
  struct stat sbuf;
764
  unsigned long oldpid = LOCAL->lastpid;
764
  unsigned long oldpid = LOCAL->lastpid;
765
				/* make sure the update takes */
765
				/* make sure the update takes */
766
  if (!stream->rdonly && LOCAL && (LOCAL->fd >= 0) && (LOCAL->ld >= 0)) {
766
  if (!stream->rdonly && LOCAL && (LOCAL->fd >= 0) && (LOCAL->ld >= 0)) {
767
    fsync (LOCAL->fd);
767
    fsync (LOCAL->fd);
768
    fstat (LOCAL->fd,&sbuf);	/* get current write time */
768
    fstat (LOCAL->fd,&sbuf);	/* get current write time */
769
    tp[1] = LOCAL->filetime = sbuf.st_mtime;
769
    tp.modtime = LOCAL->filetime = sbuf.st_mtime;
770
				/* we are the last flag updater */
770
				/* we are the last flag updater */
771
    LOCAL->lastpid = (unsigned long) getpid ();
771
    LOCAL->lastpid = (unsigned long) getpid ();
772
				/* update header if needed */
772
				/* update header if needed */
773
    if (((LOCAL->ffuserflag < NUSERFLAGS) &&
773
    if (((LOCAL->ffuserflag < NUSERFLAGS) &&
774
	 stream->user_flags[LOCAL->ffuserflag]) || (oldpid != LOCAL->lastpid))
774
	 stream->user_flags[LOCAL->ffuserflag]) || (oldpid != LOCAL->lastpid))
775
      mbx_update_header (stream);
775
      mbx_update_header (stream);
776
    tp[0] = time (0);		/* make sure read comes after all that */
776
    tp.actime = time (0);		/* make sure read comes after all that */
777
    utime (stream->mailbox,tp);
777
    utime (stream->mailbox,&tp);
778
  }
778
  }
779
  if (LOCAL->ld >= 0) {		/* unlock now */
779
  if (LOCAL->ld >= 0) {		/* unlock now */
780
    unlockfd (LOCAL->ld,LOCAL->lock);
780
    unlockfd (LOCAL->ld,LOCAL->lock);
Lines 984-990 Link Here
984
long mbx_copy (MAILSTREAM *stream,char *sequence,char *mailbox,long options)
984
long mbx_copy (MAILSTREAM *stream,char *sequence,char *mailbox,long options)
985
{
985
{
986
  struct stat sbuf;
986
  struct stat sbuf;
987
  time_t tp[2];
987
  struct utimbuf tp;
988
  MESSAGECACHE *elt;
988
  MESSAGECACHE *elt;
989
  unsigned long i,j,k,m;
989
  unsigned long i,j,k,m;
990
  long ret = LONGT;
990
  long ret = LONGT;
Lines 1069-1079 Link Here
1069
    mail_free_searchset (&source);
1069
    mail_free_searchset (&source);
1070
    mail_free_searchset (&dest);
1070
    mail_free_searchset (&dest);
1071
  }
1071
  }
1072
  if (ret) tp[0] = time (0) - 1;/* set atime to now-1 if successful copy */
1072
  if (ret) tp.actime = time (0) - 1;/* set atime to now-1 if successful copy */
1073
				/* else preserve \Marked status */
1073
				/* else preserve \Marked status */
1074
  else tp[0] = (sbuf.st_ctime > sbuf.st_atime) ? sbuf.st_atime : time(0);
1074
  else tp.actime = (sbuf.st_ctime > sbuf.st_atime) ? sbuf.st_atime : time(0);
1075
  tp[1] = sbuf.st_mtime;	/* preserve mtime */
1075
  tp.modtime = sbuf.st_mtime;	/* preserve mtime */
1076
  utime (file,tp);		/* set the times */
1076
  utime (file,&tp);		/* set the times */
1077
  close (fd);			/* close the file */
1077
  close (fd);			/* close the file */
1078
  MM_NOCRITICAL (stream);	/* release critical */
1078
  MM_NOCRITICAL (stream);	/* release critical */
1079
  unlockfd (ld,lock);		/* release exclusive parse/append permission */
1079
  unlockfd (ld,lock);		/* release exclusive parse/append permission */
Lines 1105-1111 Link Here
1105
  struct stat sbuf;
1105
  struct stat sbuf;
1106
  int fd,ld;
1106
  int fd,ld;
1107
  char *flags,*date,tmp[MAILTMPLEN],file[MAILTMPLEN],lock[MAILTMPLEN];
1107
  char *flags,*date,tmp[MAILTMPLEN],file[MAILTMPLEN],lock[MAILTMPLEN];
1108
  time_t tp[2];
1108
  struct utimbuf tp;
1109
  FILE *df;
1109
  FILE *df;
1110
  MESSAGECACHE elt;
1110
  MESSAGECACHE elt;
1111
  long f;
1111
  long f;
Lines 1207-1217 Link Here
1207
    }
1207
    }
1208
    else mail_free_searchset (&dst);
1208
    else mail_free_searchset (&dst);
1209
				/* set atime to now-1 if successful copy */
1209
				/* set atime to now-1 if successful copy */
1210
    if (ret) tp[0] = time (0) - 1;
1210
    if (ret) tp.actime = time (0) - 1;
1211
				/* else preserve \Marked status */
1211
				/* else preserve \Marked status */
1212
    else tp[0] = (sbuf.st_ctime > sbuf.st_atime) ? sbuf.st_atime : time(0);
1212
    else tp.actime = (sbuf.st_ctime > sbuf.st_atime) ? sbuf.st_atime : time(0);
1213
    tp[1] = sbuf.st_mtime;	/* preserve mtime */
1213
    tp.modtime = sbuf.st_mtime;	/* preserve mtime */
1214
    utime (file,tp);		/* set the times */
1214
    utime (file,&tp);		/* set the times */
1215
    fclose (df);		/* close the file */
1215
    fclose (df);		/* close the file */
1216
    MM_NOCRITICAL (dstream);	/* release critical */
1216
    MM_NOCRITICAL (dstream);	/* release critical */
1217
  }
1217
  }
Lines 1441-1450 Link Here
1441
  fstat (LOCAL->fd,&sbuf);	/* get status again to ensure time is right */
1441
  fstat (LOCAL->fd,&sbuf);	/* get status again to ensure time is right */
1442
  LOCAL->filetime = sbuf.st_mtime;
1442
  LOCAL->filetime = sbuf.st_mtime;
1443
  if (added && !stream->rdonly){/* make sure atime updated */
1443
  if (added && !stream->rdonly){/* make sure atime updated */
1444
    time_t tp[2];
1444
    struct utimbuf tp;
1445
    tp[0] = time (0);
1445
    tp.actime = time (0);
1446
    tp[1] = LOCAL->filetime;
1446
    tp.modtime = LOCAL->filetime;
1447
    utime (stream->mailbox,tp);
1447
    utime (stream->mailbox,&tp);
1448
  }
1448
  }
1449
  stream->silent = silent;	/* can pass up events now */
1449
  stream->silent = silent;	/* can pass up events now */
1450
  mail_exists (stream,nmsgs);	/* notify upper level of new mailbox size */
1450
  mail_exists (stream,nmsgs);	/* notify upper level of new mailbox size */
Lines 1691-1697 Link Here
1691
unsigned long mbx_rewrite (MAILSTREAM *stream,unsigned long *reclaimed,
1691
unsigned long mbx_rewrite (MAILSTREAM *stream,unsigned long *reclaimed,
1692
			   long flags)
1692
			   long flags)
1693
{
1693
{
1694
  time_t tp[2];
1694
  struct utimbuf tp;
1695
  struct stat sbuf;
1695
  struct stat sbuf;
1696
  off_t pos,ppos;
1696
  off_t pos,ppos;
1697
  int ld;
1697
  int ld;
Lines 1810-1818 Link Here
1810
    fsync (LOCAL->fd);		/* force disk update */
1810
    fsync (LOCAL->fd);		/* force disk update */
1811
  }
1811
  }
1812
  fstat (LOCAL->fd,&sbuf);	/* get new write time */
1812
  fstat (LOCAL->fd,&sbuf);	/* get new write time */
1813
  tp[1] = LOCAL->filetime = sbuf.st_mtime;
1813
  tp.modtime = LOCAL->filetime = sbuf.st_mtime;
1814
  tp[0] = time (0);		/* reset atime to now */
1814
  tp.actime = time (0);		/* reset atime to now */
1815
  utime (stream->mailbox,tp);
1815
  utime (stream->mailbox,&tp);
1816
  unlockfd (ld,lock);		/* release exclusive parse/append permission */
1816
  unlockfd (ld,lock);		/* release exclusive parse/append permission */
1817
				/* notify upper level of new mailbox size */
1817
				/* notify upper level of new mailbox size */
1818
  mail_exists (stream,stream->nmsgs);
1818
  mail_exists (stream,stream->nmsgs);
(-)a/src/osdep/unix/mh.c (-4 / +4 lines)
Lines 1276-1283 Link Here
1276
1276
1277
void mh_setdate (char *file,MESSAGECACHE *elt)
1277
void mh_setdate (char *file,MESSAGECACHE *elt)
1278
{
1278
{
1279
  time_t tp[2];
1279
  struct utimbuf tp;
1280
  tp[0] = time (0);		/* atime is now */
1280
  tp.actime = time (0);		/* atime is now */
1281
  tp[1] = mail_longdate (elt);	/* modification time */
1281
  tp.modtime = mail_longdate (elt);	/* modification time */
1282
  utime (file,tp);		/* set the times */
1282
  utime (file,&tp);		/* set the times */
1283
}
1283
}
(-)a/src/osdep/unix/mmdf.c (-26 / +26 lines)
Lines 366-372 Link Here
366
  int ret = NIL;
366
  int ret = NIL;
367
  char *t,file[MAILTMPLEN];
367
  char *t,file[MAILTMPLEN];
368
  struct stat sbuf;
368
  struct stat sbuf;
369
  time_t tp[2];
369
  struct utimbuf tp;
370
  errno = EINVAL;		/* assume invalid argument */
370
  errno = EINVAL;		/* assume invalid argument */
371
				/* must be non-empty file */
371
				/* must be non-empty file */
372
  if ((t = dummy_file (file,name)) && !stat (t,&sbuf)) {
372
  if ((t = dummy_file (file,name)) && !stat (t,&sbuf)) {
Lines 377-385 Link Here
377
      close (fd);		/* close the file */
377
      close (fd);		/* close the file */
378
				/* \Marked status? */
378
				/* \Marked status? */
379
      if ((sbuf.st_ctime > sbuf.st_atime) || (sbuf.st_mtime > sbuf.st_atime)) {
379
      if ((sbuf.st_ctime > sbuf.st_atime) || (sbuf.st_mtime > sbuf.st_atime)) {
380
	tp[0] = sbuf.st_atime;	/* preserve atime and mtime */
380
	tp.actime = sbuf.st_atime;	/* preserve atime and mtime */
381
	tp[1] = sbuf.st_mtime;
381
	tp.modtime = sbuf.st_mtime;
382
	utime (file,tp);	/* set the times */
382
	utime (file,&tp);	/* set the times */
383
      }
383
      }
384
    }
384
    }
385
  }
385
  }
Lines 1024-1030 Link Here
1024
  int fd;
1024
  int fd;
1025
  char *s,file[MAILTMPLEN];
1025
  char *s,file[MAILTMPLEN];
1026
  DOTLOCK lock;
1026
  DOTLOCK lock;
1027
  time_t tp[2];
1027
  struct utimbuf tp;
1028
  unsigned long i,j;
1028
  unsigned long i,j;
1029
  MESSAGECACHE *elt;
1029
  MESSAGECACHE *elt;
1030
  long ret = T;
1030
  long ret = T;
Lines 1126-1137 Link Here
1126
    mail_free_searchset (&source);
1126
    mail_free_searchset (&source);
1127
    mail_free_searchset (&dest);
1127
    mail_free_searchset (&dest);
1128
  }
1128
  }
1129
  tp[1] = time (0);		/* set mtime to now */
1129
  tp.modtime = time (0);		/* set mtime to now */
1130
  if (ret) tp[0] = tp[1] - 1;	/* set atime to now-1 if successful copy */
1130
  if (ret) tp.actime = tp.modtime - 1;	/* set atime to now-1 if successful copy */
1131
  else tp[0] =			/* else preserve \Marked status */
1131
  else tp.actime =			/* else preserve \Marked status */
1132
	 ((sbuf.st_ctime > sbuf.st_atime) || (sbuf.st_mtime > sbuf.st_atime)) ?
1132
	 ((sbuf.st_ctime > sbuf.st_atime) || (sbuf.st_mtime > sbuf.st_atime)) ?
1133
	 sbuf.st_atime : tp[1];
1133
	 sbuf.st_atime : tp.modtime;
1134
  utime (file,tp);		/* set the times */
1134
  utime (file,&tp);		/* set the times */
1135
  mmdf_unlock (fd,NIL,&lock);	/* unlock and close mailbox */
1135
  mmdf_unlock (fd,NIL,&lock);	/* unlock and close mailbox */
1136
  if (tstream) {		/* update last UID if we can */
1136
  if (tstream) {		/* update last UID if we can */
1137
    MMDFLOCAL *local = (MMDFLOCAL *) tstream->local;
1137
    MMDFLOCAL *local = (MMDFLOCAL *) tstream->local;
Lines 1165-1171 Link Here
1165
  int fd;
1165
  int fd;
1166
  unsigned long i;
1166
  unsigned long i;
1167
  char *flags,*date,buf[BUFLEN],tmp[MAILTMPLEN],file[MAILTMPLEN];
1167
  char *flags,*date,buf[BUFLEN],tmp[MAILTMPLEN],file[MAILTMPLEN];
1168
  time_t tp[2];
1168
  struct utimbuf tp;
1169
  FILE *sf,*df;
1169
  FILE *sf,*df;
1170
  MESSAGECACHE elt;
1170
  MESSAGECACHE elt;
1171
  DOTLOCK lock;
1171
  DOTLOCK lock;
Lines 1279-1298 Link Here
1279
  }
1279
  }
1280
  fstat (fd,&sbuf);		/* get current file size */
1280
  fstat (fd,&sbuf);		/* get current file size */
1281
  rewind (sf);
1281
  rewind (sf);
1282
  tp[1] = time (0);		/* set mtime to now */
1282
  tp.modtime = time (0);		/* set mtime to now */
1283
				/* write all messages */
1283
				/* write all messages */
1284
  if (!mmdf_append_msgs (tstream,sf,df,au ? dst : NIL) ||
1284
  if (!mmdf_append_msgs (tstream,sf,df,au ? dst : NIL) ||
1285
      (fflush (df) == EOF) || fsync (fd)) {
1285
      (fflush (df) == EOF) || fsync (fd)) {
1286
    sprintf (buf,"Message append failed: %s",strerror (errno));
1286
    sprintf (buf,"Message append failed: %s",strerror (errno));
1287
    MM_LOG (buf,ERROR);
1287
    MM_LOG (buf,ERROR);
1288
    ftruncate (fd,sbuf.st_size);
1288
    ftruncate (fd,sbuf.st_size);
1289
    tp[0] =			/* preserve \Marked status */
1289
    tp.actime =			/* preserve \Marked status */
1290
      ((sbuf.st_ctime > sbuf.st_atime) || (sbuf.st_mtime > sbuf.st_atime)) ?
1290
      ((sbuf.st_ctime > sbuf.st_atime) || (sbuf.st_mtime > sbuf.st_atime)) ?
1291
      sbuf.st_atime : tp[1];
1291
      sbuf.st_atime : tp.modtime;
1292
    ret = NIL;			/* return error */
1292
    ret = NIL;			/* return error */
1293
  }
1293
  }
1294
  else tp[0] = tp[1] - 1;	/* set atime to now-1 if successful copy */
1294
  else tp.actime = tp.modtime - 1;	/* set atime to now-1 if successful copy */
1295
  utime (file,tp);		/* set the times */
1295
  utime (file,&tp);		/* set the times */
1296
  fclose (sf);			/* done with scratch file */
1296
  fclose (sf);			/* done with scratch file */
1297
				/* force UIDVALIDITY assignment now */
1297
				/* force UIDVALIDITY assignment now */
1298
  if (tstream && !tstream->uid_validity) tstream->uid_validity = time (0);
1298
  if (tstream && !tstream->uid_validity) tstream->uid_validity = time (0);
Lines 1526-1556 Link Here
1526
{
1526
{
1527
  if (stream) {			/* need to muck with times? */
1527
  if (stream) {			/* need to muck with times? */
1528
    struct stat sbuf;
1528
    struct stat sbuf;
1529
    time_t tp[2];
1529
    struct utimbuf tp;
1530
    time_t now = time (0);
1530
    time_t now = time (0);
1531
    fstat (fd,&sbuf);		/* get file times */
1531
    fstat (fd,&sbuf);		/* get file times */
1532
    if (LOCAL->ld >= 0) {	/* yes, readwrite session? */
1532
    if (LOCAL->ld >= 0) {	/* yes, readwrite session? */
1533
      tp[0] = now;		/* set atime to now */
1533
      tp.actime = now;		/* set atime to now */
1534
				/* set mtime to (now - 1) if necessary */
1534
				/* set mtime to (now - 1) if necessary */
1535
      tp[1] = (now > sbuf.st_mtime) ? sbuf.st_mtime : now - 1;
1535
      tp.modtime = (now > sbuf.st_mtime) ? sbuf.st_mtime : now - 1;
1536
    }
1536
    }
1537
    else if (stream->recent) {	/* readonly with recent messages */
1537
    else if (stream->recent) {	/* readonly with recent messages */
1538
      if ((sbuf.st_atime >= sbuf.st_mtime) ||
1538
      if ((sbuf.st_atime >= sbuf.st_mtime) ||
1539
	  (sbuf.st_atime >= sbuf.st_ctime))
1539
	  (sbuf.st_atime >= sbuf.st_ctime))
1540
				/* keep past mtime, whack back atime */
1540
				/* keep past mtime, whack back atime */
1541
	tp[0] = (tp[1] = (sbuf.st_mtime < now) ? sbuf.st_mtime : now) - 1;
1541
	tp.actime = (tp.modtime = (sbuf.st_mtime < now) ? sbuf.st_mtime : now) - 1;
1542
      else now = 0;		/* no time change needed */
1542
      else now = 0;		/* no time change needed */
1543
    }
1543
    }
1544
				/* readonly with no recent messages */
1544
				/* readonly with no recent messages */
1545
    else if ((sbuf.st_atime < sbuf.st_mtime) ||
1545
    else if ((sbuf.st_atime < sbuf.st_mtime) ||
1546
	     (sbuf.st_atime < sbuf.st_ctime)) {
1546
	     (sbuf.st_atime < sbuf.st_ctime)) {
1547
      tp[0] = now;		/* set atime to now */
1547
      tp.actime = now;		/* set atime to now */
1548
				/* set mtime to (now - 1) if necessary */
1548
				/* set mtime to (now - 1) if necessary */
1549
      tp[1] = (now > sbuf.st_mtime) ? sbuf.st_mtime : now - 1;
1549
      tp.modtime = (now > sbuf.st_mtime) ? sbuf.st_mtime : now - 1;
1550
    }
1550
    }
1551
    else now = 0;		/* no time change needed */
1551
    else now = 0;		/* no time change needed */
1552
				/* set the times, note change */
1552
				/* set the times, note change */
1553
    if (now && !utime (stream->mailbox,tp)) LOCAL->filetime = tp[1];
1553
    if (now && !utime (stream->mailbox,&tp)) LOCAL->filetime = tp.modtime;
1554
  }
1554
  }
1555
  flock (fd,LOCK_UN);		/* release flock'ers */
1555
  flock (fd,LOCK_UN);		/* release flock'ers */
1556
  if (!stream) close (fd);	/* close the file if no stream */
1556
  if (!stream) close (fd);	/* close the file if no stream */
Lines 2238-2244 Link Here
2238
  MESSAGECACHE *elt;
2238
  MESSAGECACHE *elt;
2239
  MMDFFILE f;
2239
  MMDFFILE f;
2240
  char *s;
2240
  char *s;
2241
  time_t tp[2];
2241
  struct utimbuf tp;
2242
  long ret,flag;
2242
  long ret,flag;
2243
  unsigned long i,j;
2243
  unsigned long i,j;
2244
  unsigned long recent = stream->recent;
2244
  unsigned long recent = stream->recent;
Lines 2391-2399 Link Here
2391
    mail_exists (stream,stream->nmsgs);
2391
    mail_exists (stream,stream->nmsgs);
2392
    mail_recent (stream,recent);
2392
    mail_recent (stream,recent);
2393
				/* set atime to now, mtime a second earlier */
2393
				/* set atime to now, mtime a second earlier */
2394
    tp[1] = (tp[0] = time (0)) - 1;
2394
    tp.modtime = (tp.actime = time (0)) - 1;
2395
				/* set the times, note change */
2395
				/* set the times, note change */
2396
    if (!utime (stream->mailbox,tp)) LOCAL->filetime = tp[1];
2396
    if (!utime (stream->mailbox,&tp)) LOCAL->filetime = tp.modtime;
2397
    close (LOCAL->fd);		/* close and reopen file */
2397
    close (LOCAL->fd);		/* close and reopen file */
2398
    if ((LOCAL->fd = open (stream->mailbox,O_RDWR,
2398
    if ((LOCAL->fd = open (stream->mailbox,O_RDWR,
2399
			   (long) mail_parameters (NIL,GET_MBXPROTECTION,NIL)))
2399
			   (long) mail_parameters (NIL,GET_MBXPROTECTION,NIL)))
(-)a/src/osdep/unix/mtx.c (-33 / +33 lines)
Lines 172-178 Link Here
172
  int ret = NIL;
172
  int ret = NIL;
173
  char *s,file[MAILTMPLEN];
173
  char *s,file[MAILTMPLEN];
174
  struct stat sbuf;
174
  struct stat sbuf;
175
  time_t tp[2];
175
  struct utimbuf tp;
176
  errno = EINVAL;		/* assume invalid argument */
176
  errno = EINVAL;		/* assume invalid argument */
177
				/* if file, get its status */
177
				/* if file, get its status */
178
  if ((s = mtx_file (file,name)) && !stat (s,&sbuf)) {
178
  if ((s = mtx_file (file,name)) && !stat (s,&sbuf)) {
Lines 194-202 Link Here
194
      close (fd);		/* close the file */
194
      close (fd);		/* close the file */
195
				/* \Marked status? */
195
				/* \Marked status? */
196
      if (sbuf.st_ctime > sbuf.st_atime) {
196
      if (sbuf.st_ctime > sbuf.st_atime) {
197
	tp[0] = sbuf.st_atime;	/* preserve atime and mtime */
197
	tp.actime = sbuf.st_atime;	/* preserve atime and mtime */
198
	tp[1] = sbuf.st_mtime;
198
	tp.modtime = sbuf.st_mtime;
199
	utime (file,tp);	/* set the times */
199
	utime (file,&tp);	/* set the times */
200
      }
200
      }
201
    }
201
    }
202
  }
202
  }
Lines 558-571 Link Here
558
558
559
void mtx_flag (MAILSTREAM *stream,char *sequence,char *flag,long flags)
559
void mtx_flag (MAILSTREAM *stream,char *sequence,char *flag,long flags)
560
{
560
{
561
  time_t tp[2];
561
  struct utimbuf tp;
562
  struct stat sbuf;
562
  struct stat sbuf;
563
  if (!stream->rdonly) {	/* make sure the update takes */
563
  if (!stream->rdonly) {	/* make sure the update takes */
564
    fsync (LOCAL->fd);
564
    fsync (LOCAL->fd);
565
    fstat (LOCAL->fd,&sbuf);	/* get current write time */
565
    fstat (LOCAL->fd,&sbuf);	/* get current write time */
566
    tp[1] = LOCAL->filetime = sbuf.st_mtime;
566
    tp.modtime = LOCAL->filetime = sbuf.st_mtime;
567
    tp[0] = time (0);		/* make sure read comes after all that */
567
    tp.actime = time (0);		/* make sure read comes after all that */
568
    utime (stream->mailbox,tp);
568
    utime (stream->mailbox,&tp);
569
  }
569
  }
570
}
570
}
571
571
Lines 729-735 Link Here
729
long mtx_expunge (MAILSTREAM *stream,char *sequence,long options)
729
long mtx_expunge (MAILSTREAM *stream,char *sequence,long options)
730
{
730
{
731
  long ret;
731
  long ret;
732
  time_t tp[2];
732
  struct utimbuf tp;
733
  struct stat sbuf;
733
  struct stat sbuf;
734
  off_t pos = 0;
734
  off_t pos = 0;
735
  int ld;
735
  int ld;
Lines 832-840 Link Here
832
      else MM_LOG ("No messages deleted, so no update needed",(long) NIL);
832
      else MM_LOG ("No messages deleted, so no update needed",(long) NIL);
833
      fsync (LOCAL->fd);	/* force disk update */
833
      fsync (LOCAL->fd);	/* force disk update */
834
      fstat (LOCAL->fd,&sbuf);	/* get new write time */
834
      fstat (LOCAL->fd,&sbuf);	/* get new write time */
835
      tp[1] = LOCAL->filetime = sbuf.st_mtime;
835
      tp.modtime = LOCAL->filetime = sbuf.st_mtime;
836
      tp[0] = time (0);		/* reset atime to now */
836
      tp.actime = time (0);		/* reset atime to now */
837
      utime (stream->mailbox,tp);
837
      utime (stream->mailbox,&tp);
838
      MM_NOCRITICAL (stream);	/* release critical */
838
      MM_NOCRITICAL (stream);	/* release critical */
839
				/* notify upper level of new mailbox size */
839
				/* notify upper level of new mailbox size */
840
      mail_exists (stream,stream->nmsgs);
840
      mail_exists (stream,stream->nmsgs);
Lines 859-865 Link Here
859
long mtx_copy (MAILSTREAM *stream,char *sequence,char *mailbox,long options)
859
long mtx_copy (MAILSTREAM *stream,char *sequence,char *mailbox,long options)
860
{
860
{
861
  struct stat sbuf;
861
  struct stat sbuf;
862
  time_t tp[2];
862
  struct utimbuf tp;
863
  MESSAGECACHE *elt;
863
  MESSAGECACHE *elt;
864
  unsigned long i,j,k;
864
  unsigned long i,j,k;
865
  long ret = LONGT;
865
  long ret = LONGT;
Lines 925-935 Link Here
925
    MM_LOG (LOCAL->buf,ERROR);
925
    MM_LOG (LOCAL->buf,ERROR);
926
    ftruncate (fd,sbuf.st_size);
926
    ftruncate (fd,sbuf.st_size);
927
  }
927
  }
928
  if (ret) tp[0] = time (0) - 1;/* set atime to now-1 if successful copy */
928
  if (ret) tp.actime = time (0) - 1;/* set atime to now-1 if successful copy */
929
				/* else preserve \Marked status */
929
				/* else preserve \Marked status */
930
  else tp[0] = (sbuf.st_ctime > sbuf.st_atime) ? sbuf.st_atime : time(0);
930
  else tp.actime = (sbuf.st_ctime > sbuf.st_atime) ? sbuf.st_atime : time(0);
931
  tp[1] = sbuf.st_mtime;	/* preserve mtime */
931
  tp.modtime = sbuf.st_mtime;	/* preserve mtime */
932
  utime (file,tp);		/* set the times */
932
  utime (file,&tp);		/* set the times */
933
  close (fd);			/* close the file */
933
  close (fd);			/* close the file */
934
  unlockfd (ld,lock);		/* release exclusive parse/append permission */
934
  unlockfd (ld,lock);		/* release exclusive parse/append permission */
935
  MM_NOCRITICAL (stream);	/* release critical */
935
  MM_NOCRITICAL (stream);	/* release critical */
Lines 944-952 Link Here
944
    if (!stream->rdonly) {	/* make sure the update takes */
944
    if (!stream->rdonly) {	/* make sure the update takes */
945
      fsync (LOCAL->fd);
945
      fsync (LOCAL->fd);
946
      fstat (LOCAL->fd,&sbuf);	/* get current write time */
946
      fstat (LOCAL->fd,&sbuf);	/* get current write time */
947
      tp[1] = LOCAL->filetime = sbuf.st_mtime;
947
      tp.modtime = LOCAL->filetime = sbuf.st_mtime;
948
      tp[0] = time (0);		/* make sure atime remains greater */
948
      tp.actime = time (0);		/* make sure atime remains greater */
949
      utime (stream->mailbox,tp);
949
      utime (stream->mailbox,&tp);
950
    }
950
    }
951
  }
951
  }
952
  if (ret && mail_parameters (NIL,GET_COPYUID,NIL))
952
  if (ret && mail_parameters (NIL,GET_COPYUID,NIL))
Lines 967-973 Link Here
967
  struct stat sbuf;
967
  struct stat sbuf;
968
  int fd,ld,c;
968
  int fd,ld,c;
969
  char *flags,*date,tmp[MAILTMPLEN],file[MAILTMPLEN],lock[MAILTMPLEN];
969
  char *flags,*date,tmp[MAILTMPLEN],file[MAILTMPLEN],lock[MAILTMPLEN];
970
  time_t tp[2];
970
  struct utimbuf tp;
971
  FILE *df;
971
  FILE *df;
972
  MESSAGECACHE elt;
972
  MESSAGECACHE elt;
973
  long f;
973
  long f;
Lines 1058-1068 Link Here
1058
    }
1058
    }
1059
    ret = NIL;
1059
    ret = NIL;
1060
  }
1060
  }
1061
  if (ret) tp[0] = time (0) - 1;/* set atime to now-1 if successful copy */
1061
  if (ret) tp.actime = time (0) - 1;/* set atime to now-1 if successful copy */
1062
				/* else preserve \Marked status */
1062
				/* else preserve \Marked status */
1063
  else tp[0] = (sbuf.st_ctime > sbuf.st_atime) ? sbuf.st_atime : time(0);
1063
  else tp.actime = (sbuf.st_ctime > sbuf.st_atime) ? sbuf.st_atime : time(0);
1064
  tp[1] = sbuf.st_mtime;	/* preserve mtime */
1064
  tp.modtime = sbuf.st_mtime;	/* preserve mtime */
1065
  utime (file,tp);		/* set the times */
1065
  utime (file,&tp);		/* set the times */
1066
  fclose (df);			/* close the file */
1066
  fclose (df);			/* close the file */
1067
  unlockfd (ld,lock);		/* release exclusive parse/append permission */
1067
  unlockfd (ld,lock);		/* release exclusive parse/append permission */
1068
  MM_NOCRITICAL (stream);	/* release critical */
1068
  MM_NOCRITICAL (stream);	/* release critical */
Lines 1209-1218 Link Here
1209
  fstat (LOCAL->fd,&sbuf);	/* get status again to ensure time is right */
1209
  fstat (LOCAL->fd,&sbuf);	/* get status again to ensure time is right */
1210
  LOCAL->filetime = sbuf.st_mtime;
1210
  LOCAL->filetime = sbuf.st_mtime;
1211
  if (added && !stream->rdonly){/* make sure atime updated */
1211
  if (added && !stream->rdonly){/* make sure atime updated */
1212
    time_t tp[2];
1212
    struct utimbuf tp;
1213
    tp[0] = time (0);
1213
    tp.actime = time (0);
1214
    tp[1] = LOCAL->filetime;
1214
    tp.modtime = LOCAL->filetime;
1215
    utime (stream->mailbox,tp);
1215
    utime (stream->mailbox,&tp);
1216
  }
1216
  }
1217
  stream->silent = silent;	/* can pass up events now */
1217
  stream->silent = silent;	/* can pass up events now */
1218
  mail_exists (stream,nmsgs);	/* notify upper level of new mailbox size */
1218
  mail_exists (stream,nmsgs);	/* notify upper level of new mailbox size */
Lines 1287-1293 Link Here
1287
1287
1288
void mtx_update_status (MAILSTREAM *stream,unsigned long msgno,long syncflag)
1288
void mtx_update_status (MAILSTREAM *stream,unsigned long msgno,long syncflag)
1289
{
1289
{
1290
  time_t tp[2];
1290
  struct utimbuf tp;
1291
  struct stat sbuf;
1291
  struct stat sbuf;
1292
  MESSAGECACHE *elt = mail_elt (stream,msgno);
1292
  MESSAGECACHE *elt = mail_elt (stream,msgno);
1293
  unsigned long j,k = 0;
1293
  unsigned long j,k = 0;
Lines 1310-1318 Link Here
1310
    if (syncflag) {		/* sync if requested */
1310
    if (syncflag) {		/* sync if requested */
1311
      fsync (LOCAL->fd);
1311
      fsync (LOCAL->fd);
1312
      fstat (LOCAL->fd,&sbuf);	/* get new write time */
1312
      fstat (LOCAL->fd,&sbuf);	/* get new write time */
1313
      tp[1] = LOCAL->filetime = sbuf.st_mtime;
1313
      tp.modtime = LOCAL->filetime = sbuf.st_mtime;
1314
      tp[0] = time (0);		/* make sure read is later */
1314
      tp.actime = time (0);		/* make sure read is later */
1315
      utime (stream->mailbox,tp);
1315
      utime (stream->mailbox,&tp);
1316
    }
1316
    }
1317
  }
1317
  }
1318
}
1318
}
(-)a/src/osdep/unix/mx.c (-4 / +4 lines)
Lines 1280-1287 Link Here
1280
1280
1281
void mx_setdate (char *file,MESSAGECACHE *elt)
1281
void mx_setdate (char *file,MESSAGECACHE *elt)
1282
{
1282
{
1283
  time_t tp[2];
1283
  struct utimbuf tp;
1284
  tp[0] = time (0);		/* atime is now */
1284
  tp.actime = time (0);		/* atime is now */
1285
  tp[1] = mail_longdate (elt);	/* modification time */
1285
  tp.modtime = mail_longdate (elt);	/* modification time */
1286
  utime (file,tp);		/* set the times */
1286
  utime (file,&tp);		/* set the times */
1287
}
1287
}
(-)a/src/osdep/unix/tenex.c (-33 / +33 lines)
Lines 179-185 Link Here
179
  int ret = NIL;
179
  int ret = NIL;
180
  char *s,file[MAILTMPLEN];
180
  char *s,file[MAILTMPLEN];
181
  struct stat sbuf;
181
  struct stat sbuf;
182
  time_t tp[2];
182
  struct utimbuf tp;
183
  errno = EINVAL;		/* assume invalid argument */
183
  errno = EINVAL;		/* assume invalid argument */
184
				/* if file, get its status */
184
				/* if file, get its status */
185
  if ((s = tenex_file (file,name)) && !stat (s,&sbuf)) {
185
  if ((s = tenex_file (file,name)) && !stat (s,&sbuf)) {
Lines 201-209 Link Here
201
      close (fd);		/* close the file */
201
      close (fd);		/* close the file */
202
				/* \Marked status? */
202
				/* \Marked status? */
203
      if (sbuf.st_ctime > sbuf.st_atime) {
203
      if (sbuf.st_ctime > sbuf.st_atime) {
204
	tp[0] = sbuf.st_atime;	/* preserve atime and mtime */
204
	tp.actime = sbuf.st_atime;	/* preserve atime and mtime */
205
	tp[1] = sbuf.st_mtime;
205
	tp.modtime = sbuf.st_mtime;
206
	utime (file,tp);	/* set the times */
206
	utime (file,&tp);	/* set the times */
207
      }
207
      }
208
    }
208
    }
209
  }
209
  }
Lines 647-660 Link Here
647
647
648
void tenex_flag (MAILSTREAM *stream,char *sequence,char *flag,long flags)
648
void tenex_flag (MAILSTREAM *stream,char *sequence,char *flag,long flags)
649
{
649
{
650
  time_t tp[2];
650
  struct utimbuf tp;
651
  struct stat sbuf;
651
  struct stat sbuf;
652
  if (!stream->rdonly) {	/* make sure the update takes */
652
  if (!stream->rdonly) {	/* make sure the update takes */
653
    fsync (LOCAL->fd);
653
    fsync (LOCAL->fd);
654
    fstat (LOCAL->fd,&sbuf);	/* get current write time */
654
    fstat (LOCAL->fd,&sbuf);	/* get current write time */
655
    tp[1] = LOCAL->filetime = sbuf.st_mtime;
655
    tp.modtime = LOCAL->filetime = sbuf.st_mtime;
656
    tp[0] = time (0);		/* make sure read comes after all that */
656
    tp.actime = time (0);		/* make sure read comes after all that */
657
    utime (stream->mailbox,tp);
657
    utime (stream->mailbox,&tp);
658
  }
658
  }
659
}
659
}
660
660
Lines 818-824 Link Here
818
long tenex_expunge (MAILSTREAM *stream,char *sequence,long options)
818
long tenex_expunge (MAILSTREAM *stream,char *sequence,long options)
819
{
819
{
820
  long ret;
820
  long ret;
821
  time_t tp[2];
821
  struct utimbuf tp;
822
  struct stat sbuf;
822
  struct stat sbuf;
823
  off_t pos = 0;
823
  off_t pos = 0;
824
  int ld;
824
  int ld;
Lines 922-930 Link Here
922
      else MM_LOG ("No messages deleted, so no update needed",(long) NIL);
922
      else MM_LOG ("No messages deleted, so no update needed",(long) NIL);
923
      fsync (LOCAL->fd);		/* force disk update */
923
      fsync (LOCAL->fd);		/* force disk update */
924
      fstat (LOCAL->fd,&sbuf);	/* get new write time */
924
      fstat (LOCAL->fd,&sbuf);	/* get new write time */
925
      tp[1] = LOCAL->filetime = sbuf.st_mtime;
925
      tp.modtime = LOCAL->filetime = sbuf.st_mtime;
926
      tp[0] = time (0);		/* reset atime to now */
926
      tp.actime = time (0);		/* reset atime to now */
927
      utime (stream->mailbox,tp);
927
      utime (stream->mailbox,&tp);
928
      MM_NOCRITICAL (stream);	/* release critical */
928
      MM_NOCRITICAL (stream);	/* release critical */
929
				/* notify upper level of new mailbox size */
929
				/* notify upper level of new mailbox size */
930
      mail_exists (stream,stream->nmsgs);
930
      mail_exists (stream,stream->nmsgs);
Lines 949-955 Link Here
949
long tenex_copy (MAILSTREAM *stream,char *sequence,char *mailbox,long options)
949
long tenex_copy (MAILSTREAM *stream,char *sequence,char *mailbox,long options)
950
{
950
{
951
  struct stat sbuf;
951
  struct stat sbuf;
952
  time_t tp[2];
952
  struct utimbuf tp;
953
  MESSAGECACHE *elt;
953
  MESSAGECACHE *elt;
954
  unsigned long i,j,k;
954
  unsigned long i,j,k;
955
  long ret = LONGT;
955
  long ret = LONGT;
Lines 1015-1025 Link Here
1015
    MM_LOG (LOCAL->buf,ERROR);
1015
    MM_LOG (LOCAL->buf,ERROR);
1016
    ftruncate (fd,sbuf.st_size);
1016
    ftruncate (fd,sbuf.st_size);
1017
  }
1017
  }
1018
  if (ret) tp[0] = time (0) - 1;/* set atime to now-1 if successful copy */
1018
  if (ret) tp.actime = time (0) - 1;/* set atime to now-1 if successful copy */
1019
				/* else preserve \Marked status */
1019
				/* else preserve \Marked status */
1020
  else tp[0] = (sbuf.st_ctime > sbuf.st_atime) ? sbuf.st_atime : time(0);
1020
  else tp.actime = (sbuf.st_ctime > sbuf.st_atime) ? sbuf.st_atime : time(0);
1021
  tp[1] = sbuf.st_mtime;	/* preserve mtime */
1021
  tp.modtime = sbuf.st_mtime;	/* preserve mtime */
1022
  utime (file,tp);		/* set the times */
1022
  utime (file,&tp);		/* set the times */
1023
  close (fd);			/* close the file */
1023
  close (fd);			/* close the file */
1024
  unlockfd (ld,lock);		/* release exclusive parse/append permission */
1024
  unlockfd (ld,lock);		/* release exclusive parse/append permission */
1025
  MM_NOCRITICAL (stream);	/* release critical */
1025
  MM_NOCRITICAL (stream);	/* release critical */
Lines 1034-1042 Link Here
1034
    if (!stream->rdonly) {	/* make sure the update takes */
1034
    if (!stream->rdonly) {	/* make sure the update takes */
1035
      fsync (LOCAL->fd);
1035
      fsync (LOCAL->fd);
1036
      fstat (LOCAL->fd,&sbuf);	/* get current write time */
1036
      fstat (LOCAL->fd,&sbuf);	/* get current write time */
1037
      tp[1] = LOCAL->filetime = sbuf.st_mtime;
1037
      tp.modtime = LOCAL->filetime = sbuf.st_mtime;
1038
      tp[0] = time (0);		/* make sure atime remains greater */
1038
      tp.actime = time (0);		/* make sure atime remains greater */
1039
      utime (stream->mailbox,tp);
1039
      utime (stream->mailbox,&tp);
1040
    }
1040
    }
1041
  }
1041
  }
1042
  if (ret && mail_parameters (NIL,GET_COPYUID,NIL))
1042
  if (ret && mail_parameters (NIL,GET_COPYUID,NIL))
Lines 1057-1063 Link Here
1057
  struct stat sbuf;
1057
  struct stat sbuf;
1058
  int fd,ld,c;
1058
  int fd,ld,c;
1059
  char *flags,*date,tmp[MAILTMPLEN],file[MAILTMPLEN],lock[MAILTMPLEN];
1059
  char *flags,*date,tmp[MAILTMPLEN],file[MAILTMPLEN],lock[MAILTMPLEN];
1060
  time_t tp[2];
1060
  struct utimbuf tp;
1061
  FILE *df;
1061
  FILE *df;
1062
  MESSAGECACHE elt;
1062
  MESSAGECACHE elt;
1063
  long f;
1063
  long f;
Lines 1155-1165 Link Here
1155
    }
1155
    }
1156
    ret = NIL;
1156
    ret = NIL;
1157
  }
1157
  }
1158
  if (ret) tp[0] = time (0) - 1;/* set atime to now-1 if successful copy */
1158
  if (ret) tp.actime = time (0) - 1;/* set atime to now-1 if successful copy */
1159
				/* else preserve \Marked status */
1159
				/* else preserve \Marked status */
1160
  else tp[0] = (sbuf.st_ctime > sbuf.st_atime) ? sbuf.st_atime : time(0);
1160
  else tp.actime = (sbuf.st_ctime > sbuf.st_atime) ? sbuf.st_atime : time(0);
1161
  tp[1] = sbuf.st_mtime;	/* preserve mtime */
1161
  tp.modtime = sbuf.st_mtime;	/* preserve mtime */
1162
  utime (file,tp);		/* set the times */
1162
  utime (file,&tp);		/* set the times */
1163
  fclose (df);			/* close the file */
1163
  fclose (df);			/* close the file */
1164
  unlockfd (ld,lock);		/* release exclusive parse/append permission */
1164
  unlockfd (ld,lock);		/* release exclusive parse/append permission */
1165
  MM_NOCRITICAL (stream);	/* release critical */
1165
  MM_NOCRITICAL (stream);	/* release critical */
Lines 1321-1330 Link Here
1321
  fstat (LOCAL->fd,&sbuf);	/* get status again to ensure time is right */
1321
  fstat (LOCAL->fd,&sbuf);	/* get status again to ensure time is right */
1322
  LOCAL->filetime = sbuf.st_mtime;
1322
  LOCAL->filetime = sbuf.st_mtime;
1323
  if (added && !stream->rdonly){/* make sure atime updated */
1323
  if (added && !stream->rdonly){/* make sure atime updated */
1324
    time_t tp[2];
1324
    struct utimbuf tp;
1325
    tp[0] = time (0);
1325
    tp.actime = time (0);
1326
    tp[1] = LOCAL->filetime;
1326
    tp.modtime = LOCAL->filetime;
1327
    utime (stream->mailbox,tp);
1327
    utime (stream->mailbox,&tp);
1328
  }
1328
  }
1329
  stream->silent = silent;	/* can pass up events now */
1329
  stream->silent = silent;	/* can pass up events now */
1330
  mail_exists (stream,nmsgs);	/* notify upper level of new mailbox size */
1330
  mail_exists (stream,nmsgs);	/* notify upper level of new mailbox size */
Lines 1399-1405 Link Here
1399
1399
1400
void tenex_update_status (MAILSTREAM *stream,unsigned long msgno,long syncflag)
1400
void tenex_update_status (MAILSTREAM *stream,unsigned long msgno,long syncflag)
1401
{
1401
{
1402
  time_t tp[2];
1402
  struct utimbuf tp;
1403
  struct stat sbuf;
1403
  struct stat sbuf;
1404
  MESSAGECACHE *elt = mail_elt (stream,msgno);
1404
  MESSAGECACHE *elt = mail_elt (stream,msgno);
1405
  unsigned long j,k = 0;
1405
  unsigned long j,k = 0;
Lines 1422-1430 Link Here
1422
    if (syncflag) {		/* sync if requested */
1422
    if (syncflag) {		/* sync if requested */
1423
      fsync (LOCAL->fd);
1423
      fsync (LOCAL->fd);
1424
      fstat (LOCAL->fd,&sbuf);	/* get new write time */
1424
      fstat (LOCAL->fd,&sbuf);	/* get new write time */
1425
      tp[1] = LOCAL->filetime = sbuf.st_mtime;
1425
      tp.modtime = LOCAL->filetime = sbuf.st_mtime;
1426
      tp[0] = time (0);		/* make sure read is later */
1426
      tp.actime = time (0);		/* make sure read is later */
1427
      utime (stream->mailbox,tp);
1427
      utime (stream->mailbox,&tp);
1428
    }
1428
    }
1429
  }
1429
  }
1430
}
1430
}
(-)a/src/osdep/unix/unix.c (-26 / +26 lines)
Lines 214-220 Link Here
214
  DRIVER *ret = NIL;
214
  DRIVER *ret = NIL;
215
  char *t,file[MAILTMPLEN];
215
  char *t,file[MAILTMPLEN];
216
  struct stat sbuf;
216
  struct stat sbuf;
217
  time_t tp[2];
217
  struct utimbuf tp;
218
  errno = EINVAL;		/* assume invalid argument */
218
  errno = EINVAL;		/* assume invalid argument */
219
				/* must be non-empty file */
219
				/* must be non-empty file */
220
  if ((t = dummy_file (file,name)) && !stat (t,&sbuf)) {
220
  if ((t = dummy_file (file,name)) && !stat (t,&sbuf)) {
Lines 226-234 Link Here
226
      close (fd);		/* close the file */
226
      close (fd);		/* close the file */
227
				/* \Marked status? */
227
				/* \Marked status? */
228
      if ((sbuf.st_ctime > sbuf.st_atime) || (sbuf.st_mtime > sbuf.st_atime)) {
228
      if ((sbuf.st_ctime > sbuf.st_atime) || (sbuf.st_mtime > sbuf.st_atime)) {
229
	tp[0] = sbuf.st_atime;	/* yes, preserve atime and mtime */
229
	tp.actime = sbuf.st_atime;	/* yes, preserve atime and mtime */
230
	tp[1] = sbuf.st_mtime;
230
	tp.modtime = sbuf.st_mtime;
231
	utime (file,tp);	/* set the times */
231
	utime (file,&tp);	/* set the times */
232
      }
232
      }
233
    }
233
    }
234
  }
234
  }
Lines 884-890 Link Here
884
  int fd;
884
  int fd;
885
  char *s,file[MAILTMPLEN];
885
  char *s,file[MAILTMPLEN];
886
  DOTLOCK lock;
886
  DOTLOCK lock;
887
  time_t tp[2];
887
  struct utimbuf tp;
888
  unsigned long i,j;
888
  unsigned long i,j;
889
  MESSAGECACHE *elt;
889
  MESSAGECACHE *elt;
890
  long ret = T;
890
  long ret = T;
Lines 990-1001 Link Here
990
    mail_free_searchset (&source);
990
    mail_free_searchset (&source);
991
    mail_free_searchset (&dest);
991
    mail_free_searchset (&dest);
992
  }
992
  }
993
  tp[1] = time (0);		/* set mtime to now */
993
  tp.modtime = time (0);		/* set mtime to now */
994
  if (ret) tp[0] = tp[1] - 1;	/* set atime to now-1 if successful copy */
994
  if (ret) tp.actime = tp.modtime - 1;	/* set atime to now-1 if successful copy */
995
  else tp[0] =			/* else preserve \Marked status */
995
  else tp.actime =			/* else preserve \Marked status */
996
	 ((sbuf.st_ctime > sbuf.st_atime) || (sbuf.st_mtime > sbuf.st_atime)) ?
996
	 ((sbuf.st_ctime > sbuf.st_atime) || (sbuf.st_mtime > sbuf.st_atime)) ?
997
	 sbuf.st_atime : tp[1];
997
	 sbuf.st_atime : tp.modtime;
998
  utime (file,tp);		/* set the times */
998
  utime (file,&tp);		/* set the times */
999
  unix_unlock (fd,NIL,&lock);	/* unlock and close mailbox */
999
  unix_unlock (fd,NIL,&lock);	/* unlock and close mailbox */
1000
  if (tstream) {		/* update last UID if we can */
1000
  if (tstream) {		/* update last UID if we can */
1001
    UNIXLOCAL *local = (UNIXLOCAL *) tstream->local;
1001
    UNIXLOCAL *local = (UNIXLOCAL *) tstream->local;
Lines 1029-1035 Link Here
1029
  int fd;
1029
  int fd;
1030
  unsigned long i;
1030
  unsigned long i;
1031
  char *flags,*date,buf[BUFLEN],tmp[MAILTMPLEN],file[MAILTMPLEN];
1031
  char *flags,*date,buf[BUFLEN],tmp[MAILTMPLEN],file[MAILTMPLEN];
1032
  time_t tp[2];
1032
  struct utimbuf tp;
1033
  FILE *sf,*df;
1033
  FILE *sf,*df;
1034
  MESSAGECACHE elt;
1034
  MESSAGECACHE elt;
1035
  DOTLOCK lock;
1035
  DOTLOCK lock;
Lines 1143-1162 Link Here
1143
  }
1143
  }
1144
  fstat (fd,&sbuf);		/* get current file size */
1144
  fstat (fd,&sbuf);		/* get current file size */
1145
  rewind (sf);
1145
  rewind (sf);
1146
  tp[1] = time (0);		/* set mtime to now */
1146
  tp.modtime = time (0);		/* set mtime to now */
1147
				/* write all messages */
1147
				/* write all messages */
1148
  if (!unix_append_msgs (tstream,sf,df,au ? dst : NIL) ||
1148
  if (!unix_append_msgs (tstream,sf,df,au ? dst : NIL) ||
1149
      (fflush (df) == EOF) || fsync (fd)) {
1149
      (fflush (df) == EOF) || fsync (fd)) {
1150
    sprintf (buf,"Message append failed: %s",strerror (errno));
1150
    sprintf (buf,"Message append failed: %s",strerror (errno));
1151
    MM_LOG (buf,ERROR);
1151
    MM_LOG (buf,ERROR);
1152
    ftruncate (fd,sbuf.st_size);
1152
    ftruncate (fd,sbuf.st_size);
1153
    tp[0] =			/* preserve \Marked status */
1153
    tp.actime =			/* preserve \Marked status */
1154
      ((sbuf.st_ctime > sbuf.st_atime) || (sbuf.st_mtime > sbuf.st_atime)) ?
1154
      ((sbuf.st_ctime > sbuf.st_atime) || (sbuf.st_mtime > sbuf.st_atime)) ?
1155
      sbuf.st_atime : tp[1];
1155
      sbuf.st_atime : tp.modtime;
1156
    ret = NIL;			/* return error */
1156
    ret = NIL;			/* return error */
1157
  }
1157
  }
1158
  else tp[0] = tp[1] - 1;	/* set atime to now-1 if successful copy */
1158
  else tp.actime = tp.modtime - 1;	/* set atime to now-1 if successful copy */
1159
  utime (file,tp);		/* set the times */
1159
  utime (file,&tp);		/* set the times */
1160
  fclose (sf);			/* done with scratch file */
1160
  fclose (sf);			/* done with scratch file */
1161
				/* force UIDVALIDITY assignment now */
1161
				/* force UIDVALIDITY assignment now */
1162
  if (tstream && !tstream->uid_validity) tstream->uid_validity = time (0);
1162
  if (tstream && !tstream->uid_validity) tstream->uid_validity = time (0);
Lines 1397-1427 Link Here
1397
{
1397
{
1398
  if (stream) {			/* need to muck with times? */
1398
  if (stream) {			/* need to muck with times? */
1399
    struct stat sbuf;
1399
    struct stat sbuf;
1400
    time_t tp[2];
1400
    struct utimbuf tp;
1401
    time_t now = time (0);
1401
    time_t now = time (0);
1402
    fstat (fd,&sbuf);		/* get file times */
1402
    fstat (fd,&sbuf);		/* get file times */
1403
    if (LOCAL->ld >= 0) {	/* yes, readwrite session? */
1403
    if (LOCAL->ld >= 0) {	/* yes, readwrite session? */
1404
      tp[0] = now;		/* set atime to now */
1404
      tp.actime = now;		/* set atime to now */
1405
				/* set mtime to (now - 1) if necessary */
1405
				/* set mtime to (now - 1) if necessary */
1406
      tp[1] = (now > sbuf.st_mtime) ? sbuf.st_mtime : now - 1;
1406
      tp.modtime = (now > sbuf.st_mtime) ? sbuf.st_mtime : now - 1;
1407
    }
1407
    }
1408
    else if (stream->recent) {	/* readonly with recent messages */
1408
    else if (stream->recent) {	/* readonly with recent messages */
1409
      if ((sbuf.st_atime >= sbuf.st_mtime) ||
1409
      if ((sbuf.st_atime >= sbuf.st_mtime) ||
1410
	  (sbuf.st_atime >= sbuf.st_ctime))
1410
	  (sbuf.st_atime >= sbuf.st_ctime))
1411
				/* keep past mtime, whack back atime */
1411
				/* keep past mtime, whack back atime */
1412
	tp[0] = (tp[1] = (sbuf.st_mtime < now) ? sbuf.st_mtime : now) - 1;
1412
	tp.actime = (tp.modtime = (sbuf.st_mtime < now) ? sbuf.st_mtime : now) - 1;
1413
      else now = 0;		/* no time change needed */
1413
      else now = 0;		/* no time change needed */
1414
    }
1414
    }
1415
				/* readonly with no recent messages */
1415
				/* readonly with no recent messages */
1416
    else if ((sbuf.st_atime < sbuf.st_mtime) ||
1416
    else if ((sbuf.st_atime < sbuf.st_mtime) ||
1417
	     (sbuf.st_atime < sbuf.st_ctime)) {
1417
	     (sbuf.st_atime < sbuf.st_ctime)) {
1418
      tp[0] = now;		/* set atime to now */
1418
      tp.actime = now;		/* set atime to now */
1419
				/* set mtime to (now - 1) if necessary */
1419
				/* set mtime to (now - 1) if necessary */
1420
      tp[1] = (now > sbuf.st_mtime) ? sbuf.st_mtime : now - 1;
1420
      tp.modtime = (now > sbuf.st_mtime) ? sbuf.st_mtime : now - 1;
1421
    }
1421
    }
1422
    else now = 0;		/* no time change needed */
1422
    else now = 0;		/* no time change needed */
1423
				/* set the times, note change */
1423
				/* set the times, note change */
1424
    if (now && !utime (stream->mailbox,tp)) LOCAL->filetime = tp[1];
1424
    if (now && !utime (stream->mailbox,&tp)) LOCAL->filetime = tp.modtime;
1425
  }
1425
  }
1426
  flock (fd,LOCK_UN);		/* release flock'ers */
1426
  flock (fd,LOCK_UN);		/* release flock'ers */
1427
  if (!stream) close (fd);	/* close the file if no stream */
1427
  if (!stream) close (fd);	/* close the file if no stream */
Lines 2075-2081 Link Here
2075
  MESSAGECACHE *elt;
2075
  MESSAGECACHE *elt;
2076
  UNIXFILE f;
2076
  UNIXFILE f;
2077
  char *s;
2077
  char *s;
2078
  time_t tp[2];
2078
  struct utimbuf tp;
2079
  long ret,flag;
2079
  long ret,flag;
2080
  unsigned long i,j;
2080
  unsigned long i,j;
2081
  unsigned long recent = stream->recent;
2081
  unsigned long recent = stream->recent;
Lines 2245-2253 Link Here
2245
    mail_exists (stream,stream->nmsgs);
2245
    mail_exists (stream,stream->nmsgs);
2246
    mail_recent (stream,recent);
2246
    mail_recent (stream,recent);
2247
				/* set atime to now, mtime a second earlier */
2247
				/* set atime to now, mtime a second earlier */
2248
    tp[1] = (tp[0] = time (0)) - 1;
2248
    tp.modtime = (tp.actime = time (0)) - 1;
2249
				/* set the times, note change */
2249
				/* set the times, note change */
2250
    if (!utime (stream->mailbox,tp)) LOCAL->filetime = tp[1];
2250
    if (!utime (stream->mailbox,&tp)) LOCAL->filetime = tp.modtime;
2251
    close (LOCAL->fd);		/* close and reopen file */
2251
    close (LOCAL->fd);		/* close and reopen file */
2252
    if ((LOCAL->fd = open (stream->mailbox,O_RDWR,
2252
    if ((LOCAL->fd = open (stream->mailbox,O_RDWR,
2253
			   (long) mail_parameters (NIL,GET_MBXPROTECTION,NIL)))
2253
			   (long) mail_parameters (NIL,GET_MBXPROTECTION,NIL)))

Return to bug 919252