s3: vfs: add SMB_VFS_GET_DOS_ATTRIBUTES_SEND/RECV
[kai/samba-autobuild/.git] / examples / VFS / skel_transparent.c
index 503c14edcc0ab25a42176a357dd7f6e4be3cdce1..cff52fa185ef66d9711cd09ea1ea75ded7da9738 100644 (file)
@@ -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)
@@ -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,