Home | History | Annotate | Download | only in rawbu

Lines Matching defs:fh

169 static int write_int32(FILE* fh, int32_t val)
171 int res = fwrite(&val, 1, sizeof(val), fh);
180 static int write_int64(FILE* fh, int64_t val)
182 int res = fwrite(&val, 1, sizeof(val), fh);
231 static int write_header(FILE* fh, int type, const char* path, const struct stat* st)
234 if (!write_int32(fh, type)) return 0;
235 if (!write_int32(fh, pathLen)) return 0;
236 if (fwrite(path, 1, pathLen, fh) != (size_t)pathLen) {
241 if (!write_int32(fh, st->st_uid)) return 0;
242 if (!write_int32(fh, st->st_gid)) return 0;
243 if (!write_int32(fh, st->st_mode)) return 0;
244 if (!write_int64(fh, ((int64_t)st->st_atime)*1000*1000*1000)) return 0;
245 if (!write_int64(fh, ((int64_t)st->st_mtime)*1000*1000*1000)) return 0;
246 if (!write_int64(fh, ((int64_t)st->st_ctime)*1000*1000*1000)) return 0;
251 static int backup_dir(FILE* fh, const char* srcPath)
314 if (write_header(fh, TYPE_DIR, fullPath, &statBuffer) == 0) {
318 if (backup_dir(fh, fullPath) == 0) {
325 if (write_header(fh, TYPE_FILE, fullPath, &statBuffer) == 0) {
331 if (!write_int64(fh, size)) {
344 int copyres = copy_file(fh, src, size, NULL, fullPath);
367 FILE* fh = fopen(destPath, "w");
368 if (fh == NULL) {
376 if (!write_int32(fh, FILE_VERSION)) goto done;
377 if (!write_int32(fh, opt_backupAll)) goto done;
378 if (!backup_dir(fh, "/data")) goto done;
379 if (!write_int32(fh, 0)) goto done;
384 if (fflush(fh) != 0) {
390 if (fsync(fileno(fh)) != 0) {
396 fclose(fh);
403 static int32_t read_int32(FILE* fh, int32_t defVal)
406 if (fread(&val, 1, sizeof(val), fh) != sizeof(val)) {
414 static int64_t read_int64(FILE* fh, int64_t defVal)
417 if (fread(&val, 1, sizeof(val), fh) != sizeof(val)) {
425 static int read_header(FILE* fh, int* type, char** path, struct stat* st)
427 *type = read_int32(fh, -1);
437 int32_t pathLen = read_int32(fh, -1);
443 if (fread(readPath, 1, pathLen, fh) != (size_t)pathLen) {
451 st->st_uid = read_int32(fh, -1);
456 st->st_gid = read_int32(fh, -1);
461 st->st_mode = read_int32(fh, -1);
466 int64_t ltime = read_int64(fh, -1);
472 ltime = read_int64(fh, -1);
478 ltime = read_int64(fh, -1);
494 FILE* fh = fopen(srcPath, "r");
495 if (fh == NULL) {
501 inputFileVersion = read_int32(fh, 0);
508 opt_backupAll = read_int32(fh, 0);
523 if (read_header(fh, &type, &path, &statBuffer) == 0) {
548 off_t size = read_int64(fh, -1);
565 int copyres = copy_file(dest, fh, size, path, NULL);
610 fclose(fh);