cnid = htonl(2);
dir = vol->v_root;
+ LOG(log_debug, logtype_afpd, "dirlookup_bypath(\"%s\")", path);
+
+ if (strcmp(vol->v_path, path) == 0)
+ return dir;
+
EC_NULL(rpath = rel_path_in_vol(path, vol->v_path)); /* 1. */
+
+ LOG(log_debug, logtype_afpd, "dirlookup_bypath: rpath: \"%s\"", cfrombstr(rpath));
+
EC_NULL(statpath = bfromcstr(vol->v_path)); /* 2. */
l = bsplit(rpath, '/');
did = cnid;
EC_ZERO(bcatcstr(statpath, "/"));
EC_ZERO(bconcat(statpath, l->entry[i]));
+
+ LOG(log_debug, logtype_afpd, "dirlookup_bypath: statpath: \"%s\"", cfrombstr(statpath));
+
EC_ZERO_LOGSTR(lstat(cfrombstr(statpath), &st),
"lstat(rpath: %s, elem: %s): %s: %s",
cfrombstr(rpath), cfrombstr(l->entry[i]),
dir,
cfrombstr(l->entry[i]),
blength(l->entry[i]))) == NULL) {
+
if ((cnid = cnid_add(vol->v_cdb, /* 6. */
&st,
did,
cfrombstr(l->entry[i]),
blength(l->entry[i]),
- 0)) == CNID_INVALID) {
+ 0)) == CNID_INVALID)
EC_FAIL;
- }
if ((dir = dirlookup(vol, cnid)) == NULL) /* 7. */
EC_FAIL;
if (ret != 0)
return NULL;
+ LOG(log_debug, logtype_afpd, "dirlookup_bypath: result: \"%s\"",
+ cfrombstr(dir->d_fullpath));
+
return dir;
}
}
/* get_id needs adp for reading CNID from adouble file */
- ad_init(&ad, vol->v_adouble, vol->v_ad_options);
- if ((ad_open(&ad, path->u_name, ADFLAGS_HF | ADFLAGS_DIR)) == 0) /* 1 */
+ ad_init(&ad, vol);
+ if ((ad_open(&ad, path->u_name, ADFLAGS_HF | ADFLAGS_DIR | ADFLAGS_RDONLY)) == 0) /* 1 */
adp = &ad;
/* Get CNID */
}
if (adp)
- ad_close_metadata(adp);
+ ad_close(adp, ADFLAGS_HF);
/* Get macname from unixname */
if (path->m_name == NULL) {
cfrombstr(dir->d_u_name), path->u_name, err);
if (adp)
- ad_close_metadata(adp);
+ ad_close(adp, ADFLAGS_HF);
if (!cdir && fullpath)
bdestroy(fullpath);
if (cdir)
ntohl(dir->d_did), cfrombstr(dir->d_fullpath));
if ((ret = lchdir(cfrombstr(dir->d_fullpath))) != 0 ) {
- LOG(log_debug, logtype_afpd, "movecwd(\"%s\"): ret: %u, %s",
- cfrombstr(dir->d_fullpath), ret, strerror(errno));
+ LOG(log_debug, logtype_afpd, "movecwd(\"%s\"): %s",
+ cfrombstr(dir->d_fullpath), strerror(errno));
if (ret == 1) {
/* p is a symlink or getcwd failed */
afp_errno = AFPERR_BADTYPE;
if (!p)
return -1;
- accessmode(p, &ma, curdir, NULL);
+ accessmode(current_vol, p, &ma, curdir, NULL);
if ((mode & OPENACC_WR) && !(ma.ma_user & AR_UWRITE))
return -1;
if ((mode & OPENACC_RD) && !(ma.ma_user & AR_UREAD))
{
struct maccess ma;
- accessmode(path->u_name, &ma, curdir, &path->st);
+ accessmode(current_vol, path->u_name, &ma, curdir, &path->st);
LOG(log_debug, logtype_afpd, "file_access(\"%s\"): mapped user mode: 0x%02x",
path->u_name, ma.ma_user);
(1 << DIRPBIT_BDATE) |
(1 << DIRPBIT_FINFO)))) {
- ad_init(&ad, vol->v_adouble, vol->v_ad_options);
+ ad_init(&ad, vol);
if ( !ad_metadata( upath, ADFLAGS_DIR, &ad) ) {
isad = 1;
- if (ad.ad_md->adf_flags & O_CREAT) {
+ if (ad.ad_mdp->adf_flags & O_CREAT) {
/* We just created it */
if (s_path->m_name == NULL) {
if ((s_path->m_name = utompath(vol,
ashort = htons(ATTRBIT_INVISIBLE);
} else
ashort = 0;
- ashort |= htons(ATTRBIT_SHARED);
memcpy( data, &ashort, sizeof( ashort ));
data += sizeof( ashort );
break;
break;
case DIRPBIT_ACCESS :
- accessmode( upath, &ma, dir , st);
+ accessmode(vol, upath, &ma, dir , st);
*data++ = ma.ma_user;
*data++ = ma.ma_world;
break;
case DIRPBIT_UNIXPR :
+ /* accessmode may change st_mode with ACLs */
+ accessmode(vol, upath, &ma, dir, st);
+
aint = htonl(st->st_uid);
memcpy( data, &aint, sizeof( aint ));
data += sizeof( aint );
memcpy( data, &aint, sizeof( aint ));
data += sizeof( aint );
- accessmode( upath, &ma, dir , st);
-
*data++ = ma.ma_user;
*data++ = ma.ma_world;
*data++ = ma.ma_group;
default :
if ( isad ) {
- ad_close_metadata( &ad );
+ ad_close(&ad, ADFLAGS_HF);
}
return( AFPERR_BITMAP );
}
data = set_name(vol, data, pdid, cfrombstr(dir->d_m_name), dir->d_did, utf8);
}
if ( isad ) {
- ad_close_metadata( &ad );
+ ad_close(&ad, ADFLAGS_HF);
}
*buflen = data - buf;
return( AFP_OK );
bitmap = bitmap>>1;
bit++;
}
- ad_init(&ad, vol->v_adouble, vol->v_ad_options);
+ ad_init(&ad, vol);
- if (ad_open(&ad, upath, ADFLAGS_HF | ADFLAGS_DIR, O_CREAT, 0777) != 0) {
+ if (ad_open(&ad, upath, ADFLAGS_HF | ADFLAGS_DIR | ADFLAGS_CREATE | ADFLAGS_RDWR, 0777) != 0) {
/*
* Check to see what we're trying to set. If it's anything
* but ACCESS, UID, or GID, give an error. If it's any of those
ad_setid(&ad, st->st_dev, st->st_ino, dir->d_did, dir->d_pdid, vol->v_stamp);
}
}
- ad_flush( &ad);
- ad_close_metadata( &ad);
+ ad_flush(&ad);
+ ad_close(&ad, ADFLAGS_HF);
}
if (change_parent_mdate && dir->d_did != DIRDID_ROOT
return( AFPERR_PARAM );
}
- ad_init(&ad, vol->v_adouble, vol->v_ad_options);
- if (ad_open(&ad, ".", ADFLAGS_HF | ADFLAGS_DIR, O_CREAT, 0777) < 0) {
+ ad_init(&ad, vol);
+ if (ad_open(&ad, ".", ADFLAGS_HF | ADFLAGS_DIR | ADFLAGS_CREATE | ADFLAGS_RDWR, 0777) < 0) {
if (vol_noadouble(vol))
goto createdir_done;
return( AFPERR_ACCESS );
fce_register_new_dir(s_path);
- ad_flush( &ad);
- ad_close_metadata( &ad);
+ ad_flush(&ad);
+ ad_close(&ad, ADFLAGS_HF);
createdir_done:
memcpy( rbuf, &dir->d_did, sizeof( uint32_t ));
vol->vfs->vfs_renamedir(vol, dirfd, src, dst);
- ad_init(&ad, vol->v_adouble, vol->v_ad_options);
+ ad_init(&ad, vol);
- if (ad_open(&ad, dst, ADFLAGS_HF | ADFLAGS_DIR) == 0) {
+ if (ad_open(&ad, dst, ADFLAGS_HF | ADFLAGS_DIR | ADFLAGS_RDWR) == 0) {
ad_setname(&ad, newname);
- ad_flush( &ad);
- ad_close_metadata( &ad);
+ ad_flush(&ad);
+ ad_close(&ad, ADFLAGS_HF);
}
return( AFP_OK );
fdir = curdir;
- ad_init(&ad, vol->v_adouble, vol->v_ad_options);
+ ad_init(&ad, vol);
/* we never want to create a resource fork here, we are going to delete it */
if ( ad_metadata( ".", ADFLAGS_DIR, &ad) == 0 ) {
ad_getattr(&ad, &ashort);
- ad_close_metadata(&ad);
+ ad_close(&ad, ADFLAGS_HF);
if ((ashort & htons(ATTRBIT_NODELETE))) {
return AFPERR_OLOCK;
}
dir_remove( vol, fdir );
} else {
LOG(log_error, logtype_afpd, "deletecurdir(\"%s\"): netatalk_rmdir_all_errors error",
- curdir->d_fullpath);
+ cfrombstr(curdir->d_fullpath));
}
delete_done:
case 2 : /* unicode */
case 4 :
- LOG(log_debug, logtype_afpd, "afp_mapname: gettgrnam for name: %s",ibuf);
+ LOG(log_debug, logtype_afpd, "afp_mapname: getgrnam for name: %s",ibuf);
if (NULL == ( gr = (struct group *)getgrnam( ibuf ))) {
return( AFPERR_NOITEM );
}
id = gr->gr_gid;
- LOG(log_debug, logtype_afpd, "afp_mapname: gettgrnam for name: %s -> id: %d",ibuf, id);
+ LOG(log_debug, logtype_afpd, "afp_mapname: getgrnam for name: %s -> id: %d",ibuf, id);
id = htonl(id);
memcpy( rbuf, &id, sizeof( id ));
*rbuflen = sizeof( id );