}
}
+static NTSTATUS new_durable_reconnect_fsp(struct smbXsrv_open *op,
+ TALLOC_CTX *mem_ctx,
+ files_sruct **_fsp)
+{
+ NTSTATUS status = NT_STATUS_NO_MEMORY;
+ files_struct *fsp = NULL;
+ TALLOC_CTX *frame = talloc_stackframe();
+ struct smbd_server_connection *sconn = op->connection->sconn;
+
+ fsp = talloc_zero(frame, struct files_struct);
+ if (fsp == NULL) {
+ goto fail;
+ }
+
+ /*
+ * This can't be a child of fsp because the file_handle can be ref'd
+ * when doing a dos/fcb open, which will then share the file_handle
+ * across multiple fsps.
+ */
+ fsp->fh = talloc_zero(frame, struct fd_handle);
+ if (fsp->fh == NULL) {
+ goto fail;
+ }
+
+ status = fsp_set_smb_fname(fsp, /*TODO*/ smb_fname);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto fail;
+ }
+
+ fsp->fh->ref_count = 1;
+ fsp->fh->fd = -1;
+ fsp->fh->gen_id = get_gen_count(sconn);
+
+ fsp->conn = conn;
+
+
+ /* success */
+
+ talloc_steal(mem_ctx, fsp);
+ talloc_steal(mem_ctx, fsp->fh);
+ *_fsp = fsp;
+
+ status = NT_STATUS_OK;
+
+fail:
+ talloc_free(frame);
+ return status;
+}
+
static NTSTATUS smb2_create_durable_reconnect(struct smbXsrv_open *op,
struct smb_request *smb1req,
TALLOC_CTX *mem_ctx,
* is file_new() appropriate?
* or do we need a replacement for this special purpose?
*/
- status = file_new(smb1req, smb1req->conn, &fsp);
+ status = new_durable_reconnect_fsp( &fsp);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
/* TODO */
- fsp->fh->fd = SMB_VFS_OPEN(smb1req->conn, smb_fname, fsp, flags, mode);
+ fsp->fh->fd = SMB_VFS_OPEN(smb1req->conn,
+ smb_fname,
+ fsp,
+ sharemode_lock->data->share_modes[0].flags,
+ mode);
if (fsp->fh->fd == -1) {
/* ... */
return ...;
}
- /* - release the sharemode lock */
+ /* - release the sharemode lock: this writes the changes */
talloc_free(sharemode_lock);
- /* - update fsp pointer in smbXsrv_open
+ /* - update fsp pointer in smbXsrv_open */
+
+ op->;
+
+ /*
* - return
*
* ... think about seek()