Add mergerfs.collect-info (#1491)
Some checks failed
CodeQL / Analyze (push) Has been cancelled
mkdocs / deploy (push) Has been cancelled

A tool to collect info for support requests.
This commit is contained in:
trapexit 2025-07-03 20:18:05 -05:00 • committed by GitHub
parent 71ddae8713
commit 9e626228be
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 391 additions and 42 deletions

68
src/mergerfs_api.cpp Normal file
View file

@ -0,0 +1,68 @@
#include "mergerfs_api.hpp"
#include "fs_close.hpp"
#include "fs_ioctl.hpp"
#include "fs_open.hpp"
#include "mergerfs_ioctl.hpp"
#include "fs_lgetxattr.hpp"
#include "str.hpp"
#include "scope_guard.hpp"
#include <string.h>
int
mergerfs::api::allpaths(const std::string &input_path_,
std::vector<std::string> &output_paths_)
{
int rv;
IOCTL_BUF buf;
rv = fs::lgetxattr(input_path_,"user.mergerfs.allpaths",buf,sizeof(buf));
if(rv < 0)
return rv;
str::split_on_null(buf,rv,&output_paths_);
return 0;
}
int
_lgetxattr(const std::string &input_path_,
const std::string &key_,
std::string &value_)
{
int rv;
IOCTL_BUF buf;
rv = fs::lgetxattr(input_path_,key_,buf,sizeof(buf));
if(rv < 0)
return rv;
value_ = buf;
return rv;
}
int
mergerfs::api::basepath(const std::string &input_path_,
std::string &basepath_)
{
return ::_lgetxattr(input_path_,"user.mergerfs.basepath",basepath_);
}
int
mergerfs::api::relpath(const std::string &input_path_,
std::string &relpath_)
{
return ::_lgetxattr(input_path_,"user.mergerfs.relpath",relpath_);
}
int
mergerfs::api::fullpath(const std::string &input_path_,
std::string &fullpath_)
{
return ::_lgetxattr(input_path_,"user.mergerfs.fullpath",fullpath_);
}