X-Git-Url: http://git.vrable.net/?p=cumulus.git;a=blobdiff_plain;f=metadata.h;h=28778c76b37dabe3725672e67060b9f94ae6f7cc;hp=f86244c251da7a12f25b5aa59dc2c583a6462dc1;hb=f38dd9bcb0caffd3fc9126b05788c936690e8288;hpb=6cefd6f6bb0c87697930ec6c378353a289f1c867 diff --git a/metadata.h b/metadata.h index f86244c..28778c7 100644 --- a/metadata.h +++ b/metadata.h @@ -1,7 +1,24 @@ -/* LBS: An LFS-inspired filesystem backup system - * Copyright (C) 2007 Michael Vrable +/* Cumulus: Smart Filesystem Backup to Dumb Servers * - * Handling of metadata written to backup snapshots. This manages the writing + * Copyright (C) 2007-2008 The Regents of the University of California + * Written by Michael Vrable + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/* Handling of metadata written to backup snapshots. This manages the writing * of file metadata into new backup snapshots, including breaking the metadata * log apart across separate objects. Eventually this should include unified * handling of the statcache, and re-use of metadata between snapshots. @@ -11,6 +28,8 @@ #define _LBS_METADATA_H #include +#include +#include #include #include #include @@ -19,33 +38,55 @@ #include "ref.h" #include "util.h" +extern bool flag_full_metadata; + /* Metadata for a single inode, ready to be written out. */ struct MetadataItem { int offset; std::string text; + + bool reused; + ObjectReference ref; }; class MetadataWriter { public: MetadataWriter(TarSegmentStore *store, const char *path, const char *snapshot_name, const char *snapshot_scheme); - void add(const std::string& path, dictionary info); + void add(dictionary info); ObjectReference close(); + bool find(const std::string& path); + ObjectReference old_ref() const { + return ObjectReference::parse(old_metadata_loc); + } + + bool is_unchanged(const struct stat *stat_buf); + + dictionary get_old_metadata() const { return old_metadata; } + std::list get_blocks(); + std::string get_checksum() { return old_metadata["checksum"]; } + private: void metadata_flush(); + void read_statcache(); // Where are objects eventually written to? TarSegmentStore *store; // File descriptors for reading/writing local statcache data std::string statcache_path, statcache_tmp_path; - FILE *statcache_out; + FILE *statcache_in, *statcache_out; // Metadata not yet written out to the segment store size_t chunk_size; std::list items; std::ostringstream metadata_root; + + // Statcache information read back in from a previous run + bool old_metadata_eof; + dictionary old_metadata; + std::string old_metadata_loc; // Reference to where the metadata is found }; #endif // _LBS_METADATA_H