1 /* Cumulus: Smart Filesystem Backup to Dumb Servers
3 * Copyright (C) 2007-2008 The Regents of the University of California
4 * Written by Michael Vrable <mvrable@cs.ucsd.edu>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 /* Handling of metadata written to backup snapshots. This manages the writing
22 * of file metadata into new backup snapshots, including breaking the metadata
23 * log apart across separate objects. Eventually this should include unified
24 * handling of the statcache, and re-use of metadata between snapshots.
27 #ifndef _LBS_METADATA_H
28 #define _LBS_METADATA_H
31 #include <sys/types.h>
41 extern bool flag_full_metadata;
43 /* Metadata for a single inode, ready to be written out. */
52 class MetadataWriter {
54 MetadataWriter(TarSegmentStore *store, const char *path,
55 const char *snapshot_name, const char *snapshot_scheme);
56 void add(dictionary info);
57 ObjectReference close();
59 bool find(const std::string& path);
60 ObjectReference old_ref() const {
61 return ObjectReference::parse(old_metadata_loc);
64 bool is_unchanged(const struct stat *stat_buf);
66 dictionary get_old_metadata() const { return old_metadata; }
67 std::list<ObjectReference> get_blocks();
68 std::string get_checksum() { return old_metadata["checksum"]; }
71 void metadata_flush();
72 void read_statcache();
74 // Where are objects eventually written to?
75 TarSegmentStore *store;
77 // File descriptors for reading/writing local statcache data
78 std::string statcache_path, statcache_tmp_path;
79 FILE *statcache_in, *statcache_out;
81 // Metadata not yet written out to the segment store
83 std::list<MetadataItem> items;
84 std::ostringstream metadata_root;
86 // Statcache information read back in from a previous run
87 bool old_metadata_eof;
88 dictionary old_metadata;
89 std::string old_metadata_loc; // Reference to where the metadata is found
92 #endif // _LBS_METADATA_H