aboutsummaryrefslogtreecommitdiff
path: root/text.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2020-09-28 15:50:52 +0200
committerMarc André Tanner <mat@brain-dump.org>2020-10-10 10:03:17 +0200
commitbaf7f5e5b25ec0e818ff189f2031e3688add96e7 (patch)
tree44cb59752180f55ae4c88544b10d0e7f05232bc7 /text.c
parent6c13d745ca6f1760f875cea2d4342115e95dcf9c (diff)
downloadvis-baf7f5e5b25ec0e818ff189f2031e3688add96e7.tar.gz
vis-baf7f5e5b25ec0e818ff189f2031e3688add96e7.tar.xz
text: use public text_stat interface where possible
Diffstat (limited to 'text.c')
-rw-r--r--text.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/text.c b/text.c
index d99c0e5..6857b13 100644
--- a/text.c
+++ b/text.c
@@ -986,14 +986,15 @@ static bool text_save_commit_atomic(TextSave *ctx) {
static bool text_save_begin_inplace(TextSave *ctx) {
Text *txt = ctx->txt;
- struct stat meta = { 0 };
+ struct stat now = { 0 };
int newfd = -1, saved_errno;
if ((ctx->fd = openat(ctx->dirfd, ctx->filename, O_CREAT|O_WRONLY, 0666)) == -1)
goto err;
- if (fstat(ctx->fd, &meta) == -1)
+ if (fstat(ctx->fd, &now) == -1)
goto err;
+ struct stat loaded = text_stat(txt);
Block *block = array_get_ptr(&txt->blocks, 0);
- if (meta.st_dev == txt->info.st_dev && meta.st_ino == txt->info.st_ino &&
+ if (now.st_dev == loaded.st_dev && now.st_ino == loaded.st_ino &&
block && block->type == MMAP_ORIG && block->size) {
/* The file we are going to overwrite is currently mmap-ed from
* text_load, therefore we copy the mmap-ed block to a temporary