Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Avoid using attr -qg for Retrieval of Mounted Root Hash #933

Merged
merged 4 commits into from Jun 4, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion cvmfs/cvmfs_server
Expand Up @@ -1767,7 +1767,9 @@ get_mounted_root_hash() {
local repository_name=$1

load_repo_config $repository_name
attr -qg root_hash ${CVMFS_SPOOL_DIR}/rdonly
__swissknife info -r $CVMFS_STRATUM0 \
-u ${CVMFS_SPOOL_DIR}/rdonly \
-C $(get_follow_http_redirects_flag)
}


Expand Down
32 changes: 32 additions & 0 deletions cvmfs/swissknife_info.cc
Expand Up @@ -46,8 +46,10 @@ static bool Exists(const string &repository, const string &file)
ParameterList CommandInfo::GetParams() {
swissknife::ParameterList r;
r.push_back(Parameter::Mandatory('r', "repository directory / url"));
r.push_back(Parameter::Optional('u', "repository mount point"));
r.push_back(Parameter::Optional('l', "log level (0-4, default: 2)"));
r.push_back(Parameter::Switch('c', "show root catalog hash"));
r.push_back(Parameter::Switch('C', "show mounted root catalog hash"));
r.push_back(Parameter::Switch('n', "show fully qualified repository name"));
r.push_back(Parameter::Switch('t', "show time stamp"));
r.push_back(Parameter::Switch('m', "check if repository is marked as "
Expand All @@ -71,8 +73,17 @@ int swissknife::CommandInfo::Main(const swissknife::ArgumentList &args) {
}
SetLogVerbosity(static_cast<LogLevels>(log_level));
}
const string mount_point = (args.find('u') != args.end())
? *args.find('u')->second
: "";
const string repository = MakeCanonicalPath(*args.find('r')->second);

// sanity check
if (args.count('C') > 0 && mount_point.empty()) {
LogCvmfs(kLogCvmfs, kLogStderr, "need a CernVM-FS mountpoint (-u) for -C");
return 1;
}

// Load manifest file
// Repository can be HTTP address or on local file system
// TODO(jblomer): do this using Manifest::Fetch
Expand Down Expand Up @@ -127,6 +138,27 @@ int swissknife::CommandInfo::Main(const swissknife::ArgumentList &args) {
// Check if we should be human readable
const bool human_readable = (args.count('h') > 0);

// Get information from the mount point
if (args.count('C') > 0) {
assert(!mount_point.empty());
const std::string root_hash_xattr = "user.root_hash";
std::string root_hash;
const bool success = platform_getxattr(mount_point,
root_hash_xattr,
&root_hash);
if (!success) {
LogCvmfs(kLogCvmfs, kLogStderr, "failed to retrieve extended attribute "
" '%s' from '%s' (errno: %d)",
root_hash_xattr.c_str(),
mount_point.c_str(),
errno);
return 1;
}
LogCvmfs(kLogCvmfs, kLogStdout, "%s%s",
(human_readable) ? "Mounted Root Hash: " : "",
root_hash.c_str());
}

// Get information from the Manifest
if (args.count('c') > 0) {
LogCvmfs(kLogCvmfs, kLogStdout, "%s%s",
Expand Down