mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
smbd: pass lease, if any, to notify_fname()
notify_fname() for NOTIFY_ACTION_DIRLEASE_BREAK will soon need the lease of the current open and to implement "MS-FSA 2.1.4.12 Algorithm to Check for an Oplock Break" with flags=PARENT_OBJECT. No change in behaviour for now, all callers pass lease=NULL; Also change path arg to struct smb_filename. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
This commit is contained in:
parent
8368236aff
commit
c1ac9e6532
@ -2335,9 +2335,11 @@ static ssize_t vfs_gpfs_pread(vfs_handle_struct *handle, files_struct *fsp,
|
||||
ret = SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
|
||||
|
||||
if ((ret != -1) && was_offline) {
|
||||
notify_fname(handle->conn, NOTIFY_ACTION_MODIFIED,
|
||||
notify_fname(handle->conn,
|
||||
NOTIFY_ACTION_MODIFIED,
|
||||
FILE_NOTIFY_CHANGE_ATTRIBUTES,
|
||||
fsp->fsp_name->base_name);
|
||||
fsp->fsp_name,
|
||||
NULL);
|
||||
}
|
||||
|
||||
return ret;
|
||||
@ -2403,9 +2405,11 @@ static ssize_t vfs_gpfs_pread_recv(struct tevent_req *req,
|
||||
|
||||
if ((state->ret != -1) && state->was_offline) {
|
||||
DEBUG(10, ("sending notify\n"));
|
||||
notify_fname(fsp->conn, NOTIFY_ACTION_MODIFIED,
|
||||
notify_fname(fsp->conn,
|
||||
NOTIFY_ACTION_MODIFIED,
|
||||
FILE_NOTIFY_CHANGE_ATTRIBUTES,
|
||||
fsp->fsp_name->base_name);
|
||||
fsp->fsp_name,
|
||||
NULL);
|
||||
}
|
||||
|
||||
return state->ret;
|
||||
@ -2422,9 +2426,11 @@ static ssize_t vfs_gpfs_pwrite(vfs_handle_struct *handle, files_struct *fsp,
|
||||
ret = SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
|
||||
|
||||
if ((ret != -1) && was_offline) {
|
||||
notify_fname(handle->conn, NOTIFY_ACTION_MODIFIED,
|
||||
notify_fname(handle->conn,
|
||||
NOTIFY_ACTION_MODIFIED,
|
||||
FILE_NOTIFY_CHANGE_ATTRIBUTES,
|
||||
fsp->fsp_name->base_name);
|
||||
fsp->fsp_name,
|
||||
NULL);
|
||||
}
|
||||
|
||||
return ret;
|
||||
@ -2491,9 +2497,11 @@ static ssize_t vfs_gpfs_pwrite_recv(struct tevent_req *req,
|
||||
|
||||
if ((state->ret != -1) && state->was_offline) {
|
||||
DEBUG(10, ("sending notify\n"));
|
||||
notify_fname(fsp->conn, NOTIFY_ACTION_MODIFIED,
|
||||
notify_fname(fsp->conn,
|
||||
NOTIFY_ACTION_MODIFIED,
|
||||
FILE_NOTIFY_CHANGE_ATTRIBUTES,
|
||||
fsp->fsp_name->base_name);
|
||||
fsp->fsp_name,
|
||||
NULL);
|
||||
}
|
||||
|
||||
return state->ret;
|
||||
|
@ -357,9 +357,11 @@ static ssize_t tsmsm_pread_recv(struct tevent_req *req,
|
||||
}
|
||||
if (state->ret >= 0 && state->was_offline) {
|
||||
struct files_struct *fsp = state->fsp;
|
||||
notify_fname(fsp->conn, NOTIFY_ACTION_MODIFIED,
|
||||
notify_fname(fsp->conn,
|
||||
NOTIFY_ACTION_MODIFIED,
|
||||
FILE_NOTIFY_CHANGE_ATTRIBUTES,
|
||||
fsp->fsp_name->base_name);
|
||||
fsp->fsp_name,
|
||||
NULL);
|
||||
}
|
||||
*vfs_aio_state = state->vfs_aio_state;
|
||||
return state->ret;
|
||||
@ -422,9 +424,11 @@ static ssize_t tsmsm_pwrite_recv(struct tevent_req *req,
|
||||
}
|
||||
if (state->ret >= 0 && state->was_offline) {
|
||||
struct files_struct *fsp = state->fsp;
|
||||
notify_fname(fsp->conn, NOTIFY_ACTION_MODIFIED,
|
||||
notify_fname(fsp->conn,
|
||||
NOTIFY_ACTION_MODIFIED,
|
||||
FILE_NOTIFY_CHANGE_ATTRIBUTES,
|
||||
fsp->fsp_name->base_name);
|
||||
fsp->fsp_name,
|
||||
NULL);
|
||||
}
|
||||
*vfs_aio_state = state->vfs_aio_state;
|
||||
return state->ret;
|
||||
@ -456,9 +460,11 @@ static ssize_t tsmsm_pread(struct vfs_handle_struct *handle, struct files_struct
|
||||
/* We can't actually force AIO at this point (came here not from reply_read_and_X)
|
||||
what we can do is to send notification that file became online
|
||||
*/
|
||||
notify_fname(handle->conn, NOTIFY_ACTION_MODIFIED,
|
||||
FILE_NOTIFY_CHANGE_ATTRIBUTES,
|
||||
fsp->fsp_name->base_name);
|
||||
notify_fname(handle->conn,
|
||||
NOTIFY_ACTION_MODIFIED,
|
||||
FILE_NOTIFY_CHANGE_ATTRIBUTES,
|
||||
fsp->fsp_name,
|
||||
NULL);
|
||||
}
|
||||
|
||||
return result;
|
||||
@ -474,9 +480,11 @@ static ssize_t tsmsm_pwrite(struct vfs_handle_struct *handle, struct files_struc
|
||||
/* We can't actually force AIO at this point (came here not from reply_read_and_X)
|
||||
what we can do is to send notification that file became online
|
||||
*/
|
||||
notify_fname(handle->conn, NOTIFY_ACTION_MODIFIED,
|
||||
FILE_NOTIFY_CHANGE_ATTRIBUTES,
|
||||
fsp->fsp_name->base_name);
|
||||
notify_fname(handle->conn,
|
||||
NOTIFY_ACTION_MODIFIED,
|
||||
FILE_NOTIFY_CHANGE_ATTRIBUTES,
|
||||
fsp->fsp_name,
|
||||
NULL);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -648,9 +648,11 @@ static NTSTATUS close_remove_share_mode(files_struct *fsp,
|
||||
}
|
||||
|
||||
if (lck_state.delete_object) {
|
||||
notify_fname(conn, NOTIFY_ACTION_REMOVED,
|
||||
notify_fname(conn,
|
||||
NOTIFY_ACTION_REMOVED,
|
||||
FILE_NOTIFY_CHANGE_FILE_NAME,
|
||||
fsp->fsp_name->base_name);
|
||||
fsp->fsp_name,
|
||||
NULL);
|
||||
}
|
||||
|
||||
return status;
|
||||
@ -1596,7 +1598,8 @@ done:
|
||||
notify_fname(conn,
|
||||
NOTIFY_ACTION_REMOVED,
|
||||
FILE_NOTIFY_CHANGE_DIR_NAME,
|
||||
fsp->fsp_name->base_name);
|
||||
fsp->fsp_name,
|
||||
NULL);
|
||||
}
|
||||
|
||||
status1 = fd_close(fsp);
|
||||
|
@ -1071,9 +1071,11 @@ int file_set_dosmode(connection_struct *conn,
|
||||
|
||||
done:
|
||||
if (!newfile) {
|
||||
notify_fname(conn, NOTIFY_ACTION_MODIFIED,
|
||||
notify_fname(conn,
|
||||
NOTIFY_ACTION_MODIFIED,
|
||||
FILE_NOTIFY_CHANGE_ATTRIBUTES,
|
||||
smb_fname->base_name);
|
||||
smb_fname,
|
||||
NULL);
|
||||
}
|
||||
if (ret == 0) {
|
||||
smb_fname->st.st_ex_mode = unixmode;
|
||||
@ -1173,9 +1175,11 @@ NTSTATUS file_set_sparse(connection_struct *conn,
|
||||
return status;
|
||||
}
|
||||
|
||||
notify_fname(conn, NOTIFY_ACTION_MODIFIED,
|
||||
notify_fname(conn,
|
||||
NOTIFY_ACTION_MODIFIED,
|
||||
FILE_NOTIFY_CHANGE_ATTRIBUTES,
|
||||
fsp->fsp_name->base_name);
|
||||
fsp->fsp_name,
|
||||
NULL);
|
||||
|
||||
fsp->fsp_name->st.cached_dos_attributes = new_dosmode;
|
||||
fsp->fsp_flags.is_sparse = sparse;
|
||||
|
@ -577,10 +577,14 @@ void remove_pending_change_notify_requests_by_fid(files_struct *fsp,
|
||||
}
|
||||
}
|
||||
|
||||
void notify_fname(connection_struct *conn, uint32_t action, uint32_t filter,
|
||||
const char *path)
|
||||
void notify_fname(struct connection_struct *conn,
|
||||
uint32_t action,
|
||||
uint32_t filter,
|
||||
const struct smb_filename *smb_fname,
|
||||
const struct smb2_lease *lease)
|
||||
{
|
||||
struct notify_context *notify_ctx = conn->sconn->notify_ctx;
|
||||
const char *path = smb_fname->base_name;
|
||||
|
||||
if (path[0] == '.' && path[1] == '/') {
|
||||
path += 2;
|
||||
|
@ -4650,14 +4650,16 @@ unlock:
|
||||
notify_fname(conn,
|
||||
NOTIFY_ACTION_ADDED,
|
||||
FILE_NOTIFY_CHANGE_FILE_NAME,
|
||||
smb_fname->base_name);
|
||||
smb_fname,
|
||||
NULL);
|
||||
}
|
||||
if (truncated) {
|
||||
notify_fname(fsp->conn,
|
||||
NOTIFY_ACTION_MODIFIED,
|
||||
FILE_NOTIFY_CHANGE_SIZE |
|
||||
FILE_NOTIFY_CHANGE_ATTRIBUTES,
|
||||
fsp->fsp_name->base_name);
|
||||
fsp->fsp_name,
|
||||
NULL);
|
||||
}
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
fd_close(fsp);
|
||||
@ -5531,7 +5533,8 @@ unlock:
|
||||
notify_fname(conn,
|
||||
NOTIFY_ACTION_ADDED,
|
||||
FILE_NOTIFY_CHANGE_DIR_NAME,
|
||||
smb_dname->base_name);
|
||||
smb_dname,
|
||||
NULL);
|
||||
}
|
||||
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
|
@ -558,8 +558,11 @@ bool remove_pending_change_notify_requests_by_mid(
|
||||
struct smbd_server_connection *sconn, uint64_t mid);
|
||||
void remove_pending_change_notify_requests_by_fid(files_struct *fsp,
|
||||
NTSTATUS status);
|
||||
void notify_fname(connection_struct *conn, uint32_t action, uint32_t filter,
|
||||
const char *path);
|
||||
void notify_fname(struct connection_struct *conn,
|
||||
uint32_t action,
|
||||
uint32_t filter,
|
||||
const struct smb_filename *smb_fname,
|
||||
const struct smb2_lease *lease);
|
||||
char *notify_filter_string(TALLOC_CTX *mem_ctx, uint32_t filter);
|
||||
struct sys_notify_context *sys_notify_context_create(TALLOC_CTX *mem_ctx,
|
||||
struct tevent_context *ev);
|
||||
|
@ -4170,8 +4170,11 @@ static NTSTATUS smb_set_file_unix_basic(connection_struct *conn,
|
||||
&ft,
|
||||
false);
|
||||
if (modify_mtime) {
|
||||
notify_fname(conn, NOTIFY_ACTION_MODIFIED,
|
||||
FILE_NOTIFY_CHANGE_LAST_WRITE, smb_fname->base_name);
|
||||
notify_fname(conn,
|
||||
NOTIFY_ACTION_MODIFIED,
|
||||
FILE_NOTIFY_CHANGE_LAST_WRITE,
|
||||
smb_fname,
|
||||
NULL);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
@ -1300,26 +1300,40 @@ static void notify_rename(struct connection_struct *conn,
|
||||
}
|
||||
|
||||
if (strcmp(parent_dir_src, parent_dir_dst) == 0) {
|
||||
notify_fname(conn, NOTIFY_ACTION_OLD_NAME, mask,
|
||||
smb_fname_src->base_name);
|
||||
notify_fname(conn, NOTIFY_ACTION_NEW_NAME, mask,
|
||||
smb_fname_dst->base_name);
|
||||
notify_fname(conn,
|
||||
NOTIFY_ACTION_OLD_NAME,
|
||||
mask,
|
||||
smb_fname_src,
|
||||
NULL);
|
||||
notify_fname(conn,
|
||||
NOTIFY_ACTION_NEW_NAME,
|
||||
mask,
|
||||
smb_fname_dst,
|
||||
NULL);
|
||||
}
|
||||
else {
|
||||
notify_fname(conn, NOTIFY_ACTION_REMOVED, mask,
|
||||
smb_fname_src->base_name);
|
||||
notify_fname(conn, NOTIFY_ACTION_ADDED, mask,
|
||||
smb_fname_dst->base_name);
|
||||
notify_fname(conn,
|
||||
NOTIFY_ACTION_REMOVED,
|
||||
mask,
|
||||
smb_fname_src,
|
||||
NULL);
|
||||
notify_fname(conn,
|
||||
NOTIFY_ACTION_ADDED,
|
||||
mask,
|
||||
smb_fname_dst,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/* this is a strange one. w2k3 gives an additional event for
|
||||
CHANGE_ATTRIBUTES and CHANGE_CREATION on the new file when renaming
|
||||
files, but not directories */
|
||||
if (!is_dir) {
|
||||
notify_fname(conn, NOTIFY_ACTION_MODIFIED,
|
||||
FILE_NOTIFY_CHANGE_ATTRIBUTES
|
||||
|FILE_NOTIFY_CHANGE_CREATION,
|
||||
smb_fname_dst->base_name);
|
||||
notify_fname(conn,
|
||||
NOTIFY_ACTION_MODIFIED,
|
||||
FILE_NOTIFY_CHANGE_ATTRIBUTES |
|
||||
FILE_NOTIFY_CHANGE_CREATION,
|
||||
smb_fname_dst,
|
||||
NULL);
|
||||
}
|
||||
out:
|
||||
TALLOC_FREE(parent_dir_src);
|
||||
|
@ -3907,8 +3907,11 @@ NTSTATUS smb_set_file_time(connection_struct *conn,
|
||||
return map_nt_error_from_unix(errno);
|
||||
}
|
||||
|
||||
notify_fname(conn, NOTIFY_ACTION_MODIFIED, action,
|
||||
smb_fname->base_name);
|
||||
notify_fname(conn,
|
||||
NOTIFY_ACTION_MODIFIED,
|
||||
action,
|
||||
smb_fname,
|
||||
NULL);
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
|
@ -649,10 +649,12 @@ int vfs_set_filelen(files_struct *fsp, off_t len)
|
||||
DEBUG(10,("vfs_set_filelen: ftruncate %s to len %.0f\n",
|
||||
fsp_str_dbg(fsp), (double)len));
|
||||
if ((ret = SMB_VFS_FTRUNCATE(fsp, len)) != -1) {
|
||||
notify_fname(fsp->conn, NOTIFY_ACTION_MODIFIED,
|
||||
FILE_NOTIFY_CHANGE_SIZE
|
||||
| FILE_NOTIFY_CHANGE_ATTRIBUTES,
|
||||
fsp->fsp_name->base_name);
|
||||
notify_fname(fsp->conn,
|
||||
NOTIFY_ACTION_MODIFIED,
|
||||
FILE_NOTIFY_CHANGE_SIZE |
|
||||
FILE_NOTIFY_CHANGE_ATTRIBUTES,
|
||||
fsp->fsp_name,
|
||||
NULL);
|
||||
}
|
||||
|
||||
contend_level2_oplocks_end(fsp, LEVEL2_CONTEND_SET_FILE_LEN);
|
||||
|
Loading…
Reference in New Issue
Block a user