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