X-Git-Url: http://git.vrable.net/?a=blobdiff_plain;f=store.h;h=656659db62762e4639d5eee1d7b13a4806b1a6b3;hb=682c41cb7eeb03676a44e3d51891d57e5e16bb48;hp=d44703140281ff6f5943ad916266f43bba48ecf1;hpb=d38558b79c81f446698c272a85f1a2782667bce3;p=cumulus.git diff --git a/store.h b/store.h index d447031..656659d 100644 --- a/store.h +++ b/store.h @@ -1,7 +1,24 @@ -/* LBS: An LFS-inspired filesystem backup system - * Copyright (C) 2006 Michael Vrable +/* Cumulus: Smart Filesystem Backup to Dumb Servers * - * Backup data is stored in a collection of objects, which are grouped together + * Copyright (C) 2006-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. + */ + +/* Backup data is stored in a collection of objects, which are grouped together * into segments for storage purposes. This implementation of the object store * represents segments as TAR files and objects as files within them. */ @@ -18,6 +35,7 @@ #include #include "localdb.h" +#include "remote.h" #include "sha1.h" #include "ref.h" @@ -69,7 +87,7 @@ struct tar_header * first; incremental writing is not supported. */ class Tarfile { public: - Tarfile(const std::string &path, const std::string &segment); + Tarfile(RemoteFile *file, const std::string &segment); ~Tarfile(); void write_object(int id, const char *data, size_t len); @@ -81,6 +99,8 @@ private: size_t size; std::string segment_name; + RemoteFile *file; + /* Filter support. */ int real_fd, filter_fd; pid_t filter_pid; @@ -92,9 +112,9 @@ private: class TarSegmentStore { public: // New segments will be stored in the given directory. - TarSegmentStore(const std::string &path, + TarSegmentStore(RemoteStore *remote, LocalDb *db = NULL) - { this->path = path; this->db = db; } + { this->remote = remote; this->db = db; } ~TarSegmentStore() { sync(); } // Writes an object to segment in the store, and returns the name @@ -113,14 +133,15 @@ public: private: struct segment_info { Tarfile *file; + std::string group; std::string name; // UUID int count; // Objects written to this segment int size; // Combined size of objects written std::string basename; // Name of segment without directory - std::string fullname; // Full path to stored segment + RemoteFile *rf; }; - std::string path; + RemoteStore *remote; std::map segments; LocalDb *db;