X-Git-Url: https://git.saurik.com/apple/hfs.git/blobdiff_plain/a56bdb9dd68c843a17a0658b5250e0cc67c22fe8..246784f7dc26d498d36b5dbe514331e0b88c00c2:/CopyHFSMeta/SparseBundle.c diff --git a/CopyHFSMeta/SparseBundle.c b/CopyHFSMeta/SparseBundle.c index e342d47..1ac5a68 100644 --- a/CopyHFSMeta/SparseBundle.c +++ b/CopyHFSMeta/SparseBundle.c @@ -10,6 +10,7 @@ #include #include +#include #include "hfsmeta.h" #include "Sparse.h" @@ -59,6 +60,21 @@ static const char *bundlePrototype = "\n" "\n"; +/* + * Do a per-volume sync. We use this just before updating the progress file, so + * that any changes -- data and metadata -- will have made it to disk, without + * causing a sync of every mounted volume. + * + */ + +static void +sync_volume(const char *path) { + int full_sync = FSCTL_SYNC_FULLSYNC | FSCTL_SYNC_WAIT; + + (void)fsctl(path, FSCTL_SYNC_VOLUME, &full_sync, 0); + return; +} + /* * Read from a sparse bundle. If the band file doesn't exist, or is shorter than * what we need to get from it, we pad out with 0's. @@ -156,7 +172,6 @@ doSparseWrite(IOWrapper_t *context, off_t offset, void *buffer, size_t len) retval = -1; goto done; } - (void)fcntl(fd, F_FULLFSYNC, 0); written += nwritten; } retval = written; @@ -326,6 +341,7 @@ SetProgress(struct IOWrapper *context, off_t prog) } else { fp = fopen(progFile, "w"); if (fp) { + sync_volume(ctx->pathname); (void)fprintf(fp, "%llu\n", prog); fclose(fp); }