static ssize_t do_read(struct file *file, char __user *buf, size_t len, loff_t *ppos, int force_block) { unsigned int saved_flags; ssize_t ret, count; if (!force_block) return __do_read(file, buf, len, ppos); saved_flags = file->f_flags; file->f_flags &= ~O_NONBLOCK; ret = 0; while (len > 0) { count = __do_read(file, buf, len, ppos); if (count == 0) break; if (count < 0) { ret = count; break; } len -= count; buf += count; ret += count; } file->f_flags = saved_flags; return ret; }
static int do_read(void *data, int size) { int r; r = __do_read(input_fd, data, size); if (r <= 0) { pr_debug("reading input file (size expected=%d received=%d)", size, r); return -1; } trace_data_size += r; return r; }
static void __process_read_request(struct stream *s) { int np = 0; struct stream_request *req; while (!event_list_empty(&s->read_queue[IO_WAIT])) { int ret; req = event_list_first_entry(&s->read_queue[IO_WAIT], struct stream_request, node); if (req->request == REQ_READ) ret = __do_read(s, req); else ret = __do_accept(s, req); if (ret && ret != -EAGAIN && ret != -EINTR) goto out; if (!ret) { __move_to_queue(req, &s->read_queue[IO_FIN]); } else break; np++; } return; out: __move_to_queue(req, &s->read_queue[IO_FIN]); }