Fixed LUFS 'Stale NFS filehandle' by list rootdir ("\\device\\." is forbidden).
[captive.git] / src / libcaptive / client / lib.c
index da2d5d7..83aab0b 100644 (file)
@@ -87,6 +87,7 @@ GnomeVFSResult captive_ObjectAttributes_init(const gchar *pathname,OBJECT_ATTRIB
 {
 gchar *w32_path,*s,*d;
 const gchar *media_root;
+gchar *pathname_normalized;
 
        g_return_val_if_fail(pathname!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
        g_return_val_if_fail(ObjectAttributes!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
@@ -101,6 +102,8 @@ const gchar *media_root;
         * and later IopCreateFile() would not consider it FO_DIRECT_DEVICE_OPEN (e.g. w/o any direct mount!).
         * On the other side it will somehow get managed automatically and it works even
         * without the trailing "\\." for root directory open - don't ask me why. :-)
+        * Tested: \\Device\\CaptiveHarddisk0\\. FAIL
+        *         \\Device\\CaptiveHarddisk0\\  OK
         */
        switch (captive_options->media) {
                case CAPTIVE_OPTION_MEDIA_CDROM: media_root="\\Device\\CdRom0";           break;        /* libcaptive/storage/cdrom.c */
@@ -110,8 +113,10 @@ const gchar *media_root;
                        media_root="";
                }
 
+       pathname_normalized=captive_path_normalize(pathname);
        w32_path=(gchar *)/* de-const it as we can modify it but we must not free() it */
-                       captive_printf_alloca("%s\\%s",media_root,pathname);
+                       captive_printf_alloca("%s\\%s",media_root,pathname_normalized);
+       g_free(pathname_normalized);
        /* translate '/' -> '\' */
        for (s=w32_path;(s=strchr(s,'/'));s++)
                *s='\\';