Contents of /trunk/mkinitrd-magellan/klibc/usr/klibc/fread.c
Parent Directory | Revision Log
Revision 532 -
(show annotations)
(download)
Sat Sep 1 22:45:15 2007 UTC (16 years, 8 months ago) by niro
File MIME type: text/plain
File size: 422 byte(s)
Sat Sep 1 22:45:15 2007 UTC (16 years, 8 months ago) by niro
File MIME type: text/plain
File size: 422 byte(s)
-import if magellan mkinitrd; it is a fork of redhats mkinitrd-5.0.8 with all magellan patches and features; deprecates magellan-src/mkinitrd
1 | /* |
2 | * fread.c |
3 | */ |
4 | |
5 | #include <errno.h> |
6 | #include <unistd.h> |
7 | #include <stdio.h> |
8 | |
9 | size_t _fread(void *buf, size_t count, FILE *f) |
10 | { |
11 | size_t bytes = 0; |
12 | ssize_t rv; |
13 | char *p = buf; |
14 | |
15 | while (count) { |
16 | rv = read(fileno(f), p, count); |
17 | if (rv == -1) { |
18 | if (errno == EINTR) { |
19 | errno = 0; |
20 | continue; |
21 | } else |
22 | break; |
23 | } else if (rv == 0) { |
24 | break; |
25 | } |
26 | |
27 | p += rv; |
28 | bytes += rv; |
29 | count -= rv; |
30 | } |
31 | |
32 | return bytes; |
33 | } |