From: jmarcus Date: Thu, 10 Oct 2002 20:27:36 +0000 (+0000) Subject: Fill in the volume creation time with the datestamp instead of the X-Git-Tag: netatalk-1-6-pre1~22 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=netatalk.git;a=commitdiff_plain;h=ed29ba4834e5ca1ccc62c384e01134326a5d559b Fill in the volume creation time with the datestamp instead of the current timestamp. This fixes most of the identical volume problems seen by some users. Tested by: Thomas Kaiser --- diff --git a/etc/afpd/volume.c b/etc/afpd/volume.c index 97a60ea2..ebb21d9c 100644 --- a/etc/afpd/volume.c +++ b/etc/afpd/volume.c @@ -1,5 +1,5 @@ /* - * $Id: volume.c,v 1.36 2002-09-29 23:31:24 sibaz Exp $ + * $Id: volume.c,v 1.37 2002-10-10 20:27:36 jmarcus Exp $ * * Copyright (c) 1990,1993 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -951,6 +951,7 @@ int *buflen; ad_setentrylen( &ad, ADEID_NAME, strlen( slash )); memcpy(ad_entry( &ad, ADEID_NAME ), slash, ad_getentrylen( &ad, ADEID_NAME )); + ad_setdate(&ad, AD_DATE_CREATE | AD_DATE_UNIX, st->st_mtime); ad_flush(&ad, ADFLAGS_HF); } diff --git a/libatalk/adouble/ad_open.c b/libatalk/adouble/ad_open.c index 1fe07ca4..3625c482 100644 --- a/libatalk/adouble/ad_open.c +++ b/libatalk/adouble/ad_open.c @@ -1,5 +1,5 @@ /* - * $Id: ad_open.c,v 1.19 2002-08-29 18:57:37 didg Exp $ + * $Id: ad_open.c,v 1.20 2002-10-10 20:27:36 jmarcus Exp $ * * Copyright (c) 1999 Adrian Sun (asun@u.washington.edu) * Copyright (c) 1990,1991 Regents of The University of Michigan. @@ -176,7 +176,6 @@ static const struct entry entry_order[] = { static __inline__ int ad_v1tov2(struct adouble *ad, const char *path) { struct stat st; - struct timeval tv; u_int16_t attr; char *buf; int fd, off; @@ -203,9 +202,6 @@ static __inline__ int ad_v1tov2(struct adouble *ad, const char *path) if ((fd = open(path, O_RDWR)) < 0) goto bail_lock; - if (gettimeofday(&tv, NULL) < 0) - goto bail_lock; - if (fstat(fd, &st) || ftruncate(fd, st.st_size + SHIFTDATA) < 0) { goto bail_open; @@ -266,7 +262,7 @@ static __inline__ int ad_v1tov2(struct adouble *ad, const char *path) /* now, fill in the space with appropriate stuff. we're operating as a v2 file now. */ - ad_setdate(ad, AD_DATE_ACCESS | AD_DATE_UNIX, tv.tv_sec); + ad_setdate(ad, AD_DATE_ACCESS | AD_DATE_UNIX, st.st_mtime); memset(ad_entry(ad, ADEID_DID), 0, ADEDLEN_DID); memset(ad_entry(ad, ADEID_AFPFILEI), 0, ADEDLEN_AFPFILEI); ad_setattr(ad, attr); @@ -718,7 +714,7 @@ int ad_open( path, adflags, oflags, mode, ad ) */ memset(ad->ad_eid, 0, sizeof( ad->ad_eid )); if ( ad->ad_hf.adf_flags & ( O_TRUNC | O_CREAT )) { - struct timeval tv; + struct stat st; ad->ad_magic = AD_MAGIC; ad->ad_version = AD_VERSION; @@ -767,15 +763,20 @@ int ad_open( path, adflags, oflags, mode, ad ) &ashort, sizeof(ashort)); } - if (gettimeofday(&tv, NULL) < 0) { + /*if (gettimeofday(&tv, NULL) < 0) { ad_close(ad, adflags); return -1; + }*/ + + if (stat(path, &st) < 0) { + ad_close(ad, adflags); + return -1; } /* put something sane in the date fields */ - ad_setdate(ad, AD_DATE_CREATE | AD_DATE_UNIX, tv.tv_sec); - ad_setdate(ad, AD_DATE_MODIFY | AD_DATE_UNIX, tv.tv_sec); - ad_setdate(ad, AD_DATE_ACCESS | AD_DATE_UNIX, tv.tv_sec); + ad_setdate(ad, AD_DATE_CREATE | AD_DATE_UNIX, st.st_mtime); + ad_setdate(ad, AD_DATE_MODIFY | AD_DATE_UNIX, st.st_mtime); + ad_setdate(ad, AD_DATE_ACCESS | AD_DATE_UNIX, st.st_mtime); ad_setdate(ad, AD_DATE_BACKUP, AD_DATE_START); } else {