fs_ops: fix file size opened with O_CREAT|O_TRUNC

Also make sure that new regular files always have a size of zero.
This commit is contained in:
CismonX 2025-04-29 14:48:39 +08:00
parent 83f201435f
commit 5a28b069c4
No known key found for this signature in database
GPG key ID: 3094873E29A482FB
2 changed files with 8 additions and 3 deletions

View file

@ -398,9 +398,8 @@ bookmark_do_create (
stat_buf->value_len = -1;
int64_t place_id = 0;
if (!is_dir) {
char const *url = "about:blank";
stat_buf->value_len = strlen(url);
status = mozplace_addref(ctx, url, stat_buf->value_len, &place_id,
stat_buf->value_len = 0;
status = mozplace_addref(ctx, STR_WITHLEN("about:blank"), &place_id,
&stat_buf->atime);
if (status < 0) {
return status;

View file

@ -409,6 +409,12 @@ bm_create (
}
}
if (flags & O_TRUNC) {
// See bm_open() for comments on O_RDONLY|O_TRUNC.
if ((flags & O_ACCMODE) != O_RDONLY) {
stat.value_len = 0;
}
}
bm_fillstat(&stat, SUBSYS_TYPE_BOOKMARK, false, stat_buf);
return 0;
}