opendb: return the path that should be deleted in odb_close_file()
authorStefan Metzmacher <metze@samba.org>
Wed, 27 Feb 2008 20:50:51 +0000 (21:50 +0100)
committerStefan Metzmacher <metze@samba.org>
Thu, 28 Feb 2008 07:10:50 +0000 (08:10 +0100)
That means the last close returns the path name if the
delete_on_close flag is set.

metze
(This used to be commit fc27730bad24e8dddaa2e7f754a16811e38a2f60)

source4/cluster/ctdb/opendb_ctdb.c
source4/ntvfs/common/opendb.c
source4/ntvfs/common/opendb.h
source4/ntvfs/common/opendb_tdb.c

index 3dfc6819b7c09bbdcd02da250cc6305e43a6fed7..3f6c8a2343fecbd73a99d75bf592acaeb4c9b8ef 100644 (file)
@@ -409,10 +409,12 @@ static NTSTATUS odb_ctdb_open_file_pending(struct odb_lock *lck, void *private)
 /*
   remove a opendb entry
 */
-static NTSTATUS odb_ctdb_close_file(struct odb_lock *lck, void *file_handle)
+static NTSTATUS odb_ctdb_close_file(struct odb_lock *lck, void *file_handle,
+                                   const char **_delete_path)
 {
        struct odb_context *odb = lck->odb;
        struct opendb_file file;
+       const char *delete_path = NULL;
        int i;
        NTSTATUS status;
 
@@ -448,6 +450,15 @@ static NTSTATUS odb_ctdb_close_file(struct odb_lock *lck, void *file_handle)
        file.num_pending = 0;
 
        file.num_entries--;
+
+       if (file.num_entries == 0 && file.delete_on_close) {
+               delete_path = talloc_strdup(lck, file.path);
+               NT_STATUS_HAVE_NO_MEMORY(delete_path);
+       }
+
+       if (_delete_path) {
+               *_delete_path = delete_path;
+       }
        
        return odb_push_record(lck, &file);
 }
index 36144d0406b09a20cb1c1d62f6ce5323e91be0f7..0b11f9dac5306b0c8e841d87e4fb8d06e3df8b15 100644 (file)
@@ -118,9 +118,10 @@ _PUBLIC_ NTSTATUS odb_open_file_pending(struct odb_lock *lck, void *private)
 /*
   remove a opendb entry
 */
-_PUBLIC_ NTSTATUS odb_close_file(struct odb_lock *lck, void *file_handle)
+_PUBLIC_ NTSTATUS odb_close_file(struct odb_lock *lck, void *file_handle,
+                                const char **delete_path)
 {
-       return ops->odb_close_file(lck, file_handle);
+       return ops->odb_close_file(lck, file_handle, delete_path);
 }
 
 
index 9591bcf6b9b38817b34cd0262488fabf952d6131..c736c25a8de9d0d416deed089d55bae69b24ca39 100644 (file)
@@ -32,7 +32,8 @@ struct opendb_ops {
                                  uint32_t open_disposition, bool break_to_none,
                                  uint32_t oplock_level, uint32_t *oplock_granted);
        NTSTATUS (*odb_open_file_pending)(struct odb_lock *lck, void *private);
-       NTSTATUS (*odb_close_file)(struct odb_lock *lck, void *file_handle);
+       NTSTATUS (*odb_close_file)(struct odb_lock *lck, void *file_handle,
+                                  const char **delete_path);
        NTSTATUS (*odb_remove_pending)(struct odb_lock *lck, void *private);
        NTSTATUS (*odb_rename)(struct odb_lock *lck, const char *path);
        NTSTATUS (*odb_set_delete_on_close)(struct odb_lock *lck, bool del_on_close);
index a51c823a633593544af1c22120cbee3df012fefb..f0269db5271b49a4f47ed63acf0964f156c0889d 100644 (file)
@@ -527,10 +527,12 @@ static NTSTATUS odb_tdb_open_file_pending(struct odb_lock *lck, void *private)
 /*
   remove a opendb entry
 */
-static NTSTATUS odb_tdb_close_file(struct odb_lock *lck, void *file_handle)
+static NTSTATUS odb_tdb_close_file(struct odb_lock *lck, void *file_handle,
+                                  const char **_delete_path)
 {
        struct odb_context *odb = lck->odb;
        struct opendb_file file;
+       const char *delete_path = NULL;
        int i;
        NTSTATUS status;
 
@@ -566,7 +568,16 @@ static NTSTATUS odb_tdb_close_file(struct odb_lock *lck, void *file_handle)
        file.num_pending = 0;
 
        file.num_entries--;
-       
+
+       if (file.num_entries == 0 && file.delete_on_close) {
+               delete_path = talloc_strdup(lck, file.path);
+               NT_STATUS_HAVE_NO_MEMORY(delete_path);
+       }
+
+       if (_delete_path) {
+               *_delete_path = delete_path;
+       }
+
        return odb_push_record(lck, &file);
 }