mirror of
https://github.com/samba-team/samba.git
synced 2025-03-23 06:50:21 +03:00
smbd: Factor out OpenDir_ntstatus()
We might have callers interested in the exact NTSTATUS error code. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
This commit is contained in:
parent
afd037df11
commit
be20147516
@ -1477,11 +1477,12 @@ static int smb_Dir_OpenDir_destructor(struct smb_Dir *dir_hnd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct smb_Dir *OpenDir(TALLOC_CTX *mem_ctx,
|
||||
connection_struct *conn,
|
||||
const struct smb_filename *smb_dname,
|
||||
const char *mask,
|
||||
uint32_t attr)
|
||||
NTSTATUS OpenDir_ntstatus(TALLOC_CTX *mem_ctx,
|
||||
connection_struct *conn,
|
||||
const struct smb_filename *smb_dname,
|
||||
const char *mask,
|
||||
uint32_t attr,
|
||||
struct smb_Dir **_dir_hnd)
|
||||
{
|
||||
struct files_struct *fsp = NULL;
|
||||
struct smb_Dir *dir_hnd = NULL;
|
||||
@ -1492,15 +1493,12 @@ struct smb_Dir *OpenDir(TALLOC_CTX *mem_ctx,
|
||||
O_RDONLY,
|
||||
&fsp);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
/* Ensure we return the actual error from status in errno. */
|
||||
errno = map_errno_from_nt_status(status);
|
||||
return NULL;
|
||||
return status;
|
||||
}
|
||||
|
||||
status = OpenDir_fsp(mem_ctx, conn, fsp, mask, attr, &dir_hnd);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
errno = map_errno_from_nt_status(status);
|
||||
return NULL;
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1508,9 +1506,30 @@ struct smb_Dir *OpenDir(TALLOC_CTX *mem_ctx,
|
||||
* but smb_Dir_OpenDir_destructor() calls the OpenDir_fsp() destructor.
|
||||
*/
|
||||
talloc_set_destructor(dir_hnd, smb_Dir_OpenDir_destructor);
|
||||
return dir_hnd;
|
||||
|
||||
*_dir_hnd = dir_hnd;
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
struct smb_Dir *OpenDir(TALLOC_CTX *mem_ctx,
|
||||
connection_struct *conn,
|
||||
const struct smb_filename *smb_dname,
|
||||
const char *mask,
|
||||
uint32_t attr)
|
||||
{
|
||||
struct smb_Dir *dir_hnd = NULL;
|
||||
NTSTATUS status;
|
||||
|
||||
status = OpenDir_ntstatus(
|
||||
mem_ctx, conn, smb_dname, mask, attr, &dir_hnd);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
/* Ensure we return the actual error from status in errno. */
|
||||
errno = map_errno_from_nt_status(status);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return dir_hnd;
|
||||
}
|
||||
/*******************************************************************
|
||||
Open a directory from an fsp.
|
||||
********************************************************************/
|
||||
|
@ -231,6 +231,12 @@ bool get_dir_entry(TALLOC_CTX *ctx,
|
||||
bool ask_sharemode);
|
||||
struct smb_Dir;
|
||||
bool is_visible_fsp(files_struct *fsp);
|
||||
NTSTATUS OpenDir_ntstatus(TALLOC_CTX *mem_ctx,
|
||||
connection_struct *conn,
|
||||
const struct smb_filename *smb_dname,
|
||||
const char *mask,
|
||||
uint32_t attr,
|
||||
struct smb_Dir **_dir_hnd);
|
||||
struct smb_Dir *OpenDir(TALLOC_CTX *mem_ctx,
|
||||
connection_struct *conn,
|
||||
const struct smb_filename *smb_fname,
|
||||
|
Loading…
x
Reference in New Issue
Block a user