*/
NTSTATUS messaging_send(struct messaging_context *msg,
struct server_id server,
- uint32_t msg_type, DATA_BLOB *data)
+ uint32_t msg_type, const DATA_BLOB *data)
{
return message_send_pid_internal(server, msg_type, data->data,
data->length, True, 0);
We must cope with range splits and merges.
****************************************************************************/
-static NTSTATUS brl_lock_posix(struct byte_range_lock *br_lck,
- const struct lock_struct *plock)
+static NTSTATUS brl_lock_posix(struct messaging_context *msg_ctx,
+ struct byte_range_lock *br_lck,
+ const struct lock_struct *plock)
{
unsigned int i, count;
struct lock_struct *locks = br_lck->lock_data;
DEBUG(10,("brl_lock_posix: sending unlock message to pid %s\n",
procid_str_static(&pend_lock->context.pid )));
- message_send_pid(pend_lock->context.pid,
- MSG_SMB_UNLOCK,
- NULL, 0, True);
+ messaging_send(msg_ctx, pend_lock->context.pid,
+ MSG_SMB_UNLOCK, &data_blob_null);
}
}
}
Lock a range of bytes.
****************************************************************************/
-NTSTATUS brl_lock(struct byte_range_lock *br_lck,
+NTSTATUS brl_lock(struct messaging_context *msg_ctx,
+ struct byte_range_lock *br_lck,
uint32 smbpid,
struct server_id pid,
br_off start,
if (lock_flav == WINDOWS_LOCK) {
ret = brl_lock_windows(br_lck, &lock, blocking_lock);
} else {
- ret = brl_lock_posix(br_lck, &lock);
+ ret = brl_lock_posix(msg_ctx, br_lck, &lock);
}
#if ZERO_ZERO
Unlock a range of bytes - Windows semantics.
****************************************************************************/
-static BOOL brl_unlock_windows(struct byte_range_lock *br_lck, const struct lock_struct *plock)
+static BOOL brl_unlock_windows(struct messaging_context *msg_ctx,
+ struct byte_range_lock *br_lck,
+ const struct lock_struct *plock)
{
unsigned int i, j;
struct lock_struct *locks = br_lck->lock_data;
DEBUG(10,("brl_unlock: sending unlock message to pid %s\n",
procid_str_static(&pend_lock->context.pid )));
- message_send_pid(pend_lock->context.pid,
- MSG_SMB_UNLOCK,
- NULL, 0, True);
+ messaging_send(msg_ctx, pend_lock->context.pid,
+ MSG_SMB_UNLOCK, &data_blob_null);
}
}
Unlock a range of bytes - POSIX semantics.
****************************************************************************/
-static BOOL brl_unlock_posix(struct byte_range_lock *br_lck, const struct lock_struct *plock)
+static BOOL brl_unlock_posix(struct messaging_context *msg_ctx,
+ struct byte_range_lock *br_lck,
+ const struct lock_struct *plock)
{
unsigned int i, j, count;
struct lock_struct *tp;
DEBUG(10,("brl_unlock: sending unlock message to pid %s\n",
procid_str_static(&pend_lock->context.pid )));
- message_send_pid(pend_lock->context.pid,
- MSG_SMB_UNLOCK,
- NULL, 0, True);
+ messaging_send(msg_ctx, pend_lock->context.pid,
+ MSG_SMB_UNLOCK, &data_blob_null);
}
}
Unlock a range of bytes.
****************************************************************************/
-BOOL brl_unlock(struct byte_range_lock *br_lck,
+BOOL brl_unlock(struct messaging_context *msg_ctx,
+ struct byte_range_lock *br_lck,
uint32 smbpid,
struct server_id pid,
br_off start,
lock.lock_flav = lock_flav;
if (lock_flav == WINDOWS_LOCK) {
- return brl_unlock_windows(br_lck, &lock);
+ return brl_unlock_windows(msg_ctx, br_lck, &lock);
} else {
- return brl_unlock_posix(br_lck, &lock);
+ return brl_unlock_posix(msg_ctx, br_lck, &lock);
}
}
fd and so we should not immediately close the fd.
****************************************************************************/
-void brl_close_fnum(struct byte_range_lock *br_lck)
+void brl_close_fnum(struct messaging_context *msg_ctx,
+ struct byte_range_lock *br_lck)
{
files_struct *fsp = br_lck->fsp;
uint16 tid = fsp->conn->cnum;
if (lock->context.tid == tid && procid_equal(&lock->context.pid, &pid) &&
(lock->fnum == fnum)) {
- brl_unlock(br_lck,
+ brl_unlock(msg_ctx,
+ br_lck,
lock->context.smbpid,
pid,
lock->start,
/* We could send specific lock info here... */
if (brl_pending_overlap(lock, pend_lock)) {
- message_send_pid(pend_lock->context.pid,
- MSG_SMB_UNLOCK,
- NULL, 0, True);
+ messaging_send(msg_ctx, pend_lock->context.pid,
+ MSG_SMB_UNLOCK, &data_blob_null);
}
}
Utility function called by locking requests.
****************************************************************************/
-struct byte_range_lock *do_lock(files_struct *fsp,
+struct byte_range_lock *do_lock(struct messaging_context *msg_ctx,
+ files_struct *fsp,
uint32 lock_pid,
SMB_BIG_UINT count,
SMB_BIG_UINT offset,
return NULL;
}
- *perr = brl_lock(br_lck,
+ *perr = brl_lock(msg_ctx,
+ br_lck,
lock_pid,
procid_self(),
offset,
Utility function called by unlocking requests.
****************************************************************************/
-NTSTATUS do_unlock(files_struct *fsp,
+NTSTATUS do_unlock(struct messaging_context *msg_ctx,
+ files_struct *fsp,
uint32 lock_pid,
SMB_BIG_UINT count,
SMB_BIG_UINT offset,
return NT_STATUS_NO_MEMORY;
}
- ok = brl_unlock(br_lck,
+ ok = brl_unlock(msg_ctx,
+ br_lck,
lock_pid,
procid_self(),
offset,
Remove any locks on this fd. Called from file_close().
****************************************************************************/
-void locking_close_file(files_struct *fsp)
+void locking_close_file(struct messaging_context *msg_ctx,
+ files_struct *fsp)
{
struct byte_range_lock *br_lck;
if (br_lck) {
cancel_pending_lock_requests_by_fid(fsp, br_lck);
- brl_close_fnum(br_lck);
+ brl_close_fnum(msg_ctx, br_lck);
TALLOC_FREE(br_lck);
}
}
Based on an initial code idea from SATOH Fumiyasu <fumiya@samba.gr.jp>
********************************************************************/
-BOOL rename_share_filename(struct share_mode_lock *lck,
+BOOL rename_share_filename(struct messaging_context *msg_ctx,
+ struct share_mode_lock *lck,
const char *servicepath,
const char *newname)
{
size_t msg_len;
char *frm = NULL;
int i;
+ DATA_BLOB msg;
if (!lck) {
return False;
safe_strcpy(&frm[16], lck->servicepath, sp_len);
safe_strcpy(&frm[16 + sp_len + 1], lck->filename, fn_len);
+ msg = data_blob_const(frm, msg_len);
+
/* Send the messages. */
for (i=0; i<lck->num_share_modes; i++) {
struct share_mode_entry *se = &lck->share_modes[i];
(unsigned int)lck->dev, (double)lck->ino,
lck->servicepath, lck->filename ));
- message_send_pid(se->pid, MSG_SMB_FILE_RENAME,
- frm, msg_len, True);
+ messaging_send(msg_ctx, se->pid, MSG_SMB_FILE_RENAME, &msg);
}
return True;
blr->length = length;
/* Add a pending lock record for this. */
- status = brl_lock(br_lck,
+ status = brl_lock(smbd_messaging_context(), br_lck,
lock_pid,
procid_self(),
offset,
* request would never have been queued. JRA.
*/
- do_unlock(fsp,
+ do_unlock(smbd_messaging_context(),
+ fsp,
lock_pid,
count,
offset,
* request would never have been queued. JRA.
*/
errno = 0;
- br_lck = do_lock(fsp,
+ br_lck = do_lock(smbd_messaging_context(),
+ fsp,
lock_pid,
count,
offset,
char *outbuf;
char params[2];
NTSTATUS status;
- struct byte_range_lock *br_lck = do_lock(blr->fsp,
+ struct byte_range_lock *br_lck = do_lock(smbd_messaging_context(),
+ blr->fsp,
blr->lock_pid,
blr->count,
blr->offset,
release_file_oplock(fsp);
}
- locking_close_file(fsp);
+ locking_close_file(smbd_messaging_context(), fsp);
status = fd_close(conn, fsp);
* Note that the requested lock size is unaffected by max_recv.
*/
- br_lck = do_lock(fsp,
+ br_lck = do_lock(smbd_messaging_context(),
+ fsp,
(uint32)SVAL(inbuf,smb_pid),
(SMB_BIG_UINT)numtoread,
(SMB_BIG_UINT)startpos,
}
if (numtowrite) {
- status = do_unlock(fsp,
+ status = do_unlock(smbd_messaging_context(),
+ fsp,
(uint32)SVAL(inbuf,smb_pid),
(SMB_BIG_UINT)numtowrite,
(SMB_BIG_UINT)startpos,
DEBUG(3,("lock fd=%d fnum=%d offset=%.0f count=%.0f\n",
fsp->fh->fd, fsp->fnum, (double)offset, (double)count));
- br_lck = do_lock(fsp,
+ br_lck = do_lock(smbd_messaging_context(),
+ fsp,
(uint32)SVAL(inbuf,smb_pid),
count,
offset,
count = (SMB_BIG_UINT)IVAL(inbuf,smb_vwv1);
offset = (SMB_BIG_UINT)IVAL(inbuf,smb_vwv3);
- status = do_unlock(fsp,
+ status = do_unlock(smbd_messaging_context(),
+ fsp,
(uint32)SVAL(inbuf,smb_pid),
count,
offset,
}
/* Send messages to all smbd's (not ourself) that the name has changed. */
- rename_share_filename(lck, conn->connectpath, newname);
+ rename_share_filename(smbd_messaging_context(), lck, conn->connectpath,
+ newname);
}
/****************************************************************************
"pid %u, file %s\n", (double)offset, (double)count,
(unsigned int)lock_pid, fsp->fsp_name ));
- status = do_unlock(fsp,
+ status = do_unlock(smbd_messaging_context(),
+ fsp,
lock_pid,
count,
offset,
BOOL defer_lock = False;
struct byte_range_lock *br_lck;
- br_lck = do_lock(fsp,
+ br_lck = do_lock(smbd_messaging_context(),
+ fsp,
lock_pid,
count,
offset,
return ERROR_DOS(ERRDOS,ERRnoaccess);
}
- do_unlock(fsp,
+ do_unlock(smbd_messaging_context(),
+ fsp,
lock_pid,
count,
offset,
(double)offset ));
if (lock_type == UNLOCK_LOCK) {
- status = do_unlock(fsp,
+ status = do_unlock(smbd_messaging_context(),
+ fsp,
lock_pid,
count,
offset,
POSIX_LOCK);
} else {
- struct byte_range_lock *br_lck = do_lock(fsp,
+ struct byte_range_lock *br_lck = do_lock(smbd_messaging_context(),
+ fsp,
lock_pid,
count,
offset,