mirror of
https://git.sr.ht/~cismonx/bookmarkfs
synced 2025-07-23 17:48:52 +00:00
build: refactor EX_FEAT() helper macro
- Rename local m4 definitions with `ex_` prefix. - Rename AC_DEFINE() definitions with `ENABLE_` prefix. - Remove flag `N`, use `Y` only.
This commit is contained in:
parent
96c1835512
commit
1d00501355
23 changed files with 132 additions and 135 deletions
16
configure.ac
16
configure.ac
|
@ -39,16 +39,16 @@ AC_PROG_MAKE_SET
|
|||
|
||||
# -- Checks for features --
|
||||
|
||||
EX_FEAT([bookmarkctl], [NE], [the bookmarkctl program])
|
||||
EX_FEAT([bookmarkctl], [E], [the bookmarkctl program])
|
||||
|
||||
EX_FEAT([bookmarkfs-fsck], [NE], [the fsck.bookmarkfs program], [
|
||||
EX_FEAT([bookmarkfs-fsck], [E], [the fsck.bookmarkfs program], [
|
||||
AS_VAR_SET([enable_bookmarkfs_util], [yes])
|
||||
AS_VAR_SET([enable_interactive_fsck], [yes])
|
||||
])
|
||||
|
||||
EX_FEAT([bookmarkfs-mkfs], [NE], [the mkfs.bookmarkfs program])
|
||||
EX_FEAT([bookmarkfs-mkfs], [E], [the mkfs.bookmarkfs program])
|
||||
|
||||
EX_FEAT([bookmarkfs-mount], [NE], [the mount.bookmarkfs program], [
|
||||
EX_FEAT([bookmarkfs-mount], [E], [the mount.bookmarkfs program], [
|
||||
AS_VAR_SET([enable_bookmarkfs_util], [yes])
|
||||
])
|
||||
|
||||
|
@ -60,16 +60,16 @@ AS_VAR_IF([host_os], [linux], [
|
|||
|
||||
EX_FEAT([xxhash-inline], [YD], [using xxhash as a header-only library])
|
||||
|
||||
EX_FEAT([bookmarkfs-debug], [ND], [debugging features for BookmarkFS])
|
||||
EX_FEAT([bookmarkfs-debug], [D], [debugging features for BookmarkFS])
|
||||
|
||||
EX_FEAT([backend-firefox], [NE], [Firefox backend], [
|
||||
EX_FEAT([backend-firefox], [E], [Firefox backend], [
|
||||
AS_VAR_SET([enable_bookmarkfs_util], [yes])
|
||||
AS_VAR_SET([enable_backend_firefox_write], [yes])
|
||||
])
|
||||
|
||||
EX_FEAT([backend-firefox-write], [DE], [write support for the Firefox backend])
|
||||
|
||||
EX_FEAT([backend-chromium], [NE], [Chromium backend], [
|
||||
EX_FEAT([backend-chromium], [E], [Chromium backend], [
|
||||
AS_VAR_SET([enable_bookmarkfs_util], [yes])
|
||||
AS_VAR_SET([enable_backend_chromium_write], [yes])
|
||||
])
|
||||
|
@ -81,7 +81,7 @@ EX_FEAT([native-watcher], [YD], [platform-specific file watcher])
|
|||
|
||||
EX_FEAT([interactive-fsck], [DE], [interactive features for fsck.bookmarkfs])
|
||||
|
||||
EX_FEAT([fsck-handler-tcl], [NE], [Tcl-based fsck handler])
|
||||
EX_FEAT([fsck-handler-tcl], [E], [Tcl-based fsck handler])
|
||||
|
||||
EX_FEAT([bookmarkfs-util], [E], [the BookmarkFS utility library], [
|
||||
EX_DEP([bookmarkfs_util], [>= 0.1], [BookmarkFS utility library], [
|
||||
|
|
|
@ -12,39 +12,36 @@ dnl EX_FEAT(feat-name, flags, feat-desc, [action-if-enabled])
|
|||
dnl
|
||||
dnl Provide an option to enable or disable a feature.
|
||||
dnl
|
||||
dnl flags:
|
||||
dnl - N: Disable this feature by default
|
||||
dnl Flags:
|
||||
dnl - Y: Enable this feature by default
|
||||
dnl - D: When enabled, define a macro for this feature in config.h
|
||||
dnl - E: When enabled, export this feature with AM_CONDITIONAL()
|
||||
dnl
|
||||
AC_DEFUN([EX_FEAT], [
|
||||
m4_pushdef([op_], m4_if(m4_index([$2], [N]), [-1], [disable], [enable]))
|
||||
m4_pushdef([feat_name_], m4_translit([$1], [-], [_]))
|
||||
AC_MSG_CHECKING(m4_normalize([if $3 is enabled]))
|
||||
AC_ARG_ENABLE([$1], [AS_HELP_STRING([--]op_[-$1], op_ [$3])], , [
|
||||
m4_pushdef([ex_op], m4_if(m4_index([$2], [Y]), [-1], [enable], [disable]))
|
||||
m4_pushdef([ex_feat], m4_translit([$1], [-], [_]))
|
||||
AC_ARG_ENABLE([$1], [AS_HELP_STRING([--]ex_op[-$1], ex_op [$3])], , [
|
||||
m4_if(m4_index([$2], [Y]), [-1], , [
|
||||
AS_VAR_SET([enable_]feat_name_, [yes])
|
||||
AS_VAR_SET([enable_]ex_feat, [yes])
|
||||
])
|
||||
])
|
||||
AS_VAR_IF([enable_]feat_name_, [yes], [
|
||||
m4_popdef([ex_op])
|
||||
AS_VAR_IF([enable_]ex_feat, [yes], [
|
||||
AC_MSG_RESULT([yes])
|
||||
$4
|
||||
m4_if(m4_index([$2], [D]), [-1], , [
|
||||
AC_DEFINE(m4_if(m4_substr(feat_name_, 0, 10), [bookmarkfs], ,
|
||||
[BOOKMARKFS_])[]m4_toupper(feat_name_),
|
||||
[1], [Define to 1 if $3 is enabled.])
|
||||
AC_DEFINE([ENABLE_]m4_toupper(ex_feat), [1],
|
||||
[Define to 1 if $3 is enabled.])
|
||||
])
|
||||
], [
|
||||
AC_MSG_RESULT([no])
|
||||
])
|
||||
m4_if(m4_index([$2], [E]), [-1], , [
|
||||
AM_CONDITIONAL(m4_translit(feat_name_, [a-z], [A-Z]),
|
||||
[test x$enable_]feat_name_[ != xno])
|
||||
AM_CONDITIONAL(m4_toupper(ex_feat), [test "x$enable_]ex_feat[" != xno])
|
||||
])
|
||||
AS_VAR_SET([desc_]feat_name_, ["$3"])
|
||||
m4_popdef([op_])
|
||||
m4_popdef([feat_name_])
|
||||
AS_VAR_SET([desc_]ex_feat, ["$3"])
|
||||
m4_popdef([ex_feat])
|
||||
])
|
||||
|
||||
dnl
|
||||
|
@ -62,18 +59,18 @@ AC_DEFUN([EX_DEP], [
|
|||
[pkg-config search path for $3])
|
||||
]), , [
|
||||
AS_VAR_SET([with_$1], [no])
|
||||
m4_ifnblank([$5], m4_foreach([feat_name_], [m4_shiftn(4, $@)], [
|
||||
AS_VAR_IF([enable_]m4_translit(feat_name_, [-], [_]), [yes], [
|
||||
m4_ifnblank([$5], m4_foreach([ex_feat], [m4_shiftn(4, $@)], [
|
||||
AS_VAR_IF([enable_]m4_translit(ex_feat, [-], [_]), [yes], [
|
||||
AS_VAR_SET([with_$1], [yes])
|
||||
])
|
||||
]))
|
||||
])
|
||||
AS_VAR_IF([with_$1], [no], [
|
||||
m4_ifnblank([$5], m4_foreach([feat_name_], [m4_shiftn(4, $@)], [
|
||||
AS_VAR_IF([enable_]m4_translit(feat_name_, [-], [_]), [yes], [
|
||||
m4_ifnblank([$5], m4_foreach([ex_feat], [m4_shiftn(4, $@)], [
|
||||
AS_VAR_IF([enable_]m4_translit(ex_feat, [-], [_]), [yes], [
|
||||
AC_MSG_ERROR(m4_normalize([
|
||||
Bad option '[--without-]feat_name_'. The $3 is mandatory
|
||||
for AS_VAR_GET([desc_]m4_translit(feat_name_, [-], [_])).
|
||||
Bad option '[--without-]ex_feat'. The $3 is mandatory
|
||||
for AS_VAR_GET([desc_]m4_translit(ex_feat, [-], [_])).
|
||||
]))
|
||||
])
|
||||
]))
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
#include <iconv.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef BOOKMARKFS_BACKEND_CHROMIUM_WRITE
|
||||
#ifdef ENABLE_BACKEND_CHROMIUM_WRITE
|
||||
# include <nettle/base16.h>
|
||||
# include <nettle/md5.h>
|
||||
#endif
|
||||
|
@ -118,11 +118,11 @@ struct backend_ctx {
|
|||
json_t *roots;
|
||||
json_t *fake_root;
|
||||
|
||||
#ifdef BOOKMARKFS_BACKEND_CHROMIUM_WRITE
|
||||
#ifdef ENABLE_BACKEND_CHROMIUM_WRITE
|
||||
uint64_t max_id;
|
||||
iconv_t cd;
|
||||
enum dirty_level dirty;
|
||||
#endif /* defined(BOOKMARKFS_BACKEND_CHROMIUM_WRITE) */
|
||||
#endif /* defined(ENABLE_BACKEND_CHROMIUM_WRITE) */
|
||||
|
||||
int dirfd;
|
||||
char const *name;
|
||||
|
@ -148,7 +148,7 @@ struct build_node_ctx {
|
|||
struct bookmarkfs_bookmark_stat *stat_buf;
|
||||
};
|
||||
|
||||
#ifdef BOOKMARKFS_BACKEND_CHROMIUM_WRITE
|
||||
#ifdef ENABLE_BACKEND_CHROMIUM_WRITE
|
||||
struct chksum_iter_ctx {
|
||||
struct md5_ctx mdctx;
|
||||
iconv_t cd;
|
||||
|
@ -161,7 +161,7 @@ struct idmap_iter_ctx {
|
|||
struct hashmap *id_map;
|
||||
struct hashmap *guid_map;
|
||||
struct hashmap *assoc_map;
|
||||
#ifdef BOOKMARKFS_BACKEND_CHROMIUM_WRITE
|
||||
#ifdef ENABLE_BACKEND_CHROMIUM_WRITE
|
||||
uint64_t max_id;
|
||||
#endif
|
||||
};
|
||||
|
@ -188,7 +188,7 @@ struct parsed_mkfsopts {
|
|||
};
|
||||
|
||||
// Forward declaration start
|
||||
#ifdef BOOKMARKFS_BACKEND_CHROMIUM_WRITE
|
||||
#ifdef ENABLE_BACKEND_CHROMIUM_WRITE
|
||||
static int build_node (struct backend_ctx *, json_t *, char const **,
|
||||
size_t, bool, struct build_node_ctx *);
|
||||
static int build_node_guid (json_t *, struct hashmap const *, uint8_t *,
|
||||
|
@ -209,7 +209,7 @@ static int store_new (struct timespec const *, json_t **);
|
|||
static int store_save (struct backend_ctx *);
|
||||
static void update_guid (struct node_entry *, struct hashmap *,
|
||||
unsigned long, uint8_t *, unsigned long);
|
||||
#endif /* defined(BOOKMARKFS_BACKEND_CHROMIUM_WRITE) */
|
||||
#endif /* defined(ENABLE_BACKEND_CHROMIUM_WRITE) */
|
||||
|
||||
static int assocmap_comp (union hashmap_key, void const *);
|
||||
static unsigned long
|
||||
|
@ -262,7 +262,7 @@ static void print_version (void);
|
|||
static int store_load (struct backend_ctx *);
|
||||
// Forward declaration end
|
||||
|
||||
#ifdef BOOKMARKFS_BACKEND_CHROMIUM_WRITE
|
||||
#ifdef ENABLE_BACKEND_CHROMIUM_WRITE
|
||||
|
||||
static int
|
||||
build_node (
|
||||
|
@ -684,7 +684,7 @@ update_guid (
|
|||
memcpy(entry->guid, guid, UUID_LEN);
|
||||
}
|
||||
|
||||
#endif /* defined(BOOKMARKFS_BACKEND_CHROMIUM_WRITE) */
|
||||
#endif /* defined(ENABLE_BACKEND_CHROMIUM_WRITE) */
|
||||
|
||||
static int
|
||||
assocmap_comp (
|
||||
|
@ -764,7 +764,7 @@ build_maps (
|
|||
ctx->id_map = id_map;
|
||||
ctx->guid_map = guid_map;
|
||||
ctx->assoc_map = assoc_map;
|
||||
#ifdef BOOKMARKFS_BACKEND_CHROMIUM_WRITE
|
||||
#ifdef ENABLE_BACKEND_CHROMIUM_WRITE
|
||||
ctx->max_id = iter_ctx.max_id;
|
||||
#endif
|
||||
json_decref(ctx->fake_root);
|
||||
|
@ -1278,11 +1278,11 @@ maps_iter_cb (
|
|||
hashmap_insert(assoc_map, hashcode_assoc, entry);
|
||||
|
||||
end:
|
||||
#ifdef BOOKMARKFS_BACKEND_CHROMIUM_WRITE
|
||||
#ifdef ENABLE_BACKEND_CHROMIUM_WRITE
|
||||
if (id > ctx->max_id) {
|
||||
ctx->max_id = id;
|
||||
}
|
||||
#endif /* defined(BOOKMARKFS_BACKEND_CHROMIUM_WRITE) */
|
||||
#endif /* defined(ENABLE_BACKEND_CHROMIUM_WRITE) */
|
||||
*parent_data_ptr = entry;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1500,7 +1500,7 @@ print_version (void)
|
|||
{
|
||||
printf("bookmarkfs-backend-chromium %d.%d.%d\n",
|
||||
BOOKMARKFS_VER_MAJOR, BOOKMARKFS_VER_MINOR, BOOKMARKFS_VER_PATCH);
|
||||
puts(BOOKMARKFS_FEATURE_STRING(DEBUG, "debug"));
|
||||
puts(BOOKMARKFS_FEATURE_STRING(BOOKMARKFS_DEBUG, "debug"));
|
||||
puts(BOOKMARKFS_FEATURE_STRING(BACKEND_CHROMIUM_WRITE, "write"));
|
||||
|
||||
bookmarkfs_print_lib_version("\n");
|
||||
|
@ -1518,13 +1518,13 @@ store_load (
|
|||
goto do_load;
|
||||
}
|
||||
|
||||
#ifdef BOOKMARKFS_BACKEND_CHROMIUM_WRITE
|
||||
#ifdef ENABLE_BACKEND_CHROMIUM_WRITE
|
||||
// Prioritize client-side modification to the store.
|
||||
// Changes made by other processes will be lost.
|
||||
if (ctx->dirty > DIRTY_LEVEL_NONE) {
|
||||
return 0;
|
||||
}
|
||||
#endif /* defined(BOOKMARKFS_BACKEND_CHROMIUM_WRITE) */
|
||||
#endif /* defined(ENABLE_BACKEND_CHROMIUM_WRITE) */
|
||||
|
||||
switch (watcher_poll(watcher)) {
|
||||
case -EAGAIN:
|
||||
|
@ -1577,7 +1577,7 @@ store_load (
|
|||
ctx->store = store;
|
||||
ctx->checksum = checksum;
|
||||
|
||||
#ifdef BOOKMARKFS_BACKEND_CHROMIUM_WRITE
|
||||
#ifdef ENABLE_BACKEND_CHROMIUM_WRITE
|
||||
if (!(ctx->flags & BOOKMARKFS_BACKEND_READONLY)) {
|
||||
ctx->dirty = DIRTY_LEVEL_NONE;
|
||||
}
|
||||
|
@ -1595,17 +1595,17 @@ backend_create (
|
|||
struct bookmarkfs_backend_create_resp *resp
|
||||
) {
|
||||
if (!(conf->flags & BOOKMARKFS_BACKEND_READONLY)) {
|
||||
#ifdef BOOKMARKFS_BACKEND_CHROMIUM_WRITE
|
||||
#ifdef ENABLE_BACKEND_CHROMIUM_WRITE
|
||||
struct timespec now;
|
||||
xgetrealtime(&now);
|
||||
if (!valid_ts_sec(now.tv_sec)) {
|
||||
log_puts("bad system time");
|
||||
return -1;
|
||||
}
|
||||
#else /* !defined(BOOKMARKFS_BACKEND_CHROMIUM_WRITE) */
|
||||
#else /* !defined(ENABLE_BACKEND_CHROMIUM_WRITE) */
|
||||
log_puts("write support is not enabled on this build");
|
||||
return -1;
|
||||
#endif /* defined(BOOKMARKFS_BACKEND_CHROMIUM_WRITE) */
|
||||
#endif /* defined(ENABLE_BACKEND_CHROMIUM_WRITE) */
|
||||
}
|
||||
|
||||
struct parsed_mntopts opts = { 0 };
|
||||
|
@ -1646,7 +1646,7 @@ backend_create (
|
|||
*ctx = (struct backend_ctx) {
|
||||
.name = name,
|
||||
.dirfd = dirfd,
|
||||
#ifdef BOOKMARKFS_BACKEND_CHROMIUM_WRITE
|
||||
#ifdef ENABLE_BACKEND_CHROMIUM_WRITE
|
||||
.cd = (iconv_t)-1,
|
||||
#endif
|
||||
.flags = conf->flags | opts.other_flags,
|
||||
|
@ -1680,7 +1680,7 @@ backend_destroy (
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef BOOKMARKFS_BACKEND_CHROMIUM_WRITE
|
||||
#ifdef ENABLE_BACKEND_CHROMIUM_WRITE
|
||||
if (!(ctx->flags & BOOKMARKFS_BACKEND_READONLY)) {
|
||||
store_save(ctx);
|
||||
}
|
||||
|
@ -1740,7 +1740,7 @@ backend_sandbox (
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifdef BOOKMARKFS_BACKEND_CHROMIUM_WRITE
|
||||
#ifdef ENABLE_BACKEND_CHROMIUM_WRITE
|
||||
if (!(ctx->flags & BOOKMARKFS_BACKEND_READONLY)) {
|
||||
// Do not lazy-init iconv in sandbox mode,
|
||||
// since it may want to load modules (e.g., from /usr/lib/gconv).
|
||||
|
@ -1820,7 +1820,7 @@ bookmark_check (
|
|||
user_data);
|
||||
} else {
|
||||
debug_assert(!(ctx->flags & BOOKMARKFS_BACKEND_READONLY));
|
||||
#ifdef BOOKMARKFS_BACKEND_CHROMIUM_WRITE
|
||||
#ifdef ENABLE_BACKEND_CHROMIUM_WRITE
|
||||
status = fsck_apply(ctx, parent_id, fsck_data, callback, user_data);
|
||||
#endif
|
||||
}
|
||||
|
@ -2061,7 +2061,7 @@ cookie_free (
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef BOOKMARKFS_BACKEND_CHROMIUM_WRITE
|
||||
#ifdef ENABLE_BACKEND_CHROMIUM_WRITE
|
||||
|
||||
static int
|
||||
backend_mkfs (
|
||||
|
@ -2606,7 +2606,7 @@ bookmark_sync (
|
|||
return store_save(ctx);
|
||||
}
|
||||
|
||||
#endif /* defined(BOOKMARKFS_BACKEND_CHROMIUM_WRITE) */
|
||||
#endif /* defined(ENABLE_BACKEND_CHROMIUM_WRITE) */
|
||||
|
||||
BOOKMARKFS_API
|
||||
struct bookmarkfs_backend const bookmarkfs_backend_chromium = {
|
||||
|
@ -2623,7 +2623,7 @@ struct bookmarkfs_backend const bookmarkfs_backend_chromium = {
|
|||
|
||||
.cookie_free = cookie_free,
|
||||
|
||||
#ifdef BOOKMARKFS_BACKEND_CHROMIUM_WRITE
|
||||
#ifdef ENABLE_BACKEND_CHROMIUM_WRITE
|
||||
.backend_mkfs = backend_mkfs,
|
||||
|
||||
.bookmark_create = bookmark_create,
|
||||
|
@ -2632,5 +2632,5 @@ struct bookmarkfs_backend const bookmarkfs_backend_chromium = {
|
|||
.bookmark_rename = bookmark_rename,
|
||||
.bookmark_set = bookmark_set,
|
||||
.bookmark_sync = bookmark_sync,
|
||||
#endif /* defined(BOOKMARKFS_BACKEND_CHROMIUM_WRITE) */
|
||||
#endif /* defined(ENABLE_BACKEND_CHROMIUM_WRITE) */
|
||||
};
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef BOOKMARKFS_BACKEND_FIREFOX_WRITE
|
||||
#ifdef ENABLE_BACKEND_FIREFOX_WRITE
|
||||
# include <nettle/base64.h>
|
||||
# include <uriparser/Uri.h>
|
||||
#endif
|
||||
|
@ -109,7 +109,7 @@ enum {
|
|||
STMT_BOOKMARK_LOOKUP_KEYWORD,
|
||||
STMT_BOOKMARK_LOOKUP_TAG_ASSOC,
|
||||
STMT_DATA_VERSION,
|
||||
#ifdef BOOKMARKFS_BACKEND_FIREFOX_WRITE
|
||||
#ifdef ENABLE_BACKEND_FIREFOX_WRITE
|
||||
PERSISTED_STMT_WRITE_START,
|
||||
STMT_BEGIN = PERSISTED_STMT_WRITE_START,
|
||||
STMT_COMMIT,
|
||||
|
@ -143,7 +143,7 @@ enum {
|
|||
STMT_MK_LOOKUP,
|
||||
STMT_MK_PURGE,
|
||||
STMT_MK_RENAME,
|
||||
#endif /* defined(BOOKMARKFS_BACKEND_FIREFOX_WRITE) */
|
||||
#endif /* defined(ENABLE_BACKEND_FIREFOX_WRITE) */
|
||||
PERSISTED_STMT_END,
|
||||
};
|
||||
|
||||
|
@ -277,7 +277,7 @@ struct parsed_mntopts {
|
|||
};
|
||||
|
||||
// Forward declaration start
|
||||
#ifdef BOOKMARKFS_BACKEND_FIREFOX_WRITE
|
||||
#ifdef ENABLE_BACKEND_FIREFOX_WRITE
|
||||
static int bookmark_do_create (struct backend_ctx *, uint64_t,
|
||||
char const *, size_t, bool,
|
||||
struct bookmarkfs_bookmark_stat *);
|
||||
|
@ -345,7 +345,7 @@ static int txn_begin (struct backend_ctx *);
|
|||
static int txn_end (struct backend_ctx *);
|
||||
static int txn_rollback (struct backend_ctx *, int);
|
||||
static int64_t usecs_now (struct timespec *);
|
||||
#endif /* defined(BOOKMARKFS_BACKEND_FIREFOX_WRITE) */
|
||||
#endif /* defined(ENABLE_BACKEND_FIREFOX_WRITE) */
|
||||
|
||||
static int bookmark_do_get (struct backend_ctx *, uint64_t, int,
|
||||
struct bookmark_get_ctx *);
|
||||
|
@ -376,7 +376,7 @@ static int store_init (sqlite3 *, uint64_t *, uint64_t *);
|
|||
static int store_check_cb (void *, sqlite3_stmt *);
|
||||
// Forward declaration end
|
||||
|
||||
#ifdef BOOKMARKFS_BACKEND_FIREFOX_WRITE
|
||||
#ifdef ENABLE_BACKEND_FIREFOX_WRITE
|
||||
|
||||
static int
|
||||
bookmark_do_create (
|
||||
|
@ -2126,7 +2126,7 @@ usecs_now (
|
|||
return timespec_to_usecs(ts_buf);
|
||||
}
|
||||
|
||||
#endif /* defined(BOOKMARKFS_BACKEND_FIREFOX_WRITE) */
|
||||
#endif /* defined(ENABLE_BACKEND_FIREFOX_WRITE) */
|
||||
|
||||
static int
|
||||
bookmark_do_get (
|
||||
|
@ -2324,13 +2324,13 @@ bookmark_do_lookup (
|
|||
}
|
||||
|
||||
bool filename_is_guid = ctx->flags & BACKEND_FILENAME_GUID;
|
||||
#ifdef BOOKMARKFS_BACKEND_FIREFOX_WRITE
|
||||
#ifdef ENABLE_BACKEND_FIREFOX_WRITE
|
||||
if (filename_is_guid && (flags & BOOKMARK_FLAG(LOOKUP_VALIDATE_GUID))) {
|
||||
if (!is_valid_guid(name, name_len)) {
|
||||
return -EPERM;
|
||||
}
|
||||
}
|
||||
#endif /* defined(BOOKMARKFS_BACKEND_FIREFOX_WRITE) */
|
||||
#endif /* defined(ENABLE_BACKEND_FIREFOX_WRITE) */
|
||||
|
||||
uint32_t bookmark_type = flags & BOOKMARKFS_BOOKMARK_TYPE_MASK;
|
||||
switch (bookmark_type) {
|
||||
|
@ -2803,7 +2803,7 @@ print_version (void)
|
|||
{
|
||||
printf("bookmarkfs-backend-firefox %d.%d.%d\n",
|
||||
BOOKMARKFS_VER_MAJOR, BOOKMARKFS_VER_MINOR, BOOKMARKFS_VER_PATCH);
|
||||
puts(BOOKMARKFS_FEATURE_STRING(DEBUG, "debug"));
|
||||
puts(BOOKMARKFS_FEATURE_STRING(BOOKMARKFS_DEBUG, "debug"));
|
||||
puts(BOOKMARKFS_FEATURE_STRING(BACKEND_FIREFOX_WRITE, "write"));
|
||||
|
||||
bookmarkfs_print_lib_version("\n");
|
||||
|
@ -2894,7 +2894,7 @@ backend_create (
|
|||
) {
|
||||
bool readonly = conf->flags & BOOKMARKFS_BACKEND_READONLY;
|
||||
if (!readonly) {
|
||||
#ifdef BOOKMARKFS_BACKEND_FIREFOX_WRITE
|
||||
#ifdef ENABLE_BACKEND_FIREFOX_WRITE
|
||||
struct timespec now;
|
||||
xgetrealtime(&now);
|
||||
if (!valid_ts_sec(now.tv_sec)) {
|
||||
|
@ -2908,10 +2908,10 @@ backend_create (
|
|||
log_printf("sqlite version too low (%d<%d)", vernum, minver);
|
||||
return -1;
|
||||
}
|
||||
#else /* !defined(BOOKMARKFS_BACKEND_FIREFOX_WRITE) */
|
||||
#else /* !defined(ENABLE_BACKEND_FIREFOX_WRITE) */
|
||||
log_puts("write support is not enabled on this build");
|
||||
return -1;
|
||||
#endif /* defined(BOOKMARKFS_BACKEND_FIREFOX_WRITE) */
|
||||
#endif /* defined(ENABLE_BACKEND_FIREFOX_WRITE) */
|
||||
}
|
||||
|
||||
struct parsed_mntopts opts = { 0 };
|
||||
|
@ -3017,11 +3017,11 @@ backend_destroy (
|
|||
}
|
||||
|
||||
int end = PERSISTED_STMT_END;
|
||||
#ifdef BOOKMARKFS_BACKEND_FIREFOX_WRITE
|
||||
#ifdef ENABLE_BACKEND_FIREFOX_WRITE
|
||||
if (ctx->flags & BOOKMARKFS_BACKEND_READONLY) {
|
||||
end = PERSISTED_STMT_WRITE_START;
|
||||
}
|
||||
#endif /* defined(BOOKMARKFS_BACKEND_FIREFOX_WRITE) */
|
||||
#endif /* defined(ENABLE_BACKEND_FIREFOX_WRITE) */
|
||||
for (int idx = 0; idx < end; ++idx) {
|
||||
sqlite3_stmt *stmt = ctx->stmts[idx];
|
||||
if (stmt != NULL) {
|
||||
|
@ -3029,7 +3029,7 @@ backend_destroy (
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef BOOKMARKFS_BACKEND_FIREFOX_WRITE
|
||||
#ifdef ENABLE_BACKEND_FIREFOX_WRITE
|
||||
if (!(ctx->flags & BOOKMARKFS_BACKEND_READONLY)) {
|
||||
store_sync(ctx->db);
|
||||
}
|
||||
|
@ -3162,7 +3162,7 @@ bookmark_check (
|
|||
status = bookmark_do_list(ctx, parent_id, idx, flags, &qctx);
|
||||
} else {
|
||||
debug_assert(!(ctx->flags & BOOKMARKFS_BACKEND_READONLY));
|
||||
#ifdef BOOKMARKFS_BACKEND_FIREFOX_WRITE
|
||||
#ifdef ENABLE_BACKEND_FIREFOX_WRITE
|
||||
status = fsck_apply(ctx, parent_id, fsck_data, &qctx);
|
||||
#endif
|
||||
}
|
||||
|
@ -3327,7 +3327,7 @@ cookie_free (
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef BOOKMARKFS_BACKEND_FIREFOX_WRITE
|
||||
#ifdef ENABLE_BACKEND_FIREFOX_WRITE
|
||||
|
||||
static int
|
||||
backend_mkfs (
|
||||
|
@ -3835,7 +3835,7 @@ bookmark_sync (
|
|||
return store_sync(ctx->db);
|
||||
}
|
||||
|
||||
#endif /* defined(BOOKMARKFS_BACKEND_FIREFOX_WRITE) */
|
||||
#endif /* defined(ENABLE_BACKEND_FIREFOX_WRITE) */
|
||||
|
||||
BOOKMARKFS_API
|
||||
struct bookmarkfs_backend const bookmarkfs_backend_firefox = {
|
||||
|
@ -3852,7 +3852,7 @@ struct bookmarkfs_backend const bookmarkfs_backend_firefox = {
|
|||
|
||||
.cookie_free = cookie_free,
|
||||
|
||||
#ifdef BOOKMARKFS_BACKEND_FIREFOX_WRITE
|
||||
#ifdef ENABLE_BACKEND_FIREFOX_WRITE
|
||||
.backend_mkfs = backend_mkfs,
|
||||
|
||||
.bookmark_create = bookmark_create,
|
||||
|
@ -3861,5 +3861,5 @@ struct bookmarkfs_backend const bookmarkfs_backend_firefox = {
|
|||
.bookmark_rename = bookmark_rename,
|
||||
.bookmark_set = bookmark_set,
|
||||
.bookmark_sync = bookmark_sync,
|
||||
#endif /* defined(BOOKMARKFS_BACKEND_FIREFOX_WRITE) */
|
||||
#endif /* defined(ENABLE_BACKEND_FIREFOX_WRITE) */
|
||||
};
|
||||
|
|
2
src/db.c
2
src/db.c
|
@ -333,7 +333,7 @@ db_query (
|
|||
}
|
||||
|
||||
fetch_rows:
|
||||
#ifdef BOOKMARKFS_DEBUG
|
||||
#ifdef ENABLE_BOOKMARKFS_DEBUG
|
||||
if (0) {
|
||||
char *sql = sqlite3_expanded_sql(stmt);
|
||||
debug_puts(sql);
|
||||
|
|
14
src/fsck.c
14
src/fsck.c
|
@ -28,7 +28,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef BOOKMARKFS_INTERACTIVE_FSCK
|
||||
#ifdef ENABLE_INTERACTIVE_FSCK
|
||||
# include <readline/history.h>
|
||||
# include <readline/readline.h>
|
||||
#endif
|
||||
|
@ -77,7 +77,7 @@ struct fsck_info {
|
|||
};
|
||||
|
||||
// Forward declaration start
|
||||
#ifdef BOOKMARKFS_INTERACTIVE_FSCK
|
||||
#ifdef ENABLE_INTERACTIVE_FSCK
|
||||
static int init_readline (struct fsck_info const *);
|
||||
#endif
|
||||
|
||||
|
@ -92,7 +92,7 @@ static int parse_opts (struct fsck_info *, int, char *[]);
|
|||
|
||||
extern struct bookmarkfs_fsck_handler const fsck_handler_simple;
|
||||
|
||||
#ifdef BOOKMARKFS_INTERACTIVE_FSCK
|
||||
#ifdef ENABLE_INTERACTIVE_FSCK
|
||||
|
||||
static int
|
||||
init_readline (
|
||||
|
@ -111,7 +111,7 @@ init_readline (
|
|||
return 0;
|
||||
}
|
||||
|
||||
#endif /* defined(BOOKMARKFS_INTERACTIVE_FSCK) */
|
||||
#endif /* defined(ENABLE_INTERACTIVE_FSCK) */
|
||||
|
||||
static void
|
||||
destroy_ctx (
|
||||
|
@ -166,7 +166,7 @@ do_fsck (
|
|||
}
|
||||
goto run_handler;
|
||||
}
|
||||
#ifdef BOOKMARKFS_INTERACTIVE_FSCK
|
||||
#ifdef ENABLE_INTERACTIVE_FSCK
|
||||
if (result == BOOKMARKFS_FSCK_USER_INPUT) {
|
||||
putchar('\n');
|
||||
data.str = readline(data.str);
|
||||
|
@ -234,7 +234,7 @@ init_all (
|
|||
}
|
||||
goto end;
|
||||
}
|
||||
#ifdef BOOKMARKFS_INTERACTIVE_FSCK
|
||||
#ifdef ENABLE_INTERACTIVE_FSCK
|
||||
if (0 != init_readline(&info)) {
|
||||
goto end;
|
||||
}
|
||||
|
@ -441,7 +441,7 @@ parse_opts (
|
|||
SUBOPT_END
|
||||
}
|
||||
OPT_OPT('i') {
|
||||
#ifdef BOOKMARKFS_INTERACTIVE_FSCK
|
||||
#ifdef ENABLE_INTERACTIVE_FSCK
|
||||
info->flags.interactive = 1;
|
||||
break;
|
||||
#else
|
||||
|
|
|
@ -52,14 +52,14 @@ struct handler_ctx {
|
|||
};
|
||||
|
||||
// Forward declaration start
|
||||
#ifdef BOOKMARKFS_INTERACTIVE_FSCK
|
||||
#ifdef ENABLE_INTERACTIVE_FSCK
|
||||
static int expect_input (struct handler_ctx *, char **);
|
||||
static int expect_next (struct handler_ctx *, int, char **);
|
||||
static int handle_input (struct handler_ctx *,
|
||||
union bookmarkfs_fsck_handler_data *);
|
||||
static void print_entry (struct bookmarkfs_fsck_data const *);
|
||||
static void print_usage (void);
|
||||
#endif /* defined(BOOKMARKFS_INTERACTIVE_FSCK) */
|
||||
#endif /* defined(ENABLE_INTERACTIVE_FSCK) */
|
||||
|
||||
static void fix_name_dup (struct handler_ctx *, struct bookmarkfs_fsck_data *);
|
||||
static void fix_entry (struct handler_ctx *, enum bookmarkfs_fsck_result,
|
||||
|
@ -70,7 +70,7 @@ static int parse_opts (struct bookmarkfs_conf_opt const *,
|
|||
struct parsed_opts *);
|
||||
// Forward declaration end
|
||||
|
||||
#ifdef BOOKMARKFS_INTERACTIVE_FSCK
|
||||
#ifdef ENABLE_INTERACTIVE_FSCK
|
||||
|
||||
static int
|
||||
expect_input (
|
||||
|
@ -216,7 +216,7 @@ print_usage (void)
|
|||
"See the user manual for more information.");
|
||||
}
|
||||
|
||||
#endif /* defined(BOOKMARKFS_INTERACTIVE_FSCK) */
|
||||
#endif /* defined(ENABLE_INTERACTIVE_FSCK) */
|
||||
|
||||
static void
|
||||
fix_name_dup (
|
||||
|
@ -291,7 +291,7 @@ handle_entry (
|
|||
fix_entry(ctx, why, entry_data);
|
||||
control = BOOKMARKFS_FSCK_APPLY;
|
||||
}
|
||||
#ifdef BOOKMARKFS_INTERACTIVE_FSCK
|
||||
#ifdef ENABLE_INTERACTIVE_FSCK
|
||||
if (ctx->flags & BOOKMARKFS_FSCK_HANDLER_INTERACTIVE) {
|
||||
ctx->data_buf = *entry_data;
|
||||
control = expect_input(ctx, &data->str);
|
||||
|
@ -370,7 +370,7 @@ fsck_handler_run (
|
|||
if (why > 0) {
|
||||
return handle_entry(ctx, why, data);
|
||||
}
|
||||
#ifdef BOOKMARKFS_INTERACTIVE_FSCK
|
||||
#ifdef ENABLE_INTERACTIVE_FSCK
|
||||
if (ctx->flags & FSCK_HANDLER_EXPECT_INPUT) {
|
||||
return handle_input(ctx, data);
|
||||
}
|
||||
|
|
|
@ -213,7 +213,7 @@ print_version (void)
|
|||
{
|
||||
printf("bookmarkfs-fsck-handler-tcl %d.%d.%d\n",
|
||||
BOOKMARKFS_VER_MAJOR, BOOKMARKFS_VER_MINOR, BOOKMARKFS_VER_PATCH);
|
||||
puts(BOOKMARKFS_FEATURE_STRING(DEBUG, "debug"));
|
||||
puts(BOOKMARKFS_FEATURE_STRING(BOOKMARKFS_DEBUG, "debug"));
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
@ -201,7 +201,7 @@ print_version (void)
|
|||
{
|
||||
printf("fsck.bookmarkfs (BookmarkFS) %d.%d.%d\n",
|
||||
BOOKMARKFS_VER_MAJOR, BOOKMARKFS_VER_MINOR, BOOKMARKFS_VER_PATCH);
|
||||
puts(BOOKMARKFS_FEATURE_STRING(DEBUG, "debug"));
|
||||
puts(BOOKMARKFS_FEATURE_STRING(BOOKMARKFS_DEBUG, "debug"));
|
||||
puts(BOOKMARKFS_FEATURE_STRING(INTERACTIVE_FSCK, "interactive"));
|
||||
|
||||
bookmarkfs_print_lib_version("\n");
|
||||
|
|
|
@ -28,10 +28,10 @@
|
|||
|
||||
#include "hash.h"
|
||||
|
||||
#ifdef BOOKMARKFS_DEBUG
|
||||
#ifdef ENABLE_BOOKMARKFS_DEBUG
|
||||
# define XXH_DEBUGLEVEL 1
|
||||
#endif
|
||||
#ifdef BOOKMARKFS_XXHASH_INLINE
|
||||
#ifdef ENABLE_XXHASH_INLINE
|
||||
# define XXH_INLINE_ALL
|
||||
# define XXH_IMPLEMENTATION
|
||||
#endif
|
||||
|
|
|
@ -128,11 +128,11 @@ json_array_search (
|
|||
json_t const *needle
|
||||
) {
|
||||
size_t idx;
|
||||
#ifdef BOOKMARKFS_DEBUG
|
||||
#ifdef ENABLE_BOOKMARKFS_DEBUG
|
||||
size_t cnt = json_array_size(haystack);
|
||||
#endif
|
||||
for (idx = 0; needle != json_array_get(haystack, idx); ++idx) {
|
||||
#ifdef BOOKMARKFS_DEBUG
|
||||
#ifdef ENABLE_BOOKMARKFS_DEBUG
|
||||
xassert(idx < cnt);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
|
||||
#define BOOKMARKFS_FEATURE_STRING_EX(which, name, off, on) \
|
||||
&(off name on name) \
|
||||
[(sizeof(STRINGIFY(BOOKMARKFS_##which)) == 2) * (sizeof(off name) - 1)]
|
||||
[(sizeof(STRINGIFY(ENABLE_##which)) == 2) * (sizeof(off name) - 1)]
|
||||
#define BOOKMARKFS_FEATURE_STRING(which, name) \
|
||||
BOOKMARKFS_FEATURE_STRING_EX(which, name, " - ", " + ")
|
||||
|
||||
|
|
|
@ -198,7 +198,7 @@ print_version (void)
|
|||
{
|
||||
printf("mkfs.bookmarkfs (BookmarkFS) %d.%d.%d\n",
|
||||
BOOKMARKFS_VER_MAJOR, BOOKMARKFS_VER_MINOR, BOOKMARKFS_VER_PATCH);
|
||||
puts(BOOKMARKFS_FEATURE_STRING(DEBUG, "debug"));
|
||||
puts(BOOKMARKFS_FEATURE_STRING(BOOKMARKFS_DEBUG, "debug"));
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -537,7 +537,7 @@ print_version (void)
|
|||
{
|
||||
printf("mount.bookmarkfs (BookmarkFS) %d.%d.%d\n",
|
||||
BOOKMARKFS_VER_MAJOR, BOOKMARKFS_VER_MINOR, BOOKMARKFS_VER_PATCH);
|
||||
puts(BOOKMARKFS_FEATURE_STRING(DEBUG, "debug"));
|
||||
puts(BOOKMARKFS_FEATURE_STRING(BOOKMARKFS_DEBUG, "debug"));
|
||||
|
||||
bookmarkfs_print_lib_version("\n");
|
||||
}
|
||||
|
|
|
@ -31,9 +31,9 @@
|
|||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#if !defined(BOOKMARKFS_SANDBOX)
|
||||
#if !defined(ENABLE_SANDBOX)
|
||||
#elif defined(__linux__)
|
||||
# ifdef BOOKMARKFS_SANDBOX_LANDLOCK
|
||||
# ifdef ENABLE_SANDBOX_LANDLOCK
|
||||
# include <linux/landlock.h>
|
||||
# include <sys/syscall.h>
|
||||
# endif
|
||||
|
@ -94,13 +94,13 @@ struct scmp_rule_def {
|
|||
static int add_scmp_rules (scmp_filter_ctx, struct scmp_rule_def const *,
|
||||
size_t);
|
||||
|
||||
#ifdef BOOKMARKFS_SANDBOX_LANDLOCK
|
||||
#ifdef ENABLE_SANDBOX_LANDLOCK
|
||||
static int landlock_create_ruleset (struct landlock_ruleset_attr const *,
|
||||
size_t, uint32_t);
|
||||
static int landlock_add_rule (int, enum landlock_rule_type,
|
||||
void const *, uint32_t);
|
||||
static int landlock_restrict_self (int, uint32_t);
|
||||
#endif /* defined(BOOKMARKFS_SANDBOX_LANDLOCK) */
|
||||
#endif /* defined(ENABLE_SANDBOX_LANDLOCK) */
|
||||
// Forward declaration end
|
||||
|
||||
static int
|
||||
|
@ -128,7 +128,7 @@ add_scmp_rules (
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifdef BOOKMARKFS_SANDBOX_LANDLOCK
|
||||
#ifdef ENABLE_SANDBOX_LANDLOCK
|
||||
|
||||
static int
|
||||
landlock_create_ruleset (
|
||||
|
@ -158,7 +158,7 @@ landlock_restrict_self (
|
|||
return syscall(SYS_landlock_restrict_self, ruleset_fd, flags);
|
||||
}
|
||||
|
||||
#endif /* defined(BOOKMARKFS_SANDBOX_LANDLOCK) */
|
||||
#endif /* defined(ENABLE_SANDBOX_LANDLOCK) */
|
||||
|
||||
int
|
||||
sandbox_enter (
|
||||
|
@ -192,7 +192,7 @@ sandbox_enter (
|
|||
|
||||
// signals
|
||||
SCMP_RULE_NOARG(sigaction, 10),
|
||||
#ifdef BOOKMARKFS_DEBUG
|
||||
#ifdef ENABLE_BOOKMARKFS_DEBUG
|
||||
// Make ASAN happy...
|
||||
SCMP_RULE_NOARG(sigaltstack, 0),
|
||||
#endif
|
||||
|
@ -298,7 +298,7 @@ sandbox_enter (
|
|||
goto apply_seccomp;
|
||||
}
|
||||
status = -1;
|
||||
#ifdef BOOKMARKFS_SANDBOX_LANDLOCK
|
||||
#ifdef ENABLE_SANDBOX_LANDLOCK
|
||||
int ruleset_version = landlock_create_ruleset(NULL, 0,
|
||||
LANDLOCK_CREATE_RULESET_VERSION);
|
||||
if (unlikely(ruleset_version < 0)) {
|
||||
|
@ -368,7 +368,7 @@ sandbox_enter (
|
|||
|
||||
#else
|
||||
log_puts("landlock is not supported on this build");
|
||||
#endif /* defined(BOOKMARKFS_SANDBOX_LANDLOCK) */
|
||||
#endif /* defined(ENABLE_SANDBOX_LANDLOCK) */
|
||||
|
||||
if (status < 0) {
|
||||
goto free_sfctx;
|
||||
|
@ -431,7 +431,7 @@ sandbox_enter (
|
|||
|
||||
#endif /* defined(SANDBOX_IMPL_CAPSICUM) */
|
||||
|
||||
#ifndef BOOKMARKFS_SANDBOX
|
||||
#ifndef ENABLE_SANDBOX
|
||||
|
||||
int
|
||||
sandbox_enter (
|
||||
|
@ -446,4 +446,4 @@ sandbox_enter (
|
|||
return -1;
|
||||
}
|
||||
|
||||
#endif /* !defined(BOOKMARKFS_SANDBOX) */
|
||||
#endif /* !defined(ENABLE_SANDBOX) */
|
||||
|
|
|
@ -30,13 +30,13 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef BOOKMARKFS_BACKEND_CHROMIUM_WRITE
|
||||
#ifdef ENABLE_BACKEND_CHROMIUM_WRITE
|
||||
# include <nettle/base16.h>
|
||||
#endif
|
||||
|
||||
#include "prng.h"
|
||||
|
||||
#ifdef BOOKMARKFS_BACKEND_CHROMIUM_WRITE
|
||||
#ifdef ENABLE_BACKEND_CHROMIUM_WRITE
|
||||
|
||||
void
|
||||
uuid_bin2hex (
|
||||
|
@ -85,7 +85,7 @@ uuid_hex2bin (
|
|||
return 0;
|
||||
}
|
||||
|
||||
#else /* !defined(BOOKMARKFS_BACKEND_CHROMIUM_WRITE) */
|
||||
#else /* !defined(ENABLE_BACKEND_CHROMIUM_WRITE) */
|
||||
|
||||
/**
|
||||
* This implementation is meant to get rid of the Nettle dependency
|
||||
|
@ -113,7 +113,7 @@ uuid_hex2bin (
|
|||
return 0;
|
||||
}
|
||||
|
||||
#endif /* defined(BOOKMARKFS_BACKEND_CHROMIUM_WRITE) */
|
||||
#endif /* defined(ENABLE_BACKEND_CHROMIUM_WRITE) */
|
||||
|
||||
void
|
||||
uuid_generate_random (
|
||||
|
|
|
@ -30,16 +30,16 @@ uint32_t
|
|||
bookmarkfs_lib_version (void)
|
||||
{
|
||||
uint32_t vernum = BOOKMARKFS_VERNUM;
|
||||
#ifdef BOOKMARKFS_DEBUG
|
||||
#ifdef ENABLE_BOOKMARKFS_DEBUG
|
||||
vernum |= BOOKMARKFS_FEAT_DEBUG;
|
||||
#endif
|
||||
#ifdef BOOKMARKFS_SANDBOX
|
||||
#ifdef ENABLE_SANDBOX
|
||||
vernum |= BOOKMARKFS_FEAT_SANDBOX;
|
||||
#ifdef BOOKMARKFS_SANDBOX_LANDLOCK
|
||||
#ifdef ENABLE_SANDBOX_LANDLOCK
|
||||
vernum |= BOOKMARKFS_FEAT_SANDBOX_LANDLOCK;
|
||||
#endif
|
||||
#endif /* defined(BOOKMARKFS_SANDBOX) */
|
||||
#ifdef BOOKMARKFS_NATIVE_WATCHER
|
||||
#endif /* defined(ENABLE_SANDBOX) */
|
||||
#ifdef ENABLE_NATIVE_WATCHER
|
||||
vernum |= BOOKMARKFS_FEAT_NATIVE_WATCHER;
|
||||
#endif
|
||||
return vernum;
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#if !defined(BOOKMARKFS_NATIVE_WATCHER)
|
||||
#if !defined(ENABLE_NATIVE_WATCHER)
|
||||
#elif defined(__linux__)
|
||||
# include <sys/fanotify.h>
|
||||
# define WATCHER_IMPL_FANOTIFY
|
||||
|
|
|
@ -36,13 +36,13 @@
|
|||
|
||||
void
|
||||
xabort_ (
|
||||
#ifdef BOOKMARKFS_DEBUG
|
||||
#ifdef ENABLE_BOOKMARKFS_DEBUG
|
||||
char const *assertion,
|
||||
#endif
|
||||
char const *name,
|
||||
int line
|
||||
) {
|
||||
#ifdef BOOKMARKFS_DEBUG
|
||||
#ifdef ENABLE_BOOKMARKFS_DEBUG
|
||||
fprintf(stderr, "%s:%d: assertion (%s) failed\n", name, line, assertion);
|
||||
#else
|
||||
fprintf(stderr, "%s:%d: assertion failed\n", name, line);
|
||||
|
|
14
src/xstd.h
14
src/xstd.h
|
@ -39,35 +39,35 @@
|
|||
# define unlikely(e) (e)
|
||||
#endif /* defined(HAVE___BUILTIN_EXPECT) */
|
||||
|
||||
#ifdef BOOKMARKFS_DEBUG
|
||||
#ifdef ENABLE_BOOKMARKFS_DEBUG
|
||||
# define xassert(e) if (unlikely(!(e))) xabort_(#e, FILE_NAME_, __LINE__)
|
||||
#else
|
||||
# define xassert(e) if (unlikely(!(e))) xabort_(FILE_NAME_, __LINE__)
|
||||
#endif
|
||||
|
||||
#ifdef BOOKMARKFS_DEBUG
|
||||
#ifdef ENABLE_BOOKMARKFS_DEBUG
|
||||
# define debug_assert(e) xassert(e)
|
||||
# define unreachable() xassert(0)
|
||||
#else /* !defined(BOOKMARKFS_DEBUG) */
|
||||
#else /* !defined(ENABLE_BOOKMARKFS_DEBUG) */
|
||||
# define debug_assert(e) if (!(e)) { unreachable(); }
|
||||
# ifdef HAVE___BUILTIN_UNREACHABLE
|
||||
# define unreachable() __builtin_unreachable()
|
||||
# else
|
||||
# define unreachable()
|
||||
# endif
|
||||
#endif /* defined(BOOKMARKFS_DEBUG) */
|
||||
#endif /* defined(ENABLE_BOOKMARKFS_DEBUG) */
|
||||
|
||||
#define log_printf_(f, ...) \
|
||||
fprintf(stderr, "%s:" f "\n", FILE_NAME_, __VA_ARGS__)
|
||||
|
||||
#ifdef BOOKMARKFS_DEBUG
|
||||
#ifdef ENABLE_BOOKMARKFS_DEBUG
|
||||
# define log_printf(f, ...) log_printf_("%d: " f, __LINE__, __VA_ARGS__)
|
||||
#else
|
||||
# define log_printf(f, ...) log_printf_(" " f, __VA_ARGS__);
|
||||
#endif
|
||||
#define log_puts(s) log_printf("%s", s)
|
||||
|
||||
#ifdef BOOKMARKFS_DEBUG
|
||||
#ifdef ENABLE_BOOKMARKFS_DEBUG
|
||||
# define debug_printf(f, ...) log_printf("[debug] " f, __VA_ARGS__)
|
||||
# define debug_puts(s) debug_printf("%s", s)
|
||||
#else
|
||||
|
@ -100,7 +100,7 @@ BOOKMARKFS_INTERNAL
|
|||
FUNCATTR_COLD FUNCATTR_NORETURN
|
||||
void
|
||||
xabort_ (
|
||||
#ifdef BOOKMARKFS_DEBUG
|
||||
#ifdef ENABLE_BOOKMARKFS_DEBUG
|
||||
char const *assertion,
|
||||
#endif
|
||||
char const *name,
|
||||
|
|
|
@ -59,7 +59,7 @@ dispatch_subcmds (
|
|||
status = subcmd_prng(argc, argv);
|
||||
} else if (0 == strcmp("watcher", cmd)) {
|
||||
status = check_watcher(argc, argv);
|
||||
#ifdef BOOKMARKFS_SANDBOX
|
||||
#ifdef ENABLE_SANDBOX
|
||||
} else if (0 == strcmp("sandbox", cmd)) {
|
||||
status = check_sandbox(argc, argv);
|
||||
#endif
|
||||
|
|
|
@ -97,7 +97,7 @@ do_check_sandbox (
|
|||
bool check_above = true;
|
||||
bool check_lookup_above = true;
|
||||
#ifdef __linux__
|
||||
# ifndef BOOKMARKFS_SANDBOX_LANDLOCK
|
||||
# ifndef ENABLE_SANDBOX_LANDLOCK
|
||||
// If only we could filter renameat2() with seccomp...
|
||||
check_above = false;
|
||||
# endif
|
||||
|
@ -153,7 +153,7 @@ check_sandbox (
|
|||
char *argv[]
|
||||
) {
|
||||
uint32_t flags = 0;
|
||||
#ifndef BOOKMARKFS_SANDBOX_LANDLOCK
|
||||
#ifndef ENABLE_SANDBOX_LANDLOCK
|
||||
flags |= SANDBOX_NO_LANDLOCK;
|
||||
#endif
|
||||
char const *path = NULL;
|
||||
|
|
|
@ -129,7 +129,7 @@ static int
|
|||
wait_for_watcher (
|
||||
struct watcher *w
|
||||
) {
|
||||
#ifdef BOOKMARKFS_NATIVE_WATCHER
|
||||
#ifdef ENABLE_NATIVE_WATCHER
|
||||
# define TRY_INTERVAL { .tv_nsec = 50 * 1000000 }
|
||||
# define MAX_TRIES 10
|
||||
#else
|
||||
|
@ -167,7 +167,7 @@ check_watcher (
|
|||
}
|
||||
|
||||
uint32_t sandbox_flags = 0;
|
||||
#ifndef BOOKMARKFS_SANDBOX_LANDLOCK
|
||||
#ifndef ENABLE_SANDBOX_LANDLOCK
|
||||
sandbox_flags |= SANDBOX_NO_LANDLOCK;
|
||||
#endif
|
||||
#if defined(__FreeBSD__)
|
||||
|
|
Loading…
Add table
Reference in a new issue