[Patch] Adding ".." may not work in readdir()

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Patch] Adding ".." may not work in readdir()

Christian Franke
Both else-if conditions at the end of readdir() are identical, so ".."
case will never be executed.

The attached patch for fhandler_disk_file.cc 1.183 may fix this
(untested blind patch, sorry ;-)

Christian


--- fhandler_disk_file.cc.orig 2006-05-08 16:21:46.984375000 +0200
+++ fhandler_disk_file.cc 2006-05-08 16:25:08.609375000 +0200
@@ -1778,25 +1778,25 @@ fhandler_disk_file::readdir (DIR *dir, d
 
   if (!(res = readdir_helper (dir, de, RtlNtStatusToDosError (status),
       buf ? buf->FileAttributes : 0, fname)))
     dir->__d_position++;
   else if (!(dir->__flags & dirent_saw_dot))
     {
       strcpy (de->d_name , ".");
       de->d_ino = readdir_get_ino_by_handle (dir->__handle);
       dir->__d_position++;
       dir->__flags |= dirent_saw_dot;
       res = 0;
     }
-  else if (!(dir->__flags & dirent_saw_dot))
+  else if (!(dir->__flags & dirent_saw_dot_dot))
     {
       strcpy (de->d_name , "..");
       de->d_ino = readdir_get_ino (dir, pc.normalized_path, true);
       dir->__d_position++;
       dir->__flags |= dirent_saw_dot_dot;
       res = 0;
     }
 
   syscall_printf ("%d = readdir (%p, %p) (%s)", res, dir, &de, res ? "***" : de->d_name);
   return res;
 }
 
Reply | Threaded
Open this post in threaded view
|

Re: [Patch] Adding ".." may not work in readdir()

Christopher Faylor-2
On Mon, May 08, 2006 at 04:42:27PM +0200, Christian Franke wrote:
>Both else-if conditions at the end of readdir() are identical, so ".."
>case will never be executed.
>
>The attached patch for fhandler_disk_file.cc 1.183 may fix this
>(untested blind patch, sorry ;-)

Thanks for the patch.  I've checked it in along with a changelog.

cgf