Home | History | Annotate | Download | only in rawbu

Lines Matching refs:fh

168 static int write_int32(FILE* fh, int32_t val)
170 int res = fwrite(&val, 1, sizeof(val), fh);
179 static int write_int64(FILE* fh, int64_t val)
181 int res = fwrite(&val, 1, sizeof(val), fh);
230 static int write_header(FILE* fh, int type, const char* path, const struct stat* st)
233 if (!write_int32(fh, type)) return 0;
234 if (!write_int32(fh, pathLen)) return 0;
235 if (fwrite(path, 1, pathLen, fh) != (size_t)pathLen) {
240 if (!write_int32(fh, st->st_uid)) return 0;
241 if (!write_int32(fh, st->st_gid)) return 0;
242 if (!write_int32(fh, st->st_mode)) return 0;
243 if (!write_int64(fh, ((int64_t)st->st_atime)*1000*1000*1000)) return 0;
244 if (!write_int64(fh, ((int64_t)st->st_mtime)*1000*1000*1000)) return 0;
245 if (!write_int64(fh, ((int64_t)st->st_ctime)*1000*1000*1000)) return 0;
250 static int backup_dir(FILE* fh, const char* srcPath)
313 if (write_header(fh, TYPE_DIR, fullPath, &statBuffer) == 0) {
317 if (backup_dir(fh, fullPath) == 0) {
324 if (write_header(fh, TYPE_FILE, fullPath, &statBuffer) == 0) {
330 if (!write_int64(fh, size)) {
343 int copyres = copy_file(fh, src, size, NULL, fullPath);
366 FILE* fh = fopen(destPath, "w");
367 if (fh == NULL) {
375 if (!write_int32(fh, FILE_VERSION)) goto done;
376 if (!write_int32(fh, opt_backupAll)) goto done;
377 if (!backup_dir(fh, "/data")) goto done;
378 if (!write_int32(fh, 0)) goto done;
383 if (fflush(fh) != 0) {
389 if (fsync(fileno(fh)) != 0) {
395 fclose(fh);
402 static int32_t read_int32(FILE* fh, int32_t defVal)
405 if (fread(&val, 1, sizeof(val), fh) != sizeof(val)) {
413 static int64_t read_int64(FILE* fh, int64_t defVal)
416 if (fread(&val, 1, sizeof(val), fh) != sizeof(val)) {
424 static int read_header(FILE* fh, int* type, char** path, struct stat* st)
426 *type = read_int32(fh, -1);
436 int32_t pathLen = read_int32(fh, -1);
442 if (fread(readPath, 1, pathLen, fh) != (size_t)pathLen) {
450 st->st_uid = read_int32(fh, -1);
455 st->st_gid = read_int32(fh, -1);
460 st->st_mode = read_int32(fh, -1);
465 int64_t ltime = read_int64(fh, -1);
471 ltime = read_int64(fh, -1);
477 ltime = read_int64(fh, -1);
493 FILE* fh = fopen(srcPath, "r");
494 if (fh == NULL) {
500 inputFileVersion = read_int32(fh, 0);
507 opt_backupAll = read_int32(fh, 0);
522 if (read_header(fh, &type, &path, &statBuffer) == 0) {
547 off_t size = read_int64(fh, -1);
564 int copyres = copy_file(dest, fh, size, path, NULL);
609 fclose(fh);