[RTEMS Project] #4674: readdir skips entries after unlink

RTEMS trac trac at rtems.org
Fri Apr 21 01:35:20 UTC 2023


#4674: readdir skips entries after unlink
-----------------------------+----------------------------
 Reporter:  Alexandre Oliva  |       Owner:  Needs Funding
     Type:  defect           |      Status:  assigned
 Priority:  normal           |   Milestone:  6.1
Component:  fs               |     Version:  6
 Severity:  normal           |  Resolution:
 Keywords:                   |  Blocked By:
 Blocking:                   |
-----------------------------+----------------------------

Comment (by z.ling111):

 Currently this is my test case.I'm not sure that I'm getting the right
 results? Is this what you mean by adding the unlink within the loop? I
 think there is an error because for every file i unlink it still shows b


 {{{

 printf( "chdir() status : %d\n\n", status );
 for (int i = 0; i<3; i++) {
     printf("Create %s\n", many_files[i]);
     int fd = open (many_files[i], O_CREAT, S_IRWXU);
     close (fd);
   }
     struct dirent* direntp;
      DIR* dirp;




     printf( "Unlinking dirs and printing" );


    dirp = opendir( "/" );
     if( dirp != NULL ) {
         for(;;) {
             direntp = readdir( dirp );
             if( direntp == NULL ) break;


             printf( "%s\n", direntp->d_name );
              status =  unlink(direntp->d_name );
         }

         closedir( dirp );

     }
      printf( "after unlinking " );

       dirp = opendir( "/" );
       char chars [3];
       int i =0;
     if( dirp != NULL ) {
         for(;;) {
             direntp = readdir( dirp );
             if( direntp == NULL ) break;

              chars[i] = *direntp->d_name;
              i++;

             printf( "%s\n", direntp->d_name );
         }
     closedir( dirp );

     }

 }}}





 {{{
 Create a
 Create b
 Create c
 Unlinking dirs and printing.
 a
 c
 after unlinking .
 b
 }}}

--
Ticket URL: <http://devel.rtems.org/ticket/4674#comment:9>
RTEMS Project <http://www.rtems.org/>
RTEMS Project


More information about the bugs mailing list