pvfs_setfileinfo: update the write time in the opendb
authorStefan Metzmacher <metze@samba.org>
Tue, 3 Jun 2008 09:47:12 +0000 (11:47 +0200)
committerStefan Metzmacher <metze@samba.org>
Tue, 3 Jun 2008 12:03:51 +0000 (14:03 +0200)
metze
(This used to be commit 418e2592b48d558ff1d32031d64263ae21cf1eb0)

source4/ntvfs/posix/pvfs_setfileinfo.c

index 1dd2c075d9abf57254552f399ecfdee4c9763e12..b0f636f99915e507d41668e14743a4b2bcf3a413 100644 (file)
@@ -454,6 +454,30 @@ NTSTATUS pvfs_setfileinfo(struct ntvfs_module_context *ntvfs,
                        return pvfs_map_errno(pvfs, errno);
                }
        }
+       if (change_mask & FILE_NOTIFY_CHANGE_LAST_WRITE) {
+               struct odb_lock *lck;
+
+               lck = odb_lock(req, h->pvfs->odb_context, &h->odb_locking_key);
+               if (lck == NULL) {
+                       DEBUG(0,("Unable to lock opendb for write time update\n"));
+                       return NT_STATUS_INTERNAL_ERROR;
+               }
+
+               status = odb_set_write_time(lck, newstats.dos.write_time, true);
+               if (!NT_STATUS_IS_OK(status)) {
+                       DEBUG(0,("Unable to update write time: %s\n",
+                               nt_errstr(status)));
+                       talloc_free(lck);
+                       return status;
+               }
+
+               talloc_free(lck);
+
+               h->write_time.update_forced = true;
+               h->write_time.update_on_close = false;
+               talloc_free(h->write_time.update_event);
+               h->write_time.update_event = NULL;
+       }
 
        /* possibly change the attribute */
        if (newstats.dos.attrib != h->name->dos.attrib) {
@@ -753,6 +777,29 @@ NTSTATUS pvfs_setpathinfo(struct ntvfs_module_context *ntvfs,
                        return pvfs_map_errno(pvfs, errno);
                }
        }
+       if (change_mask & FILE_NOTIFY_CHANGE_LAST_WRITE) {
+               if (lck == NULL) {
+                       DATA_BLOB lkey;
+                       status = pvfs_locking_key(name, name, &lkey);
+                       NT_STATUS_NOT_OK_RETURN(status);
+
+                       lck = odb_lock(req, pvfs->odb_context, &lkey);
+                       data_blob_free(&lkey);
+                       if (lck == NULL) {
+                               DEBUG(0,("Unable to lock opendb for write time update\n"));
+                               return NT_STATUS_INTERNAL_ERROR;
+                       }
+               }
+
+               status = odb_set_write_time(lck, newstats.dos.write_time, true);
+               if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
+                       /* it could be that nobody has opened the file */
+               } else if (!NT_STATUS_IS_OK(status)) {
+                       DEBUG(0,("Unable to update write time: %s\n",
+                               nt_errstr(status)));
+                       return status;
+               }
+       }
 
        /* possibly change the attribute */
        newstats.dos.attrib |= (name->dos.attrib & FILE_ATTRIBUTE_DIRECTORY);