opendir: use internal protected-mode interfaces
authorH. Peter Anvin <hpa@zytor.com>
Thu, 25 Feb 2010 05:31:02 +0000 (21:31 -0800)
committerH. Peter Anvin <hpa@zytor.com>
Thu, 25 Feb 2010 05:31:02 +0000 (21:31 -0800)
No need to do yet another bounce through lowmem for no good reason.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
core/fs/readdir.c

index 7a58eda..33a67c8 100644 (file)
@@ -9,11 +9,18 @@
  */
 void opendir(com32sys_t *regs)
 {
-    char *src = MK_PTR(regs->es, regs->esi.w[0]);
-    char *dst = MK_PTR(regs->ds, regs->edi.w[0]);
-    strcpy(dst, src);
-    pm_searchdir(regs);
-    regs->eax.l = (uint32_t)handle_to_file(regs->esi.w[0]);    
+    const char *src = MK_PTR(regs->es, regs->esi.w[0]);
+    struct file *file;
+    int rv;
+
+    rv = searchdir(src);
+    if (rv < 0) {
+       regs->eax.l = 0;
+       regs->eflags.l |= EFLAGS_ZF;
+    } else {
+       regs->eax.l = (uint32_t)handle_to_file(rv);
+       regs->eflags.l &= ~EFLAGS_ZF;
+    }
 }
 
 /*