#ifndef DRSNAP_H #define DRSNAP_H class SUPERBLOCK; class SNAPFILE: public ARRAY_OBJ{ SSTRING dir; // Directory holding the data file SSTRING map; // Classification map SSTRING branch; // Logical name of the branch int rev; // Sequence number SSTRING path; // Full path of the data file unsigned *bitmap; // Tell if a chunk is contain is this snapshot unsigned bitmapsize; SNAPFILE *parent; int fd; unsigned long long size; // Volume size bool root; // This is the original volume. No bitmap // needed bool in_use; // Only one client per data file /*~PROTOBEG~ SNAPFILE */ public: SNAPFILE (const char *_dir, const char *_map, const char *_branch, int _rev); void bitmap_or (SNAPFILE *common, unsigned *res); int checkrange (unsigned long long from, int len); private: int copy_from_parent (unsigned long long from, int len); int copy_on_write (unsigned long long from, int len); public: unsigned getbitmapsize (void)const; void getbranchname (SSTRING&_branch)const; void getmap (SSTRING&_map)const; const char *getpath (void)const; int getrevision (void)const; unsigned long long getsize (void)const; bool is_inuse (void)const; bool is_ok (void); bool is_root (void)const; private: int raw_read (unsigned long long from, int len, int tofd); public: int read (unsigned long long from, int len, int tofd); private: int read_part (unsigned long long from, int len, int tofd); public: int readsb (SUPERBLOCK&sb); private: int seek (unsigned long long from); public: void set_inuse (void); void setparent (SNAPFILE *_parent); void setsize (unsigned long long _size); void setsize_fromfile (void); SNAPFILE *snap (const char suffix, const char *newbranch); SNAPFILE *snap (void); void unset_inuse (void); int write (unsigned long long from, const char *buf, int len); ~SNAPFILE (void); /*~PROTOEND~ SNAPFILE */ }; typedef ARRAY_OBJS SNAPFILES; #include "drsnap.p" #endif