svn commit: samba r14925 - in branches/SAMBA_4_0/source/ntvfs:
posix sysdep
tridge at samba.org
tridge at samba.org
Wed Apr 5 08:52:04 GMT 2006
Author: tridge
Date: 2006-04-05 08:52:03 +0000 (Wed, 05 Apr 2006)
New Revision: 14925
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=14925
Log:
trigger NOTIFY_ACTION_OLD_NAME and NOTIFY_ACTION_NEW_NAME events for
renames, if in the same directory. For renames between directories
generate NOTIFY_ACTION_REMOVED and NOTIFY_ACTION_ADDED
Modified:
branches/SAMBA_4_0/source/ntvfs/posix/pvfs_rename.c
branches/SAMBA_4_0/source/ntvfs/posix/pvfs_setfileinfo.c
branches/SAMBA_4_0/source/ntvfs/sysdep/sys_notify.c
Changeset:
Modified: branches/SAMBA_4_0/source/ntvfs/posix/pvfs_rename.c
===================================================================
--- branches/SAMBA_4_0/source/ntvfs/posix/pvfs_rename.c 2006-04-05 08:50:33 UTC (rev 14924)
+++ branches/SAMBA_4_0/source/ntvfs/posix/pvfs_rename.c 2006-04-05 08:52:03 UTC (rev 14925)
@@ -24,7 +24,51 @@
#include "vfs_posix.h"
#include "librpc/gen_ndr/security.h"
+
/*
+ do a file rename, and send any notify triggers
+*/
+NTSTATUS pvfs_do_rename(struct pvfs_state *pvfs, const char *name1, const char *name2)
+{
+ const char *r1, *r2;
+
+ if (rename(name1, name2) == -1) {
+ return pvfs_map_errno(pvfs, errno);
+ }
+
+ /*
+ renames to the same directory cause a OLD_NAME->NEW_NAME notify.
+ renames to a different directory are considered a remove/add
+ */
+ r1 = strrchr_m(name1, '/');
+ r2 = strrchr_m(name2, '/');
+
+ if ((r1-name1) != (r2-name2) ||
+ strncmp(name1, name2, r1-name1) != 0) {
+ notify_trigger(pvfs->notify_context,
+ NOTIFY_ACTION_REMOVED,
+ FILE_NOTIFY_CHANGE_FILE_NAME,
+ name1);
+ notify_trigger(pvfs->notify_context,
+ NOTIFY_ACTION_ADDED,
+ FILE_NOTIFY_CHANGE_FILE_NAME,
+ name2);
+ } else {
+ notify_trigger(pvfs->notify_context,
+ NOTIFY_ACTION_OLD_NAME,
+ FILE_NOTIFY_CHANGE_FILE_NAME,
+ name1);
+ notify_trigger(pvfs->notify_context,
+ NOTIFY_ACTION_NEW_NAME,
+ FILE_NOTIFY_CHANGE_FILE_NAME,
+ name2);
+ }
+
+ return NT_STATUS_OK;
+}
+
+
+/*
resolve a wildcard rename pattern. This works on one component of the name
*/
static const char *pvfs_resolve_wildcard_component(TALLOC_CTX *mem_ctx,
@@ -173,18 +217,10 @@
return NT_STATUS_NO_MEMORY;
}
- if (rename(name1->full_name, fname2) == -1) {
- talloc_free(mem_ctx);
- return pvfs_map_errno(pvfs, errno);
- }
+ status = pvfs_do_rename(pvfs, name1->full_name, fname2);
- status = odb_rename(lck, fname2);
-
if (NT_STATUS_IS_OK(status)) {
- notify_trigger(pvfs->notify_context,
- NOTIFY_ACTION_MODIFIED,
- FILE_NOTIFY_CHANGE_FILE_NAME,
- name1->full_name);
+ status = odb_rename(lck, fname2);
}
failed:
@@ -302,11 +338,10 @@
return status;
}
- if (rename(name1->full_name, name2->full_name) == -1) {
- return pvfs_map_errno(pvfs, errno);
+ status = pvfs_do_rename(pvfs, name1->full_name, name2->full_name);
+ if (NT_STATUS_IS_OK(status)) {
+ status = odb_rename(lck, name2->full_name);
}
-
- status = odb_rename(lck, name2->full_name);
return NT_STATUS_OK;
}
@@ -375,19 +410,14 @@
switch (ren->ntrename.in.flags) {
case RENAME_FLAG_RENAME:
status = pvfs_access_check_parent(pvfs, req, name2, SEC_DIR_ADD_FILE);
- if (!NT_STATUS_IS_OK(status)) {
- return status;
- }
- if (rename(name1->full_name, name2->full_name) == -1) {
- return pvfs_map_errno(pvfs, errno);
- }
+ NT_STATUS_NOT_OK_RETURN(status);
+ status = pvfs_do_rename(pvfs, name1->full_name, name2->full_name);
+ NT_STATUS_NOT_OK_RETURN(status);
break;
case RENAME_FLAG_HARD_LINK:
status = pvfs_access_check_parent(pvfs, req, name2, SEC_DIR_ADD_FILE);
- if (!NT_STATUS_IS_OK(status)) {
- return status;
- }
+ NT_STATUS_NOT_OK_RETURN(status);
if (link(name1->full_name, name2->full_name) == -1) {
return pvfs_map_errno(pvfs, errno);
}
@@ -395,9 +425,7 @@
case RENAME_FLAG_COPY:
status = pvfs_access_check_parent(pvfs, req, name2, SEC_DIR_ADD_FILE);
- if (!NT_STATUS_IS_OK(status)) {
- return status;
- }
+ NT_STATUS_NOT_OK_RETURN(status);
return pvfs_copy_file(pvfs, name1, name2);
case RENAME_FLAG_MOVE_CLUSTER_INFORMATION:
Modified: branches/SAMBA_4_0/source/ntvfs/posix/pvfs_setfileinfo.c
===================================================================
--- branches/SAMBA_4_0/source/ntvfs/posix/pvfs_setfileinfo.c 2006-04-05 08:50:33 UTC (rev 14924)
+++ branches/SAMBA_4_0/source/ntvfs/posix/pvfs_setfileinfo.c 2006-04-05 08:52:03 UTC (rev 14925)
@@ -147,18 +147,12 @@
return status;
}
- if (rename(name->full_name, name2->full_name) == -1) {
- return pvfs_map_errno(pvfs, errno);
+ status = pvfs_do_rename(pvfs, name->full_name, name2->full_name);
+ if (NT_STATUS_IS_OK(status)) {
+ name->full_name = talloc_steal(name, name2->full_name);
+ name->original_name = talloc_steal(name, name2->original_name);
}
- notify_trigger(pvfs->notify_context,
- NOTIFY_ACTION_MODIFIED,
- FILE_NOTIFY_CHANGE_FILE_NAME,
- name->full_name);
-
- name->full_name = talloc_steal(name, name2->full_name);
- name->original_name = talloc_steal(name, name2->original_name);
-
return NT_STATUS_OK;
}
Modified: branches/SAMBA_4_0/source/ntvfs/sysdep/sys_notify.c
===================================================================
--- branches/SAMBA_4_0/source/ntvfs/sysdep/sys_notify.c 2006-04-05 08:50:33 UTC (rev 14924)
+++ branches/SAMBA_4_0/source/ntvfs/sysdep/sys_notify.c 2006-04-05 08:52:03 UTC (rev 14925)
@@ -97,7 +97,7 @@
sys_notify_callback_t callback, void *private, void **handle)
{
if (!ctx->notify_watch) {
- return NT_STATUS_NOT_IMPLEMENTED;
+ return NT_STATUS_INVALID_SYSTEM_SERVICE;
}
return ctx->notify_watch(ctx, e, callback, private, handle);
}
More information about the samba-cvs
mailing list