diff options
| author | Klessing, Daniel <Daniel.Klessing@de.fujitsu.com> | 2011-10-30 13:05:38 +0700 |
|---|---|---|
| committer | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2011-10-30 13:05:38 +0700 |
| commit | 846ac8422390ed9aa1f572a6089f2a7fc41f4aed (patch) | |
| tree | 0f9f3805a49a8035a66e93c58acea8b16910b7c3 /scripts/basic | |
| parent | 4713c7fb769e8e627459394291310c9a335fbbdb (diff) | |
| download | busybox-w32-846ac8422390ed9aa1f572a6089f2a7fc41f4aed.tar.gz busybox-w32-846ac8422390ed9aa1f572a6089f2a7fc41f4aed.tar.bz2 busybox-w32-846ac8422390ed9aa1f572a6089f2a7fc41f4aed.zip | |
fixdep: fix mmap() on msys
Diffstat (limited to 'scripts/basic')
| -rw-r--r-- | scripts/basic/fixdep.c | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c index 02678a4cc..fd2e2375f 100644 --- a/scripts/basic/fixdep.c +++ b/scripts/basic/fixdep.c | |||
| @@ -134,14 +134,36 @@ | |||
| 134 | void *mmap(void *start UNUSED, size_t size, int prot UNUSED, | 134 | void *mmap(void *start UNUSED, size_t size, int prot UNUSED, |
| 135 | int flags UNUSED, int fd, off_t offset UNUSED) | 135 | int flags UNUSED, int fd, off_t offset UNUSED) |
| 136 | { | 136 | { |
| 137 | void *p = malloc(size); | 137 | void *p; |
| 138 | void *curP; | ||
| 139 | ssize_t readB; | ||
| 140 | |||
| 141 | p = malloc(size); | ||
| 138 | if (!p) | 142 | if (!p) |
| 139 | return NULL; | 143 | return (void*)((long)-1); |
| 140 | if (read(fd, p, size) != size) { | 144 | |
| 141 | perror("fixdep: read config"); | 145 | curP = p; |
| 142 | free(p); | 146 | |
| 143 | return NULL; | 147 | while (size > 0) |
| 148 | { | ||
| 149 | readB = read(fd, curP, size); | ||
| 150 | |||
| 151 | if (readB == 0) | ||
| 152 | { | ||
| 153 | /* EOF reached */ | ||
| 154 | break; | ||
| 155 | } | ||
| 156 | else if (readB < 0) | ||
| 157 | { | ||
| 158 | perror("fixdep: read config"); | ||
| 159 | free(p); | ||
| 160 | return (void*)((long)-1); | ||
| 161 | } | ||
| 162 | |||
| 163 | size -= readB; | ||
| 164 | curP += readB; | ||
| 144 | } | 165 | } |
| 166 | |||
| 145 | return p; | 167 | return p; |
| 146 | } | 168 | } |
| 147 | void munmap(void *p, size_t size UNUSED) | 169 | void munmap(void *p, size_t size UNUSED) |
