summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2008-03-12 15:32:47 +0100
committerStefan Metzmacher <metze@samba.org>2008-04-07 12:29:25 +0200
commit2ccf50256e31bd7b9da0f7a7c223bebca5bca062 (patch)
treecce0d5430e82941b8195e6952fd2704241f4ddfa /source3/smbd
parent4f715d110279098bb62cb3f5b0831f1a8868068a (diff)
downloadsamba-2ccf50256e31bd7b9da0f7a7c223bebca5bca062.tar.gz
samba-2ccf50256e31bd7b9da0f7a7c223bebca5bca062.tar.bz2
samba-2ccf50256e31bd7b9da0f7a7c223bebca5bca062.zip
locking: store the write time in the locking.tdb
This is needed to implement the strange write time update logic later. We need to store 2 time timestamps to distinguish between the time the file system had before the first client opened the file and a forced timestamp update. metze (This used to be commit 6aaa2ce0eeb46f6735ec984a2e7aadde7a7f456d)
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/close.c6
-rw-r--r--source3/smbd/open.c15
-rw-r--r--source3/smbd/oplock.c9
-rw-r--r--source3/smbd/reply.c3
-rw-r--r--source3/smbd/trans2.c3
5 files changed, 24 insertions, 12 deletions
diff --git a/source3/smbd/close.c b/source3/smbd/close.c
index b06c0d1e9c..8a5c82cc93 100644
--- a/source3/smbd/close.c
+++ b/source3/smbd/close.c
@@ -246,7 +246,8 @@ static NTSTATUS close_remove_share_mode(files_struct *fsp,
* This prevents race conditions with the file being created. JRA.
*/
- lck = get_share_mode_lock(talloc_tos(), fsp->file_id, NULL, NULL);
+ lck = get_share_mode_lock(talloc_tos(), fsp->file_id, NULL, NULL,
+ NULL);
if (lck == NULL) {
DEBUG(0, ("close_remove_share_mode: Could not get share mode "
@@ -535,7 +536,8 @@ static NTSTATUS close_directory(files_struct *fsp, enum file_close_type close_ty
* reference to a directory also.
*/
- lck = get_share_mode_lock(talloc_tos(), fsp->file_id, NULL, NULL);
+ lck = get_share_mode_lock(talloc_tos(), fsp->file_id, NULL, NULL,
+ NULL);
if (lck == NULL) {
DEBUG(0, ("close_directory: Could not get share mode lock for %s\n", fsp->fsp_name));
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index 0cc48c4f1c..f3ed234c87 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -1221,7 +1221,8 @@ NTSTATUS open_file_ntcreate(connection_struct *conn,
request_time = pml->request_time;
/* Remove the deferred open entry under lock. */
- lck = get_share_mode_lock(talloc_tos(), state->id, NULL, NULL);
+ lck = get_share_mode_lock(talloc_tos(), state->id, NULL, NULL,
+ NULL);
if (lck == NULL) {
DEBUG(0, ("could not get share mode lock\n"));
} else {
@@ -1450,11 +1451,12 @@ NTSTATUS open_file_ntcreate(connection_struct *conn,
}
if (file_existed) {
+ struct timespec old_write_time = get_mtimespec(psbuf);
id = vfs_file_id_from_sbuf(conn, psbuf);
lck = get_share_mode_lock(talloc_tos(), id,
conn->connectpath,
- fname);
+ fname, &old_write_time);
if (lck == NULL) {
file_free(fsp);
@@ -1661,7 +1663,7 @@ NTSTATUS open_file_ntcreate(connection_struct *conn,
}
if (!file_existed) {
-
+ struct timespec old_write_time = get_mtimespec(psbuf);
/*
* Deal with the race condition where two smbd's detect the
* file doesn't exist and do the create at the same time. One
@@ -1681,7 +1683,7 @@ NTSTATUS open_file_ntcreate(connection_struct *conn,
lck = get_share_mode_lock(talloc_tos(), id,
conn->connectpath,
- fname);
+ fname, &old_write_time);
if (lck == NULL) {
DEBUG(0, ("open_file_ntcreate: Could not get share "
@@ -2095,6 +2097,7 @@ NTSTATUS open_directory(connection_struct *conn,
bool dir_existed = VALID_STAT(*psbuf) ? True : False;
struct share_mode_lock *lck = NULL;
NTSTATUS status;
+ struct timespec mtimespec;
int info = 0;
DEBUG(5,("open_directory: opening directory %s, access_mask = 0x%x, "
@@ -2217,9 +2220,11 @@ NTSTATUS open_directory(connection_struct *conn,
string_set(&fsp->fsp_name,fname);
+ mtimespec = get_mtimespec(psbuf);
+
lck = get_share_mode_lock(talloc_tos(), fsp->file_id,
conn->connectpath,
- fname);
+ fname, &mtimespec);
if (lck == NULL) {
DEBUG(0, ("open_directory: Could not get share mode lock for %s\n", fname));
diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c
index 420aa94fe6..c3409547fe 100644
--- a/source3/smbd/oplock.c
+++ b/source3/smbd/oplock.c
@@ -181,7 +181,8 @@ bool remove_oplock(files_struct *fsp)
struct share_mode_lock *lck;
/* Remove the oplock flag from the sharemode. */
- lck = get_share_mode_lock(talloc_tos(), fsp->file_id, NULL, NULL);
+ lck = get_share_mode_lock(talloc_tos(), fsp->file_id, NULL, NULL,
+ NULL);
if (lck == NULL) {
DEBUG(0,("remove_oplock: failed to lock share entry for "
"file %s\n", fsp->fsp_name ));
@@ -206,7 +207,8 @@ bool downgrade_oplock(files_struct *fsp)
bool ret;
struct share_mode_lock *lck;
- lck = get_share_mode_lock(talloc_tos(), fsp->file_id, NULL, NULL);
+ lck = get_share_mode_lock(talloc_tos(), fsp->file_id, NULL, NULL,
+ NULL);
if (lck == NULL) {
DEBUG(0,("downgrade_oplock: failed to lock share entry for "
"file %s\n", fsp->fsp_name ));
@@ -757,7 +759,8 @@ void release_level_2_oplocks_on_change(files_struct *fsp)
if (!LEVEL_II_OPLOCK_TYPE(fsp->oplock_type))
return;
- lck = get_share_mode_lock(talloc_tos(), fsp->file_id, NULL, NULL);
+ lck = get_share_mode_lock(talloc_tos(), fsp->file_id, NULL, NULL,
+ NULL);
if (lck == NULL) {
DEBUG(0,("release_level_2_oplocks_on_change: failed to lock "
"share mode entry for file %s.\n", fsp->fsp_name ));
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 972f30dbbd..b300c09f4f 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -5515,7 +5515,8 @@ NTSTATUS rename_internals_fsp(connection_struct *conn,
return NT_STATUS_ACCESS_DENIED;
}
- lck = get_share_mode_lock(talloc_tos(), fsp->file_id, NULL, NULL);
+ lck = get_share_mode_lock(talloc_tos(), fsp->file_id, NULL, NULL,
+ NULL);
/*
* We have the file open ourselves, so not being able to get the
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index d7a0f6eff8..308ba271b8 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -6431,7 +6431,8 @@ static NTSTATUS smb_posix_unlink(connection_struct *conn,
* non-POSIX opens return SHARING_VIOLATION.
*/
- lck = get_share_mode_lock(talloc_tos(), fsp->file_id, NULL, NULL);
+ lck = get_share_mode_lock(talloc_tos(), fsp->file_id, NULL, NULL,
+ NULL);
if (lck == NULL) {
DEBUG(0, ("smb_posix_unlink: Could not get share mode "
"lock for file %s\n", fsp->fsp_name));