NTSTATUS do_unlock(files_struct *fsp, uint32 lock_pid, SMB_BIG_UINT count, SMB_BIG_UINT offset, enum brl_flavour lock_flav) { BOOL ok = False; struct byte_range_lock *br_lck = NULL; if (!fsp->can_lock) { return fsp->is_directory ? NT_STATUS_INVALID_DEVICE_REQUEST : NT_STATUS_INVALID_HANDLE; } if (!lp_locking(fsp->conn->params)) { return NT_STATUS_OK; } DEBUG(10,("do_unlock: unlock start=%.0f len=%.0f requested for fnum %d file %s\n", (double)offset, (double)count, fsp->fnum, fsp->fsp_name )); br_lck = brl_get_locks(NULL, fsp); if (!br_lck) { return NT_STATUS_NO_MEMORY; } ok = brl_unlock(br_lck, lock_pid, procid_self(), offset, count, lock_flav); TALLOC_FREE(br_lck); if (!ok) { DEBUG(10,("do_unlock: returning ERRlock.\n" )); return NT_STATUS_RANGE_NOT_LOCKED; } if (lock_flav == WINDOWS_LOCK && fsp->current_lock_count != NO_LOCKING_COUNT) { SMB_ASSERT(fsp->current_lock_count > 0); fsp->current_lock_count--; } return NT_STATUS_OK; }
NTSTATUS do_unlock(struct messaging_context *msg_ctx, files_struct *fsp, uint64_t smblctx, uint64_t count, uint64_t offset, enum brl_flavour lock_flav) { bool ok = False; struct byte_range_lock *br_lck = NULL; if (!fsp->can_lock) { return fsp->is_directory ? NT_STATUS_INVALID_DEVICE_REQUEST : NT_STATUS_INVALID_HANDLE; } if (!lp_locking(fsp->conn->params)) { return NT_STATUS_OK; } DEBUG(10,("do_unlock: unlock start=%.0f len=%.0f requested for %s file %s\n", (double)offset, (double)count, fsp_fnum_dbg(fsp), fsp_str_dbg(fsp))); br_lck = brl_get_locks(talloc_tos(), fsp); if (!br_lck) { return NT_STATUS_NO_MEMORY; } ok = brl_unlock(msg_ctx, br_lck, smblctx, messaging_server_id(fsp->conn->sconn->msg_ctx), offset, count, lock_flav); TALLOC_FREE(br_lck); if (!ok) { DEBUG(10,("do_unlock: returning ERRlock.\n" )); return NT_STATUS_RANGE_NOT_LOCKED; } decrement_current_lock_count(fsp, lock_flav); return NT_STATUS_OK; }
void remove_pending_lock_requests_by_fid(files_struct *fsp) { blocking_lock_record *blr, *next = NULL; for(blr = blocking_lock_queue; blr; blr = next) { next = blr->next; if(blr->fsp->fnum == fsp->fnum) { DEBUG(10,("remove_pending_lock_requests_by_fid - removing request type %d for \ file %s fnum = %d\n", blr->com_type, fsp->fsp_name, fsp->fnum )); brl_unlock(blr->fsp->dev, blr->fsp->inode, blr->fsp->fnum, blr->lock_pid, sys_getpid(), blr->fsp->conn->cnum, blr->offset, blr->count, True, NULL, NULL); free_blocking_lock_record(blr); } }
BOOL do_unlock(uint16 smbpid, files_struct * fsp, struct vfs_connection_struct *conn, SMB_BIG_UINT count, SMB_BIG_UINT offset, uint32 *err) { BOOL ok = False; if (!lp_locking(conn->snum)) return (True); if (!OPEN_FSP(fsp) || !fsp->can_lock || (fsp->conn != conn)) { *err = NT_STATUS_NOT_LOCKED; return False; } DEBUG(10, ("do_unlock: unlock start=%.0f len=%.0f requested for file %s\n", (double)offset, (double)count, smbstrA(fsp->fsp_name))); /* * Remove the existing lock record from the tdb lockdb * before looking at POSIX locks. If this record doesn't * match then don't bother looking to remove POSIX locks. */ ok = brl_unlock(fsp->sbuf.st_dev, fsp->sbuf.st_ino, fsp->fnum, smbpid, sys_getpid(), conn->snum, offset, count); if (!ok) { DEBUG(10, ("do_unlock: returning ERRlock.\n")); *err = NT_STATUS_RANGE_NOT_LOCKED; return False; } if (!lp_posix_locking(conn->snum)) return True; (void)release_posix_lock(fsp, offset, count); return True; /* Did unlock */ }
static NTSTATUS do_lock(files_struct *fsp,connection_struct *conn, uint16 lock_pid, SMB_BIG_UINT count,SMB_BIG_UINT offset,enum brl_type lock_type) { NTSTATUS status; if (!lp_locking(SNUM(conn))) return NT_STATUS_OK; /* NOTE! 0 byte long ranges ARE allowed and should be stored */ DEBUG(10,("do_lock: lock type %s start=%.0f len=%.0f requested for file %s\n", lock_type_name(lock_type), (double)offset, (double)count, fsp->fsp_name )); if (OPEN_FSP(fsp) && fsp->can_lock && (fsp->conn == conn)) { status = brl_lock(fsp->dev, fsp->inode, fsp->fnum, lock_pid, sys_getpid(), conn->cnum, offset, count, lock_type); if (NT_STATUS_IS_OK(status) && lp_posix_locking(SNUM(conn))) { /* * Try and get a POSIX lock on this range. * Note that this is ok if it is a read lock * overlapping on a different fd. JRA. */ if (!set_posix_lock(fsp, offset, count, lock_type)) { status = NT_STATUS_LOCK_NOT_GRANTED; /* * We failed to map - we must now remove the brl * lock entry. */ (void)brl_unlock(fsp->dev, fsp->inode, fsp->fnum, lock_pid, sys_getpid(), conn->cnum, offset, count, False); } } } return status; }
NTSTATUS do_unlock(files_struct *fsp, uint16 lock_pid, SMB_BIG_UINT count, SMB_BIG_UINT offset, enum brl_flavour lock_flav) { BOOL ok = False; struct byte_range_lock *br_lck = NULL; if (!lp_locking(SNUM(fsp->conn))) { return NT_STATUS_OK; } if (!OPEN_FSP(fsp) || !fsp->can_lock) { return NT_STATUS_INVALID_HANDLE; } DEBUG(10,("do_unlock: unlock start=%.0f len=%.0f requested for fnum %d file %s\n", (double)offset, (double)count, fsp->fnum, fsp->fsp_name )); br_lck = brl_get_locks(fsp); if (!br_lck) { return NT_STATUS_NO_MEMORY; } ok = brl_unlock(br_lck, lock_pid, procid_self(), offset, count, lock_flav); byte_range_lock_destructor(br_lck); if (!ok) { DEBUG(10,("do_unlock: returning ERRlock.\n" )); return NT_STATUS_RANGE_NOT_LOCKED; } return NT_STATUS_OK; }
void remove_pending_lock_requests_by_fid(files_struct *fsp) { blocking_lock_record *blr = (blocking_lock_record *)ubi_slFirst( &blocking_lock_queue ); blocking_lock_record *prev = NULL; while(blr != NULL) { if(blr->fsp->fnum == fsp->fnum) { DEBUG(10,("remove_pending_lock_requests_by_fid - removing request type %d for \ file %s fnum = %d\n", blr->com_type, fsp->fsp_name, fsp->fnum )); brl_unlock(blr->fsp->dev, blr->fsp->inode, blr->fsp->fnum, blr->lock_pid, sys_getpid(), blr->fsp->conn->cnum, blr->offset, blr->count, True); free_blocking_lock_record((blocking_lock_record *)ubi_slRemNext( &blocking_lock_queue, prev)); blr = (blocking_lock_record *)(prev ? ubi_slNext(prev) : ubi_slFirst(&blocking_lock_queue)); continue; } prev = blr; blr = (blocking_lock_record *)ubi_slNext(blr); }
NTSTATUS do_unlock(files_struct *fsp,connection_struct *conn, uint16 lock_pid, SMB_BIG_UINT count,SMB_BIG_UINT offset) { BOOL ok = False; if (!lp_locking(SNUM(conn))) return NT_STATUS_OK; if (!OPEN_FSP(fsp) || !fsp->can_lock || (fsp->conn != conn)) { return NT_STATUS_INVALID_HANDLE; } DEBUG(10,("do_unlock: unlock start=%.0f len=%.0f requested for file %s\n", (double)offset, (double)count, fsp->fsp_name )); /* * Remove the existing lock record from the tdb lockdb * before looking at POSIX locks. If this record doesn't * match then don't bother looking to remove POSIX locks. */ ok = brl_unlock(fsp->dev, fsp->inode, fsp->fnum, lock_pid, sys_getpid(), conn->cnum, offset, count, False); if (!ok) { DEBUG(10,("do_unlock: returning ERRlock.\n" )); return NT_STATUS_RANGE_NOT_LOCKED; } if (!lp_posix_locking(SNUM(conn))) return NT_STATUS_OK; (void)release_posix_lock(fsp, offset, count); return NT_STATUS_OK; }
BOOL do_lock(uint16 smbpid, files_struct * fsp, struct vfs_connection_struct *conn, SMB_BIG_UINT count, SMB_BIG_UINT offset, enum brl_type lock_type, uint32 *err) { BOOL ok = False; if (!lp_locking(conn->snum)) return (True); if (count == 0) { *err = NT_STATUS_ACCESS_DENIED; return False; } DEBUG(10, ("do_lock: lock type %s start=%.0f len=%.0f requested for file %s\n", lock_type_name(lock_type), (double)offset, (double)count, smbstrA(fsp->fsp_name))); if (OPEN_FSP(fsp) && fsp->can_lock && (fsp->conn == conn)) { ok = brl_lock(fsp->sbuf.st_dev, fsp->sbuf.st_ino, fsp->fnum, smbpid, sys_getpid(), conn->snum, offset, count, lock_type); if (ok && lp_posix_locking(conn->snum)) { /* * Try and get a POSIX lock on this range. * Note that this is ok if it is a read lock * overlapping on a different fd. JRA. */ ok = set_posix_lock(fsp, offset, count, lock_type); if (!ok) { /* * We failed to map - we must now remove the brl * lock entry. */ (void)brl_unlock(fsp->sbuf.st_dev, fsp->sbuf.st_ino, fsp->fnum, smbpid, sys_getpid(), conn->snum, offset, count); } } } if (!ok) { *err = NT_STATUS_LOCK_NOT_GRANTED; return False; } return True; /* Got lock */ }