summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2007-01-31 14:24:29 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:17:35 -0500
commit697ccab3f0c8d9cae7ce982009957a79254e4665 (patch)
tree6f4a4c65d9190c7af3602675b49fd7a2a79ec4a1 /source3/smbd
parent18c2c8cece94c28c9986a7d71ed092959f50385a (diff)
downloadsamba-697ccab3f0c8d9cae7ce982009957a79254e4665.tar.gz
samba-697ccab3f0c8d9cae7ce982009957a79254e4665.tar.bz2
samba-697ccab3f0c8d9cae7ce982009957a79254e4665.zip
r21089: Do notifies on rename
(This used to be commit 2aadb95a7e58777ee7ff024cc9e14f4334970d50)
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/reply.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 7ffebd9118..3c7b3c4e18 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -4113,6 +4113,48 @@ NTSTATUS rename_internals_fsp(connection_struct *conn, files_struct *fsp, pstrin
return status;
}
+/*
+ * Do the notify calls from a rename
+ */
+
+static void notify_rename(connection_struct *conn, BOOL is_dir,
+ const char *oldpath, const char *newpath)
+{
+ char *olddir, *newdir;
+ const char *oldname, *newname;
+ uint32 mask;
+
+ mask = is_dir ? FILE_NOTIFY_CHANGE_DIR_NAME
+ : FILE_NOTIFY_CHANGE_FILE_NAME;
+
+ if (!parent_dirname_talloc(NULL, oldpath, &olddir, &oldname)
+ || !parent_dirname_talloc(NULL, newpath, &newdir, &newname)) {
+ TALLOC_FREE(olddir);
+ return;
+ }
+
+ if (strcmp(olddir, newdir) == 0) {
+ notify_fname(conn, NOTIFY_ACTION_OLD_NAME, mask, oldpath);
+ notify_fname(conn, NOTIFY_ACTION_NEW_NAME, mask, newpath);
+ }
+ else {
+ notify_fname(conn, NOTIFY_ACTION_REMOVED, mask, oldpath);
+ notify_fname(conn, NOTIFY_ACTION_ADDED, mask, newpath);
+ }
+ TALLOC_FREE(olddir);
+ TALLOC_FREE(newdir);
+
+ /* 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,
+ newpath);
+ }
+}
+
/****************************************************************************
The guts of the rename command, split out so it may be called by the NT SMB
code.
@@ -4319,6 +4361,8 @@ NTSTATUS rename_internals(connection_struct *conn, pstring name,
rename_open_files(conn, lck, sbuf1.st_dev,
sbuf1.st_ino, newname);
TALLOC_FREE(lck);
+ notify_rename(conn, S_ISDIR(sbuf1.st_mode),
+ directory, newname);
return NT_STATUS_OK;
}