예제 #1
0
파일: ops.c 프로젝트: alepharchives/diod
static u32
_read_dir_linux (Fid *f, u8* buf, u64 offset, u32 count)
{
    struct dirent dbuf, *dp;
    int i, n = 0, err;

    if (offset == 0)
        ioctx_rewinddir (f->ioctx);
    else
        ioctx_seekdir (f->ioctx, offset);
    do {
        err = ioctx_readdir_r (f->ioctx, &dbuf, &dp);
        if (err > 0) {
            np_uerror (err);
            break;
        }
        if (err == 0 && dp == NULL)
            break;
        if ((f->flags & DIOD_FID_FLAGS_MOUNTPT) && strcmp (dp->d_name, ".")
                                                && strcmp (dp->d_name, ".."))
                continue;
        i = _copy_dirent_linux (f, dp, buf + n, count - n);
        if (i == 0)
            break;
        n += i;
    } while (n < count);
    return n;
}
예제 #2
0
파일: ops.c 프로젝트: eugmes/diod
static u32
_read_dir_linux (Fid *f, u8* buf, u64 offset, u32 count)
{
    int i, n = 0;

    if (offset == 0)
        rewinddir (f->dir);
    else
        seekdir (f->dir, offset);
    do {
        if (!(f->dirent = readdir (f->dir)))
            break;
        if (f->mountpt && strcmp (f->dirent->d_name, ".") 
                       && strcmp (f->dirent->d_name, ".."))
                continue;
        i = _copy_dirent_linux (f, buf + n, count - n);
        if (i == 0)
            break;
        n += i;
    } while (n < count);
    return n;
}
예제 #3
0
파일: ops.c 프로젝트: lowfatcomputing/diod
/* FIXME: seekdir(previous d_off) OK?
 * If not, substitute saved_dir_position for d_off in last returned.
 * If so, get rid of saved_dir_position and 2nd seekdir.
 */
static u32
_read_dir_linux (Fid *f, u8* buf, u64 offset, u32 count)
{
    int i, n = 0;
    off_t saved_dir_pos;

    if (offset == 0)
        rewinddir (f->dir);
    else
        seekdir (f->dir, offset);
    do {
        saved_dir_pos = telldir (f->dir);
        if (!(f->dirent = readdir (f->dir))) /* FIXME: use readdir_r */
            break;
        i = _copy_dirent_linux (f, buf + n, count - n);
        if (i == 0) {
            seekdir (f->dir, saved_dir_pos);
            break;
        }
        n += i;
    } while (n < count);
    return n;
}