mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-11-24 17:06:24 -05:00
Update submitting bug reports, improve collect-info (#1598)
Some checks failed
mkdocs / deploy (push) Has been cancelled
Some checks failed
mkdocs / deploy (push) Has been cancelled
This commit is contained in:
parent
9b046d9a34
commit
72fb6e4aba
5 changed files with 127 additions and 63 deletions
|
|
@ -1,5 +1,7 @@
|
|||
#include "mergerfs_api.hpp"
|
||||
|
||||
#include "fs_xattr.hpp"
|
||||
#include "fs_exists.hpp"
|
||||
#include "fs_lgetxattr.hpp"
|
||||
#include "str.hpp"
|
||||
|
||||
|
|
@ -33,6 +35,27 @@ _lgetxattr(const std::string &input_path_,
|
|||
return rv;
|
||||
}
|
||||
|
||||
bool
|
||||
mergerfs::api::is_mergerfs(const fs::path &mountpoint_)
|
||||
{
|
||||
fs::path dot_mergerfs_filepath;
|
||||
|
||||
dot_mergerfs_filepath = mountpoint_ / ".mergerfs";
|
||||
|
||||
return fs::exists(dot_mergerfs_filepath);
|
||||
}
|
||||
|
||||
int
|
||||
mergerfs::api::get_kvs(const fs::path &mountpoint_,
|
||||
std::map<std::string,std::string> *kvs_)
|
||||
{
|
||||
fs::path dot_mergerfs_filepath;
|
||||
|
||||
dot_mergerfs_filepath = mountpoint_ / ".mergerfs";
|
||||
|
||||
return fs::xattr::get(dot_mergerfs_filepath,kvs_);
|
||||
}
|
||||
|
||||
int
|
||||
mergerfs::api::allpaths(const std::string &input_path_,
|
||||
std::vector<std::string> &output_paths_)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
#include "fs_path.hpp"
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
|
@ -8,6 +11,13 @@ namespace mergerfs
|
|||
{
|
||||
namespace api
|
||||
{
|
||||
bool
|
||||
is_mergerfs(const fs::path &path);
|
||||
|
||||
int
|
||||
get_kvs(const fs::path &mountpoint,
|
||||
std::map<std::string,std::string> *kvs);
|
||||
|
||||
int
|
||||
basepath(const std::string &path,
|
||||
std::string &basepath);
|
||||
|
|
|
|||
|
|
@ -28,11 +28,10 @@ _write_str(const std::string &output_,
|
|||
::fwrite(str_.c_str(),1,str_.size(),f);
|
||||
}
|
||||
|
||||
template<typename ARGS>
|
||||
static
|
||||
void
|
||||
_run(const ARGS &args_,
|
||||
const std::string &output_)
|
||||
_run(const std::initializer_list<const char*> &args_,
|
||||
const std::string &output_)
|
||||
{
|
||||
std::string hdr;
|
||||
|
||||
|
|
@ -69,13 +68,7 @@ static
|
|||
void
|
||||
_mounts(const std::string &output_)
|
||||
{
|
||||
auto args =
|
||||
{
|
||||
"cat",
|
||||
"/proc/mounts"
|
||||
};
|
||||
|
||||
::_run(args,output_);
|
||||
::_run({"cat","/proc/mounts"},output_);
|
||||
}
|
||||
|
||||
static
|
||||
|
|
@ -93,8 +86,7 @@ _mount_point_stats(const std::string &output_)
|
|||
mergerfs::api::allpaths(mount.dir.string(),allpaths);
|
||||
for(const auto &path : allpaths)
|
||||
{
|
||||
auto args = {"stat",path.c_str()};
|
||||
::_run(args,output_);
|
||||
::_run({"stat",path.c_str()},output_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -103,65 +95,74 @@ static
|
|||
void
|
||||
_mergerfs_version(const std::string &output_)
|
||||
{
|
||||
auto args =
|
||||
{
|
||||
"mergerfs",
|
||||
"--version"
|
||||
};
|
||||
::_run({"mergerfs","--version"},output_);
|
||||
}
|
||||
|
||||
::_run(args,output_);
|
||||
static
|
||||
void
|
||||
_mergerfs_settings(const std::string &output_)
|
||||
{
|
||||
fs::MountVec mounts;
|
||||
|
||||
fs::mounts(mounts);
|
||||
|
||||
for(const auto &mount : mounts)
|
||||
{
|
||||
int rv;
|
||||
std::map<std::string,std::string> kvs;
|
||||
|
||||
rv = mergerfs::api::get_kvs(mount.dir.string(),&kvs);
|
||||
if(rv < 0)
|
||||
continue;
|
||||
|
||||
std::string output_str;
|
||||
|
||||
output_str = fmt::format("=== {}/.mergerfs\n",mount.dir.string());
|
||||
for(const auto &[k,v] : kvs)
|
||||
output_str += fmt::format("{}={}\n",k,v);
|
||||
output_str += "\n\n";
|
||||
|
||||
_write_str(output_,output_str);
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
_uname(const std::string &output_)
|
||||
{
|
||||
auto args =
|
||||
{
|
||||
"uname",
|
||||
"-a"
|
||||
};
|
||||
|
||||
::_run(args,output_);
|
||||
::_run({"uname","-a"},output_);
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
_lsb_release(const std::string &output_)
|
||||
{
|
||||
auto args =
|
||||
{
|
||||
"lsb_release",
|
||||
"-a"
|
||||
};
|
||||
|
||||
::_run(args,output_);
|
||||
::_run({"lsb_release","-a"},output_);
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
_df(const std::string &output_)
|
||||
{
|
||||
auto args =
|
||||
{
|
||||
"df",
|
||||
"-h"
|
||||
};
|
||||
|
||||
::_run(args,output_);
|
||||
::_run({"df","-h"},output_);
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
_fstab(const std::string &output_)
|
||||
{
|
||||
auto args =
|
||||
{
|
||||
"cat",
|
||||
"/etc/fstab"
|
||||
};
|
||||
::_run({"cat","/etc/fstab"},output_);
|
||||
}
|
||||
|
||||
::_run(args,output_);
|
||||
static
|
||||
void
|
||||
_software_versions(const std::string &output_)
|
||||
{
|
||||
::_run({"docker","--version"},output_);
|
||||
::_run({"docker","compose","--version"},output_);
|
||||
::_run({"podman","--version"},output_);
|
||||
::_run({"podman","compose","--version"},output_);
|
||||
::_run({"smbd","--version"},output_);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -195,7 +196,9 @@ mergerfs::collect_info::main(int argc_,
|
|||
::_lsblk(output_filepath);
|
||||
::_mounts(output_filepath);
|
||||
::_mount_point_stats(output_filepath);
|
||||
::_mergerfs_settings(output_filepath);
|
||||
::_fstab(output_filepath);
|
||||
::_software_versions(output_filepath);
|
||||
|
||||
fmt::print("* Upload the following file to your"
|
||||
" GitHub ticket or put on https://pastebin.com"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue