next up previous contents
Next: Dodatek B Up: Pobieranie arg Previous: Pobieranie arg   Spis rzeczy

Dodatek A

Funkcja piszaca do generatora liczb losowych


 ssize_t read_mem(struct file * file, char * buf, 

size_t count, loff_t *ppos)
{
  unsigned long 	p = *ppos;
  unsigned long 	end_mem;
  ssize_t 	read;

 		  end_mem =__pa(high_memory); 

if (p >= end_mem)
return 0;
if (count > end_mem - p)
count = end_mem - p;
read = 0;
#if defined(__sparc__) || defined(__mc68000__)
/* we don't have page 0 mapped on sparc and m68k.. */
if (p < PAGE_SIZE) {
unsigned long sz = PAGE_SIZE-p;
if (sz > count)
sz = count;
if (sz > 0) {
if(clear_user(buf, sz))
return -EFAULT;
buf += sz;
p += sz;
count -= sz;
read += sz;
}
}
#endif
if (copy_to_user(buf, __va(p), count))
return -EFAULT;
read += count;
*ppos += read;
return read;
}



jasiek 2002-01-25