From 0e67d6c9257e8b16609ab78f4ebefa7b0118e6e2 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Sun, 6 Mar 2011 22:52:50 +0100 Subject: [PATCH] Minor package changes --- AUTHORS | 7 ++--- HISTORY | 9 ++++-- INSTALL | 10 +++++-- Makefile.am | 78 ++++++++++++++++++++++++++++++++++++++++++++++------ README | 7 ++++- config.h | 8 +----- configure.ac | 17 ++++++++---- elem.c | 1 + elem.h | 6 ++-- snapraid.c | 8 +++--- state.c | 1 - state.h | 1 + sync.c | 1 + 13 files changed, 115 insertions(+), 39 deletions(-) diff --git a/AUTHORS b/AUTHORS index 40e8c2ef..80829088 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,9 +1,8 @@ -AUTHORS -======= +SnapRAID AUTHORS +================ -The author of snapraid is Andrea Mazzoleni. +The author of SnapRAID is Andrea Mazzoleni. You can contact me sending an email at: amadvance@users.sourceforge.net - diff --git a/HISTORY b/HISTORY index 108aeae1..e249f2d1 100644 --- a/HISTORY +++ b/HISTORY @@ -1,5 +1,8 @@ -SNAPRAID VERSION 0.1 2011/02 -================================ +SnapRAID HISTORY +================ -* First release of snapraid +0.1 2011/3 +========== + +* First public release of SnapRAID. diff --git a/INSTALL b/INSTALL index a89589ac..c5e0fccf 100644 --- a/INSTALL +++ b/INSTALL @@ -1,5 +1,5 @@ -INSTALL -======= +SnapRAID INSTALL +================ As root or user type: @@ -11,3 +11,9 @@ type: make install +then change the example configuration file snapraid.conf to fit +your needs and copy it in /etc/snapraid.conf. + +The documentation is in the man page: + + man snapraid diff --git a/Makefile.am b/Makefile.am index 4bbaa0bb..e55ee321 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,11 +5,23 @@ snapraid_SOURCES = \ snapraid.c \ getopt.c \ md5.c \ - tommy.c - + tommy.c \ + util.c \ + elem.c \ + state.c \ + scan.c \ + sync.c \ + check.c \ + parity.c \ + handle.c noinst_HEADERS = \ portable.h \ + util.h \ + elem.h \ + state.h \ + parity.h \ + handle.h \ md5.h \ tommyarray.h \ tommychain.h \ @@ -17,7 +29,6 @@ noinst_HEADERS = \ tommyhashdyn.h \ tommylist.h \ tommytypes.h \ - util.h \ tommyarray.c \ tommyhash.c \ tommyhashdyn.c \ @@ -30,6 +41,7 @@ EXTRA_DIST = \ autogen.sh \ noautomake.sh \ README AUTHORS HISTORY INSTALL COPYING \ + snapraid.d snapraid.1 snapraid.txt snapraid.html \ test.conf \ acinclude.m4 @@ -37,7 +49,11 @@ clean-local: rm -f valgrind.log callgrind.log rm -rf test -CHECK = ./snapraid -v -c test.conf sync +maintainer-clean-local: + rm -f README AUTHORS HISTORY INSTALL + rm -f snapraid.1 snapraid.txt snapraid.html + +CHECK = ./snapraid -v -c test.conf fix check-local: rm -rf test @@ -45,14 +61,29 @@ check-local: mkdir test/disk1 mkdir test/disk2 mkdir test/disk3 + echo Create some files, sync and check ./testgen 1 3 2000 - ./snapraid -v -c $(srcdir)/test.conf sync - ./snapraid -v -c $(srcdir)/test.conf check + ./snapraid -c $(srcdir)/test.conf sync + ./snapraid -c $(srcdir)/test.conf check + echo Create some more files, sync and check ./testgen 2 3 2000 - ./snapraid -v -c $(srcdir)/test.conf sync - ./snapraid -v -c $(srcdir)/test.conf check + ./snapraid -c $(srcdir)/test.conf sync + ./snapraid -c $(srcdir)/test.conf check + echo Delete some files, fix and check rm test/disk1/a* - ./snapraid -v -c $(srcdir)/test.conf check + ./snapraid -c $(srcdir)/test.conf check 2>/dev/null + ./snapraid -c $(srcdir)/test.conf fix 2>/dev/null + ./snapraid -c $(srcdir)/test.conf check + echo Delete the parity, fix and check + rm test/parity + ./snapraid -c $(srcdir)/test.conf check 2>/dev/null + ./snapraid -c $(srcdir)/test.conf fix 2>/dev/null + ./snapraid -c $(srcdir)/test.conf check + echo Corrupt the parity, fix and check + dd if=/dev/zero of=test/parity bs=1024 count=1000 seek=1000 conv=notrunc + ./snapraid -c $(srcdir)/test.conf check 2>/dev/null + ./snapraid -c $(srcdir)/test.conf fix 2>/dev/null + ./snapraid -c $(srcdir)/test.conf check echo Success! valgrind: @@ -81,3 +112,32 @@ cachegrind: 2> cachegrind.log tail cachegrind.log +# Rules for documentation + +%.1 : %.d + advd2 man < $(srcdir)/$< > $@ + +%.txt : %.d + advd2 txt < $(srcdir)/$< | todos > $@ + +%.html : %.d + advd2 html < $(srcdir)/$< > $@ + +%.hh : %.d + advd2 frame < $(srcdir)/$< > $@ + +# Windows distribution + +DISTWIN = \ + snapraid.txt \ + snapraid.html \ + snapraid.exe \ + snapraid.rc + +distwindows: $(DISTWIN) + rm -f $(PACKAGE)-$(VERSION)-windows-x86.zip + mkdir tmp + cp $(DISTWIN) tmp + cd tmp && zip -r ../$(PACKAGE)-$(VERSION)-windows-x86.zip * + rm -r tmp + diff --git a/README b/README index 0c6a1a6d..e8392241 100644 --- a/README +++ b/README @@ -1,5 +1,10 @@ -SNAPRAID +SnapRAID ======== +SnapRAID is a backup program for a disk array using redundancy. +Just like a RAID system but based on snapshots. +The official site of SnapRAID is: + + http://snapraid.sourceforge.net diff --git a/config.h b/config.h index 4028bb24..7ad51e89 100644 --- a/config.h +++ b/config.h @@ -101,12 +101,6 @@ /* Define to 1 if you have the header file. */ #define HAVE_UNISTD_H 1 -/* Define to 1 if you have the header file. */ -#define HAVE_UTIME_H 1 - -/* Define to 1 if `utime(file, NULL)' sets file's timestamp to the present. */ -#define HAVE_UTIME_NULL 1 - /* Define to 1 if you have the `vsnprintf' function. */ #define HAVE_VSNPRINTF 1 @@ -126,7 +120,7 @@ #define PACKAGE_TARNAME "snapraid" /* Define to the home page for this package. */ -#define PACKAGE_URL "" +#define PACKAGE_URL "http://snapraid.sourceforge.net" /* Define to the version of this package. */ #define PACKAGE_VERSION "0.1" diff --git a/configure.ac b/configure.ac index 8b44cd3e..1ad55355 100644 --- a/configure.ac +++ b/configure.ac @@ -1,10 +1,10 @@ dnl Process this file with autoconf to produce a configure script. -AC_INIT([snapraid], [0.1]) +AC_PREREQ([2.65]) +AC_INIT([snapraid], [0.1], [], [], [http://snapraid.sourceforge.net]) AM_INIT_AUTOMAKE([foreign no-dependencies]) AC_CONFIG_SRCDIR([snapraid.c]) AC_CONFIG_HEADER([config.h]) AC_CANONICAL_HOST -AC_COPYRIGHT([Copyright 2011 Andrea Mazzoleni]) dnl Checks for programs. AC_PROG_CC @@ -16,8 +16,7 @@ dnl Checks for header files. AC_HEADER_STDC AC_HEADER_DIRENT AC_HEADER_TIME -AC_FUNC_UTIME_NULL -AC_CHECK_HEADERS([unistd.h getopt.h stdint.h]) +AC_CHECK_HEADERS([fcntl.h stddef.h stdint.h stdlib.h string.h sys/time.h unistd.h getopt.h]) dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST @@ -25,10 +24,18 @@ AC_C_INLINE AC_C_RESTRICT AC_C_VOLATILE AC_TYPE_SIZE_T +AC_TYPE_OFF_T +AC_TYPE_SIZE_T +AC_TYPE_SSIZE_T +AC_TYPE_UINT32_T +AC_TYPE_UINT64_T +AC_TYPE_UINT8_T dnl Checks for library functions. +AC_FUNC_MALLOC +AC_CHECK_FUNCS([memset strchr strerror strrchr]) AC_CHECK_FUNCS([getopt getopt_long snprintf vsnprintf]) -AC_CHECK_FUNCS([fsync fallocate]) +AC_CHECK_FUNCS([ftruncate fsync posix_fallocate posix_fadvise pread pwrite]) dnl Configure for 64 bit files CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64" diff --git a/elem.c b/elem.c index dcaee407..0a530f47 100644 --- a/elem.c +++ b/elem.c @@ -116,3 +116,4 @@ void disk_free(struct snapraid_disk* disk) tommy_array_done(&disk->blockarr); free(disk); } + diff --git a/elem.h b/elem.h index 9f77e37c..5855655c 100644 --- a/elem.h +++ b/elem.h @@ -39,9 +39,9 @@ /** * Basic position type. - * With a 32 bit and 128k block you can address 256 TB. + * With 32 bits and 128k blocks you can address 256 TB. */ -typedef unsigned pos_t; +typedef uint32_t pos_t; struct snapraid_file; @@ -62,7 +62,7 @@ struct snapraid_file { char sub[PATH_MAX]; /**< Sub path of the file. Without the disk dir. The disk is implicit. */ uint64_t size; /**< Size of the file. */ struct snapraid_block* blockvec; /**< All the blocks of the file. */ - unsigned blockmax; /**< Number of blocks. */ + pos_t blockmax; /**< Number of blocks. */ time_t mtime; /**< Modification time. */ int is_present; /**< If it's seen as present. */ diff --git a/snapraid.c b/snapraid.c index 804733ae..d33fb716 100644 --- a/snapraid.c +++ b/snapraid.c @@ -25,16 +25,16 @@ /* main */ void version(void) { - printf(PACKAGE " v" VERSION " by Andrea Mazzoleni\n"); + printf(PACKAGE " v" VERSION " by Andrea Mazzoleni, " PACKAGE_URL "\n"); } void usage(void) { version(); - printf("Usage: snapraid [options]\n"); + printf("Usage: " PACKAGE " [options]\n"); printf("\n"); printf("Options:\n"); - printf(" " SWITCH_GETOPT_LONG("-c, --conf FILE ", "-c") " Configuration file (default /etc/snapraid.conf)\n"); + printf(" " SWITCH_GETOPT_LONG("-c, --conf FILE ", "-c") " Configuration file (default /etc/" PACKAGE ".conf)\n"); printf(" " SWITCH_GETOPT_LONG("-s, --start BLK ", "-s") " Start from the specified block number\n"); printf(" " SWITCH_GETOPT_LONG("-f, --force ", "-f") " Force dangerous operations\n"); printf(" " SWITCH_GETOPT_LONG("-v, --verbose ", "-v") " Verbose\n"); @@ -82,7 +82,7 @@ int main(int argc, char* argv[]) pos_t blockstart; /* defaults */ - conf = "/etc/snapraid.conf"; + conf = "/etc/" PACKAGE ".conf"; verbose = 0; force = 0; blockstart = 0; diff --git a/state.c b/state.c index 73429315..64872826 100644 --- a/state.c +++ b/state.c @@ -487,4 +487,3 @@ int state_progress(time_t* start, time_t* last, pos_t blockpos, pos_t blockmax, return 0; } - diff --git a/state.h b/state.h index cce6f20c..0b157b6b 100644 --- a/state.h +++ b/state.h @@ -69,3 +69,4 @@ void state_check(struct snapraid_state* state, int fix, pos_t blockstart); int state_progress(time_t* start, time_t* last, pos_t blockpos, pos_t blockmax, uint64_t count_block, uint64_t count_size); #endif + diff --git a/sync.c b/sync.c index 67458a1d..4d97c926 100644 --- a/sync.c +++ b/sync.c @@ -162,3 +162,4 @@ void state_sync(struct snapraid_state* state, pos_t blockstart) parity_close(path, f); } +