]> arthur.barton.de Git - netatalk.git/commitdiff
Fix another error in moveandrename introduce probably because the *at func cleanup...
authorFrank Lahm <franklahm@googlemail.com>
Wed, 23 Mar 2011 13:19:09 +0000 (14:19 +0100)
committerFrank Lahm <franklahm@googlemail.com>
Wed, 23 Mar 2011 13:19:09 +0000 (14:19 +0100)
etc/afpd/directory.c
etc/afpd/enumerate.c
etc/afpd/file.c
etc/afpd/filedir.c

index cdf9574158f261250da4f55b5446357a9a4eb601..50cdcef7c75b8772f6533c52c69a69bc4296645c 100644 (file)
@@ -301,7 +301,7 @@ static int cname_mtouname(const struct vol *vol, const struct dir *dir, struct p
 {
     static char temp[ MAXPATHLEN + 1];
     char *t;
-    cnid_t fileid;
+    cnid_t fileid = 0;
 
     if (afp_version >= 30) {
         if (toUTF8) {
index edccf39af8ddc812a9e262ceca839d725b2d1d56..1659fb77ff89cc5fbff15513fe5915600b718ae4 100644 (file)
@@ -284,11 +284,12 @@ static int enumerate(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_,
         sd.sd_last = sd.sd_buf;
         /* if dir was in the cache we don't have the inode */
         if (( !o_path->st_valid && lstat( ".", &o_path->st ) < 0 ) ||
-              (ret = for_each_dirent(vol, ".", enumerate_loop, (void *)&sd)) < 0) 
+            (ret = for_each_dirent(vol, ".", enumerate_loop, (void *)&sd)) < 0) 
         {
+            LOG(log_error, logtype_afpd, "enumerate: loop error: %s (%d)", strerror(errno), errno);
             switch (errno) {
             case EACCES:
-               return AFPERR_ACCESS;
+                return AFPERR_ACCESS;
             case ENOTDIR:
                 return AFPERR_BADTYPE;
             case ENOMEM:
index cb3af78af52d21ee364075ccd24d8fb85e9df36e..6888182fd41f755807e3e8f2c0f5d27a77b7f26e 100644 (file)
@@ -316,6 +316,8 @@ int getmetadata(struct vol *vol,
     struct stat         *st;
     struct maccess     ma;
 
+    LOG(log_debug, logtype_afpd, "getmetadata(\"%s\")", path->u_name);
+
     upath = path->u_name;
     st = &path->st;
     data = buf;
@@ -613,6 +615,8 @@ int getfilparams(struct vol *vol,
     int                 opened = 0;
     int rc;    
 
+    LOG(log_debug, logtype_afpd, "getfilparams(\"%s\")", path->u_name);
+
     opened = PARAM_NEED_ADP(bitmap);
     adp = NULL;
 
@@ -746,6 +750,17 @@ int afp_createfile(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_,
 
     path = s_path->m_name;
     ad_setname(adp, path);
+
+    struct stat st;
+    if (lstat(upath, &st) != 0) {
+        LOG(log_error, logtype_afpd, "afp_createfile(\"%s\"): stat: %s",
+            upath, strerror(errno));
+        ad_close( adp, ADFLAGS_DF|ADFLAGS_HF);
+        return AFPERR_MISC;
+    }
+
+    (void)get_id(vol, adp, &st, dir->d_did, upath, strlen(upath));
+
     ad_flush( adp);
     ad_close( adp, ADFLAGS_DF|ADFLAGS_HF );
 
index 0e9c367023a7161dcb2f4c3dfff7c30b7577bbcd..c16ba484e34cf3c17e470c08af057a450d4878d5 100644 (file)
@@ -351,22 +351,24 @@ static int moveandrename(const struct vol *vol,
     if (!isdir) {
         if ((oldunixname = strdup(mtoupath(vol, oldname, sdir->d_did, utf8_encoding()))) == NULL)
             return AFPERR_PARAM; /* can't convert */
+        id = cnid_get(vol->v_cdb, sdir->d_did, oldunixname, strlen(oldunixname));
 
 #ifndef HAVE_ATFUNCS
         /* Need full path */
-        id = cnid_get(vol->v_cdb, sdir->d_did, p, strlen(p));
-        p = ctoupath( vol, sdir, oldname );
-        if (!p)
+        free(oldunixname);
+        if ((oldunixname = strdup(ctoupath(vol, sdir, oldname))) == NULL)
             return AFPERR_PARAM; /* pathname too long */
 #endif /* HAVE_ATFUNCS */
 
         path.st_valid = 0;
         path.u_name = oldunixname;
+
 #ifdef HAVE_ATFUNCS
         opened = of_findnameat(sdir_fd, &path);
 #else
         opened = of_findname(&path);
 #endif /* HAVE_ATFUNCS */
+
         if (opened) {
             /* reuse struct adouble so it won't break locks */
             adp = opened->of_ad;
@@ -378,8 +380,6 @@ static int moveandrename(const struct vol *vol,
         adflags = ADFLAGS_DIR;
     }
 
-    LOG(log_debug, logtype_afpd, "oldunixname: \"%s\"", oldunixname);
-
     /*
      * oldunixname now points to either
      *   a) full pathname of the source fs object (if renameat is not available)
@@ -445,8 +445,6 @@ static int moveandrename(const struct vol *vol,
         goto exit;
     }
 
-    LOG(log_debug, logtype_afpd, "oldunixname: \"%s\"", oldunixname);
-
     if ( !isdir ) {
         path.st_valid = 1;
         path.st_errno = errno;