UNFINISHED - does not compile - work on durable reconnect
authorMichael Adam <obnox@samba.org>
Sun, 12 Feb 2012 12:20:28 +0000 (13:20 +0100)
committerStefan Metzmacher <metze@samba.org>
Thu, 10 May 2012 16:41:30 +0000 (18:41 +0200)
source3/smbd/smb2_create.c

index acffd66d62e20eac43f47e8dd3c5fc6698938577..22d0ab5261511a3a2345928316c4257c6b9ece1a 100644 (file)
@@ -388,6 +388,49 @@ static void smbd_smb2_request_create_done(struct tevent_req *tsubreq)
        }
 }
 
+NTSTATUS smb2_create_durable_reconnect(struct smbXsrv_open_global *open,
+                                      TALLOC_CTX *mem_ctx,
+                                      files_struct **fsp)
+{
+       struct share_mode_lock *sharemode_lock;
+
+       /* 1. check entry in locking.tdb */
+
+       /*
+        * TODO: need to use different fetch function
+        * parse_share_modes currently checks for serverid_exists
+        * possibilites:
+        * - adapt fetch_share_mode / parse_share_modes to honour durable
+        *   (i.e. not make share mode invalid if server does not exist for
+        *    durable)
+        */
+       sharemode_lock = fetch_share_mode_unlocked(mem_ctx, open->backend_file_id);
+       if (sharemode_lock == NULL) {
+               /* TODO: use/create other fetch func with better error code */
+               return NT_STATUS_OBJECT_NAME_NOT_FOUND;
+       }
+
+       if (sharemode_lock->data->num_share_modes == 0) {
+               /* should not happen? internal error? */
+               return NT_STATUS_INTERNAL_DB_ERROR;
+       }
+
+       if (sharemode_lock->data->num_share_modes > 1) {
+               /* can't be durable if there is more than one handle on the file */
+               return NT_STATUS_OBJECT_NAME_NOT_FOUND;
+       }
+
+       if (serverid_exists(sharemode_lock->data->share_modes[0].pid))  {
+               /*
+                * server still exists
+                * TOD: check whether session exists?...
+                */
+               return NT_STATUS_OBJECT_NAME_NOT_FOUND;
+       }
+
+       /* 2. proceed with opening file */
+}
+
 struct smbd_smb2_create_state {
        struct smbd_smb2_request *smb2req;
        struct smb_request *smb1req;