mirror of
https://github.com/Zygo/bees.git
synced 2025-05-18 05:45:45 +02:00
Merge branch 'master' into subvol-threads
This commit is contained in:
commit
c39b72b4a7
@ -57,6 +57,10 @@ namespace crucible {
|
|||||||
|
|
||||||
typedef ResourceHandle<int, IOHandle> Fd;
|
typedef ResourceHandle<int, IOHandle> Fd;
|
||||||
|
|
||||||
|
static string __relative_path;
|
||||||
|
void set_relative_path(string path);
|
||||||
|
string relative_path();
|
||||||
|
|
||||||
// Functions named "foo_or_die" throw exceptions on failure.
|
// Functions named "foo_or_die" throw exceptions on failure.
|
||||||
|
|
||||||
// Attempt to open the file with the given mode
|
// Attempt to open the file with the given mode
|
||||||
|
23
lib/fd.cc
23
lib/fd.cc
@ -527,6 +527,22 @@ namespace crucible {
|
|||||||
THROW_ERROR(runtime_error, "readlink: maximum buffer size exceeded");
|
THROW_ERROR(runtime_error, "readlink: maximum buffer size exceeded");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string
|
||||||
|
relative_path()
|
||||||
|
{
|
||||||
|
return __relative_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
set_relative_path(string path)
|
||||||
|
{
|
||||||
|
path = path + "/";
|
||||||
|
for (string::size_type i = path.find("//"); i != string::npos; i = path.find("//")) {
|
||||||
|
path.erase(i, 1);
|
||||||
|
}
|
||||||
|
__relative_path = path;
|
||||||
|
}
|
||||||
|
|
||||||
// Turn a FD into a human-recognizable filename OR an error message.
|
// Turn a FD into a human-recognizable filename OR an error message.
|
||||||
string
|
string
|
||||||
name_fd(int fd)
|
name_fd(int fd)
|
||||||
@ -534,7 +550,12 @@ namespace crucible {
|
|||||||
try {
|
try {
|
||||||
ostringstream oss;
|
ostringstream oss;
|
||||||
oss << "/proc/self/fd/" << fd;
|
oss << "/proc/self/fd/" << fd;
|
||||||
return readlink_or_die(oss.str());
|
string path = readlink_or_die(oss.str());
|
||||||
|
if (!__relative_path.empty() && 0 == path.find(__relative_path))
|
||||||
|
{
|
||||||
|
path.erase(0, __relative_path.length());
|
||||||
|
}
|
||||||
|
return path;
|
||||||
} catch (exception &e) {
|
} catch (exception &e) {
|
||||||
return string(e.what());
|
return string(e.what());
|
||||||
}
|
}
|
||||||
|
@ -15,11 +15,8 @@ UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
|||||||
# BEESHOME="$MNT_DIR/.beeshome"
|
# BEESHOME="$MNT_DIR/.beeshome"
|
||||||
# BEESSTATUS="$WORK_DIR/$UUID.status"
|
# BEESSTATUS="$WORK_DIR/$UUID.status"
|
||||||
|
|
||||||
## Make path shorter in logs
|
## Default options to apply, see --help for details
|
||||||
# LOG_SHORT_PATH=N
|
# OPTIONS="--relative-paths --notimestamps"
|
||||||
|
|
||||||
## Remove timestamp from bees output
|
|
||||||
# LOG_FILTER_TIME=N
|
|
||||||
|
|
||||||
## Bees DB size
|
## Bees DB size
|
||||||
# Hash Table Sizing
|
# Hash Table Sizing
|
||||||
|
@ -64,7 +64,6 @@ MNT_DIR="${MNT_DIR:-$WORK_DIR/mnt/$UUID}"
|
|||||||
BEESHOME="${BEESHOME:-$MNT_DIR/.beeshome}"
|
BEESHOME="${BEESHOME:-$MNT_DIR/.beeshome}"
|
||||||
BEESSTATUS="${BEESSTATUS:-$WORK_DIR/$UUID.status}"
|
BEESSTATUS="${BEESSTATUS:-$WORK_DIR/$UUID.status}"
|
||||||
DB_SIZE="${DB_SIZE:-$((64*AL16M))}"
|
DB_SIZE="${DB_SIZE:-$((64*AL16M))}"
|
||||||
LOG_SHORT_PATH="${LOG_SHORT_PATH:-N}"
|
|
||||||
|
|
||||||
INFO "Check: Disk exists"
|
INFO "Check: Disk exists"
|
||||||
if [ ! -b "/dev/disk/by-uuid/$UUID" ]; then
|
if [ ! -b "/dev/disk/by-uuid/$UUID" ]; then
|
||||||
@ -116,14 +115,4 @@ fi
|
|||||||
|
|
||||||
MNT_DIR="${MNT_DIR//\/\//\/}"
|
MNT_DIR="${MNT_DIR//\/\//\/}"
|
||||||
|
|
||||||
filter_path(){
|
cd $MNT_DIR && exec @LIBEXEC_PREFIX@/bees ${ARGUMENTS[@]} $OPTIONS "$MNT_DIR"
|
||||||
if YN $LOG_SHORT_PATH; then
|
|
||||||
sed -e "s#$MNT_DIR##g"
|
|
||||||
else
|
|
||||||
cat
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
@LIBEXEC_PREFIX@/bees ${ARGUMENTS[@]} $OPTIONS "$MNT_DIR" 3>&1 2>&1 | filter_path
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
|
18
src/bees.cc
18
src/bees.cc
@ -37,6 +37,8 @@ do_cmd_help(char *argv[])
|
|||||||
"\t-h, --help\t\tShow this help\n"
|
"\t-h, --help\t\tShow this help\n"
|
||||||
"\t-t, --timestamps\tShow timestamps in log output (default)\n"
|
"\t-t, --timestamps\tShow timestamps in log output (default)\n"
|
||||||
"\t-T, --notimestamps\tOmit timestamps in log output\n"
|
"\t-T, --notimestamps\tOmit timestamps in log output\n"
|
||||||
|
"\t-p, --absolute-paths\tShow absolute paths (default)\n"
|
||||||
|
"\t-P, --relative-paths\tShow paths relative to $CWD\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Optional environment variables:\n"
|
"Optional environment variables:\n"
|
||||||
"\tBEESHOME\tPath to hash table and configuration files\n"
|
"\tBEESHOME\tPath to hash table and configuration files\n"
|
||||||
@ -611,6 +613,8 @@ bees_main(int argc, char *argv[])
|
|||||||
|
|
||||||
THROW_CHECK1(invalid_argument, argc, argc >= 0);
|
THROW_CHECK1(invalid_argument, argc, argc >= 0);
|
||||||
|
|
||||||
|
string cwd(readlink_or_die("/proc/self/cwd"));
|
||||||
|
|
||||||
// Defaults
|
// Defaults
|
||||||
bool chatter_prefix_timestamp = true;
|
bool chatter_prefix_timestamp = true;
|
||||||
|
|
||||||
@ -621,10 +625,12 @@ bees_main(int argc, char *argv[])
|
|||||||
static struct option long_options[] = {
|
static struct option long_options[] = {
|
||||||
{ "timestamps", no_argument, NULL, 't' },
|
{ "timestamps", no_argument, NULL, 't' },
|
||||||
{ "notimestamps", no_argument, NULL, 'T' },
|
{ "notimestamps", no_argument, NULL, 'T' },
|
||||||
|
{ "absolute-paths", no_argument, NULL, 'p' },
|
||||||
|
{ "relative-paths", no_argument, NULL, 'P' },
|
||||||
{ "help", no_argument, NULL, 'h' }
|
{ "help", no_argument, NULL, 'h' }
|
||||||
};
|
};
|
||||||
|
|
||||||
c = getopt_long(argc, argv, "Tth", long_options, &option_index);
|
c = getopt_long(argc, argv, "TtPph", long_options, &option_index);
|
||||||
if (-1 == c) {
|
if (-1 == c) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -636,6 +642,12 @@ bees_main(int argc, char *argv[])
|
|||||||
case 't':
|
case 't':
|
||||||
chatter_prefix_timestamp = true;
|
chatter_prefix_timestamp = true;
|
||||||
break;
|
break;
|
||||||
|
case 'P':
|
||||||
|
crucible::set_relative_path(cwd);
|
||||||
|
break;
|
||||||
|
case 'p':
|
||||||
|
crucible::set_relative_path("");
|
||||||
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
do_cmd_help(argv); // fallthrough
|
do_cmd_help(argv); // fallthrough
|
||||||
default:
|
default:
|
||||||
@ -645,6 +657,10 @@ bees_main(int argc, char *argv[])
|
|||||||
|
|
||||||
Chatter::enable_timestamp(chatter_prefix_timestamp);
|
Chatter::enable_timestamp(chatter_prefix_timestamp);
|
||||||
|
|
||||||
|
if (!relative_path().empty()) {
|
||||||
|
BEESLOG("using relative path " << relative_path() << "\n");
|
||||||
|
}
|
||||||
|
|
||||||
// There can be only one because we measure running time with it
|
// There can be only one because we measure running time with it
|
||||||
bees_ioctl_lock_set.max_size(1);
|
bees_ioctl_lock_set.max_size(1);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user