Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2014
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.46 KB | None | 0 0
  1. static ssize_t dice_read(struct file * file, char * buf,
  2.               size_t count, loff_t *ppos)
  3. {
  4.     char roll;
  5.     int i;
  6.     char newBuffer[count];
  7.     /*
  8.      * We only support reading the whole string at once.
  9.      */
  10.    
  11.     for (int i=0; i<count; i++)
  12.     {
  13.         roll = get_random_byte(6) +1;
  14.         newBuffer[i] = roll;
  15.     }
  16.    
  17.        
  18.      
  19.     if (copy_to_user(buf, newBuffer, count))
  20.         return -EINVAL;
  21.     /*
  22.      * Tell the user how much data we wrote.
  23.      */
  24.     *ppos = count;
  25.  
  26.     return count;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement