/*
- * $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.
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 );
/*
- * $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.
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 *));
/*
- * $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.
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 *
/*
- * $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.
int len, ret;
size_t namelen;
u_int16_t bitmap;
+ char path[ MAXPATHLEN + 1];
char *vol_uname;
char *vol_mname;
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;
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);