FreeBSD/lib/libstand/dosfs.c
/*
 * Offset-based I/O primitive
 */
Offset-based I/O primitive
Offset - based I / O primitive
static int
ioread(DOS_FS *fs, u_int offset, void *buf, u_int nbyte)
{
    char *s;
    u_int off, n;
    int err;
    s = buf;
    if ((off = offset & (SECSIZ - 1))) {
        offset -= off;
        if ((n = SECSIZ - off) > nbyte)
            n = nbyte;
        if ((err = ioget(fs->fd, bytsec(offset), off, s, n)))
            return err;
        offset += SECSIZ;
        s += n;
        nbyte -= n;
    }
    n = nbyte & (SECSIZ - 1);
    if (nbyte -= n) {
        if ((err = ioget(fs->fd, bytsec(offset), 0, s, nbyte)))
            return err;
        offset += nbyte;
        s += nbyte;
    }
    if (n) {
        if ((err = ioget(fs->fd, bytsec(offset), 0, s, n)))
            return err;
    }
    return 0;
}
static int ioread ( DOS_FS * fs , u_int offset , void * buf , u_int nbyte ) { char * s ; u_int off , n ; int err ; s = buf ; if ( ( off = offset & ( SECSIZ - 1 ) ) ) { offset -= off ; if ( ( n = SECSIZ - off ) > nbyte ) n = nbyte ; if ( ( err = ioget ( fs -> fd , bytsec ( offset ) , off , s , n ) ) ) return err ; offset += SECSIZ ; s += n ; nbyte -= n ; } n = nbyte & ( SECSIZ - 1 ) ; if ( nbyte -= n ) { if ( ( err = ioget ( fs -> fd , bytsec ( offset ) , 0 , s , nbyte ) ) ) return err ; offset += nbyte ; s += nbyte ; } if ( n ) { if ( ( err = ioget ( fs -> fd , bytsec ( offset ) , 0 , s , n ) ) ) return err ; } return 0 ; }
Offset-based I/O primitive
Offset - based I / O primitive