Compare commits

...

5 commits

Author SHA1 Message Date
CismonX
5a28b069c4
fs_ops: fix file size opened with O_CREAT|O_TRUNC
Also make sure that new regular files always have a size of zero.
2025-04-29 14:48:39 +08:00
CismonX
83f201435f
backend_firefox: add keyword xattr
This allows users to quickly discover which keyword is
associated with a given bookmark.

Updating keywords via xattr is not implemented,
since it can be done trivially using existing API.
2025-04-29 12:46:29 +08:00
CismonX
0e20604c73
backend_firefox: fix stmt id for keyword delete 2025-04-28 20:04:40 +08:00
CismonX
9c0d5fb337
test: improve filesystem tests
- Add a final check to see whether the fs daemon is still there.
- Other misc updates.
2025-04-07 19:32:44 +08:00
CismonX
565063ee9b
chore: bump version to 0.1.1 2025-04-07 12:23:50 +08:00
8 changed files with 32 additions and 11 deletions

View file

@ -8,7 +8,7 @@ dnl This file is offered as-is, without any warranty.
dnl
AC_PREREQ([2.70])
AC_INIT([bookmarkfs], [0.1.0], [bug-bookmarkfs@nongnu.org])
AC_INIT([bookmarkfs], [0.1.1], [bug-bookmarkfs@nongnu.org])
AC_CONFIG_SRCDIR([bookmarkfs_util.pc.in])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])

View file

@ -1358,6 +1358,12 @@ The bookmark creation time.
Value is a decimal integer representing number of microseconds since
the Unix epoch.
@item keyword
The keyword associated with the bookmark.
@xref{Keywords}.
This attribute is read-only.
@end table
Notable limitations:

View file

@ -59,6 +59,7 @@
#define BM_XATTR_TITLE 2
#define BM_XATTR_GUID 3
#define BM_XATTR_DATE_ADDED 4
#define BM_XATTR_KEYWORD 5
#define MOZBM_XATTR_START BM_XATTR_TITLE
#define BACKEND_EXCLUSIVE_LOCK ( 1u << 16 )
@ -397,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;
@ -1086,7 +1086,7 @@ mozkw_delete (
char const *name,
size_t name_len
) {
sqlite3_stmt **stmt_ptr = &ctx->stmts[STMT_MOZKW_RENAME];
sqlite3_stmt **stmt_ptr = &ctx->stmts[STMT_MOZKW_DELETE];
char const *sql = "DELETE FROM `moz_keywords` "
"WHERE `keyword` = ? RETURNING `place_id`";
@ -2092,7 +2092,10 @@ bookmark_do_get (
#define BOOKMARK_GET_(cols, join) "SELECT CASE ? " cols "END " \
"FROM `moz_bookmarks` `b` " join "WHERE `b`.`id` = ?"
#define BOOKMARK_GET(cols) BOOKMARK_GET_(cols \
"WHEN " STRINGIFY(BM_XATTR_DATE_ADDED) " THEN `b`.`dateAdded` ", )
"WHEN " STRINGIFY(BM_XATTR_DATE_ADDED) " THEN `b`.`dateAdded` " \
"WHEN " STRINGIFY(BM_XATTR_KEYWORD) " THEN " \
"(SELECT `keyword` FROM `moz_keywords` `k` " \
"WHERE `k`.`place_id` = `b`.`fk`) ", )
#define BOOKMARK_GET_EX BOOKMARK_GET_( \
"WHEN " STRINGIFY(BM_XATTR_NULL) " THEN `p`.`url` " \
"WHEN " STRINGIFY(BM_XATTR_DESC) " THEN `p`.`description` " \
@ -2637,6 +2640,9 @@ get_xattr_id (
return BM_XATTR_GUID;
}
}
if (0 == strcmp("keyword", name)) {
return BM_XATTR_KEYWORD;
}
return -1;
}
@ -2942,9 +2948,9 @@ backend_create (
resp_flags |= BOOKMARKFS_BACKEND_EXCLUSIVE;
}
char const *xattr_names = "guid\0date_added\0description\0";
char const *xattr_names = "guid\0date_added\0description\0keyword\0";
if (opts.flags & BACKEND_FILENAME_GUID) {
xattr_names = "title\0date_added\0description\0";
xattr_names = "title\0date_added\0description\0keyword\0";
}
resp->name = "firefox";
@ -3724,6 +3730,9 @@ bookmark_set (
}
break;
case BM_XATTR_KEYWORD:
return -EPERM;
default:
return -ENOATTR;
}

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;
}

View file

@ -27,7 +27,7 @@
#define BOOKMARKFS_VER_MAJOR 0
#define BOOKMARKFS_VER_MINOR 1
#define BOOKMARKFS_VER_PATCH 0
#define BOOKMARKFS_VER_PATCH 1
#define bookmarkfs_make_vernum(major, minor, patch) \
( ((major) << 16) | ((minor) << 8) | ((patch) << 0) )

View file

@ -122,7 +122,7 @@ do_check_fs_regrw (
#ifndef O_DIRECT
# define O_DIRECT 0
#endif
int fd = open(path, O_RDWR | O_TRUNC | O_DIRECT);
int fd = open(path, O_RDWR | O_CREAT | O_TRUNC | O_DIRECT);
ASSERT_NE(-1, fd);
struct stat stat_buf;

View file

@ -19,7 +19,6 @@ ATX_CHECK_FS_NEW_ANY([file_max=524288], [
echo "prng seed: $seed"
ATX_RUN([
touch $name
check-fs regrw -n 524288 -s "$seed" $name
])
])

View file

@ -139,6 +139,7 @@ m4_define([ATX_CHECK_FS], [
fi
done
$6
ATX_RUN_ONE([check-fs ismount "$4"])
], [
umount "$4"
])