1 /* LBS: An LFS-inspired filesystem backup system
2 * Copyright (C) 2007 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
22 /* Metadata for a single inode, ready to be written out. */
31 class MetadataWriter {
33 MetadataWriter(TarSegmentStore *store, const char *path,
34 const char *snapshot_name, const char *snapshot_scheme);
35 void add(dictionary info);
36 ObjectReference close();
38 bool find(const std::string& path);
39 ObjectReference *old_ref() const {
40 return ObjectReference::parse(old_metadata_loc);
43 dictionary get_old_metadata() const { return old_metadata; }
46 void metadata_flush();
47 void read_statcache();
49 // Where are objects eventually written to?
50 TarSegmentStore *store;
52 // File descriptors for reading/writing local statcache data
53 std::string statcache_path, statcache_tmp_path;
54 FILE *statcache_in, *statcache_out;
56 // Metadata not yet written out to the segment store
58 std::list<MetadataItem> items;
59 std::ostringstream metadata_root;
61 // Statcache information read back in from a previous run
62 bool old_metadata_eof;
63 dictionary old_metadata;
64 std::string old_metadata_loc; // Reference to where the metadata is found
67 #endif // _LBS_METADATA_H