From 173a647698da0e67047aa1073552cc06ed90c87d Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 2 Jan 2014 17:54:53 +0100 Subject: [PATCH] notify: Move path construction to notify_trigger notify_msg won't need to construct the path anymore, it will be able to put the parts into iovecs Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Tue Dec 16 21:22:26 CET 2014 on sn-devel-104 --- source3/smbd/notify.c | 13 ++----------- source3/smbd/notify_internal.c | 19 ++++++++++++++++--- source3/smbd/proto.h | 3 ++- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/source3/smbd/notify.c b/source3/smbd/notify.c index ac1a55ce842..5ac8c0c791d 100644 --- a/source3/smbd/notify.c +++ b/source3/smbd/notify.c @@ -442,21 +442,12 @@ void notify_fname(connection_struct *conn, uint32 action, uint32 filter, const char *path) { struct notify_context *notify_ctx = conn->sconn->notify_ctx; - char *fullpath, *to_free; - char tmpbuf[PATH_MAX]; - ssize_t len; if (path[0] == '.' && path[1] == '/') { path += 2; } - len = full_path_tos(conn->connectpath, path, tmpbuf, sizeof(tmpbuf), - &fullpath, &to_free); - if (len == -1) { - DEBUG(0, ("full_path_tos failed\n")); - return; - } - notify_trigger(notify_ctx, action, filter, fullpath); - TALLOC_FREE(to_free); + + notify_trigger(notify_ctx, action, filter, conn->connectpath, path); } static void notify_fsp(files_struct *fsp, struct timespec when, diff --git a/source3/smbd/notify_internal.c b/source3/smbd/notify_internal.c index 9c0b1901f8c..e612f163da9 100644 --- a/source3/smbd/notify_internal.c +++ b/source3/smbd/notify_internal.c @@ -616,7 +616,8 @@ static bool notify_pull_remote_blob(TALLOC_CTX *mem_ctx, } void notify_trigger(struct notify_context *notify, - uint32_t action, uint32_t filter, const char *path) + uint32_t action, uint32_t filter, + const char *dir, const char *name) { struct ctdbd_connection *ctdbd_conn; struct notify_trigger_index_state idx_state; @@ -625,22 +626,33 @@ void notify_trigger(struct notify_context *notify, uint32_t last_vnn; uint8_t *remote_blob = NULL; size_t remote_blob_len = 0; + char *path, *to_free; + char tmpbuf[PATH_MAX]; + ssize_t len; DEBUG(10, ("notify_trigger called action=0x%x, filter=0x%x, " - "path=%s\n", (unsigned)action, (unsigned)filter, path)); + "dir=%s, name=%s\n", (unsigned)action, (unsigned)filter, + dir, name)); /* see if change notify is enabled at all */ if (notify == NULL) { return; } - if (path[0] != '/') { + if (dir[0] != '/') { /* * The rest of this routine assumes an absolute path. */ return; } + len = full_path_tos(dir, name, tmpbuf, sizeof(tmpbuf), + &path, &to_free); + if (len == -1) { + DEBUG(1, ("full_path_tos failed\n")); + return; + } + idx_state.mem_ctx = talloc_tos(); idx_state.vnns = NULL; idx_state.found_my_vnn = false; @@ -708,6 +720,7 @@ void notify_trigger(struct notify_context *notify, done: TALLOC_FREE(remote_blob); TALLOC_FREE(idx_state.vnns); + TALLOC_FREE(to_free); } static void notify_trigger_local(struct notify_context *notify, diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 44ea6f0c754..121682c9659 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -554,7 +554,8 @@ NTSTATUS notify_add(struct notify_context *notify, void *private_data); NTSTATUS notify_remove(struct notify_context *notify, void *private_data); void notify_trigger(struct notify_context *notify, - uint32_t action, uint32_t filter, const char *path); + uint32_t action, uint32_t filter, + const char *dir, const char *path); void notify_walk_idx(struct notify_context *notify, void (*fn)(const char *path, uint32_t *vnns, size_t num_vnns, -- 2.34.1