]> arthur.barton.de Git - netatalk.git/commitdiff
deal with folders deleted by a different process.
authordidg <didg>
Tue, 2 Mar 2004 13:27:07 +0000 (13:27 +0000)
committerdidg <didg>
Tue, 2 Mar 2004 13:27:07 +0000 (13:27 +0000)
etc/afpd/filedir.c
etc/afpd/fork.h
etc/afpd/ofork.c
etc/afpd/volume.c

index 5f43b98d2756d8dd03dc32879faf6f63563b7e97..d2c849b7e8a2ab310d7c21cdaaa60b291562597b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: filedir.c,v 1.45.2.2.2.7 2004-02-20 21:23:13 didg Exp $
+ * $Id: filedir.c,v 1.45.2.2.2.8 2004-03-02 13:27:07 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -177,10 +177,10 @@ int               ibuflen, *rbuflen;
     if (!s_path->st_valid) {
         /* it's a dir and it should be there
          * because we chdir in it in cname or
-         * it's curdir (maybe deleted, but then we can't know)
-         * 
+         * it's curdir (maybe deleted, but then we can't know).
+         * So we need to try harder.
          */
-        of_stat(s_path);
+        of_statdir(s_path);
     }
     if ( s_path->st_errno != 0 ) {
         return( AFPERR_NOOBJ );
index 8c00a38d213a27ed09620309d10c5406d6386860..3600a6e7736f88ed9e0e55581f5cc185edb1284a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: fork.h,v 1.8 2003-01-16 21:18:15 didg Exp $
+ * $Id: fork.h,v 1.8.6.1 2004-03-02 13:27:08 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -68,6 +68,7 @@ extern int          of_rename    __P((const struct vol *,
 extern int          of_flush     __P((const struct vol *));
 extern void         of_pforkdesc __P((FILE *));
 extern int          of_stat      __P((struct path *));
+extern int          of_statdir   __P((struct path *));
 /* in fork.c */
 extern int          flushfork    __P((struct ofork *));
 
index 8d47061cd07f4097a4deb397f80b177007a02f96..225f25391985f33ed43f93083afdc18144bfa9e9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: ofork.c,v 1.20.6.4 2004-02-14 15:47:20 didg Exp $
+ * $Id: ofork.c,v 1.20.6.5 2004-03-02 13:27:08 didg Exp $
  *
  * Copyright (c) 1996 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -286,6 +286,26 @@ int ret;
    return ret;
 }
 
+/* -------------------------- 
+ * assume 
+*/
+int of_statdir  (struct path *path)
+{
+static char pathname[ MAXPATHLEN + 1];
+int ret;
+
+    if (*path->m_name) {
+        /* not curdir */
+        return of_stat (path);
+    }
+    path->st_errno = 0;
+    path->st_valid = 1;
+    strcpy(pathname, "../");
+    strlcat(pathname, path->dir->d_u_name, MAXPATHLEN);
+    if ((ret = stat(pathname, &path->st)) < 0)
+       path->st_errno = errno;
+   return ret;
+}
 
 /* -------------------------- */
 struct ofork *
index 7633fb0ad8e8d54587ed77ffff159f519158ca89..4b03f06b9916d09f4407e9ebc854c3335e2af878 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: volume.c,v 1.51.2.7.2.23 2004-03-01 14:01:02 bfernhomberg Exp $
+ * $Id: volume.c,v 1.51.2.7.2.24 2004-03-02 13:27:08 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -1500,6 +1500,7 @@ int               ibuflen, *rbuflen;
     int                len, ret;
     size_t     namelen;
     u_int16_t  bitmap;
+    char        path[ MAXPATHLEN + 1];
     char        *vol_uname;
     char        *vol_mname;
 
@@ -1564,36 +1565,6 @@ int              ibuflen, *rbuflen;
 
     volume->v_dir = volume->v_root = NULL;
 
-    /* FIXME unix name != mac name */
-
-    len = convert_string_allocate( CH_UCS2, (utf8_encoding()?CH_UTF8_MAC:obj->options.maccharset),
-                                      volume->v_name, namelen, &vol_mname);
-    if ( !vol_mname || len <= 0) {
-        ret = AFPERR_MISC;
-        goto openvol_err;
-    }
-       
-    len = convert_string_allocate( CH_UCS2 , volume->v_volcharset, volume->v_name, namelen, &vol_uname);
-
-    if ( !vol_uname || len <= 0) {
-       free(vol_mname);
-        ret = AFPERR_MISC;
-        goto openvol_err;
-    }
-       
-    if ((dir = dirnew(vol_mname, vol_uname) ) == NULL) {
-       free(vol_mname);
-       free(vol_uname);
-        LOG(log_error, logtype_afpd, "afp_openvol: malloc: %s", strerror(errno) );
-        ret = AFPERR_MISC;
-        goto openvol_err;
-    }
-    free(vol_mname);
-    free(vol_uname);
-
-    dir->d_did = DIRDID_ROOT;
-    dir->d_color = DIRTREE_COLOR_BLACK; /* root node is black */
-    volume->v_dir = volume->v_root = dir;
     volume->v_flags |= AFPVOL_OPEN;
     volume->v_cdb = NULL;  
 
@@ -1626,6 +1597,38 @@ int              ibuflen, *rbuflen;
         ret = AFPERR_PARAM;
         goto openvol_err;
     }
+
+    len = convert_string_allocate( CH_UCS2, (utf8_encoding()?CH_UTF8_MAC:obj->options.maccharset),
+                                      volume->v_name, namelen, &vol_mname);
+    if ( !vol_mname || len <= 0) {
+        ret = AFPERR_MISC;
+        goto openvol_err;
+    }
+    
+    if ( NULL == getcwd(path, MAXPATHLEN)) {
+        /* shouldn't be fatal but it will fail later */
+        LOG(log_error, logtype_afpd, "afp_openvol: volume pathlen too long" );
+        ret = AFPERR_MISC;
+        goto openvol_err;
+    }        
+    
+    if ((vol_uname = strrchr(path, '/')) == NULL)
+         vol_uname = path;
+    else if (*(vol_uname + 1) != '\0')
+         vol_uname++;
+       
+    if ((dir = dirnew(vol_mname, vol_uname) ) == NULL) {
+       free(vol_mname);
+        LOG(log_error, logtype_afpd, "afp_openvol: malloc: %s", strerror(errno) );
+        ret = AFPERR_MISC;
+        goto openvol_err;
+    }
+    free(vol_mname);
+
+    dir->d_did = DIRDID_ROOT;
+    dir->d_color = DIRTREE_COLOR_BLACK; /* root node is black */
+    volume->v_dir = volume->v_root = dir;
+
     curdir = volume->v_dir;
     if (volume->v_cnidscheme == NULL) {
         volume->v_cnidscheme = strdup(DEFAULT_CNID_SCHEME);