diff --git a/Makefile.in b/Makefile.in index ff9ef0e..1981dbe 100644 --- a/Makefile.in +++ b/Makefile.in @@ -408,6 +408,7 @@ clean: distclean: clean $(RM) Makefile (cd $(LIBBSCDIR); make clean) + $(RM_RF) buildtmp install: $(PROG) @mkdir -p $(DESTDIR)$(PREFIX)/bin diff --git a/main.c b/main.c index 499e47e..6f19692 100644 --- a/main.c +++ b/main.c @@ -35,7 +35,7 @@ #include #include #include -#include +#include "pcompress.h" #include #include diff --git a/rabin/global/dedupe_config.h b/rabin/global/dedupe_config.h index f2c42a3..b4dad9d 100644 --- a/rabin/global/dedupe_config.h +++ b/rabin/global/dedupe_config.h @@ -88,7 +88,7 @@ typedef struct { struct seg_map_fd *seg_fd_r; // One read-only fd per thread for mapping in portions of the // segment metadata cache. int valid; - void *dbdata; + void *db_index; } archive_config_t; #pragma pack(1) diff --git a/rabin/global/index.c b/rabin/global/index.c index ed65813..3e7b926 100644 --- a/rabin/global/index.c +++ b/rabin/global/index.c @@ -31,12 +31,12 @@ #include #include #include -#include -#include #include -#include #include +#include "utils/utils.h" +#include "allocator.h" +#include "utils/xxhash.h" #include "index.h" /* @@ -51,6 +51,7 @@ typedef struct { uint64_t memlimit; uint64_t memused; int hash_entry_size, intervals, hash_slots; + char *index_file; } index_t; archive_config_t * @@ -72,6 +73,14 @@ init_global_db(char *configfile) return (cfg); } +int +init_on_disk_index(archive_config_t *cfg) +{ + if (file_exists()) { + + } +} + void static cleanup_indx(index_t *indx) { @@ -307,7 +316,7 @@ init_global_db_s(char *path, char *tmppath, uint32_t chunksize, uint64_t user_ch } } cfg->segcache_pos = 0; - cfg->dbdata = indx; + cfg->db_index = indx; return (cfg); } @@ -475,7 +484,7 @@ db_lookup_insert_s(archive_config_t *cfg, uchar_t *sim_cksum, int interval, uint64_t item_offset, uint32_t item_size, int do_insert) { uint32_t htab_entry; - index_t *indx = (index_t *)(cfg->dbdata); + index_t *indx = (index_t *)(cfg->db_index); hash_entry_t **htab, *ent, **pent; assert((cfg->similarity_cksum_sz & (sizeof (size_t) - 1)) == 0); @@ -549,7 +558,7 @@ void destroy_global_db_s(archive_config_t *cfg) { int i; - index_t *indx = (index_t *)(cfg->dbdata); + index_t *indx = (index_t *)(cfg->db_index); cleanup_indx(indx); if (cfg->pct_interval > 0) { diff --git a/rabin/global/index.h b/rabin/global/index.h index d63bd0c..6cc4abb 100644 --- a/rabin/global/index.h +++ b/rabin/global/index.h @@ -41,6 +41,7 @@ typedef struct _hash_entry { uchar_t cksum[1]; } hash_entry_t; + archive_config_t *init_global_db(char *configfile); int setup_db_config_s(archive_config_t *cfg, uint32_t chunksize, uint64_t *user_chunk_sz, int *pct_interval, const char *algo, cksum_t ck, cksum_t ck_sim, diff --git a/utils/utils.c b/utils/utils.c index c74eb3e..ca7f47d 100644 --- a/utils/utils.c +++ b/utils/utils.c @@ -45,15 +45,15 @@ #include #include -#ifndef __APPLE__ -#include -#else +#ifdef __APPLE__ #include #include #include #include static mach_timebase_info_data_t sTimebaseInfo; +#else +#include #endif #define _IN_UTILS_ @@ -637,6 +637,17 @@ is_incompressible(int type) return (ic); } +int +file_exists(char *path) +{ + FILE *fh = fopen(path, "r"); + if (fh != NULL) { + fclose(fh); + return (1); + } + return (0); +} + /************************************************************ * Portability wrappers for synchronization primitives. ***********************************************************/ diff --git a/utils/utils.h b/utils/utils.h index f9e6135..749be94 100644 --- a/utils/utils.h +++ b/utils/utils.h @@ -348,6 +348,7 @@ extern int chk_dir(char *dir); extern void init_algo_props(algo_props_t *props); extern void init_pcompress(); extern char *get_temp_dir(); +extern int file_exists(char *path); /* Pointer type for compress and decompress functions. */ typedef int (*compress_func_ptr)(void *src, uint64_t srclen, void *dst,