From 656ce0e153743e3ec38421641b0bd86fa72e5ed2 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Sat, 21 Jul 2007 18:22:47 +0000 Subject: [PATCH] kes Implement grow tool to grow a file for testing very large databases. kes Add big-vol-test to test Bacula seeking with > 5GB. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@5210 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/tools/Makefile.in | 4 ++- bacula/src/tools/grow.c | 58 ++++++++++++++++++++++++++++++++++++ bacula/src/version.h | 6 ++-- bacula/technotes-2.1 | 3 ++ 4 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 bacula/src/tools/grow.c diff --git a/bacula/src/tools/Makefile.in b/bacula/src/tools/Makefile.in index b9df3731b5..1dc10c8b9f 100644 --- a/bacula/src/tools/Makefile.in +++ b/bacula/src/tools/Makefile.in @@ -52,7 +52,7 @@ INSTOOLS = $(INS@DIR_TOOLS@) @echo "Compiling $<" $(NO_ECHO)$(CXX) $(DEFS) $(DEBUG) -c $(CPPFLAGS) $(PYTHON_INC) -I$(srcdir) -I$(basedir) $(DINCLUDE) $(CFLAGS) $< #------------------------------------------------------------------------- -all: Makefile $(TOOLS) gigaslam +all: Makefile $(TOOLS) gigaslam grow @echo "==== Make of tools is good ====" @echo " " @@ -106,6 +106,8 @@ gigaslam.o: gigaslam.c gigaslam: gigaslam.o $(CC) -o $@ gigaslam.o +grow: grow.o ../lib/libbac.a + $(CXX) $(LDFLAGS) -L../lib -o $@ grow.o -lbac -lm $(DLIB) $(LIBS) $(GETTEXT_LIBS) $(OPENSSL_LIBS) Makefile: $(srcdir)/Makefile.in $(topdir)/config.status cd $(topdir) \ diff --git a/bacula/src/tools/grow.c b/bacula/src/tools/grow.c new file mode 100644 index 0000000000..3736acaf03 --- /dev/null +++ b/bacula/src/tools/grow.c @@ -0,0 +1,58 @@ +/* + By John Walker written ages ago. + + Create a sparse file. + + Beat denial of service floggers to death by persuading + them to download a HOW_BIG pseudo GIF file which is actually + a holey file occupying trivial space on our server. + + Make: make gigaslam + Run: ./gigaslam + Output: a file named gigaslam.gif that contains something like + 16K bytes (i.e. 2-8K blocks), but appears to be 1GB in + length because the second block is written at a 1GB + address. + + Be careful what you do with this file as not all programs know + how to deal with sparse files. + + Tweaked by Kern Sibbald, July 2007 to grow a file to a specified + size. + +*/ + +#ifdef __GNUC__ +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif +#ifndef _FILE_OFFSET_BITS +#define _FILE_OFFSET_BITS 64 +#endif +#endif + +#include "bacula.h" + +int main(int argc, char *argv[]) +{ + off_t howBig; + FILE *fp; + + if (argc != 3) { + Pmsg0(0, "Calling sequence: grow \n"); + exit(1); + } + howBig = str_to_int64(argv[2]); + fp = fopen(argv[1], "w+"); + if (!fp) { + berrno be; + Pmsg2(0, "Could not open %s for write. ERR=%s\n", argv[1], be.bstrerror()); + exit(1); + } + char trailer[] = "xxxxxxx\n"; + + fseeko(fp, howBig - strlen(trailer), SEEK_SET); + fwrite(trailer, strlen(trailer), 1, fp); + fclose(fp); + return 0; +} diff --git a/bacula/src/version.h b/bacula/src/version.h index db3e95e941..be204d93f9 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -3,9 +3,9 @@ */ #undef VERSION -#define VERSION "2.1.28" -#define BDATE "20 July 2007" -#define LSMDATE "20Jul07" +#define VERSION "2.1.29" +#define BDATE "21 July 2007" +#define LSMDATE "21Jul07" #define PROG_COPYRIGHT "Copyright (C) %d-2007 Free Software Foundation Europe e.V.\n" #define BYEAR "2007" /* year for copyright messages in progs */ diff --git a/bacula/technotes-2.1 b/bacula/technotes-2.1 index 2f21b2a4cf..45925b4a8a 100644 --- a/bacula/technotes-2.1 +++ b/bacula/technotes-2.1 @@ -1,6 +1,9 @@ Technical notes on version 2.1 General: +21Jul07 +kes Implement grow tool to grow a file for testing very large databases. +kes Add big-vol-test to test Bacula seeking with > 5GB. Release 2.1.28 beta 19Jul07 kes Modify find_next_volume() to return all values in Media record. -- 2.39.5