Commit graph

186 commits

Author SHA1 Message Date
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
CismonX
3422d68193
backend: allow bad system time in readonly mode
In readonly mode, we're not using the current time as timestamp,
thus a bad system time won't hurt.

Also in Chromium backend, use zero timestamp for the bookmark root
dir, to accomodate this change (no one cares about it anyway).
2025-03-23 14:56:16 +08:00
CismonX
03b638408d
test: more comments and log output 2025-03-22 11:38:59 +08:00
CismonX
2024008373
frontend_util: fix usage of xasprintf()
Expressions with side effects should not be passed as arguments,
since they may be used multiple times.
2025-03-22 10:53:04 +08:00
CismonX
827ed94f6d
doc: misc update 2025-03-21 12:57:01 +08:00
CismonX
a2dda5ec84
build: hard fail on unsupported platforms
Attempting to build on an unsupported platform should trigger
an error instead of a warning.
2025-03-21 09:06:30 +08:00
CismonX
750c16077c
backend: prevent timestamp overflow
When updating timestamps, make sure that the corresponding
microsecond value fits in a single signed 64-bit integer,
so that it won't result in an integer overflow, which is UB.

Also forbid timestamps before the Unix epoch, since working with
negative time_t is problematic.

This check does not apply to current timestamp, however,
add a check on backend startup to ensure sane system time.

There's no need to validate `tv_nsec`, since the kernel already
does that for us.
2025-03-20 12:46:11 +08:00
CismonX
09e186b348
fs_ops: fix setattr 2025-03-20 12:21:47 +08:00
CismonX
e0d2aa2058
backend: refactor bookmark_set() for timestamps
Do not expose UTIME_OMIT to backends, but instead specify
which timestamps to update with flags.

This allows us to further refactor backend code, especially
the Chromium backend.
2025-03-20 12:14:59 +08:00
CismonX
d36c070ef2
backend_chromium: refactor parse_ts()
We only need to parse a single integer.
There's no chance that a 64-bit integer cannot hold a valid timestamp.
2025-03-20 10:11:35 +08:00
CismonX
00f40beec7
xstd: add helper function for getting current time
Also, don't bother with failed clock_gettime() calls.
2025-03-19 21:26:27 +08:00
CismonX
d7c7ec0174
bookmarkctl: xattr: misc refactor 2025-03-19 12:25:30 +08:00
CismonX
b96ed2a490
doc: add docs for bookmarkctl xattr-* sub-commands 2025-03-18 06:19:59 +08:00
CismonX
db0ca276b1
bookmarkctl: xattr-get: replace -N option with -qq
The `-N` option does not make sense without `-q`,
so we replace it with a second `-q`.
2025-03-18 06:08:30 +08:00
CismonX
4be158c988
fsck_util: rename: escape -> translit
In the `escape_control_chars()` function, we're not actually
"escaping" the characters, just replacing them.
2025-03-17 12:45:40 +08:00
CismonX
00ae9dbccb
doc: update docs for the utility library
- Correct the time complexity of hash table insert.
- Explain more about hash table limitation regarding collisions.
2025-03-16 12:48:58 +08:00
CismonX
18bfbc73da
test: fix helper program
In commit 68aafe3d8d, we forgot to update the code in
the helper test program, which also uses these macros.
2025-03-16 11:53:54 +08:00
CismonX
552a5797dc
doc: refactor style 2025-03-16 11:32:32 +08:00
CismonX
7ae2b283c3
bookmarkctl: add sub-commands for xattr
Provides platform-agnostic command-line interface for managing
extended attributes on a BookmarkFS filesystem.
2025-03-15 17:25:26 +08:00
CismonX
402cc1a304
doc: misc update (mostly style improvements) 2025-03-14 08:20:33 +08:00
CismonX
f6e3b743d1
build: rename autoconf helper macros
These macros are supposed to be reusable for other projects.
Also, a shorter name improves the readability of the config script.
2025-03-14 07:44:51 +08:00
CismonX
2ce0be8a18
bookmarkctl: better handling of command-line args 2025-03-13 14:45:10 +08:00
CismonX
68aafe3d8d
frontend: add helper macros for getopt() 2025-03-13 07:55:35 +08:00
CismonX
bd343ddf4b
backend_firefox: fix integer parsing 2025-03-12 17:22:54 +08:00
CismonX
0a4ff8770e
backend_firefox: misc refactor
- Follow the "best practice" in the SQLite manual, where calls to
  sqlite3_column_bytes() should come after sqlite3_column_text().
  This change does not affect the values returned.
- Other misc updates.
2025-03-11 16:22:29 +08:00
CismonX
08b9ea81d6
doc: misc update 2025-03-11 10:33:31 +08:00
CismonX
48b1d8c98d
backend_firefox: tombstone for deleted bookmarks
If a bookmark is assigned SYNC_STATUS_NORMAL (value 2),
a "tombstone" has to be inserted upon deletion,
so that the browser could purge it from remote.
2025-03-10 14:40:26 +08:00
CismonX
217e185496
backend_firefox: temp ts buffer for usecs_now() 2025-03-09 16:27:09 +08:00
CismonX
85b02f6c2b
backend_firefox, fs_ops: store hashcode in entry
Trade a bit of memory for hashmap rehash/remove efficiency.
2025-03-09 15:44:29 +08:00
CismonX
3e6bcb8b4f
backend_firefox: set bookmark initial sync status
New bookmarks should be assigned SYNC_STATUS_NEW (value 1).
2025-03-09 14:21:13 +08:00
CismonX
0b317c2727
test: misc refactor 2025-03-09 11:35:17 +08:00
CismonX
ca43bc6939
test: add tests for hashmap 2025-03-08 13:52:57 +08:00
CismonX
aed846b286
test: extract common prng helpers for future use 2025-03-08 13:50:47 +08:00
CismonX
1ed607de69
hashmap: tidy up log messages 2025-03-08 13:44:38 +08:00
CismonX
9fab17734c
chore: misc cleanup 2025-03-07 14:35:45 +08:00
CismonX
cadde0b61e
doc: update docs for the utility library
Move documentation for the hash table from source code comments
to the user manual.
2025-03-06 10:33:15 +08:00
CismonX
c2a91d6420
hashmap: refactor interface
- `hashmap_insert()` no longer takes key as argument, and
  takes the pointer to be associated with the entry as argument.
- Rename `hashmap_entry_delete` -> `hashmap_delete`.
- Make `user_data` the first argument for `hashmap_walk_func`.
- Other misc renames.
2025-03-06 06:40:28 +08:00
CismonX
b585a05c91
chore: remove null pointer representation check
That part of code in configure.ac look stupid, remove it.

If we _do_ try to run BookmarkFS on such an exotic platform with
non-zero null pointers, the breakage should be detected by the tests
(if it can run or even build at all).
2025-03-05 16:43:00 +08:00
CismonX
1836692719
test: disable LSAN for sandbox tests
since they do not play well with seccomp and landlock
2025-03-05 13:36:38 +08:00
CismonX
29be925c92
test: ATX_FEAT_NAME -> ATX_FEAT_VAR
Since we're only using the feature variables in shell expansion,
using this form should make the testsuite code look cleaner.
2025-03-05 07:34:40 +08:00
CismonX
95121cb78f
test: add helper macro ATX_RUN
This is meant to be a workaround for a limitation of Autotest,
where `set -e` has no effect in AT_CHECK().

Also we don't want to use `trap ... ERR`, since it is not portable.
2025-03-05 07:01:34 +08:00
CismonX
9050d01fe4
test: add tests for sandbox 2025-03-04 12:05:17 +08:00
CismonX
182967497d
sandbox: various fix and improvements
- Workaround a glibc issue for filtering negative syscall arguments.
- Allow unlinkat() syscall.
- Add extra filter for openat() in read-only mode when Landlock
  is not available.
2025-03-04 11:29:04 +08:00
CismonX
31192fc715
test: refactor watcher tests 2025-03-03 13:55:08 +08:00
CismonX
f6ff129f23
test: check-bookmarkfs-util -> check-util-lib 2025-03-03 09:21:26 +08:00
CismonX
97ddb47cc8
test: refactor tests
- Output more error message.
- Improve conditional tests for watcher.
2025-03-02 12:45:11 +08:00
CismonX
b8d03f008c
doc: add chapter for the utility library
Move the documentation of the following library components
from source code comments to the user manual:

- hash
- prng
- sandbox
- watcher
2025-03-02 11:18:34 +08:00
CismonX
b1100445b7
watcher: misc fix
- The initial `impl_rearm()` should always be performed by the
  worker thread, so that we won't get spurious zero returns from
  `watcher_poll()`.
- Sandboxing should not be implicitly disabled if not implemented.
- Shift internal watcher flags, to save space for public ones
  if we wish to add any in the future.
2025-03-02 06:54:06 +08:00
CismonX
8cbd5846d9
chore: tidy up 2025-03-01 23:40:34 +08:00