Driver/tiny_tty/tiny_read_proc()

Last-modified: 2007-09-26 (水) 14:13:33

tiny_tty_driver->read_proc = tiny_read_proc;

tiny_init()の中でread_procを指定

357 :static int tiny_read_proc(char *page, char **start, off_t off, int count,
358 : int *eof, void *data)
359 :{
360 : struct tiny_serial *tiny;
361 : off_t begin = 0;
362 : int length = 0;
363 : int i;
364 :
365 : length += sprintf(page, "tinyserinfo:1.0 driver:%s\n", DRIVER_VERSION);
366 : for (i = 0; i < TINY_TTY_MINORS && length < PAGE_SIZE; ++i) {
367 : tiny = tiny_table[i];
368 : if (tiny == NULL)
369 : continue;
370 :
371 : length += sprintf(page+length, "%d\n", i);
372 : if *1
373 : goto done;
374 : if ((length + begin) < off) {
375 : begin += length;
376 : length = 0;
377 : }
378 : }
379 : *eof = 1;
380 :done:
381 : if (off >= (length + begin))
382 : return 0;
383 : *start = page + (off-begin);
384 : return (count < begin+length-off) ? count : begin + length-off;
385 :}
386 :


*1 length + begin) > (off + count