/*
- * $Id: directory.c,v 1.116 2009-10-29 11:35:58 didg Exp $
+ * $Id: directory.c,v 1.117 2009-11-13 00:27:35 didg Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
* frPutAway: 4 home directory ID
*/
+static struct dir *
+vol_tree_root(const struct vol *vol, u_int32_t did)
+{
+ struct dir *dir;
+
+ if (vol->v_curdir && vol->v_curdir->d_did == did) {
+ dir = vol->v_curdir;
+ }
+ else {
+ dir = vol->v_root;
+ }
+ return dir;
+}
+
/*
* redid did assignment for directories. now we use red-black trees.
* how exciting.
*/
struct dir *
- dirsearch(const struct vol *vol, u_int32_t did)
+dirsearch(const struct vol *vol, u_int32_t did)
{
struct dir *dir;
rootpar.d_child = vol->v_dir;
return( &rootpar );
}
-#if 0
- /* XXX would be nice to check against curdir but we need to keep its volume */
- if (vol->curdir && curdir->d_did == did) {
- dir = curdir;
- }
- else {
- dir = vol->v_root;
- }
-#endif
- dir = vol->v_root;
+
+ dir = vol_tree_root(vol, did);
afp_errno = AFPERR_NOOBJ;
while ( dir != SENTINEL ) {
* different. actually, it has to worry about a bunch of things that
* insertion doesn't care about. */
-static void dir_remove( const struct vol *vol _U_, struct dir *dir)
+static void dir_remove( struct vol *vol, struct dir *dir)
{
#ifdef REMOVE_NODES
struct ofork *of, *last;
/* i'm not sure if it really helps to delete stuff. */
dir_hash_del(vol, dir);
+ vol->v_curdir = NULL;
#ifndef REMOVE_NODES
dirfreename(dir);
dir->d_m_name = NULL;
* process. It's fixable within afpd if fnctl_lock, doable with smb and
* next to impossible for nfs and local filesystem access.
*/
-static void dir_invalidate( const struct vol *vol, struct dir *dir)
+static void dir_invalidate( struct vol *vol, struct dir *dir)
{
if (curdir == dir) {
/* v_root can't be deleted */
{
struct dir *pdir;
- pdir = vol->v_root;
+ pdir = vol_tree_root(vol, dir->d_did);
while (pdir->d_did != dir->d_did ) {
if ( pdir->d_did > dir->d_did ) {
if ( pdir->d_left == SENTINEL ) {
}
/* ------------------ */
-static struct path *invalidate (const struct vol *vol, struct dir *dir, struct path *ret)
+static struct path *invalidate (struct vol *vol, struct dir *dir, struct path *ret)
{
/* it's tricky:
movecwd failed some of dir path are not there anymore.
/*
* Move curdir to dir, with a possible chdir()
*/
-int movecwd(const struct vol *vol, struct dir *dir)
+int movecwd(struct vol *vol, struct dir *dir)
{
char path[MAXPATHLEN + 1];
struct dir *d;
}
return( -1 );
}
- curdir = dir;
+ vol->v_curdir = curdir = dir;
return( 0 );
}
}
/* ------------------ */
-int setdirparams(const struct vol *vol,
+int setdirparams(struct vol *vol,
struct path *path, u_int16_t d_bitmap, char *buf )
{
struct maccess ma;
}
/* delete an empty directory */
-int deletecurdir(const struct vol *vol)
+int deletecurdir(struct vol *vol)
{
struct dirent *de;
struct stat st;
/*
- * $Id: directory.h,v 1.32 2009-10-22 12:35:38 franklahm Exp $
+ * $Id: directory.h,v 1.33 2009-11-13 00:27:35 didg Exp $
*
* Copyright (c) 1990,1991 Regents of The University of Michigan.
* All Rights Reserved.
extern struct dir *adddir (struct vol *, struct dir *,
struct path *);
-extern int movecwd (const struct vol *, struct dir *);
-extern int deletecurdir (const struct vol *);
+extern int movecwd (struct vol *, struct dir *);
+extern int deletecurdir (struct vol *);
extern struct path *cname (struct vol *, struct dir *,
char **);
extern mode_t mtoumode (struct maccess *);
extern void utommode (struct stat *, struct maccess *);
extern int getdirparams (const struct vol *, u_int16_t, struct path *,
struct dir *, char *, size_t *);
-extern int setdirparams (const struct vol *, struct path *, u_int16_t, char *);
+extern int setdirparams (struct vol *, struct path *, u_int16_t, char *);
extern int renamedir (const struct vol *, char *, char *, struct dir *,
struct dir *, char *);
extern int path_error (struct path *, int error);
/*
- * $Id: fork.h,v 1.16 2009-10-15 10:43:13 didg Exp $
+ * $Id: fork.h,v 1.17 2009-11-13 00:27:35 didg Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
extern int of_flush (const struct vol *);
extern void of_pforkdesc (FILE *);
extern int of_stat (struct path *);
-extern int of_statdir (const struct vol *vol, struct path *);
+extern int of_statdir (struct vol *vol, struct path *);
extern int of_closefork (struct ofork *ofork);
extern void of_closevol (const struct vol *vol);
extern struct adouble *of_ad (const struct vol *, struct path *, struct adouble *);
/*
- * $Id: ofork.c,v 1.29 2009-11-06 03:51:54 didg Exp $
+ * $Id: ofork.c,v 1.30 2009-11-13 00:27:36 didg Exp $
*
* Copyright (c) 1996 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
stat(".") works even if "." is deleted thus
we have to stat ../name because we want to know if it's there
*/
-int of_statdir (const struct vol *vol, struct path *path)
+int of_statdir (struct vol *vol, struct path *path)
{
static char pathname[ MAXPATHLEN + 1] = "../";
int ret;
/*
- * $Id: volume.c,v 1.101 2009-11-09 01:36:18 didg Exp $
+ * $Id: volume.c,v 1.102 2009-11-13 00:27:36 didg Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
dir->d_color = DIRTREE_COLOR_BLACK; /* root node is black */
dir->d_m_name_ucs2 = strdup_w(volume->v_name);
volume->v_dir = volume->v_root = dir;
+ volume->v_curdir = NULL;
volume->v_hash = dirhash();
curdir = volume->v_dir;
/*
- * $Id: volume.h,v 1.5 2009-11-09 01:36:18 didg Exp $
+ * $Id: volume.h,v 1.6 2009-11-13 00:27:38 didg Exp $
*
* Copyright (c) 1990,1994 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
char *v_path;
struct dir *v_dir, *v_root;
+ struct dir *v_curdir; /* cache */
+
hash_t *v_hash;
time_t v_mtime;