fibdrv.c
/* calculate the fibonacci number at given offset */
calculate the fibonacci number at given offset
calculate the fibonacci number at given offset
static ssize_t fib_read(struct file *file,
                        char *buf,
                        size_t size,
                        loff_t *offset)
{
    Big_number result;
    result = fib_sequence(*offset);
    int ret = 0;
    char result_buf[40];
    if (result.upper > 0) {
        snprintf(result_buf, 40, "%llu%019llu", result.upper, result.lower);
    } else {
        snprintf(result_buf, 40, "%llu", result.lower);
    }
    ret = copy_to_user(buf, result_buf, 40);
    return ret;
}
static ssize_t fib_read ( struct file * file , char * buf , size_t size , loff_t * offset ) { Big_number result ; result = fib_sequence ( * offset ) ; int ret = 0 ; char result_buf [ 40 ] ; if ( result . upper > 0 ) { snprintf ( result_buf , 40 , " " , result . upper , result . lower ) ; } else { snprintf ( result_buf , 40 , " " , result . lower ) ; } ret = copy_to_user ( buf , result_buf , 40 ) ; return ret ; }
calculate the fibonacci number at given offset
calculate the fibonacci number at given offset