1 /* LBS: An LFS-inspired filesystem backup system
2 * Copyright (C) 2007-2008 Michael Vrable
4 * Handling of metadata written to backup snapshots. This manages the writing
5 * of file metadata into new backup snapshots, including breaking the metadata
6 * log apart across separate objects. Eventually this should include unified
7 * handling of the statcache, and re-use of metadata between snapshots.
10 #ifndef _LBS_METADATA_H
11 #define _LBS_METADATA_H
14 #include <sys/types.h>
24 extern bool flag_full_metadata;
26 /* Metadata for a single inode, ready to be written out. */
35 class MetadataWriter {
37 MetadataWriter(TarSegmentStore *store, const char *path,
38 const char *snapshot_name, const char *snapshot_scheme);
39 void add(dictionary info);
40 ObjectReference close();
42 bool find(const std::string& path);
43 ObjectReference old_ref() const {
44 return ObjectReference::parse(old_metadata_loc);
47 bool is_unchanged(const struct stat *stat_buf);
49 dictionary get_old_metadata() const { return old_metadata; }
50 std::list<ObjectReference> get_blocks();
51 std::string get_checksum() { return old_metadata["checksum"]; }
54 void metadata_flush();
55 void read_statcache();
57 // Where are objects eventually written to?
58 TarSegmentStore *store;
60 // File descriptors for reading/writing local statcache data
61 std::string statcache_path, statcache_tmp_path;
62 FILE *statcache_in, *statcache_out;
64 // Metadata not yet written out to the segment store
66 std::list<MetadataItem> items;
67 std::ostringstream metadata_root;
69 // Statcache information read back in from a previous run
70 bool old_metadata_eof;
71 dictionary old_metadata;
72 std::string old_metadata_loc; // Reference to where the metadata is found
75 #endif // _LBS_METADATA_H