This is the mail archive of the cygwin-patches mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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;
 }
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]