Skip to content

Commit

Permalink
s3: vfs: add SMB_VFS_GET_DOS_ATTRIBUTES_SEND/RECV
Browse files Browse the repository at this point in the history
Signed-off-by: Ralph Boehme <[email protected]>
Reviewed-by: Stefan Metzmacher <[email protected]>
  • Loading branch information
slowfranklin committed Jul 27, 2018
1 parent 8a6013f commit 47d7743
Show file tree
Hide file tree
Showing 13 changed files with 563 additions and 0 deletions.
48 changes: 48 additions & 0 deletions examples/VFS/skel_opaque.c
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,52 @@ static NTSTATUS skel_get_dos_attributes(struct vfs_handle_struct *handle,
return NT_STATUS_NOT_IMPLEMENTED;
}

struct skel_get_dos_attributes_state {
struct vfs_aio_state aio_state;
uint32_t dosmode;
};

static struct tevent_req *skel_get_dos_attributes_send(
TALLOC_CTX *mem_ctx,
const struct smb_vfs_ev_glue *evg,
struct vfs_handle_struct *handle,
files_struct *dir_fsp,
struct smb_filename *smb_fname)
{
struct tevent_context *ev = smb_vfs_ev_glue_ev_ctx(evg);
struct tevent_req *req = NULL;
struct skel_get_dos_attributes_state *state = NULL;

req = tevent_req_create(mem_ctx, &state,
struct skel_get_dos_attributes_state);
if (req == NULL) {
return NULL;
}

tevent_req_nterror(req, NT_STATUS_NOT_IMPLEMENTED);
return tevent_req_post(req, ev);
}

static NTSTATUS skel_get_dos_attributes_recv(struct tevent_req *req,
struct vfs_aio_state *aio_state,
uint32_t *dosmode)
{
struct skel_get_dos_attributes_state *state =
tevent_req_data(req,
struct skel_get_dos_attributes_state);
NTSTATUS status;

if (tevent_req_is_nterror(req, &status)) {
tevent_req_received(req);
return status;
}

*aio_state = state->aio_state;
*dosmode = state->dosmode;
tevent_req_received(req);
return NT_STATUS_OK;
}

static NTSTATUS skel_fget_dos_attributes(struct vfs_handle_struct *handle,
struct files_struct *fsp,
uint32_t *dosmode)
Expand Down Expand Up @@ -1069,6 +1115,8 @@ static struct vfs_fn_pointers skel_opaque_fns = {

/* DOS attributes. */
.get_dos_attributes_fn = skel_get_dos_attributes,
.get_dos_attributes_send_fn = skel_get_dos_attributes_send,
.get_dos_attributes_recv_fn = skel_get_dos_attributes_recv,
.fget_dos_attributes_fn = skel_fget_dos_attributes,
.set_dos_attributes_fn = skel_set_dos_attributes,
.fset_dos_attributes_fn = skel_fset_dos_attributes,
Expand Down
82 changes: 82 additions & 0 deletions examples/VFS/skel_transparent.c
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,86 @@ static NTSTATUS skel_get_dos_attributes(struct vfs_handle_struct *handle,
dosmode);
}

struct skel_get_dos_attributes_state {
struct vfs_aio_state aio_state;
uint32_t dosmode;
};

static void skel_get_dos_attributes_done(struct tevent_req *subreq);

static struct tevent_req *skel_get_dos_attributes_send(
TALLOC_CTX *mem_ctx,
const struct smb_vfs_ev_glue *evg,
struct vfs_handle_struct *handle,
files_struct *dir_fsp,
struct smb_filename *smb_fname)
{
struct tevent_context *ev = smb_vfs_ev_glue_ev_ctx(evg);
struct tevent_req *req = NULL;
struct skel_get_dos_attributes_state *state = NULL;
struct tevent_req *subreq = NULL;

req = tevent_req_create(mem_ctx, &state,
struct skel_get_dos_attributes_state);
if (req == NULL) {
return NULL;
}

subreq = SMB_VFS_NEXT_GET_DOS_ATTRIBUTES_SEND(mem_ctx,
evg,
handle,
dir_fsp,
smb_fname);
if (tevent_req_nomem(subreq, req)) {
return tevent_req_post(req, ev);
}
tevent_req_set_callback(subreq, skel_get_dos_attributes_done, req);

return req;
}

static void skel_get_dos_attributes_done(struct tevent_req *subreq)
{
struct tevent_req *req =
tevent_req_callback_data(subreq,
struct tevent_req);
struct skel_get_dos_attributes_state *state =
tevent_req_data(req,
struct skel_get_dos_attributes_state);
NTSTATUS status;

status = SMB_VFS_NEXT_GET_DOS_ATTRIBUTES_RECV(subreq,
&state->aio_state,
&state->dosmode);
TALLOC_FREE(subreq);
if (tevent_req_nterror(req, status)) {
return;
}

tevent_req_done(req);
return;
}

static NTSTATUS skel_get_dos_attributes_recv(struct tevent_req *req,
struct vfs_aio_state *aio_state,
uint32_t *dosmode)
{
struct skel_get_dos_attributes_state *state =
tevent_req_data(req,
struct skel_get_dos_attributes_state);
NTSTATUS status;

if (tevent_req_is_nterror(req, &status)) {
tevent_req_received(req);
return status;
}

*aio_state = state->aio_state;
*dosmode = state->dosmode;
tevent_req_received(req);
return NT_STATUS_OK;
}

static NTSTATUS skel_fget_dos_attributes(struct vfs_handle_struct *handle,
struct files_struct *fsp,
uint32_t *dosmode)
Expand Down Expand Up @@ -1298,6 +1378,8 @@ static struct vfs_fn_pointers skel_transparent_fns = {

/* DOS attributes. */
.get_dos_attributes_fn = skel_get_dos_attributes,
.get_dos_attributes_send_fn = skel_get_dos_attributes_send,
.get_dos_attributes_recv_fn = skel_get_dos_attributes_recv,
.fget_dos_attributes_fn = skel_fget_dos_attributes,
.set_dos_attributes_fn = skel_set_dos_attributes,
.fset_dos_attributes_fn = skel_fset_dos_attributes,
Expand Down
33 changes: 33 additions & 0 deletions source3/include/vfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@
/* Version 40 - Introduce smb_vfs_ev_glue infrastructure. */
/* Version 40 - Add vfs_not_implemented_* helper functions. */
/* Version 40 - Add SMB_VFS_GETXATTRAT_SEND/RECV */
/* Version 40 - Add SMB_VFS_GET_DOS_ATTRIBUTES_SEND/RECV */

#define SMB_VFS_INTERFACE_VERSION 40

Expand Down Expand Up @@ -900,6 +901,18 @@ struct vfs_fn_pointers {
struct files_struct *fsp,
uint32_t dosmode);

struct tevent_req *(*get_dos_attributes_send_fn)(
TALLOC_CTX *mem_ctx,
const struct smb_vfs_ev_glue *evg,
struct vfs_handle_struct *handle,
files_struct *dir_fsp,
struct smb_filename *smb_fname);

NTSTATUS (*get_dos_attributes_recv_fn)(
struct tevent_req *req,
struct vfs_aio_state *aio_state,
uint32_t *dosmode);

/* NT ACL operations. */

NTSTATUS (*fget_nt_acl_fn)(struct vfs_handle_struct *handle,
Expand Down Expand Up @@ -1355,6 +1368,16 @@ NTSTATUS smb_vfs_call_set_dos_attributes(struct vfs_handle_struct *handle,
NTSTATUS smb_vfs_call_fset_dos_attributes(struct vfs_handle_struct *handle,
struct files_struct *fsp,
uint32_t dosmode);
struct tevent_req *smb_vfs_call_get_dos_attributes_send(
TALLOC_CTX *mem_ctx,
const struct smb_vfs_ev_glue *evg,
struct vfs_handle_struct *handle,
files_struct *dir_fsp,
struct smb_filename *smb_fname);
NTSTATUS smb_vfs_call_get_dos_attributes_recv(
struct tevent_req *req,
struct vfs_aio_state *aio_state,
uint32_t *dosmode);
struct tevent_req *smb_vfs_call_offload_read_send(
TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
Expand Down Expand Up @@ -1827,6 +1850,16 @@ NTSTATUS vfs_not_implemented_readdir_attr(struct vfs_handle_struct *handle,
NTSTATUS vfs_not_implemented_get_dos_attributes(struct vfs_handle_struct *handle,
struct smb_filename *smb_fname,
uint32_t *dosmode);
struct tevent_req *vfs_not_implemented_get_dos_attributes_send(
TALLOC_CTX *mem_ctx,
const struct smb_vfs_ev_glue *evg,
struct vfs_handle_struct *handle,
files_struct *dir_fsp,
struct smb_filename *smb_fname);
NTSTATUS vfs_not_implemented_get_dos_attributes_recv(
struct tevent_req *req,
struct vfs_aio_state *aio_state,
uint32_t *dosmode);
NTSTATUS vfs_not_implemented_fget_dos_attributes(struct vfs_handle_struct *handle,
struct files_struct *fsp,
uint32_t *dosmode);
Expand Down
15 changes: 15 additions & 0 deletions source3/include/vfs_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,21 @@
#define SMB_VFS_NEXT_FGET_DOS_ATTRIBUTES(handle, fsp, attributes) \
smb_vfs_call_fget_dos_attributes((handle)->next, (fsp), (attributes))

#define SMB_VFS_GET_DOS_ATTRIBUTES_SEND(mem_ctx, evg, dir_fsp, smb_fname) \
smb_vfs_call_get_dos_attributes_send((mem_ctx), (evg), \
(dir_fsp)->conn->vfs_handles, \
(dir_fsp), (smb_fname))
#define SMB_VFS_GET_DOS_ATTRIBUTES_RECV(req, aio_state, dosmode) \
smb_vfs_call_get_dos_attributes_recv((req), (aio_state), (dosmode))

#define SMB_VFS_NEXT_GET_DOS_ATTRIBUTES_SEND(mem_ctx, evg, handle, dir_fsp, \
smb_fname) \
smb_vfs_call_get_dos_attributes_send((mem_ctx), (evg), \
(handle)->next, \
(dir_fsp), (smb_fname))
#define SMB_VFS_NEXT_GET_DOS_ATTRIBUTES_RECV(req, aio_state, dosmode) \
smb_vfs_call_get_dos_attributes_recv((req), (aio_state), (dosmode))

#define SMB_VFS_SET_DOS_ATTRIBUTES(conn, smb_fname, attributes) \
smb_vfs_call_set_dos_attributes((conn)->vfs_handles, (smb_fname), (attributes))
#define SMB_VFS_NEXT_SET_DOS_ATTRIBUTES(handle, smb_fname, attributes) \
Expand Down
2 changes: 2 additions & 0 deletions source3/modules/vfs_catia.c
Original file line number Diff line number Diff line change
Expand Up @@ -2447,6 +2447,8 @@ static struct vfs_fn_pointers vfs_catia_fns = {
.translate_name_fn = catia_translate_name,
.fsctl_fn = catia_fsctl,
.get_dos_attributes_fn = catia_get_dos_attributes,
.get_dos_attributes_send_fn = vfs_not_implemented_get_dos_attributes_send,
.get_dos_attributes_recv_fn = vfs_not_implemented_get_dos_attributes_recv,
.set_dos_attributes_fn = catia_set_dos_attributes,
.fset_dos_attributes_fn = catia_fset_dos_attributes,
.fget_dos_attributes_fn = catia_fget_dos_attributes,
Expand Down
2 changes: 2 additions & 0 deletions source3/modules/vfs_default.c
Original file line number Diff line number Diff line change
Expand Up @@ -3164,6 +3164,8 @@ static struct vfs_fn_pointers vfs_default_fns = {
.set_dos_attributes_fn = vfswrap_set_dos_attributes,
.fset_dos_attributes_fn = vfswrap_fset_dos_attributes,
.get_dos_attributes_fn = vfswrap_get_dos_attributes,
.get_dos_attributes_send_fn = vfs_not_implemented_get_dos_attributes_send,
.get_dos_attributes_recv_fn = vfs_not_implemented_get_dos_attributes_recv,
.fget_dos_attributes_fn = vfswrap_fget_dos_attributes,
.offload_read_send_fn = vfswrap_offload_read_send,
.offload_read_recv_fn = vfswrap_offload_read_recv,
Expand Down
Loading

0 comments on commit 47d7743

Please sign in to comment.