]> arthur.barton.de Git - netatalk.git/commitdiff
Fill in the volume creation time with the datestamp instead of the
authorjmarcus <jmarcus>
Thu, 10 Oct 2002 20:27:36 +0000 (20:27 +0000)
committerjmarcus <jmarcus>
Thu, 10 Oct 2002 20:27:36 +0000 (20:27 +0000)
current timestamp.  This fixes most of the identical volume problems
seen by some users.

Tested by: Thomas Kaiser <Thomas.Kaiser@kaiser-edv.de>

etc/afpd/volume.c
libatalk/adouble/ad_open.c

index 97a60ea2a9aad9d628b9001bcc1225ed58d839a7..ebb21d9c91c48e67eb0db49dde7de52b61bdd53c 100644 (file)
@@ -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);
     }
 
index 1fe07ca405420cb9e50675c14d77bafd68bdf182..3625c4829abc92167771d4d3f78554ea00856c6e 100644 (file)
@@ -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 {