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
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";
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();