mirror of
https://git.sr.ht/~cismonx/bookmarkfs
synced 2025-07-23 09:38:53 +00:00
all: minor refactor
This commit is contained in:
parent
7816e955b7
commit
55c0726c7f
3 changed files with 14 additions and 15 deletions
20
src/fs_ops.c
20
src/fs_ops.c
|
@ -53,8 +53,8 @@
|
||||||
// Chromium saves its bookmarks (`bookmarks::BookmarkStorage::kSaveDelay`).
|
// Chromium saves its bookmarks (`bookmarks::BookmarkStorage::kSaveDelay`).
|
||||||
//
|
//
|
||||||
// See Chromium source code: /components/bookmarks/browser/bookmark_storage.h
|
// See Chromium source code: /components/bookmarks/browser/bookmark_storage.h
|
||||||
#define FS_ENTRY_TIMEOUT_MAX INT32_MAX
|
#define FS_ENTRY_TIMEOUT_MAX 3600.
|
||||||
#define FS_ENTRY_TIMEOUT_SECS ( ctx.flags.exclusive ? INT32_MAX : 2.5 )
|
#define FS_ENTRY_TIMEOUT ( ctx.flags.exclusive ? FS_ENTRY_TIMEOUT_MAX : 2.5 )
|
||||||
|
|
||||||
#define BOOKMARKS_ROOT_ID ( ctx.bookmarks_root_id )
|
#define BOOKMARKS_ROOT_ID ( ctx.bookmarks_root_id )
|
||||||
#define TAGS_ROOT_ID ( ctx.tags_root_id )
|
#define TAGS_ROOT_ID ( ctx.tags_root_id )
|
||||||
|
@ -75,12 +75,12 @@
|
||||||
#define INODE_SUBSYS_ID(ino) ( (ino) & SUBSYS_ID_MASK )
|
#define INODE_SUBSYS_ID(ino) ( (ino) & SUBSYS_ID_MASK )
|
||||||
#define SUBSYS_NODEID(id, t) ( ((fuse_ino_t)(t) << SUBSYS_ID_BITS) | (id) )
|
#define SUBSYS_NODEID(id, t) ( ((fuse_ino_t)(t) << SUBSYS_ID_BITS) | (id) )
|
||||||
|
|
||||||
#define STRUCT_FUSE_ENTRY_PARAM_INIT \
|
#define STRUCT_FUSE_ENTRY_PARAM_INIT \
|
||||||
{ \
|
{ \
|
||||||
.generation = 1, \
|
.generation = 1, \
|
||||||
.attr = STRUCT_STAT_INIT, \
|
.attr = STRUCT_STAT_INIT, \
|
||||||
.attr_timeout = FS_ENTRY_TIMEOUT_SECS, \
|
.attr_timeout = FS_ENTRY_TIMEOUT, \
|
||||||
.entry_timeout = FS_ENTRY_TIMEOUT_SECS, \
|
.entry_timeout = FS_ENTRY_TIMEOUT, \
|
||||||
}
|
}
|
||||||
#define STRUCT_STAT_INIT \
|
#define STRUCT_STAT_INIT \
|
||||||
{ .st_nlink = 1, .st_uid = ctx.uid, .st_gid = ctx.gid }
|
{ .st_nlink = 1, .st_uid = ctx.uid, .st_gid = ctx.gid }
|
||||||
|
@ -1890,7 +1890,7 @@ fs_op_getattr (
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
send_reply(attr, req, &stat_buf, FS_ENTRY_TIMEOUT_SECS);
|
send_reply(attr, req, &stat_buf, FS_ENTRY_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -2344,7 +2344,7 @@ fs_op_setattr (
|
||||||
send_reply(err, req, -status);
|
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
|
void
|
||||||
|
|
|
@ -288,7 +288,7 @@ impl_watch (
|
||||||
}
|
}
|
||||||
|
|
||||||
end:
|
end:
|
||||||
debug_printf("file %s changed", w->name);
|
debug_printf("%s: file changed", w->name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,6 +339,8 @@ watcher_create (
|
||||||
.name = name,
|
.name = name,
|
||||||
.pipefd[1] = -1,
|
.pipefd[1] = -1,
|
||||||
.flags = flags,
|
.flags = flags,
|
||||||
|
.mutex = PTHREAD_MUTEX_INITIALIZER,
|
||||||
|
.cond = PTHREAD_COND_INITIALIZER,
|
||||||
};
|
};
|
||||||
if (flags & WATCHER_NOOP) {
|
if (flags & WATCHER_NOOP) {
|
||||||
return w;
|
return w;
|
||||||
|
@ -353,8 +355,6 @@ watcher_create (
|
||||||
if (unlikely(0 != impl_init(w))) {
|
if (unlikely(0 != impl_init(w))) {
|
||||||
goto close_pipes;
|
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);
|
int status = pthread_create(&w->worker, NULL, worker_loop, w);
|
||||||
if (unlikely(status != 0)) {
|
if (unlikely(status != 0)) {
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
//
|
//
|
||||||
// The list should be kept short, since anything added there may
|
// The list should be kept short, since anything added there may
|
||||||
// introduce extra syscall filtering overhead.
|
// introduce extra syscall filtering overhead.
|
||||||
#ifdef __FreeBSD__
|
#if defined(__FreeBSD__)
|
||||||
# define WATCHER_CAN_CREATE_IN_SANDBOX
|
# define WATCHER_CAN_CREATE_IN_SANDBOX
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -94,5 +94,4 @@ watcher_poll (
|
||||||
struct watcher *w
|
struct watcher *w
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
#endif /* !defined(BOOKMARKFS_WATCHER_H_) */
|
#endif /* !defined(BOOKMARKFS_WATCHER_H_) */
|
||||||
|
|
Loading…
Add table
Reference in a new issue