/*
- * $Id: directory.c,v 1.86 2008-08-31 13:25:57 didg Exp $
+ * $Id: directory.c,v 1.90 2009-01-30 04:57:42 didg Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
#define SENTINEL (&sentinel)
static struct dir sentinel = { SENTINEL, SENTINEL, NULL, DIRTREE_COLOR_BLACK,
NULL, NULL, NULL, NULL, NULL, 0, 0,
- 0, 0, NULL, NULL, NULL};
+ 0, 0, NULL, NULL};
static struct dir rootpar = { SENTINEL, SENTINEL, NULL, 0,
NULL, NULL, NULL, NULL, NULL, 0, 0,
- 0, 0, NULL, NULL, NULL};
+ 0, 0, NULL, NULL};
/* (from IM: Toolbox Essentials)
* dirFinderInfo (DInfo) fields:
/* remove the node from the tree. this is just like insertion, but
* different. actually, it has to worry about a bunch of things that
* insertion doesn't care about. */
-static void dir_remove( vol, dir )
-struct vol *vol;
-struct dir *dir;
+static void dir_remove( const struct vol *vol _U_, struct dir *dir)
{
#ifdef REMOVE_NODES
struct ofork *of, *last;
dirfreename(dir);
dir->d_m_name = NULL;
dir->d_u_name = NULL;
- dir->d_m_name_ucs2 = NULL;
#else /* ! REMOVE_NODES */
/* go searching for a node with at most one child */
/* set the node's d_name */
node->d_m_name = save.d_m_name;
node->d_u_name = save.d_u_name;
- node->d_m_name_ucs2 = save.d_m_name_ucs2;
}
if (node->d_color == DIRTREE_COLOR_BLACK)
dir_rmrecolor(vol, leaf);
- if (node->d_m_name_ucs2)
- free(node->d_u_name_ucs2);
if (node->d_u_name != node->d_m_name) {
free(node->d_u_name);
}
LOG(log_error, logtype_afpd, "adddir: malloc: %s", strerror(errno) );
return NULL;
}
- if ((size_t)-1 == convert_string_allocate((utf8_encoding())?CH_UTF8_MAC:vol->v_maccharset, CH_UCS2, path->m_name, strlen(path->m_name), &cdir->d_m_name_ucs2)) {
- LOG(log_error, logtype_afpd, "Couldn't set UCS2 name for %s", name);
- cdir->d_m_name_ucs2 = NULL;
- }
cdir->d_did = id;
dirfreename(edir);
edir->d_m_name = cdir->d_m_name;
edir->d_u_name = cdir->d_u_name;
- edir->d_m_name_ucs2 = cdir->d_m_name_ucs2;
free(cdir);
cdir = edir;
LOG(log_error, logtype_afpd, "adddir: insert %s", edir->d_m_name);
if (dir->d_u_name != dir->d_m_name) {
free(dir->d_u_name);
}
- if (dir->d_m_name_ucs2)
- free(dir->d_m_name_ucs2);
free(dir->d_m_name);
}
return NULL;
}
- dir->d_m_name_ucs2 = NULL;
dir->d_left = dir->d_right = SENTINEL;
dir->d_next = dir->d_prev = dir;
return dir;
0x69232f74U, 0xfead7bb3U, 0xe9089ab6U, 0xf012f6aeU,
};
- const unsigned char *str = k->d_u_name;
+ const unsigned char *str = (unsigned char *)k->d_u_name;
hash_val_t acc = 0;
while (*str) {
char *upath;
struct dir *dir;
- int bit, aint, isad = 1;
+ int bit, isad = 1;
int cdate, bdate;
int owner, group;
u_int16_t ashort, bshort;
ma.ma_world = *buf++;
ma.ma_group = *buf++;
ma.ma_owner = *buf++;
- mpriv = mtoumode( &ma ) | vol->v_perm;
+ mpriv = mtoumode( &ma ) | vol->v_dperm;
if (dir_rx_set(mpriv) && setdirmode( vol, upath, mpriv) < 0 ) {
err = set_dir_errors(path, "setdirmode", errno);
bitmap = 0;
change_parent_mdate = 1;
memcpy( &upriv, buf, sizeof( upriv ));
buf += sizeof( upriv );
- upriv = ntohl (upriv) | vol->v_perm;
+ upriv = ntohl (upriv) | vol->v_dperm;
if (dir_rx_set(upriv)) {
/* maybe we are trying to set perms back */
if ( setdirunixmode(vol, upath, upriv) < 0 ) {
int afp_syncdir(obj, ibuf, ibuflen, rbuf, rbuflen )
-AFPObj *obj;
-char *ibuf, *rbuf;
+AFPObj *obj _U_;
+char *ibuf, *rbuf _U_;
int ibuflen _U_, *rbuflen;
{
DIR *dp;
if ( fsync ( dfd ) < 0 ) {
LOG(log_error, logtype_afpd, "syncdir(%s): ddir(%d) %s", dir->d_u_name, dfd, strerror(errno) );
}
-
+ closedir(dp);
+
return ( AFP_OK );
}
strcpy( dir->d_u_name, dst );
}
- if (dir->d_m_name_ucs2)
- free(dir->d_m_name_ucs2);
-
- dir->d_m_name_ucs2 = NULL;
- if ((size_t)-1 == convert_string_allocate((utf8_encoding())?CH_UTF8_MAC:vol->v_maccharset, CH_UCS2, dir->d_m_name, strlen(dir->d_m_name), (char**)&dir->d_m_name_ucs2))
- dir->d_m_name_ucs2 = NULL;
-
if (( parent = dir->d_parent ) == NULL ) {
return( AFP_OK );
}