summaryrefslogtreecommitdiff
path: root/core/dir.c
blob: d745a32fa7a69238709f7a443e4a18c1be6b086e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <stdio.h>
#include <string.h>
#include <sys/dirent.h>
#include <fs.h>
#include <core.h>

extern struct fs_info *this_fs;

/* 
 * open dir, return the file structure pointer in _eax_, or NULL if failed 
 */
void vfs_opendir(com32sys_t *regs)
{	
    this_fs->fs_ops->opendir(regs);
    regs->eax.l = (uint32_t)handle_to_file(regs->esi.w[0]);	
}

/*
 * Read one dirent at one time. 
 *
 * @input: _esi_ register stores the address of DIR structure
 * @output: _eax_ register stores the address of newly read dirent structure
 */
void vfs_readdir(com32sys_t *regs)
{
    DIR *dir = (DIR *)regs->esi.l;	
    struct dirent *de = NULL;
    
    if (dir->dd_dir)
	de = this_fs->fs_ops->readdir(dir->dd_dir);
    else
	de = NULL;
    
    /* Return the newly read de in _eax_ register */
    regs->eax.l = (uint32_t)de;
}

void vfs_closedir(com32sys_t *regs)
{
    DIR *dir = (DIR *)regs->esi.l;
    _close_file(dir->dd_dir);
}