mirror of
https://github.com/ceph/ceph
synced 2025-02-19 17:08:05 +00:00
rados: add getxattr, setxattr
This commit is contained in:
parent
6a88d572f2
commit
515efd5a2f
37
src/rados.cc
37
src/rados.cc
@ -32,7 +32,7 @@ using namespace librados;
|
||||
|
||||
void usage()
|
||||
{
|
||||
cerr << "usage: radostool [options] [commands]" << std::endl;
|
||||
cerr << "usage: rados [options] [commands]" << std::endl;
|
||||
/* cerr << "If no commands are specified, enter interactive mode.\n";
|
||||
cerr << "Commands:" << std::endl;
|
||||
cerr << " stop -- cleanly shut down file system" << std::endl
|
||||
@ -47,6 +47,8 @@ void usage()
|
||||
cerr << " get objname [outfile] -- fetch object\n";
|
||||
cerr << " put objname [infile] -- write object\n";
|
||||
cerr << " rm objname -- remove object\n";
|
||||
cerr << " getxattr objame attr\n";
|
||||
cerr << " setxattr objame attr val\n";
|
||||
cerr << " ls -- list objects in pool\n\n";
|
||||
cerr << " chown 123 -- change the pool owner to auid 123\n";
|
||||
|
||||
@ -288,6 +290,39 @@ int main(int argc, const char **argv)
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
else if (strcmp(nargs[0], "setxattr") == 0) {
|
||||
if (!pool || nargs.size() < 4)
|
||||
usage();
|
||||
|
||||
string oid(nargs[1]);
|
||||
string attr_name(nargs[2]);
|
||||
string attr_val(nargs[3]);
|
||||
|
||||
bufferlist bl;
|
||||
bl.append(attr_val.c_str(), attr_val.length());
|
||||
|
||||
ret = rados.setxattr(p, oid, attr_name.c_str(), bl);
|
||||
if (ret < 0) {
|
||||
cerr << "error setting xattr " << pool << "/" << oid << "/" << attr_name << ": " << strerror_r(-ret, buf, sizeof(buf)) << std::endl;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
else if (strcmp(nargs[0], "getxattr") == 0) {
|
||||
if (!pool || nargs.size() < 3)
|
||||
usage();
|
||||
|
||||
string oid(nargs[1]);
|
||||
string attr_name(nargs[2]);
|
||||
|
||||
bufferlist bl;
|
||||
ret = rados.getxattr(p, oid, attr_name.c_str(), bl);
|
||||
if (ret < 0) {
|
||||
cerr << "error setting xattr " << pool << "/" << oid << "/" << attr_name << ": " << strerror_r(-ret, buf, sizeof(buf)) << std::endl;
|
||||
goto out;
|
||||
}
|
||||
string s(bl.c_str(), bl.length());
|
||||
cout << s << std::endl;
|
||||
}
|
||||
else if (strcmp(nargs[0], "rm") == 0) {
|
||||
if (!pool || nargs.size() < 2)
|
||||
usage();
|
||||
|
Loading…
Reference in New Issue
Block a user