FDOS/kernel

Dosemu2 test suite test `test_fat_fcb_find_wild_1` failing on current git master

andrewbird opened this issue · 3 comments

The Dosemu2 test suite is showing a problem regarding wildcards and FCB based file functions. The following code is used to print out the files found, but only returns one result when it should return multiple items.

        self.mkcom_with_gas(ename, r"""                                         
.text                                                                           
.code16                                                                         
                                                                                
    .globl  _start16                                                            
_start16:                                                                       
                                                                                
    push    %%cs                                                                
    pop     %%ds                                                                
                                                                                
    # Get DTA -> ES:BX                                                          
    movw    $0x2f00, %%ax                                                       
    int     $0x21                                                               
    pushw   %%es                                                                
    pushw   %%bx                                                                
    popl    pdta                                                                
                                                                                
    # FindFirst                                                                 
findfirst:                                                                      
    movw    $0x1100, %%ax                                                       
    movw    $fcb, %%dx                                                          
    int     $0x21                                                               
                                                                                
    cmpb    $0, %%al                                                            
    je      prsucc                                                              
                                                                                
prfail:                                                                         
    movw    $failmsg, %%dx                                                      
    movb    $0x9, %%ah                                                          
    int     $0x21                                                               
    jmp     exit                                                                
                                                                                
prsucc:                                                                         
    movw    $succmsg, %%dx                                                      
    movb    $0x9, %%ah                                                          
    int     $0x21                                                               
                                                                                
prfilename:                                                                     
    push    %%ds                                                                
    lds     pdta, %%si                                                          
    inc     %%si                                                                
                                                                                
    push    %%cs                                                                
    pop     %%es                                                                
    movw    $prires, %%di                                                       
    inc     %%di                                                                
                                                                                
    movw    $11, %%cx                                                           
    cld                                                                         
    repne   movsb                                                               
                                                                                
    pop     %%ds                                                                
    movw    $prires, %%dx                                                       
    movb    $0x9, %%ah                                                          
    int     $0x21                                                               
                                                                                
    # FindNext                                                                  
findnext:                                                                       
    movw    $0x1200, %%ax                                                       
    movw    $fcb, %%dx                                                          
    int     $0x21                                                               
                                                                                
    cmpb    $0, %%al                                                            
    je      prfilename                                                          
                                                                                
exit:                                                                           
    movb    $0x4c, %%ah                                                         
    int     $0x21                                                               
                                                                                
fcb:                                                                            
    .byte   0       # 0 default drive                                           
fn1:                                                                            
    .ascii  "% -8s"    # 8 bytes                                                
fe1:                                                                            
    .ascii  "% -3s"    # 3 bytes                                                
wk1:                                                                            
    .space  25                                                                  
                                                                                
pdta:                                                                           
    .long   0                                                                   
                                                                                
prires:                                                                         
    .ascii  "("                                                                 
fname:                                                                          
    .space  8, 20                                                               
fext:                                                                           
    .space  3, 20                                                               
    .ascii  ")\r\n$"                                                            
                                                                                
succmsg:                                                                        
    .ascii  "Find Operation Success\r\n$"                                       
failmsg:                                                                        
    .ascii  "Find Operation Failed\r\n$"                                        
                                                                                
""" % (fn1, fe1))                                                               
FreeDOS git master
C:\>testit.bat^M                                                                
testit.bat^M                                                                    
C:\>d:^M                                                                        
D:\>c:\fcbfind3^M                                                               
Find Operation Success^M                                                        
(THREE   IN )^M                                                                 
D:\>DIR^M                                                                       
 Volume in drive D has no label^M                                               
 Volume Serial Number is 1234-5678^M                                            
 Directory of D:\^M                                                             
^M                                                                              
THREE    IN              7  07-28-21  6:56p^M                                   
TWO      IN              7  07-28-21  6:56p^M                                   
FIVE     IN              7  07-28-21  6:56p^M                                   
NONE     CTL             7  07-28-21  6:56p^M                                   
ONE      IN              7  07-28-21  6:56p^M                                   
FOUR     IN              7  07-28-21  6:56p^M                                   
         6 file(s)             42 bytes^M                                       
         0 dir(s)      10,592,256 bytes free^M                                  
D:\>rem end^M                                                                   
MS-DOS 6.22
C:\>testit.bat^M                                                                
testit.bat^M^M                                                                  
^M                                                                              
C:\>d:^M                                                                        
^M                                                                              
D:\>c:\fcbfind3^M                                                               
Find Operation Success^M                                                        
(THREE   IN )^M                                                                 
(TWO     IN )^M                                                                 
(FIVE    IN )^M                                                                 
(ONE     IN )^M                                                                 
(FOUR    IN )^M                                                                 
^M                                                                              
D:\>DIR^M                                                                       
^M                                                                              
 Volume in drive D has no label^M                                               
 Volume Serial Number is 1234-5678^M                                            
 Directory of D:\^M                                                             
^M                                                                              
THREE    IN              7 07-28-21   7:09p^M                                   
TWO      IN              7 07-28-21   7:09p^M                                   
FIVE     IN              7 07-28-21   7:09p^M                                   
NONE     CTL             7 07-28-21   7:09p^M                                   
ONE      IN              7 07-28-21   7:09p^M                                   
FOUR     IN              7 07-28-21   7:09p^M                                   
        6 file(s)             42 bytes^M                                        
                      10,592,256 bytes free^M                                   
^M                                                                              

I've attached a minimal test case here fat_fcb_find_wild_1.zip

I seem to remember a similar bug being fixed on FDPP, but I can't find the issue in the tracker, although I think the code has diverged in that area quite a lot so I doubt there's any commit that can directly apply.

It might be this commit dosemu2/fdpp@a6c4107, but it was over 18 months ago, so I can't be sure.

Actually I just tried this recreating this patch in the current FreeDOS and it fixes the problem, since it was yours @stsp, perhaps you'd like to submit as PR?

stsp commented

Please do whatever you like.