BackupPC-XS
view release on metacpan or search on metacpan
void bpc_digest_append_ext(bpc_digest *digest, uint32 ext);
void bpc_digest_digest2str(bpc_digest *digest, char *hexStr);
void bpc_digest_str2digest(bpc_digest *digest, char *hexStr);
int bpc_digest_compare(bpc_digest *digest1, bpc_digest *digest2);
void bpc_digest_md52path(char *path, int compress, bpc_digest *digest);
void bpc_digest_md52path_v3(char *path, int compress, bpc_digest *digest);
void bpc_digest_buffer2MD5_v3(bpc_digest *digest, uchar *buffer, size_t bufferLen);
void bpc_fileNameEltMangle(char *path, int pathSize, char *pathUM);
void bpc_fileNameMangle(char *path, int pathSize, char *pathUM);
void bpc_logMsgf(char *fmt, ...);
void bpc_logErrf(char *fmt, ...);
void bpc_logMsgGet(char **mesg, size_t *mesgLen);
void bpc_logMsgErrorCntGet(unsigned long *errorCnt);
void bpc_logMsgCBSet(void (*cb)(int errFlag, char *mesg, size_t mesgLen));
/*
* Compute file digest
*/
int bpc_fileDigest(char *fileName, int compress, bpc_digest *digest);
/*
* Directory operations
*/
int bpc_path_create(char *path);
int bpc_path_remove(bpc_deltaCount_info *deltaInfo, char *path, int compress);
int bpc_path_refCountAll(bpc_deltaCount_info *deltaInfo, char *path, int compress, int incr);
int bpc_path_refCountAllInodeMax(bpc_deltaCount_info *deltaInfo, char *path, int compress, int incr, unsigned int *inodeMax);
int bpc_lockRangeFd(int fd, OFF_T offset, OFF_T len, int block);
int bpc_unlockRangeFd(int fd, OFF_T offset, OFF_T len);
int bpc_lockRangeFile(char *lockFile, OFF_T offset, OFF_T len, int block);
void bpc_unlockRangeFile(int lockFd);
/*
* File attribs
*/
typedef struct {
bpc_hashtable_key key;
void *value;
uint32 valueLen;
} bpc_attrib_xattr;
typedef struct {
bpc_hashtable_key key;
char *name;
ushort type;
ushort compress;
/*
* isTemp is set if this is a temporary attribute entry (eg: mkstemp), that
* doesn't have referencing counting for the digest. Therefore, when a
* temporary file is created or deleted, there is no change to the
* reference counts.
*/
ushort isTemp;
uint32 mode;
uid_t uid;
gid_t gid;
uint32 nlinks;
time_t mtime;
OFF_T size;
ino_t inode;
int32 backupNum;
bpc_digest digest;
/*
* hash table of bpc_attrib_xattr entries, indexed by xattr key
*/
bpc_hashtable xattrHT;
} bpc_attrib_file;
/*
* A directory is a hash table of file attributes, indexed by file name
*/
typedef struct {
bpc_digest digest;
ushort compress;
ushort needRewrite;
/*
* hash table of bpc_attrib_file entries, indexed by file name
*/
bpc_hashtable filesHT;
} bpc_attrib_dir;
bpc_attrib_xattr *bpc_attrib_xattrGet(bpc_attrib_file *file, void *key, int keyLen, int allocate_if_missing);
void bpc_attrib_xattrDestroy(bpc_attrib_xattr *xattr);
int bpc_attrib_xattrDelete(bpc_attrib_file *file, void *key, int keyLen);
int bpc_attrib_xattrDeleteAll(bpc_attrib_file *file);
int bpc_attrib_xattrSetValue(bpc_attrib_file *file, void *key, int keyLen, void *value, uint32 valueLen);
int bpc_attrib_xattrCount(bpc_attrib_file *file);
size_t bpc_attrib_xattrList(bpc_attrib_file *file, char *list, size_t listLen, int ignoreRsyncACLs);
void bpc_attrib_fileInit(bpc_attrib_file *file, char *fileName, int xattrNumEntries);
void bpc_attrib_fileDestroy(bpc_attrib_file *file);
bpc_attrib_file *bpc_attrib_fileGet(bpc_attrib_dir *dir, char *fileName, int allocate_if_missing);
int bpc_attrib_fileIterate(bpc_attrib_dir *dir, bpc_attrib_file **file, uint *idx);
void bpc_attrib_fileCopyOpt(bpc_attrib_file *fileDest, bpc_attrib_file *fileSrc, int overwriteEmptyDigest);
void bpc_attrib_fileCopy(bpc_attrib_file *fileDest, bpc_attrib_file *fileSrc);
int bpc_attrib_fileCompare(bpc_attrib_file *file0, bpc_attrib_file *file1);
void bpc_attrib_fileDeleteName(bpc_attrib_dir *dir, char *fileName);
int bpc_attrib_fileCount(bpc_attrib_dir *dir);
char *bpc_attrib_fileType2Text(int type);
void bpc_attrib_dirInit(bpc_attrib_dir *dir, int compressLevel);
void bpc_attrib_dirDestroy(bpc_attrib_dir *dir);
int bpc_attrib_dirNeedRewrite(bpc_attrib_dir *dir);
ssize_t bpc_attrib_getEntries(bpc_attrib_dir *dir, char *entries, ssize_t entrySize);
void bpc_attrib_dirRefCount(bpc_deltaCount_info *deltaInfo, bpc_attrib_dir *dir, int incr);
void bpc_attrib_dirRefCountInodeMax(bpc_deltaCount_info *deltaInfo, bpc_attrib_dir *dir, int incr, unsigned int *inodeMax);
void bpc_attrib_attribFilePath(char *path, char *dir, char *attribFileName);
bpc_digest *bpc_attrib_dirDigestGet(bpc_attrib_dir *dir);
uchar *bpc_attrib_buf2file(bpc_attrib_file *file, uchar *buf, uchar *bufEnd, int xattrNumEntries, int *xattrFixup);
uchar *bpc_attrib_buf2fileFull(bpc_attrib_file *file, uchar *buf, uchar *bufEnd);
uchar *bpc_attrib_file2buf(bpc_attrib_file *file, uchar *buf, uchar *bufEnd);
int bpc_attrib_digestRead(bpc_attrib_dir *dir, bpc_digest *digest, char *attribPath);
int bpc_attrib_dirRead(bpc_attrib_dir *dir, char *dirPath, char *attribFileName, int backupNum);
int bpc_attrib_dirWrite(bpc_deltaCount_info *deltaInfo, bpc_attrib_dir *dir, char *dirPath, char *attribFileName, bpc_digest *oldDigest);
void bpc_attrib_backwardCompat(int writeOldStyleAttribFile, int keepOldAttribFiles);
/*
* Attrib caching
*/
#define BPC_FTYPE_FILE (0)
#define BPC_FTYPE_HARDLINK (1)
#define BPC_FTYPE_SYMLINK (2)
#define BPC_FTYPE_CHARDEV (3)
#define BPC_FTYPE_BLOCKDEV (4)
#define BPC_FTYPE_DIR (5)
#define BPC_FTYPE_FIFO (6)
#define BPC_FTYPE_SOCKET (8)
#define BPC_FTYPE_UNKNOWN (9)
#define BPC_FTYPE_DELETED (10)
#define BPC_FTYPE_INVALID (11)
typedef struct {
int num;
int compress;
int version;
} bpc_backup_info;
typedef struct {
int backupNum;
int compress;
int readOnly;
uint cacheLruCnt;
/*
* optional merging of backups to create view for restore
*/
bpc_backup_info *bkupMergeList;
int bkupMergeCnt;
/*
* Hash table of cached file attributes.
* Key is the mangled attrib path (excluding backupTopDir[], and including attrib file name).
* Value is a bpc_attrib_dir structure.
* - Keys of the bpc_attrib_dir hash table are the file names in that directory.
*/
bpc_hashtable attrHT;
/*
* Hash table of cached inode attributes.
* Key is the inode attribute path (excluding backupTopDir[]).
* Value is a bpc_attrib_dir structure.
* - Keys of the bpc_attrib_dir hash table are the inode numbers converted to ascii hex, lsb first.
*/
bpc_hashtable inodeHT;
/*
* Delta reference count for any changes as we write/change files or attributes
*/
bpc_deltaCount_info *deltaInfo;
char shareName[BPC_MAXPATHLEN];
int shareNameLen;
char shareNameUM[BPC_MAXPATHLEN];
char hostName[BPC_MAXPATHLEN];
char hostDir[BPC_MAXPATHLEN];
char backupTopDir[BPC_MAXPATHLEN];
char currentDir[BPC_MAXPATHLEN];
} bpc_attribCache_info;
typedef struct {
bpc_hashtable_key key;
int dirty;
/*
* We flag directories whose parents either don't exist or aren't directories.
* We ignore attributes on bad directories.
* Initially this flag is zero, meaning we don't know if this directory is ok.
* After we check, > 0 means parent does exist and is a directory ; < 0 means dir is bad
*/
int dirOk;
uint lruCnt;
bpc_attrib_dir dir;
} bpc_attribCache_dir;
void bpc_attribCache_init(bpc_attribCache_info *ac, char *host, int backupNum, char *shareNameUM, int compress);
void bpc_attribCache_setDeltaInfo(bpc_attribCache_info *ac, bpc_deltaCount_info *deltaInfo);
void bpc_attribCache_setMergeList(bpc_attribCache_info *ac, bpc_backup_info *bkupList, int bkupCnt);
void bpc_attribCache_destroy(bpc_attribCache_info *ac);
int bpc_attribCache_readOnly(bpc_attribCache_info *ac, int readOnly);
void bpc_attribCache_setCurrentDirectory(bpc_attribCache_info *ac, char *dir);
bpc_attrib_file *bpc_attribCache_getFile(bpc_attribCache_info *ac, char *path, int allocate_if_missing, int dontReadInode);
int bpc_attribCache_setFile(bpc_attribCache_info *ac, char *path, bpc_attrib_file *file, int dontOverwriteInode);
int bpc_attribCache_deleteFile(bpc_attribCache_info *ac, char *path);
bpc_attrib_file *bpc_attribCache_getInode(bpc_attribCache_info *ac, ino_t inode, int allocate_if_missing);
int bpc_attribCache_setInode(bpc_attribCache_info *ac, ino_t inode, bpc_attrib_file *inodeSrc);
int bpc_attribCache_deleteInode(bpc_attribCache_info *ac, ino_t inode);
int bpc_attribCache_getDirEntryCnt(bpc_attribCache_info *ac, char *path);
ssize_t bpc_attribCache_getDirEntries(bpc_attribCache_info *ac, char *path, char *entries, ssize_t entrySize);
void bpc_attribCache_flush(bpc_attribCache_info *ac, int all, char *path);
void bpc_attribCache_getFullMangledPath(bpc_attribCache_info *ac, char *path, char *dirName, int backupNum);
#endif
( run in 1.595 second using v1.01-cache-2.11-cpan-39bf76dae61 )