From c55e44b6a7c8ca569010ddd7596ba05239c4d673 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 7 Dec 2007 11:58:40 +0100 Subject: Re-arrange create_file() parameters This changes them to be a bit closer to open_file_ntcreate and thus provides less surprises to developers (This used to be commit d000258b96b9bb714efdfe982947370a6dfb5d55) --- source3/smbd/nttrans.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/smbd/nttrans.c') diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c index fb85a67d0a..01ac1abeb0 100644 --- a/source3/smbd/nttrans.c +++ b/source3/smbd/nttrans.c @@ -498,8 +498,8 @@ void reply_ntcreate_and_X(connection_struct *conn, struct smb_request *req) } status = create_file(conn, req, root_dir_fid, fname, flags, - access_mask, file_attributes, share_access, - create_disposition, create_options, + access_mask, share_access, create_disposition, + create_options, file_attributes, allocation_size, NULL, NULL, &fsp, &info, &oplock_granted, &sbuf); @@ -942,8 +942,8 @@ static void call_nt_transact_create(connection_struct *conn, } status = create_file(conn, req, root_dir_fid, fname, flags, - access_mask, file_attributes, share_access, - create_disposition, create_options, + access_mask, share_access, create_disposition, + create_options, file_attributes, allocation_size, sd, ea_list, &fsp, &info, &oplock_granted, &sbuf); -- cgit From ce535b4dd8c410d91f9c0fa2d1d973b4326af64d Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 7 Dec 2007 12:39:30 +0100 Subject: More parameter shuffling (This used to be commit 8f70f691ffa3e171a73d04a1c867aa6fca4d4583) --- source3/smbd/nttrans.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/smbd/nttrans.c') diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c index 01ac1abeb0..a8afd580b3 100644 --- a/source3/smbd/nttrans.c +++ b/source3/smbd/nttrans.c @@ -497,9 +497,9 @@ void reply_ntcreate_and_X(connection_struct *conn, struct smb_request *req) } } - status = create_file(conn, req, root_dir_fid, fname, flags, + status = create_file(conn, req, root_dir_fid, fname, access_mask, share_access, create_disposition, - create_options, file_attributes, + create_options, file_attributes, flags, allocation_size, NULL, NULL, &fsp, &info, &oplock_granted, &sbuf); @@ -941,9 +941,9 @@ static void call_nt_transact_create(connection_struct *conn, return; } - status = create_file(conn, req, root_dir_fid, fname, flags, + status = create_file(conn, req, root_dir_fid, fname, access_mask, share_access, create_disposition, - create_options, file_attributes, + create_options, file_attributes, flags, allocation_size, sd, ea_list, &fsp, &info, &oplock_granted, &sbuf); -- cgit From ca4eee5bbe477af2abcdbed542c5e8f7ef5eb610 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 7 Dec 2007 12:57:11 +0100 Subject: Pass only internal oplock request values to create_file Other callers (e.g. reply_open_and_X) might have other ideas of the bit shuffling (This used to be commit 6a58d823e51ccc8efd6682005e367c9096abc993) --- source3/smbd/nttrans.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 66 insertions(+), 4 deletions(-) (limited to 'source3/smbd/nttrans.c') diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c index a8afd580b3..716f682c1a 100644 --- a/source3/smbd/nttrans.c +++ b/source3/smbd/nttrans.c @@ -433,6 +433,7 @@ void reply_ntcreate_and_X(connection_struct *conn, struct smb_request *req) struct timespec a_timespec; struct timespec m_timespec; NTSTATUS status; + int oplock_request; uint8_t oplock_granted = NO_OPLOCK_RETURN; TALLOC_CTX *ctx = talloc_tos(); @@ -497,11 +498,16 @@ void reply_ntcreate_and_X(connection_struct *conn, struct smb_request *req) } } + oplock_request = (flags & REQUEST_OPLOCK) ? EXCLUSIVE_OPLOCK : 0; + if (oplock_request) { + oplock_request |= (flags & REQUEST_BATCH_OPLOCK) + ? BATCH_OPLOCK : 0; + } + status = create_file(conn, req, root_dir_fid, fname, access_mask, share_access, create_disposition, create_options, file_attributes, flags, - allocation_size, NULL, NULL, - &fsp, &info, &oplock_granted, &sbuf); + allocation_size, NULL, NULL, &fsp, &info, &sbuf); if (!NT_STATUS_IS_OK(status)) { if (open_was_deferred(req->mid)) { @@ -519,6 +525,31 @@ void reply_ntcreate_and_X(connection_struct *conn, struct smb_request *req) return; } + /* + * If the caller set the extended oplock request bit + * and we granted one (by whatever means) - set the + * correct bit for extended oplock reply. + */ + + if (oplock_request && + (lp_fake_oplocks(SNUM(conn)) + || EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type))) { + + /* + * Exclusive oplock granted + */ + + if (flags & REQUEST_BATCH_OPLOCK) { + oplock_granted = BATCH_OPLOCK_RETURN; + } else { + oplock_granted = EXCLUSIVE_OPLOCK_RETURN; + } + } else if (fsp->oplock_type == LEVEL_II_OPLOCK) { + oplock_granted = LEVEL_II_OPLOCK_RETURN; + } else { + oplock_granted = NO_OPLOCK_RETURN; + } + file_len = sbuf.st_size; fattr = dos_mode(conn,fname,&sbuf); if (fattr == 0) { @@ -834,6 +865,7 @@ static void call_nt_transact_create(connection_struct *conn, NTSTATUS status; size_t param_len; SMB_BIG_UINT allocation_size; + int oplock_request; uint8_t oplock_granted; TALLOC_CTX *ctx = talloc_tos(); @@ -941,11 +973,16 @@ static void call_nt_transact_create(connection_struct *conn, return; } + oplock_request = (flags & REQUEST_OPLOCK) ? EXCLUSIVE_OPLOCK : 0; + if (oplock_request) { + oplock_request |= (flags & REQUEST_BATCH_OPLOCK) + ? BATCH_OPLOCK : 0; + } + status = create_file(conn, req, root_dir_fid, fname, access_mask, share_access, create_disposition, create_options, file_attributes, flags, - allocation_size, sd, ea_list, - &fsp, &info, &oplock_granted, &sbuf); + allocation_size, sd, ea_list, &fsp, &info, &sbuf); if(!NT_STATUS_IS_OK(status)) { if (open_was_deferred(req->mid)) { @@ -961,6 +998,31 @@ static void call_nt_transact_create(connection_struct *conn, return; } + /* + * If the caller set the extended oplock request bit + * and we granted one (by whatever means) - set the + * correct bit for extended oplock reply. + */ + + if (oplock_request && + (lp_fake_oplocks(SNUM(conn)) + || EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type))) { + + /* + * Exclusive oplock granted + */ + + if (flags & REQUEST_BATCH_OPLOCK) { + oplock_granted = BATCH_OPLOCK_RETURN; + } else { + oplock_granted = EXCLUSIVE_OPLOCK_RETURN; + } + } else if (fsp->oplock_type == LEVEL_II_OPLOCK) { + oplock_granted = LEVEL_II_OPLOCK_RETURN; + } else { + oplock_granted = NO_OPLOCK_RETURN; + } + file_len = sbuf.st_size; fattr = dos_mode(conn,fname,&sbuf); if (fattr == 0) { -- cgit From a23d09081fdb089c776e568418cba75c2c2e8271 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 7 Dec 2007 15:55:57 +0100 Subject: Attempt to fix make test :-) (This used to be commit de3a3e3745e58cbfa777ae426e38bad3d74230d4) --- source3/smbd/nttrans.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/smbd/nttrans.c') diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c index 716f682c1a..99b2bf65bb 100644 --- a/source3/smbd/nttrans.c +++ b/source3/smbd/nttrans.c @@ -506,7 +506,7 @@ void reply_ntcreate_and_X(connection_struct *conn, struct smb_request *req) status = create_file(conn, req, root_dir_fid, fname, access_mask, share_access, create_disposition, - create_options, file_attributes, flags, + create_options, file_attributes, oplock_request, allocation_size, NULL, NULL, &fsp, &info, &sbuf); if (!NT_STATUS_IS_OK(status)) { @@ -981,7 +981,7 @@ static void call_nt_transact_create(connection_struct *conn, status = create_file(conn, req, root_dir_fid, fname, access_mask, share_access, create_disposition, - create_options, file_attributes, flags, + create_options, file_attributes, oplock_request, allocation_size, sd, ea_list, &fsp, &info, &sbuf); if(!NT_STATUS_IS_OK(status)) { -- cgit