version 1.6.2.3, 2014/02/06 00:56:16
|
version 1.6.2.5, 2014/02/06 09:19:51
|
Line 92 EmptyStore(int img)
|
Line 92 EmptyStore(int img)
|
for (i = howmany(iSize, bufSize); i < howmany(imgSize, bufSize); i++) |
for (i = howmany(iSize, bufSize); i < howmany(imgSize, bufSize); i++) |
if ((wlen = write(img, buf, bufSize)) == -1 || |
if ((wlen = write(img, buf, bufSize)) == -1 || |
(wlen && wlen != bufSize)) { |
(wlen && wlen != bufSize)) { |
EERROR(EIO, "Error at chunk %d init %d bytes, " | if (wlen == -1) |
"should be %u\n", i, wlen, bufSize); | ESYSERR(0); |
| else |
| EERROR(EIO, "Error at chunk %d init %d bytes, " |
| "should be %u\n", i, wlen, bufSize); |
return -1; |
return -1; |
} else |
} else |
VERB(1) printf("+Written chunk #%d\n", i); |
VERB(1) printf("+Written chunk #%d\n", i); |
Line 106 static int
|
Line 109 static int
|
FillStore(int img, int fd) |
FillStore(int img, int fd) |
{ |
{ |
register int i, j; |
register int i, j; |
u_char buf[bufSize]; | u_char *pos, buf[bufSize]; |
ssize_t rlen, wlen; | ssize_t rlen, wlen, len; |
|
|
VERB(1) printf("Fill store %s from image file %s\n", imgName, imgFile); |
VERB(1) printf("Fill store %s from image file %s\n", imgName, imgFile); |
|
|
for (j = 0, i = howmany(iSize, bufSize); i < howmany(imgSize, bufSize); |
for (j = 0, i = howmany(iSize, bufSize); i < howmany(imgSize, bufSize); |
i++, j++) { |
i++, j++) { |
memset(buf, 0, sizeof buf); |
memset(buf, 0, sizeof buf); |
rlen = read(fd, buf, bufSize); | for (len = bufSize, pos = buf; len > 0; len -= rlen, pos += rlen) { |
if (rlen == -1) { | rlen = read(fd, pos, len); |
ESYSERR(0); | if (rlen == -1) { |
return -1; | ESYSERR(0); |
} else if (!rlen) | return -1; |
break; | } else if (!rlen) |
else | break; |
VERB(1) printf("+Readed %d bytes for chunk #%d\n", rlen, j); | else |
| VERB(1) printf("+Readed %d bytes for chunk #%d\n", rlen, j); |
| } |
|
|
wlen = write(img, buf, bufSize); |
wlen = write(img, buf, bufSize); |
if (wlen == -1) { |
if (wlen == -1) { |
Line 271 main(int argc, char **argv)
|
Line 276 main(int argc, char **argv)
|
return 4; |
return 4; |
} |
} |
} else { /* GET */ |
} else { /* GET */ |
|
iSize ^= iSize; |
if (EmptyStore(fd) == -1) { |
if (EmptyStore(fd) == -1) { |
if (fd > 2) |
if (fd > 2) |
close(fd); |
close(fd); |