nwconn: resolve AFP entry-id-relative name lookups
This commit is contained in:
46
src/nwconn.c
46
src/nwconn.c
@@ -672,13 +672,48 @@ static int afp_get_entry_id_from_name(uint8 *afp_req, int afp_len,
|
||||
}
|
||||
|
||||
if (!path_len) {
|
||||
XDPRINTF((2,0, "AFP Get Entry ID From Name rejected: entry-id-only lookup unsupported vol=%d entry=0x%08x",
|
||||
XDPRINTF((2,0, "AFP Get Entry ID From Name rejected: missing path vol=%d entry=0x%08x",
|
||||
(int)volume_number, request_entry_id));
|
||||
return(-0x9c); /* Invalid Path until persistent entry-id lookup exists */
|
||||
return(-0x9c); /* Invalid Path */
|
||||
}
|
||||
|
||||
volume = conn_get_kpl_unxname(unixname, sizeof(unixname), 0,
|
||||
afp_req + 7, path_len);
|
||||
if (request_entry_id) {
|
||||
char base_path[256];
|
||||
char entry_path[512];
|
||||
int used;
|
||||
|
||||
result = afp_namespace_path_from_entry_id((int)volume_number,
|
||||
request_entry_id,
|
||||
base_path, sizeof(base_path));
|
||||
if (result) {
|
||||
XDPRINTF((2,0, "AFP Get Entry ID From Name base lookup failed: vol=%d entry=0x%08x result=-0x%x",
|
||||
(int)volume_number, request_entry_id, -result));
|
||||
return(result);
|
||||
}
|
||||
|
||||
if (*base_path)
|
||||
used = slprintf(entry_path, sizeof(entry_path), "%s:%s/%.*s",
|
||||
nw_volumes[volume_number].sysname, base_path,
|
||||
path_len, afp_req + 7);
|
||||
else
|
||||
used = slprintf(entry_path, sizeof(entry_path), "%s:%.*s",
|
||||
nw_volumes[volume_number].sysname, path_len,
|
||||
afp_req + 7);
|
||||
if (used < 0 || used >= (int)sizeof(entry_path))
|
||||
return(-0x96);
|
||||
|
||||
volume = conn_get_kpl_unxname(unixname, sizeof(unixname), 0,
|
||||
(uint8 *)entry_path, used);
|
||||
if (volume < 0) {
|
||||
XDPRINTF((2,0, "AFP Get Entry ID From Name relative path resolve failed: vol=%d entry=0x%08x base='%s' name='%s' path='%s' result=-0x%x",
|
||||
(int)volume_number, request_entry_id, base_path,
|
||||
visable_data(afp_req + 7, path_len), entry_path, -volume));
|
||||
return(volume);
|
||||
}
|
||||
} else {
|
||||
volume = conn_get_kpl_unxname(unixname, sizeof(unixname), 0,
|
||||
afp_req + 7, path_len);
|
||||
}
|
||||
if (volume < 0) {
|
||||
XDPRINTF((2,0, "AFP Get Entry ID From Name path resolve failed: vol=%d entry=0x%08x path='%s' result=-0x%x",
|
||||
(int)volume_number, request_entry_id,
|
||||
@@ -696,9 +731,10 @@ static int afp_get_entry_id_from_name(uint8 *afp_req, int afp_len,
|
||||
entry_id = afp_get_or_create_entry_id(unixname, volume, &stbuff, &result);
|
||||
|
||||
U32_TO_BE32(entry_id, response);
|
||||
XDPRINTF((3,0, "AFP Get Entry ID From Name: vol=%d entry=0x%08x path='%s' reply_entry=0x%08x%s",
|
||||
XDPRINTF((3,0, "AFP Get Entry ID From Name: vol=%d entry=0x%08x path='%s' reply_entry=0x%08x%s%s",
|
||||
(int)volume_number, request_entry_id,
|
||||
visable_data(afp_req + 7, path_len), entry_id,
|
||||
request_entry_id ? " entry-id" : "",
|
||||
result ? " fallback" : ""));
|
||||
return(4);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user