SQUASH - DOES NOT COMPILE - work towards durable reconnect
authorMichael Adam <obnox@samba.org>
Tue, 14 Feb 2012 15:00:55 +0000 (16:00 +0100)
committerStefan Metzmacher <metze@samba.org>
Thu, 10 May 2012 16:41:48 +0000 (18:41 +0200)
source3/smbd/smb2_create.c

index feae4bdf4e0e0f23e83e8c870df70d0716280cca..a1cf124fe2fc5f796099b47fa17cc3330e6b0ec4 100644 (file)
@@ -390,6 +390,55 @@ static void smbd_smb2_request_create_done(struct tevent_req *tsubreq)
        }
 }
 
+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,
@@ -451,22 +500,30 @@ static NTSTATUS smb2_create_durable_reconnect(struct smbXsrv_open *op,
         * 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()