aboutsummaryrefslogtreecommitdiff
path: root/src/base/fs/read.c
blob: 7e60823a5557889cfc581330db322df1010216b1 (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
#include <u.h>
#include <base.h>
#include <sys.h>

int
fs·read(fs·Directory *dir, fs·DirEntry **ent)
{
    int err;
    uintptr n;

    fs·DirEntry *de;
    if(dir->pos >= dir->end){
        if((err=sys·direntry(dir->fd, arrlen(dir->buf), dir->buf, &n)))
            return err;
        dir->pos = 0;
        dir->end = n;
    }

    de = (fs·DirEntry *)(dir->buf + dir->pos);
    dir->pos += de->len;
    dir->off  = de->off;

    *ent = de;
    return 0;
}