opendb: add odb_get_path()
authorStefan Metzmacher <metze@samba.org>
Thu, 28 Feb 2008 08:06:49 +0000 (09:06 +0100)
committerStefan Metzmacher <metze@samba.org>
Fri, 29 Feb 2008 14:17:52 +0000 (15:17 +0100)
metze
(This used to be commit 02071f151a22257d31f8a8b254625e2067e7b94d)

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

index 3d67162d6dae2360bc7517f590542d99dd48c2e3..e84f2364d40f183791f8b3052688bee7a82a8481 100644 (file)
@@ -542,6 +542,25 @@ static NTSTATUS odb_ctdb_rename(struct odb_lock *lck, const char *path)
        return odb_push_record(lck, &file);
 }
 
+/*
+  get the path of an open file
+*/
+static NTSTATUS odb_ctdb_get_path(struct odb_lock *lck, const char **path)
+{
+       struct opendb_file file;
+       NTSTATUS status;
+
+       *path = NULL;
+
+       status = odb_pull_record(lck, &file);
+       /* we don't ignore NT_STATUS_OBJECT_NAME_NOT_FOUND here */
+       NT_STATUS_NOT_OK_RETURN(status);
+
+       *path = file.path;
+
+       return NT_STATUS_OK;
+}
+
 /*
   update delete on close flag on an open file
 */
@@ -653,6 +672,7 @@ static const struct opendb_ops opendb_ctdb_ops = {
        .odb_close_file          = odb_ctdb_close_file,
        .odb_remove_pending      = odb_ctdb_remove_pending,
        .odb_rename              = odb_ctdb_rename,
+       .odb_get_path            = odb_ctdb_get_path,
        .odb_set_delete_on_close = odb_ctdb_set_delete_on_close,
        .odb_get_delete_on_close = odb_ctdb_get_delete_on_close,
        .odb_can_open            = odb_ctdb_can_open,
index d8cb67686b9221ff3938e7fc9e0e8b407fdf5fa9..6c1a9c070ae82426afd6d946512d3ae10c149e2b 100644 (file)
@@ -142,6 +142,14 @@ _PUBLIC_ NTSTATUS odb_rename(struct odb_lock *lck, const char *path)
        return ops->odb_rename(lck, path);
 }
 
+/*
+  get back the path of an open file
+*/
+_PUBLIC_ NTSTATUS odb_get_path(struct odb_lock *lck, const char **path)
+{
+       return ops->odb_get_path(lck, path);
+}
+
 /*
   update delete on close flag on an open file
 */
index 33f2e1c88d21a9fdf59b5e784ba5a32430de6c68..69a7f718ba6d4d14398fbfa415769696eabe71d0 100644 (file)
@@ -36,6 +36,7 @@ struct opendb_ops {
                                   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_get_path)(struct odb_lock *lck, const char **path);
        NTSTATUS (*odb_set_delete_on_close)(struct odb_lock *lck, bool del_on_close);
        NTSTATUS (*odb_get_delete_on_close)(struct odb_context *odb, 
                                            DATA_BLOB *key, bool *del_on_close);
index 37c1c0850b1d9e69681d3c9a3c9b6ff6b165100f..47b35f594c61d24b4c9651b18c113dd251ba5d40 100644 (file)
@@ -713,6 +713,25 @@ static NTSTATUS odb_tdb_rename(struct odb_lock *lck, const char *path)
        return odb_push_record(lck, &file);
 }
 
+/*
+  get the path of an open file
+*/
+static NTSTATUS odb_tdb_get_path(struct odb_lock *lck, const char **path)
+{
+       struct opendb_file file;
+       NTSTATUS status;
+
+       *path = NULL;
+
+       status = odb_pull_record(lck, &file);
+       /* we don't ignore NT_STATUS_OBJECT_NAME_NOT_FOUND here */
+       NT_STATUS_NOT_OK_RETURN(status);
+
+       *path = file.path;
+
+       return NT_STATUS_OK;
+}
+
 /*
   update delete on close flag on an open file
 */
@@ -802,6 +821,7 @@ static const struct opendb_ops opendb_tdb_ops = {
        .odb_close_file          = odb_tdb_close_file,
        .odb_remove_pending      = odb_tdb_remove_pending,
        .odb_rename              = odb_tdb_rename,
+       .odb_get_path            = odb_tdb_get_path,
        .odb_set_delete_on_close = odb_tdb_set_delete_on_close,
        .odb_get_delete_on_close = odb_tdb_get_delete_on_close,
        .odb_can_open            = odb_tdb_can_open,