Commit graph

234 commits

Author SHA1 Message Date
CismonX
dad1984d7f
build: move bookmarkfs_util.pc.in to ./src
Whatever pkg-config is interested in all lies within ./src.
2025-06-18 16:13:07 +08:00
CismonX
9de097d9ee
build: refactor configuration scripts
- Move common `AC_DEFINE()` usage to `EX_FEAT()`.
- Remove unused argument `action-if-disabled` for `EX_FEAT()`.
- Conditionally enable features by default.
2025-06-17 13:41:17 +08:00
CismonX
fb0d39dfc3
defs: remove HAVE_PIPE2 macro
This feature check is only used in `xpipe2()`.
2025-06-17 12:24:08 +08:00
CismonX
99ac2b79f8
test: misc fix and refactor 2025-06-16 18:32:36 +08:00
CismonX
ba9a23c295
backend_firefox: refactor db query utils
- `DO_QUERY()` macro:
  * Pass stmt idx as argument instead of pointer.
  * Remove the `BEFORE_QUERY` argument.
- Shorter names for stmt idx.
2025-06-16 11:22:53 +08:00
CismonX
31f4311419
backend_firefox: misc refactor
- `mozorigin_get()`, `mozplace_addref()`: pass struct as argument.
- `parse_mozurl_host()`: rename to `parse_mozurl`; add comments;
  store parse results to argument of type `struct mozorigin`.
- Rename objects of type `struct mozXXX` from `XXX_cols` to `mX`.
- ...
2025-06-15 17:45:52 +08:00
CismonX
6fc165ff65
all: properly handle time_t on 32-bit platforms
Do not force 64-bit `time_t` on 32-bit platforms, since libfuse
does not do so.  Linking shared objects with incompatible types
breaks ABI, resulting in undefined behavior.

Instead, add run-time checks to make sure that timestamps do not
overflow.  If they do, set to `INT32_MAX`.

Also tidy up build scripts, tests, and the installation guide.
2025-06-14 11:43:03 +08:00
CismonX
f1451d206e
chore: bump version to 0.1.2 2025-06-12 11:31:39 +08:00
CismonX
303c934894
test: misc refactor
- If the utility library is not built, link to the existing library
  when building helper programs for filesystem tests.
- Refactor PRNG seeding in tests.
2025-06-11 20:45:16 +08:00
CismonX
14b5a79147
build: fix builds with existing utility library
Regression in commit 81db7a786c.
2025-06-11 17:11:19 +08:00
CismonX
1e5149cdc0
doc: misc corrections and improvements 2025-06-10 21:17:37 +08:00
CismonX
6f2a00dd6f
fs_ops: refactor setattr
- Only perform one operation per call.
- Always fail with EPERM if given unsupported flags.
2025-06-09 19:51:25 +08:00
CismonX
c23623b5a3
test: add tests for file atime/mtime 2025-06-08 12:34:10 +08:00
CismonX
fdfd6fe069
backend_firefox: fix directory attr update 2025-06-08 07:24:39 +08:00
CismonX
5082e7c67c
fs_ops: fix mtime update of regular files
Explicit mtime update (e.g., via futimens(2)) should override
file handle mtime.
2025-06-07 19:55:27 +08:00
CismonX
72b9e200d9
fs_ops: misc refactor
- Use nodeid for fh_map keys as well as bm_*() and intfs_*() args.
- bm_readdir(), fs_op_rename(): check subsys type more gracefully.
- ...
2025-06-07 08:57:48 +08:00
CismonX
29338ca02b
backend_firefox: purge dangling refs on delete
When a bookmark is deleted, if there are no other bookmarks
referencing the corresponding `moz_place` entry, tag and keyword
references to that entry are considered "dangling" references,
and shall be automatically removed.

Also reverts commit b5fa6960ef,
since the NULL title check is no longer necessary.
2025-06-06 22:46:44 +08:00
CismonX
eb426f9fc4
bookmarkctl: xattr-get: rename -m option to -a 2025-06-06 19:41:09 +08:00
CismonX
b5fa6960ef
backend_firefox: hide dangling keywords
When a bookmark associated with a keyword is deleted,
there may still be dangling references (e.g., tags) to the
corresponding `moz_places` entry.

By filtering out NULL titles, `bookmark_lookup()` and
`bookmark_list()` now only give keywords associated with
valid bookmarks.
2025-06-05 08:27:59 +08:00
CismonX
6fb9438d3c
fs_ops: fix opendir for keyword directory 2025-06-05 07:39:53 +08:00
CismonX
c1cf9db2a1
test: add tests for tags and keywords 2025-06-02 09:20:19 +08:00
CismonX
495f8592e6
fs_ops: fix deletion of tag directories 2025-06-02 08:41:33 +08:00
CismonX
d5eae85774
test: refactor filesystem tests 2025-06-01 21:35:07 +08:00
CismonX
ab88e0e839
test: add tests for directory entries 2025-05-28 18:51:02 +08:00
CismonX
e6809b7e84
xstd: add xgetdents() 2025-05-28 18:27:55 +08:00
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
CismonX
763bba9444
backend_firefox: fix bookmark_check()
Regression in commit 85b02f6c2b.
2025-04-03 10:23:54 +08:00
CismonX
5ad23ac8f6
hashmap: allow rehash failure
There is a chance that rehash may fail,
even with a decent hash function, and no collision attack.

Allow the hashmap to be rehashed for a second time during insert,
and ignore rehash failures during delete.
2025-04-03 09:51:09 +08:00
CismonX
52b7f87536
test: add tests for regular file read/write 2025-04-02 18:09:09 +08:00
CismonX
1e047a9331
test: misc refactor
- Move common defs and helper functions to check_util.h/check_utils.c.
- Add a prepare script argument for ATX_CHECK_FS* macros.
- ASSERT_EXPR_INT(): Use long int as expression result type.
- Other misc updates.
2025-04-01 22:01:44 +08:00
CismonX
81db7a786c
build: rename bookmarkfs.pc -> bookmarkfs_util.pc
Also update configure_ext.m4 to support EX_DEP() with underscores
in package name.
2025-04-01 12:49:21 +08:00
CismonX
906769f1f7
doc: misc corrections and improvements 2025-03-31 21:30:47 +08:00
CismonX
159c2c7625
fsck_util: improve fsck output format
Now the built-in fsck handler and `bookmarkctl fsck` produces
output that is both parsable and human-readable.

Also document the output format in the user manual.
2025-03-30 14:10:31 +08:00
CismonX
cbda096f44
ci: setup FUSE on Alpine build
Unlike distros using systemd, FUSE is not enabled by default on Alpine.

To setup FUSE manually:
1. modprobe fuse
2. mount -t fusectl fusectl /sys/fs/fuse/connections
3. chmod 666 /dev/fuse

Normal users may prefer using OpenRC services to automate these steps,
which is what we do in this patch.

Also install the umount program from util-linux, since the busybox one
does not support unprivileged dismount for FUSE.
2025-03-29 19:27:13 +08:00
CismonX
f20cd2cf74
ci: fix FreeBSD and Alpine builds
- Apply workaround for libiconv on FreeBSD.
- Disable tcc bounds checking (`tcc -b`) on Alpine, since it requires
  manually linking to /usr/lib/tcc/bcheck.o (in package tcc-dev).
  No need to bother with it.  Such checks are better covered with ASAN
  on Debian and Arch Linux builds.
2025-03-29 17:47:18 +08:00
CismonX
63d8b8e213
backend_firefox: fix sqlite version compatibility
In commit 348f13df02, we replaced
`length(url)` with `octet_length(url)`.
However, `octet_length` was added in SQLite 3.43, while we claim to
support SQLite 3.35 and later.

Stable GNU/Linux distros like Debian may still be using pre-3.43
releases of SQLite, so don't bump that version too soon.
Instead, use `length(CAST(url AS BLOB))`, which is a bit less
efficient than `octet_length(url)`, but O(1) nonetheless.
2025-03-29 16:14:10 +08:00
CismonX
1bbe928e50
test: add basic tests for filesystem 2025-03-29 15:20:04 +08:00
CismonX
c9ccc4f6df
backend_chromium: fix use-after-free
It's a regression in commit bdfa812d79.
2025-03-29 13:22:52 +08:00
CismonX
44100f8852
test: add test harness for filesystem 2025-03-28 16:39:29 +08:00
CismonX
9da346753d
test: misc refactor
- Repeat simple tests that may fail upon multiple invocations.
- ...
2025-03-28 14:29:18 +08:00
CismonX
bdfa812d79
backend: respect the BOOKMARK_DELETE_DIR flag
Following commit 2e3685f217,
make sure all backends check this flag and return correct error codes.

Normally this is not mandatory, since the kernel looks up
the directory entry to be removed, and fails if the system call
is inappropriate (e.g., calling rmdir() on a regular file).
This happens before FUSE_UNLINK or FUSE_RMDIR is sent to the server.

However, when not in exclusive mode, there is a short window that
TOCTOU problem may occur, which may lead to undesired behavior
(e.g., deletion of a non-empty directory) or even the corruption of
bookmark storage if not properly checked.

Also explain this flag in the user manual.
2025-03-27 12:36:27 +08:00
CismonX
86c7af8f6f
doc: explain exlusive mode in backend API docs
Add add cross references when appropriate.
2025-03-27 12:12:30 +08:00
CismonX
2e3685f217
backend_firefox: fix directory deletion
Also reverts commit fef7b4d3a8.

The DELETE_DIR flag is in fact useful, but bookmark_delete()
incorrectly checked CREATE_DIR instead.
2025-03-26 19:03:00 +08:00
CismonX
bd80cbf2c1
frontend: silently ignore empty subopts 2025-03-25 12:19:11 +08:00
CismonX
bced141b98
test: misc fix and refactor
- Do not exit with status 99.  It is considered a "hard failure"
  in Autotest, and cleanup script won't be executed.
- Fix ATX_FEAT_PREREQ().
- Remove unneeded helper macros.
- Add more log output.
2025-03-24 19:30:32 +08:00
CismonX
7b5ed129be
doc: misc update 2025-03-24 10:35:35 +08:00