Finish removal of iconv_convenience in public API's.
[bbaumbach/samba-autobuild/.git] / source4 / ntvfs / common / opendb_tdb.c
index 99c0a95c20a4cac21853e6b50cd1a6f9b5e60af7..944ec866314fb0ea4c6d7eb6315b489053d90cb2 100644 (file)
@@ -40,7 +40,7 @@
 
 #include "includes.h"
 #include "system/filesys.h"
-#include "lib/tdb/include/tdb.h"
+#include "../tdb/include/tdb.h"
 #include "messaging/messaging.h"
 #include "tdb_wrap.h"
 #include "lib/messaging/irpc.h"
@@ -246,7 +246,7 @@ static NTSTATUS odb_pull_record(struct odb_lock *lck, struct opendb_file *file)
        blob.data = dbuf.dptr;
        blob.length = dbuf.dsize;
 
-       ndr_err = ndr_pull_struct_blob(&blob, lck, lp_iconv_convenience(lck->odb->ntvfs_ctx->lp_ctx), file, (ndr_pull_flags_fn_t)ndr_pull_opendb_file);
+       ndr_err = ndr_pull_struct_blob(&blob, lck, file, (ndr_pull_flags_fn_t)ndr_pull_opendb_file);
        free(dbuf.dptr);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                return ndr_map_error2ntstatus(ndr_err);
@@ -274,7 +274,7 @@ static NTSTATUS odb_push_record(struct odb_lock *lck, struct opendb_file *file)
                return NT_STATUS_OK;
        }
 
-       ndr_err = ndr_push_struct_blob(&blob, lck, lp_iconv_convenience(lck->odb->ntvfs_ctx->lp_ctx), file, (ndr_push_flags_fn_t)ndr_push_opendb_file);
+       ndr_err = ndr_push_struct_blob(&blob, lck, file, (ndr_push_flags_fn_t)ndr_push_opendb_file);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                return ndr_map_error2ntstatus(ndr_err);
        }
@@ -452,7 +452,8 @@ static NTSTATUS odb_tdb_open_can_internal(struct odb_context *odb,
 */
 static NTSTATUS odb_tdb_open_file(struct odb_lock *lck,
                                  void *file_handle, const char *path,
-                                 int *fd, bool allow_level_II_oplock,
+                                 int *fd, NTTIME open_write_time,
+                                 bool allow_level_II_oplock,
                                  uint32_t oplock_level, uint32_t *oplock_granted)
 {
        struct odb_context *odb = lck->odb;
@@ -474,6 +475,10 @@ static NTSTATUS odb_tdb_open_file(struct odb_lock *lck,
                NT_STATUS_HAVE_NO_MEMORY(lck->file.path);
        }
 
+       if (lck->file.open_write_time == 0) {
+               lck->file.open_write_time = open_write_time;
+       }
+
        /*
          possibly grant an exclusive, batch or level2 oplock
        */
@@ -543,7 +548,7 @@ static NTSTATUS odb_tdb_open_file(struct odb_lock *lck,
 /*
   register a pending open file in the open files database
 */
-static NTSTATUS odb_tdb_open_file_pending(struct odb_lock *lck, void *private)
+static NTSTATUS odb_tdb_open_file_pending(struct odb_lock *lck, void *private_data)
 {
        struct odb_context *odb = lck->odb;
 
@@ -557,7 +562,7 @@ static NTSTATUS odb_tdb_open_file_pending(struct odb_lock *lck, void *private)
        NT_STATUS_HAVE_NO_MEMORY(lck->file.pending);
 
        lck->file.pending[lck->file.num_pending].server = odb->ntvfs_ctx->server_id;
-       lck->file.pending[lck->file.num_pending].notify_ptr = private;
+       lck->file.pending[lck->file.num_pending].notify_ptr = private_data;
 
        lck->file.num_pending++;
 
@@ -705,7 +710,7 @@ static NTSTATUS odb_tdb_break_oplocks(struct odb_lock *lck)
 /*
   remove a pending opendb entry
 */
-static NTSTATUS odb_tdb_remove_pending(struct odb_lock *lck, void *private)
+static NTSTATUS odb_tdb_remove_pending(struct odb_lock *lck, void *private_data)
 {
        struct odb_context *odb = lck->odb;
        int i;
@@ -716,7 +721,7 @@ static NTSTATUS odb_tdb_remove_pending(struct odb_lock *lck, void *private)
 
        /* find the entry, and delete it */
        for (i=0;i<lck->file.num_pending;i++) {
-               if (private == lck->file.pending[i].notify_ptr &&
+               if (private_data == lck->file.pending[i].notify_ptr &&
                    cluster_id_equal(&odb->ntvfs_ctx->server_id, &lck->file.pending[i].server)) {
                        if (i < lck->file.num_pending-1) {
                                memmove(lck->file.pending+i, lck->file.pending+i+1,
@@ -784,21 +789,54 @@ static NTSTATUS odb_tdb_set_delete_on_close(struct odb_lock *lck, bool del_on_cl
        return odb_push_record(lck, &lck->file);
 }
 
+/*
+  update the write time on an open file
+*/
+static NTSTATUS odb_tdb_set_write_time(struct odb_lock *lck,
+                                      NTTIME write_time, bool force)
+{
+       if (lck->file.path == NULL) {
+               return NT_STATUS_OBJECT_NAME_NOT_FOUND;
+       }
+
+       if (lck->file.changed_write_time != 0 && !force) {
+               return NT_STATUS_OK;
+       }
+
+       lck->file.changed_write_time = write_time;
+
+       return odb_push_record(lck, &lck->file);
+}
+
 /*
   return the current value of the delete_on_close bit, and how many
   people still have the file open
 */
-static NTSTATUS odb_tdb_get_delete_on_close(struct odb_context *odb, 
-                                           DATA_BLOB *key, bool *del_on_close)
+static NTSTATUS odb_tdb_get_file_infos(struct odb_context *odb, DATA_BLOB *key,
+                                      bool *del_on_close, NTTIME *write_time)
 {
        struct odb_lock *lck;
 
-       (*del_on_close) = false;
+       if (del_on_close) {
+               *del_on_close = false;
+       }
+       if (write_time) {
+               *write_time = 0;
+       }
 
        lck = odb_lock(odb, odb, key);
        NT_STATUS_HAVE_NO_MEMORY(lck);
 
-       (*del_on_close) = lck->file.delete_on_close;
+       if (del_on_close) {
+               *del_on_close = lck->file.delete_on_close;
+       }
+       if (write_time) {
+               if (lck->file.changed_write_time == 0) {
+                       *write_time = lck->file.open_write_time;
+               } else {
+                       *write_time = lck->file.changed_write_time;
+               }
+       }
 
        talloc_free(lck);
 
@@ -852,7 +890,8 @@ static const struct opendb_ops opendb_tdb_ops = {
        .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_set_write_time      = odb_tdb_set_write_time,
+       .odb_get_file_infos      = odb_tdb_get_file_infos,
        .odb_can_open            = odb_tdb_can_open,
        .odb_update_oplock       = odb_tdb_update_oplock,
        .odb_break_oplocks       = odb_tdb_break_oplocks