More aggressive error handing with pagesize queries

This commit is contained in:
Antonio SJ Musumeci
2026-03-24 21:13:34 -04:00
committed by trapexit
parent 07b1e6bdba
commit 3099b15db1
3 changed files with 16 additions and 12 deletions
+2 -4
View File
@@ -18,6 +18,7 @@
#include "config_pagesize.hpp"
#include "fatal.hpp"
#include "from_string.hpp"
#include <cassert>
@@ -58,10 +59,7 @@ ConfigPageSize::from_string(const std::string_view s_)
tmp = sysconf(_SC_PAGESIZE);
if(tmp <= 0)
{
perror("mergerfs: pagesize query failed");
std::abort();
}
fatal::abort("pagesize query failed - {}",strerror(errno));
pagesize = (u64)tmp;
+4 -2
View File
@@ -13,6 +13,8 @@
#include "mutex.hpp"
#include "debug.hpp"
#include "fatal.hpp"
#include "fmt/core.h"
#include "fuse_cfg.hpp"
#include "fuse_i.h"
#include "fuse_kernel.h"
@@ -20,7 +22,6 @@
#include "fuse_opt.h"
#include "fuse_pollhandle.h"
#include "stat_utils.h"
#include "fmt/core.h"
#include <stdio.h>
#include <stdlib.h>
@@ -62,9 +63,10 @@ void
fuse_ll_constructor(void)
{
pagesize = sysconf(_SC_PAGESIZE);
if(pagesize <= 0)
fatal::abort("pagesize query failed - {}",strerror(errno));
}
static
void
convert_stat(const struct stat *stbuf_,
+10 -6
View File
@@ -17,12 +17,11 @@
#include "fuse_msgbuf.hpp"
#include "fatal.hpp"
#include "fuse.h"
#include "fuse_kernel.h"
#include "objpool.hpp"
#include "fmt/core.h"
#include <unistd.h>
#include <cassert>
@@ -34,7 +33,7 @@ static u64 g_bufsize = 0;
/* Extra pages: 1 for page-alignment headroom, 1 for
fuse_in_header+fuse_write_in alignment */
#define MSGBUF_OVERHEAD_PAGES 2
static constexpr u64 MSGBUF_OVERHEAD_PAGES = 2ULL;
static
__attribute__((constructor))
@@ -43,7 +42,9 @@ _constructor()
{
long pagesize = sysconf(_SC_PAGESIZE);
assert(pagesize > 0);
if(pagesize <= 0)
fatal::abort("pagesize query failed - {}",strerror(errno));
g_pagesize = pagesize;
assert((sizeof(struct fuse_in_header) + sizeof(struct fuse_write_in))
@@ -57,9 +58,9 @@ struct PageAlignedAllocator
void*
allocate(size_t size_, size_t align_)
{
void *buf = NULL;
void *buf = nullptr;
int rv = posix_memalign(&buf, align_, size_);
return (rv == 0) ? buf : NULL;
return (rv == 0) ? buf : nullptr;
}
void
@@ -131,6 +132,9 @@ msgbuf_alloc_page_aligned()
void
msgbuf_free(fuse_msgbuf_t *msgbuf_)
{
if(msgbuf_ == nullptr)
return;
g_msgbuf_pool.free_size(msgbuf_,g_bufsize);
}