mirror of
https://git.sr.ht/~cismonx/bookmarkfs
synced 2025-06-07 19:58:50 +00:00
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:
parent
83f201435f
commit
5a28b069c4
2 changed files with 8 additions and 3 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue