version 1.3.2.2, 2014/02/05 22:51:25
|
version 1.6.2.3, 2014/02/06 00:56:16
|
Line 47 SUCH DAMAGE.
|
Line 47 SUCH DAMAGE.
|
|
|
|
|
char imgName[PATH_MAX], imgFile[PATH_MAX]; |
char imgName[PATH_MAX], imgFile[PATH_MAX]; |
off_t imgSize, iSize; | off_t imgSize, iSize, fromBegin; |
int Verbose, bufSize = IMGBUF_SIZE; |
int Verbose, bufSize = IMGBUF_SIZE; |
extern char compiled[], compiledby[], compilehost[]; |
extern char compiled[], compiledby[], compilehost[]; |
|
|
Line 61 Usage()
|
Line 61 Usage()
|
"\t-v\t\tVerbose ...\n" |
"\t-v\t\tVerbose ...\n" |
"\t-R\t\tReboot system after complete\n" |
"\t-R\t\tReboot system after complete\n" |
"\t-p\t\tPipe suitable transfer on little chunks\n" |
"\t-p\t\tPipe suitable transfer on little chunks\n" |
|
"\t-i\t\tStart fill storage from begin\n" |
"\t-g\t\tGet image from Storage\n" |
"\t-g\t\tGet image from Storage\n" |
"\t-t\t\tTruncate Storage file name\n" |
"\t-t\t\tTruncate Storage file name\n" |
"\t-s <size>\tStorage size (required for stdin)\n" |
"\t-s <size>\tStorage size (required for stdin)\n" |
Line 77 EmptyStore(int img)
|
Line 78 EmptyStore(int img)
|
|
|
VERB(1) printf("Erase store %s\n", imgName); |
VERB(1) printf("Erase store %s\n", imgName); |
|
|
iSize = lseek(img, 0, SEEK_END); | if (!fromBegin) { |
if (iSize == -1) { | iSize = lseek(img, 0, SEEK_END); |
ESYSERR(0); | if (iSize == -1) { |
return -1; | ESYSERR(0); |
| return -1; |
| } else |
| imgSize += E_ALIGN(iSize, bufSize); |
} else |
} else |
imgSize += E_ALIGN(iSize, bufSize); | iSize ^= iSize; |
|
|
memset(buf, 0, sizeof buf); |
memset(buf, 0, sizeof buf); |
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, sizeof buf)) == -1 || | if ((wlen = write(img, buf, bufSize)) == -1 || |
wlen != sizeof buf) { | (wlen && wlen != bufSize)) { |
EERROR(EIO, "Error at chunk %d init %d bytes, should be %u\n", | EERROR(EIO, "Error at chunk %d init %d bytes, " |
i, wlen, sizeof buf); | "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 110 FillStore(int img, int fd)
|
Line 114 FillStore(int img, int fd)
|
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, sizeof buf); | rlen = read(fd, buf, bufSize); |
if (rlen == -1) { |
if (rlen == -1) { |
ESYSERR(0); |
ESYSERR(0); |
return -1; |
return -1; |
Line 119 FillStore(int img, int fd)
|
Line 123 FillStore(int img, int fd)
|
else |
else |
VERB(1) printf("+Readed %d bytes for chunk #%d\n", rlen, j); |
VERB(1) printf("+Readed %d bytes for chunk #%d\n", rlen, j); |
|
|
wlen = write(img, buf, rlen); | wlen = write(img, buf, bufSize); |
if (wlen == -1) { |
if (wlen == -1) { |
ESYSERR(0); |
ESYSERR(0); |
return -1; |
return -1; |
} else if (!wlen || wlen != rlen) { | } else if (wlen && wlen != bufSize) { |
EERROR(EIO, "Readed %d bytes are not equal to written %d bytes\n", | EERROR(EIO, "Error at chunk %d written %d bytes, " |
rlen, wlen); | "should be %u\n", i, wlen, bufSize); |
} else |
} else |
VERB(1) printf("+Written %d bytes at chunk #%d\n", wlen, i); |
VERB(1) printf("+Written %d bytes at chunk #%d\n", wlen, i); |
} |
} |
Line 139 main(int argc, char **argv)
|
Line 143 main(int argc, char **argv)
|
char ch, m = 0, R = 0; |
char ch, m = 0, R = 0; |
int fd, img, tr = 0; |
int fd, img, tr = 0; |
|
|
while ((ch = getopt(argc, argv, "hvRpgts:f:")) != -1) | while ((ch = getopt(argc, argv, "hvRipgts:f:")) != -1) |
switch (ch) { |
switch (ch) { |
case 'f': |
case 'f': |
strlcpy(imgName, optarg, sizeof imgName); |
strlcpy(imgName, optarg, sizeof imgName); |
Line 154 main(int argc, char **argv)
|
Line 158 main(int argc, char **argv)
|
case 't': |
case 't': |
tr = O_TRUNC; |
tr = O_TRUNC; |
break; |
break; |
case 'g': |
|
m = 1; |
|
break; |
|
case 'p': |
case 'p': |
bufSize = IMGBUF_SIZE2; |
bufSize = IMGBUF_SIZE2; |
|
break; |
|
case 'g': |
|
m = 1; |
|
case 'i': |
|
fromBegin = 1; |
break; |
break; |
case 'R': |
case 'R': |
R = 1; |
R = 1; |