From: short <> Date: Sat, 6 Dec 2003 18:50:37 +0000 (+0000) Subject: Prevent "mv dir dir/subdir" as it is not catched by ntfs.sys of NT-5.1sp1. X-Git-Tag: captive-1_1_3~10 X-Git-Url: http://git.jankratochvil.net/?p=captive.git;a=commitdiff_plain;h=d4afbf8737ffb06a4a8a1db2a85f65204688a893 Prevent "mv dir dir/subdir" as it is not catched by ntfs.sys of NT-5.1sp1. - Bugreport by Ulrich Mueller. --- diff --git a/src/libcaptive/client/file-parent.c b/src/libcaptive/client/file-parent.c index 1d0da83..c7d999f 100644 --- a/src/libcaptive/client/file-parent.c +++ b/src/libcaptive/client/file-parent.c @@ -25,6 +25,8 @@ #include "vfs-parent.h" #include "reactos/ntos/types.h" /* for ULONG */ #include "parent-connector.h" +#include "captive/client.h" /* for captive_path_normalize() */ +#include static gpointer captive_file_parent_object_parent_class=NULL; @@ -520,12 +522,31 @@ static GnomeVFSResult captive_file_parent_move CaptiveFileParentObject *captive_file_parent_object_old; GnomeVFSResult r; gint retried=0; +gchar *chksub_pathname_old,*chksub_pathname_new,*chksub_s_old,*chksub_s_new; g_return_val_if_fail(CAPTIVE_FILE_PARENT_IS_OBJECT(captive_file_object_old),GNOME_VFS_ERROR_BAD_PARAMETERS); g_return_val_if_fail(pathname_new!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS); captive_file_parent_object_old=CAPTIVE_FILE_PARENT_OBJECT(captive_file_object_old); + /* Prevent "mv dir dir/subdir" as it is not catched by ntfs.sys of NT-5.1sp1. */ + /* FIXME: UTF8/Unicode */ + /* FIXME: Move to 'CaptiveFileSlaveObject' but it has no '->pathname' stored now! */ + chksub_pathname_old=captive_path_normalize(captive_file_parent_object_old->pathname); + chksub_pathname_new=captive_path_normalize(pathname_new); + for ( + chksub_s_old=chksub_pathname_old,chksub_s_new=chksub_pathname_new; + *chksub_s_old && *chksub_s_new && tolower(*chksub_s_old)==tolower(*chksub_s_new); + chksub_s_old++,chksub_s_new++); + g_assert(chksub_s_old>chksub_pathname_old); + g_assert(chksub_s_new>chksub_pathname_new); + if (!*chksub_s_old && (!*chksub_s_new || *chksub_s_new=='/')) + return GNOME_VFS_ERROR_DIRECTORY_BUSY; + if (!*chksub_s_new && (!*chksub_s_old || *chksub_s_old=='/')) + return GNOME_VFS_ERROR_DIRECTORY_BUSY; + g_free(chksub_pathname_old); + g_free(chksub_pathname_new); + do { if (GNOME_VFS_OK!=(r=captive_parent_connector_open(CAPTIVE_PARENT_CONNECTOR(captive_file_parent_object_old)))) return r;