mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 16:37:19 +09:00
import: enable sparse file writing logic only for files we create
Only if we create a file we know for sure that it is empty and hence our sparse file logic of skipping over NUL bytes can can work. If we hwoever are called to write data to some existing file/block device, we must do regular writes to override everything that might be in place before. Hence, conditionalize sparse file writing on the write offset not being configured (which is how we internally distinguish write to existing file and write to new file)
This commit is contained in:
@@ -368,7 +368,7 @@ static int raw_import_write(const void *p, size_t sz, void *userdata) {
|
||||
}
|
||||
|
||||
/* Generate sparse file if we created/truncated the file */
|
||||
if (S_ISREG(i->output_stat.st_mode)) {
|
||||
if (S_ISREG(i->output_stat.st_mode) && i->offset == UINT64_MAX) {
|
||||
ssize_t n;
|
||||
|
||||
n = sparse_write(i->output_fd, p, sz, 64);
|
||||
|
||||
@@ -306,7 +306,7 @@ static int pull_job_write_uncompressed(const void *p, size_t sz, void *userdata)
|
||||
|
||||
if (j->disk_fd >= 0) {
|
||||
|
||||
if (S_ISREG(j->disk_stat.st_mode)) {
|
||||
if (S_ISREG(j->disk_stat.st_mode) && j->offset == UINT64_MAX) {
|
||||
ssize_t n;
|
||||
|
||||
n = sparse_write(j->disk_fd, p, sz, 64);
|
||||
|
||||
Reference in New Issue
Block a user