user/lib/libc/src/file/fd/read.c
/**
 * Reads from the file descriptor given by `filedes`
 */
Reads from the file descriptor given by `filedes`
Reads from the file descriptor given by ` filedes `
ssize_t read(int filedes, void *buf, size_t nbyte) {
    stream_t *fp = ConvertFdToStream(filedes);
    if(!fp) {
        errno = EBADF;
        return -1 ;
    }
    if(fp->read) {
        return fp->read(fp, buf, nbyte);
    } else {
        errno = ENODEV;
        return -1;
    }
}
ssize_t read ( int filedes , void * buf , size_t nbyte ) { stream_t * fp = ConvertFdToStream ( filedes ) ; if ( ! fp ) { errno = EBADF ; return -1 ; } if ( fp -> read ) { return fp -> read ( fp , buf , nbyte ) ; } else { errno = ENODEV ; return -1 ; } }
Reads from the file descriptor given by `filedes`
Reads from the file descriptor given by ` filedes `
// get the file descriptor // perform read