Commit 424f2c1d authored by Mike Hibler's avatar Mike Hibler

1. Add -N option to frisbee client to not decompress the image.

   This way we can use frisbee as a fast network copy.

2. In imageunzip, don't truncate the output file until we have performed
   basic validity checks.  Otherwise, if you happened to reverse the order
   of the imagefile and the output disk, it would truncate the imagefile
   and THEN fail.

3. Strip binaries when they are installed.
parent 63d6f910
......@@ -49,6 +49,7 @@ int idledelay = CLIENT_WRITER_IDLE_DELAY;
int startdelay = 0, startat = 0;
int nothreads = 0;
int nodecompress = 0;
int debug = 0;
int tracing = 0;
char traceprefix[64];
......@@ -70,6 +71,7 @@ extern int ImageUnzipInit(char *filename, int slice, int debug, int zero,
int nothreads, int dostype,
unsigned long writebufmem);
extern void ImageUnzipSetMemory(unsigned long writebufmem);
extern int ImageWriteChunk(int chunkno, char *chunkdata);
extern int ImageUnzipChunk(char *chunkdata);
extern void ImageUnzipFlush(void);
extern int ImageUnzipQuit(void);
......@@ -167,7 +169,7 @@ main(int argc, char **argv)
int dostype = -1;
int slice = 0;
while ((ch = getopt(argc, argv, "dhp:m:s:i:tbznT:r:E:D:C:W:S:M:R:I:O")) != -1)
while ((ch = getopt(argc, argv, "dhp:m:s:i:tbznT:r:E:D:C:W:S:M:R:I:ON")) != -1)
switch(ch) {
case 'd':
debug++;
......@@ -278,6 +280,10 @@ main(int argc, char **argv)
randomize = 0;
break;
case 'N':
nodecompress = 1;
break;
case 'h':
case '?':
default:
......@@ -721,8 +727,14 @@ ChunkerStartup(void)
decompblocks, writeridles);
wasidle = 0;
if (ImageUnzipChunk(ChunkBuffer[i].blocks[0].data))
pfatal("ImageUnzipChunk failed");
if (nodecompress) {
if (ImageWriteChunk(ChunkBuffer[i].thischunk,
ChunkBuffer[i].blocks[0].data))
pfatal("ImageWriteChunk failed");
} else {
if (ImageUnzipChunk(ChunkBuffer[i].blocks[0].data))
pfatal("ImageUnzipChunk failed");
}
/*
* Okay, free the slot up for another chunk.
......
......@@ -115,9 +115,9 @@ install: $(INSTALL_BINDIR)/imagezip $(INSTALL_BINDIR)/imageunzip $(INSTALL_BINDI
client: all
client-install: client
$(INSTALL) -m 755 -o root -g wheel -d $(DESTDIR)/usr/local/bin
$(INSTALL_PROGRAM) imagezip $(DESTDIR)/usr/local/bin/imagezip
$(INSTALL_PROGRAM) imageunzip $(DESTDIR)/usr/local/bin/imageunzip
$(INSTALL_PROGRAM) imagedump $(DESTDIR)/usr/local/bin/imagedump
$(INSTALL_PROGRAM) -s imagezip $(DESTDIR)/usr/local/bin/imagezip
$(INSTALL_PROGRAM) -s imageunzip $(DESTDIR)/usr/local/bin/imageunzip
$(INSTALL_PROGRAM) -s imagedump $(DESTDIR)/usr/local/bin/imagedump
clean: subdir-clean
rm -f *.o imagezip imageunzip imagedump imagehash version.c
......
......@@ -87,6 +87,7 @@ static struct timeval stamp;
#endif
int readmbr(int slice);
int fixmbr(int slice, int dtype);
static int write_subblock(int, char *);
static int inflate_subblock(char *);
void writezeros(off_t offset, off_t zcount);
void writedata(off_t offset, size_t count, void *buf);
......@@ -546,6 +547,28 @@ main(int argc, char **argv)
if (docrconly)
outfd = -1;
else if (argc == 2 && strcmp(argv[1], "-")) {
/*
* XXX perform seek and MBR checks before we truncate
* the output file. If they have their input/output
* arguments reversed, we don't want to truncate their
* image file! (I speak from bitter experience).
*/
if (slice && (outfd = open(argv[1], O_RDONLY, 0666)) >= 0) {
if (lseek(outfd, (off_t)0, SEEK_SET) < 0) {
fprintf(stderr, "Output file is not seekable, "
"cannot specify a slice\n");
exit(1);
}
if (readmbr(slice)) {
fprintf(stderr, "Failed to read MBR\n");
exit(1);
}
close(outfd);
}
/*
* Open the output file for writing.
*/
if ((outfd =
open(argv[1], O_RDWR|O_CREAT|O_TRUNC, 0666)) < 0) {
perror("opening output file");
......@@ -749,6 +772,12 @@ ImageUnzipSetMemory(unsigned long _writebufmem)
#endif
}
int
ImageWriteChunk(int chunkno, char *chunkdata)
{
return write_subblock(chunkno, chunkdata);
}
int
ImageUnzipChunk(char *chunkdata)
{
......@@ -897,6 +926,29 @@ DiskWriter(void *arg)
}
#endif
/*
* Just write the raw, compressed chunk data to disk
*/
static int
write_subblock(int chunkno, char *chunkbufp)
{
writebuf_t *wbuf;
off_t offset, size, bytesleft;
offset = chunkno * SUBBLOCKSIZE;
bytesleft = SUBBLOCKSIZE;
while (bytesleft > 0) {
size = (bytesleft >= OUTSIZE) ? OUTSIZE : bytesleft;
wbuf = alloc_writebuf(offset, size, 1, 1);
memcpy(wbuf->data, chunkbufp, size);
dowrite_request(wbuf);
chunkbufp += size;
offset += size;
bytesleft -= size;
}
return 0;
}
static int
inflate_subblock(char *chunkbufp)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment