all: minor refactor

This commit is contained in:
CismonX 2025-02-26 00:23:27 +08:00
parent 7816e955b7
commit 55c0726c7f
No known key found for this signature in database
GPG key ID: 3094873E29A482FB
3 changed files with 14 additions and 15 deletions

View file

@ -53,8 +53,8 @@
// Chromium saves its bookmarks (`bookmarks::BookmarkStorage::kSaveDelay`).
//
// See Chromium source code: /components/bookmarks/browser/bookmark_storage.h
#define FS_ENTRY_TIMEOUT_MAX INT32_MAX
#define FS_ENTRY_TIMEOUT_SECS ( ctx.flags.exclusive ? INT32_MAX : 2.5 )
#define FS_ENTRY_TIMEOUT_MAX 3600.
#define FS_ENTRY_TIMEOUT ( ctx.flags.exclusive ? FS_ENTRY_TIMEOUT_MAX : 2.5 )
#define BOOKMARKS_ROOT_ID ( ctx.bookmarks_root_id )
#define TAGS_ROOT_ID ( ctx.tags_root_id )
@ -75,12 +75,12 @@
#define INODE_SUBSYS_ID(ino) ( (ino) & SUBSYS_ID_MASK )
#define SUBSYS_NODEID(id, t) ( ((fuse_ino_t)(t) << SUBSYS_ID_BITS) | (id) )
#define STRUCT_FUSE_ENTRY_PARAM_INIT \
{ \
.generation = 1, \
.attr = STRUCT_STAT_INIT, \
.attr_timeout = FS_ENTRY_TIMEOUT_SECS, \
.entry_timeout = FS_ENTRY_TIMEOUT_SECS, \
#define STRUCT_FUSE_ENTRY_PARAM_INIT \
{ \
.generation = 1, \
.attr = STRUCT_STAT_INIT, \
.attr_timeout = FS_ENTRY_TIMEOUT, \
.entry_timeout = FS_ENTRY_TIMEOUT, \
}
#define STRUCT_STAT_INIT \
{ .st_nlink = 1, .st_uid = ctx.uid, .st_gid = ctx.gid }
@ -1890,7 +1890,7 @@ fs_op_getattr (
return;
}
send_reply(attr, req, &stat_buf, FS_ENTRY_TIMEOUT_SECS);
send_reply(attr, req, &stat_buf, FS_ENTRY_TIMEOUT);
}
void
@ -2344,7 +2344,7 @@ fs_op_setattr (
send_reply(err, req, -status);
}
send_reply(attr, req, stat_buf, FS_ENTRY_TIMEOUT_SECS);
send_reply(attr, req, stat_buf, FS_ENTRY_TIMEOUT);
}
void

View file

@ -288,7 +288,7 @@ impl_watch (
}
end:
debug_printf("file %s changed", w->name);
debug_printf("%s: file changed", w->name);
return 0;
}
@ -339,6 +339,8 @@ watcher_create (
.name = name,
.pipefd[1] = -1,
.flags = flags,
.mutex = PTHREAD_MUTEX_INITIALIZER,
.cond = PTHREAD_COND_INITIALIZER,
};
if (flags & WATCHER_NOOP) {
return w;
@ -353,8 +355,6 @@ watcher_create (
if (unlikely(0 != impl_init(w))) {
goto close_pipes;
}
pthread_mutex_init(&w->mutex, NULL);
pthread_cond_init(&w->cond, NULL);
int status = pthread_create(&w->worker, NULL, worker_loop, w);
if (unlikely(status != 0)) {

View file

@ -31,7 +31,7 @@
//
// The list should be kept short, since anything added there may
// introduce extra syscall filtering overhead.
#ifdef __FreeBSD__
#if defined(__FreeBSD__)
# define WATCHER_CAN_CREATE_IN_SANDBOX
#endif
@ -94,5 +94,4 @@ watcher_poll (
struct watcher *w
);
#endif /* !defined(BOOKMARKFS_WATCHER_H_) */