void set_snap(rados_pool_t pool, __u64 seq);
- int create(rados_pool_t pool, const object_t& oid, bool exclusive);
+ int create(rados_pool_t pool, const std::string& oid, bool exclusive);
- int write(rados_pool_t pool, const object_t& oid, off_t off, bufferlist& bl, size_t len);
- int write_full(rados_pool_t pool, const object_t& oid, bufferlist& bl);
- int read(rados_pool_t pool, const object_t& oid, off_t off, bufferlist& bl, size_t len);
- int remove(rados_pool_t pool, const object_t& oid);
+ int write(rados_pool_t pool, const std::string& oid, off_t off, bufferlist& bl, size_t len);
+ int write_full(rados_pool_t pool, const std::string& oid, bufferlist& bl);
+ int read(rados_pool_t pool, const std::string& oid, off_t off, bufferlist& bl, size_t len);
+ int remove(rados_pool_t pool, const std::string& oid);
- int getxattr(rados_pool_t pool, const object_t& oid, const char *name, bufferlist& bl);
- int setxattr(rados_pool_t pool, const object_t& oid, const char *name, bufferlist& bl);
- int getxattrs(rados_pool_t pool, const object_t& oid, map<nstring, bufferlist>& attrset);
- int stat(rados_pool_t pool, const object_t& oid, __u64 *psize, time_t *pmtime);
+ int getxattr(rados_pool_t pool, const std::string& oid, const char *name, bufferlist& bl);
+ int setxattr(rados_pool_t pool, const std::string& oid, const char *name, bufferlist& bl);
+ int getxattrs(rados_pool_t pool, const std::string& oid, map<std::string, bufferlist>& attrset);
+ int stat(rados_pool_t pool, const std::string& oid, __u64 *psize, time_t *pmtime);
- int tmap_update(rados_pool_t pool, const object_t& oid, bufferlist& cmdbl);
+ int tmap_update(rados_pool_t pool, const std::string& oid, bufferlist& cmdbl);
- int exec(rados_pool_t pool, const object_t& oid, const char *cls, const char *method,
+ int exec(rados_pool_t pool, const std::string& oid, const char *cls, const char *method,
bufferlist& inbl, bufferlist& outbl);
struct ListCtx {
ListCtx() : ctx(NULL) {}
};
- int list(rados_pool_t pool, int max, std::list<object_t>& entries, Rados::ListCtx& ctx);
+ int list(rados_pool_t pool, int max, std::list<std::string>& entries, Rados::ListCtx& ctx);
int list_pools(std::vector<std::string>& v);
int get_pool_stats(std::vector<std::string>& v,
std::map<std::string,rados_pool_stat_t>& stats);
void release();
};
- int aio_read(rados_pool_t pool, const object_t& oid, off_t off, bufferlist *pbl, size_t len,
+ int aio_read(rados_pool_t pool, const std::string& oid, off_t off, bufferlist *pbl, size_t len,
AioCompletion **pc);
- int aio_write(rados_pool_t pool, const object_t& oid, off_t off, const bufferlist& bl, size_t len,
+ int aio_write(rados_pool_t pool, const std::string& oid, off_t off, const bufferlist& bl, size_t len,
AioCompletion **pc);
};
nstring name;
object_t(const char *s = 0) : name(s) {}
+ object_t(const string& s) : name(s) {}
void swap(object_t& o) {
name.swap(o.name);
}
int getxattr(PoolCtx& pool, const object_t& oid, const char *name, bufferlist& bl);
int setxattr(PoolCtx& pool, const object_t& oid, const char *name, bufferlist& bl);
- int getxattrs(PoolCtx& pool, const object_t& oid, map<nstring, bufferlist>& attrset);
+ int getxattrs(PoolCtx& pool, const object_t& oid, map<string, bufferlist>& attrset);
int list_pools(std::vector<string>& ls);
int get_pool_stats(std::vector<string>& ls, map<string,rados_pool_stat_t>& result);
return bl.length();
}
-int RadosClient::getxattrs(PoolCtx& pool, const object_t& oid, map<nstring, bufferlist>& attrset)
+int RadosClient::getxattrs(PoolCtx& pool, const object_t& oid, map<std::string, bufferlist>& attrset)
{
utime_t ut = g_clock.now();
lock.Lock();
ceph_object_layout layout = objecter->osdmap->make_object_layout(oid, pool.poolid);
+ map<nstring, bufferlist> aset;
objecter->getxattrs(oid, layout, pool.snap_seq,
- attrset,
- 0, onack);
+ aset,
+ 0, onack);
lock.Unlock();
+ attrset.clear();
+ for (map<nstring,bufferlist>::iterator p = aset.begin(); p != aset.end(); p++)
+ attrset[p->first.c_str()] = p->second;
+
mylock.Lock();
while (!done)
cond.Wait(mylock);
return client->get_fs_stats(result);
}
-int Rados::list(rados_pool_t pool, int max, std::list<object_t>& entries, Rados::ListCtx& ctx)
+int Rados::list(rados_pool_t pool, int max, std::list<string>& entries, Rados::ListCtx& ctx)
{
if (!client)
return -EINVAL;
}
op = (Objecter::ListContext *) ctx.ctx;
- return client->list(*(RadosClient::PoolCtx *)pool, max, entries, op);
+ std::list<object_t> e;
+ int r = client->list(*(RadosClient::PoolCtx *)pool, max, e, op);
+ while (!e.empty()) {
+ entries.push_back(e.front().name.c_str());
+ e.pop_front();
+ }
+ return r;
}
-int Rados::create(rados_pool_t pool, const object_t& oid, bool exclusive)
+int Rados::create(rados_pool_t pool, const string& o, bool exclusive)
{
if (!client)
return -EINVAL;
-
+ object_t oid(o);
return client->create(*(RadosClient::PoolCtx *)pool, oid, exclusive);
}
-int Rados::write(rados_pool_t pool, const object_t& oid, off_t off, bufferlist& bl, size_t len)
+int Rados::write(rados_pool_t pool, const string& o, off_t off, bufferlist& bl, size_t len)
{
if (!client)
return -EINVAL;
-
+ object_t oid(o);
return client->write(*(RadosClient::PoolCtx *)pool, oid, off, bl, len);
}
-int Rados::write_full(rados_pool_t pool, const object_t& oid, bufferlist& bl)
+int Rados::write_full(rados_pool_t pool, const string& o, bufferlist& bl)
{
if (!client)
return -EINVAL;
-
+ object_t oid(o);
return client->write_full(*(RadosClient::PoolCtx *)pool, oid, bl);
}
-int Rados::remove(rados_pool_t pool, const object_t& oid)
+int Rados::remove(rados_pool_t pool, const string& o)
{
if (!client)
return -EINVAL;
-
+ object_t oid(o);
return client->remove(*(RadosClient::PoolCtx *)pool, oid);
}
-int Rados::read(rados_pool_t pool, const object_t& oid, off_t off, bufferlist& bl, size_t len)
+int Rados::read(rados_pool_t pool, const string& o, off_t off, bufferlist& bl, size_t len)
{
if (!client)
return -EINVAL;
-
+ object_t oid(o);
return client->read(*(RadosClient::PoolCtx *)pool, oid, off, bl, len);
}
-int Rados::getxattr(rados_pool_t pool, const object_t& oid, const char *name, bufferlist& bl)
+int Rados::getxattr(rados_pool_t pool, const string& o, const char *name, bufferlist& bl)
{
if (!client)
return -EINVAL;
-
+ object_t oid(o);
return client->getxattr(*(RadosClient::PoolCtx *)pool, oid, name, bl);
}
-int Rados::getxattrs(rados_pool_t pool, const object_t& oid, map<nstring, bufferlist>& attrset)
+int Rados::getxattrs(rados_pool_t pool, const string& o, map<std::string, bufferlist>& attrset)
{
if (!client)
return -EINVAL;
-
+ object_t oid(o);
return client->getxattrs(*(RadosClient::PoolCtx *)pool, oid, attrset);
}
-int Rados::setxattr(rados_pool_t pool, const object_t& oid, const char *name, bufferlist& bl)
+int Rados::setxattr(rados_pool_t pool, const string& o, const char *name, bufferlist& bl)
{
if (!client)
return -EINVAL;
-
+ object_t oid(o);
return client->setxattr(*(RadosClient::PoolCtx *)pool, oid, name, bl);
}
-int Rados::stat(rados_pool_t pool, const object_t& oid, __u64 *psize, time_t *pmtime)
+int Rados::stat(rados_pool_t pool, const string& o, __u64 *psize, time_t *pmtime)
{
if (!client)
return -EINVAL;
-
+ object_t oid(o);
return client->stat(*(RadosClient::PoolCtx *)pool, oid, psize, pmtime);
}
-int Rados::tmap_update(rados_pool_t pool, const object_t& oid, bufferlist& cmdbl)
+int Rados::tmap_update(rados_pool_t pool, const string& o, bufferlist& cmdbl)
{
if (!client)
return -EINVAL;
+ object_t oid(o);
return client->tmap_update(*(RadosClient::PoolCtx *)pool, oid, cmdbl);
}
-int Rados::exec(rados_pool_t pool, const object_t& oid, const char *cls, const char *method,
+int Rados::exec(rados_pool_t pool, const string& o, const char *cls, const char *method,
bufferlist& inbl, bufferlist& outbl)
{
if (!client)
return -EINVAL;
-
+ object_t oid(o);
return client->exec(*(RadosClient::PoolCtx *)pool, oid, cls, method, inbl, outbl);
}
}
// AIO
-int Rados::aio_read(rados_pool_t pool, const object_t& oid, off_t off, bufferlist *pbl, size_t len,
+int Rados::aio_read(rados_pool_t pool, const string& oid, off_t off, bufferlist *pbl, size_t len,
Rados::AioCompletion **pc)
{
RadosClient::PoolCtx *ctx = (RadosClient::PoolCtx *)pool;
return r;
}
-int Rados::aio_write(rados_pool_t pool, const object_t& oid, off_t off, const bufferlist& bl, size_t len,
+int Rados::aio_write(rados_pool_t pool, const string& oid, off_t off, const bufferlist& bl, size_t len,
AioCompletion **pc)
{
RadosClient::PoolCtx *ctx = (RadosClient::PoolCtx *)pool;
Rados::ListCtx ctx;
while (1) {
- list<object_t> vec;
+ list<string> vec;
ret = rados.list(p, 1 << 10, vec, ctx);
if (ret < 0) {
cerr << "got error: " << strerror_r(-ret, buf, sizeof(buf)) << std::endl;
if (vec.empty())
break;
- for (list<object_t>::iterator iter = vec.begin(); iter != vec.end(); ++iter)
- *outstream << iter->name << std::endl;
+ for (list<string>::iterator iter = vec.begin(); iter != vec.end(); ++iter)
+ *outstream << *iter << std::endl;
}
if (!stdout)
delete outstream;
else if (strcmp(nargs[0], "get") == 0) {
if (!pool || nargs.size() < 3)
usage();
- object_t oid(nargs[1]);
+ string oid(nargs[1]);
ret = rados.read(p, oid, 0, outdata, 0);
if (ret < 0) {
cerr << "error reading " << pool << "/" << oid << ": " << strerror_r(-ret, buf, sizeof(buf)) << std::endl;
if (!pool || nargs.size() < 3)
usage();
- object_t oid(nargs[1]);
+ string oid(nargs[1]);
if (strcmp(nargs[2], "-") == 0) {
char buf[256];
else if (strcmp(nargs[0], "rm") == 0) {
if (!pool || nargs.size() < 2)
usage();
- object_t oid(nargs[1]);
+ string oid(nargs[1]);
ret = rados.remove(p, oid);
if (ret < 0) {
cerr << "error removing " << pool << "/" << oid << ": " << strerror_r(-ret, buf, sizeof(buf)) << std::endl;
snprintf(buf, 128, "%s", ctime(&tm));
bl.append(buf, strlen(buf));
- object_t oid("bar");
+ const char *oid = "bar";
rados_pool_t pool;
int r = rados.open_pool("data", &pool);
if (!opt_create && !opt_delete && !opt_list)
usage();
- string imgmd_str = imgname;
- imgmd_str += RBD_SUFFIX;
- object_t md_oid(imgmd_str.c_str());
- object_t dir_oid(RBD_DIRECTORY);
+ string md_oid = imgname;
+ md_oid += RBD_SUFFIX;
+ string dir_oid = RBD_DIRECTORY;
rados_pool_t pool;
for (__u64 i=0; i<numseg; i++) {
char o[RBD_MAX_SEG_NAME_SIZE];
sprintf(o, "%s.%012llx", imgname, (unsigned long long)i);
- object_t oid(o);
+ string oid = o;
rados.remove(pool, oid);
if ((i & 127) == 0) {
cout << "\r\t" << i << "/" << numseg;
std::string& marker, std::vector<RGWObjEnt>& result, map<string, bool>& common_prefixes) = 0;
/** Create a new bucket*/
- virtual int create_bucket(std::string& id, std::string& bucket, map<nstring, bufferlist>& attrs, __u64 auid=0) = 0;
+ virtual int create_bucket(std::string& id, std::string& bucket, map<std::string, bufferlist>& attrs, __u64 auid=0) = 0;
/** write an object to the storage device in the appropriate pool
with the given stats */
virtual int put_obj(std::string& id, std::string& bucket, std::string& obj, const char *data, size_t size,
time_t *mtime,
- map<nstring, bufferlist>& attrs) = 0;
+ map<std::string, bufferlist>& attrs) = 0;
/**
* Copy an object.
* id: unused (well, it's passed to put_obj)
const time_t *unmod_ptr,
const char *if_match,
const char *if_nomatch,
- map<nstring, bufferlist>& attrs,
+ map<std::string, bufferlist>& attrs,
struct rgw_err *err) = 0;
/**
* Delete a bucket.
* (if get_data==false) length of the object
*/
virtual int get_obj(std::string& bucket, std::string& obj,
- char **data, off_t ofs, off_t end,
- map<nstring, bufferlist> *attrs,
- const time_t *mod_ptr,
- const time_t *unmod_ptr,
- const char *if_match,
- const char *if_nomatch,
- bool get_data,
- struct rgw_err *err) = 0;
+ char **data, off_t ofs, off_t end,
+ map<std::string, bufferlist> *attrs,
+ const time_t *mod_ptr,
+ const time_t *unmod_ptr,
+ const char *if_match,
+ const char *if_nomatch,
+ bool get_data,
+ struct rgw_err *err) = 0;
/**
* Get the attributes for an object.
}
-int RGWFS::create_bucket(std::string& id, std::string& bucket, map<nstring, bufferlist>& attrs, __u64 auid)
+int RGWFS::create_bucket(std::string& id, std::string& bucket, map<std::string, bufferlist>& attrs, __u64 auid)
{
int len = strlen(DIR_NAME) + 1 + bucket.size() + 1;
char buf[len];
if (mkdir(buf, 0755) < 0)
return -errno;
- map<nstring, bufferlist>::iterator iter;
+ map<std::string, bufferlist>::iterator iter;
for (iter = attrs.begin(); iter != attrs.end(); ++iter) {
- nstring name = iter->first;
+ const string& name = iter->first;
bufferlist& bl = iter->second;
if (bl.length()) {
int RGWFS::put_obj(std::string& id, std::string& bucket, std::string& obj, const char *data, size_t size,
time_t *mtime,
- map<nstring, bufferlist>& attrs)
+ map<string, bufferlist>& attrs)
{
int len = strlen(DIR_NAME) + 1 + bucket.size() + 1 + obj.size() + 1;
char buf[len];
return -errno;
int r;
- map<nstring, bufferlist>::iterator iter;
+ map<string, bufferlist>::iterator iter;
for (iter = attrs.begin(); iter != attrs.end(); ++iter) {
- nstring name = iter->first;
+ const string& name = iter->first;
bufferlist& bl = iter->second;
if (bl.length()) {
const time_t *unmod_ptr,
const char *if_match,
const char *if_nomatch,
- map<nstring, bufferlist>& attrs,
+ map<string, bufferlist>& attrs,
struct rgw_err *err)
{
int ret;
char *data;
- map<nstring, bufferlist> attrset;
+ map<string, bufferlist> attrset;
ret = get_obj(src_bucket, src_obj, &data, 0, -1, &attrset,
mod_ptr, unmod_ptr, if_match, if_nomatch, true, err);
if (ret < 0)
return ret;
- map<nstring, bufferlist>::iterator iter;
+ map<string, bufferlist>::iterator iter;
for (iter = attrs.begin(); iter != attrs.end(); ++iter) {
attrset[iter->first] = iter->second;
}
attrs = attrset;
- ret = put_obj(id, dest_bucket, dest_obj, data, ret, mtime, attrs);
+ ret = put_obj(id, dest_bucket, dest_obj, data, ret, mtime, attrs);
return ret;
}
int RGWFS::get_obj(std::string& bucket, std::string& obj,
char **data, off_t ofs, off_t end,
- map<nstring, bufferlist> *attrs,
+ map<string, bufferlist> *attrs,
const time_t *mod_ptr,
const time_t *unmod_ptr,
const char *if_match,
int list_objects(std::string& id, std::string& bucket, int max, std::string& prefix, std::string& delim,
std::string& marker, std::vector<RGWObjEnt>& result, map<string, bool>& common_prefixes);
- int create_bucket(std::string& id, std::string& bucket, map<nstring, bufferlist>& attrs, __u64 auid=0);
+ int create_bucket(std::string& id, std::string& bucket, map<std::string, bufferlist>& attrs, __u64 auid=0);
int put_obj(std::string& id, std::string& bucket, std::string& obj, const char *data, size_t size,
time_t *mtime,
- map<nstring, bufferlist>& attrs);
+ map<std::string, bufferlist>& attrs);
int copy_obj(std::string& id, std::string& dest_bucket, std::string& dest_obj,
std::string& src_bucket, std::string& src_obj,
time_t *mtime,
const time_t *unmod_ptr,
const char *if_match,
const char *if_nomatch,
- map<nstring, bufferlist>& attrs,
+ map<std::string, bufferlist>& attrs,
struct rgw_err *err);
int delete_bucket(std::string& id, std::string& bucket);
int delete_obj(std::string& id, std::string& bucket, std::string& obj);
int get_obj(std::string& bucket, std::string& obj,
char **data, off_t ofs, off_t end,
- map<nstring, bufferlist> *attrs,
+ map<std::string, bufferlist> *attrs,
const time_t *mod_ptr,
const time_t *unmod_ptr,
const char *if_match,
* attrs: will be filled up with attrs mapped as <attr_name, attr_contents>
*
*/
-void get_request_metadata(struct req_state *s, map<nstring, bufferlist>& attrs)
+void get_request_metadata(struct req_state *s, map<string, bufferlist>& attrs)
{
map<string, string>::iterator iter;
for (iter = s->x_amz_map.begin(); iter != s->x_amz_map.end(); ++iter) {
void RGWCreateBucket::execute()
{
RGWAccessControlPolicy policy;
- map<nstring, bufferlist> attrs;
+ map<string, bufferlist> attrs;
bufferlist aclbl;
bool pol_ret = policy.create_canned(s->user.user_id, s->user.display_name, s->canned_acl);
policy.encode(aclbl);
string md5_str(calc_md5);
- map<nstring, bufferlist> attrs;
+ map<string, bufferlist> attrs;
bufferlist bl;
bl.append(md5_str.c_str(), md5_str.size() + 1);
attrs[RGW_ATTR_ETAG] = bl;
RGWAccessControlPolicy dest_policy;
bool ret;
bufferlist aclbl;
- map<nstring, bufferlist> attrs;
+ map<string, bufferlist> attrs;
bufferlist bl;
RGWAccessControlPolicy src_policy;
string empty_str;
struct req_state;
/** Get the HTTP request metadata */
-extern void get_request_metadata(struct req_state *s, map<nstring, bufferlist>& attrs);
+extern void get_request_metadata(struct req_state *s, map<string, bufferlist>& attrs);
/**
* Get the ACL for an object off of disk. If you hold the req_state, use next
* method.
time_t unmod_time;
time_t *mod_ptr;
time_t *unmod_ptr;
- map<nstring, bufferlist> attrs;
+ map<string, bufferlist> attrs;
char *data;
int ret;
struct rgw_err err;
time_t *mod_ptr;
time_t *unmod_ptr;
int ret;
- map<nstring, bufferlist> attrs;
+ map<string, bufferlist> attrs;
struct rgw_err err;
string src_bucket;
string src_object;
* here.
*/
int RGWRados::list_objects(string& id, string& bucket, int max, string& prefix, string& delim,
- string& marker, vector<RGWObjEnt>& result, map<string, bool>& common_prefixes)
+ string& marker, vector<RGWObjEnt>& result, map<string, bool>& common_prefixes)
{
rados_pool_t pool;
- map<string, object_t> dir_map;
+ set<string> dir_set;
int r = rados->open_pool(bucket.c_str(), &pool);
if (r < 0)
#define MAX_ENTRIES 1000
do {
- list<object_t> entries;
+ list<string> entries;
r = rados->list(pool, MAX_ENTRIES, entries, ctx);
if (r < 0)
return r;
- list<object_t>::iterator iter;
- for (iter = entries.begin(); iter != entries.end(); ++iter) {
- string name = iter->name.c_str();
-
+ for (list<string>::iterator iter = entries.begin(); iter != entries.end(); ++iter) {
if (prefix.empty() ||
- (name.compare(0, prefix.size(), prefix) == 0)) {
- dir_map[name] = *iter;
+ (iter->compare(0, prefix.size(), prefix) == 0)) {
+ dir_set.insert(*iter);
}
}
} while (r);
- map<string, object_t>::iterator map_iter;
+ set<string>::iterator p;
if (!marker.empty())
- map_iter = dir_map.lower_bound(marker);
+ p = dir_set.lower_bound(marker);
else
- map_iter = dir_map.begin();
+ p = dir_set.begin();
if (max < 0) {
- max = dir_map.size();
+ max = dir_set.size();
}
result.clear();
int i, count = 0;
- for (i=0; i<max && map_iter != dir_map.end(); i++, ++map_iter) {
+ for (i=0; i<max && p != dir_set.end(); i++, ++p) {
RGWObjEnt obj;
- obj.name = map_iter->first;
+ obj.name = *p;
if (!delim.empty()) {
int delim_pos = obj.name.find(delim, prefix.size());
}
__u64 s;
- if (rados->stat(pool, map_iter->second, &s, &obj.mtime) < 0)
+ if (rados->stat(pool, *p, &s, &obj.mtime) < 0)
continue;
obj.size = s;
bufferlist bl;
obj.etag[0] = '\0';
- if (rados->getxattr(pool, map_iter->second, RGW_ATTR_ETAG, bl) >= 0) {
+ if (rados->getxattr(pool, *p, RGW_ATTR_ETAG, bl) >= 0) {
strncpy(obj.etag, bl.c_str(), sizeof(obj.etag));
obj.etag[sizeof(obj.etag)-1] = '\0';
}
* if auid is set, it sets the auid of the underlying rados pool
* returns 0 on success, -ERR# otherwise.
*/
-int RGWRados::create_bucket(std::string& id, std::string& bucket, map<nstring, bufferlist>& attrs, __u64 auid)
+int RGWRados::create_bucket(std::string& id, std::string& bucket, map<std::string, bufferlist>& attrs, __u64 auid)
{
- object_t bucket_oid(bucket.c_str());
-
- int ret = rados->create(root_pool, bucket_oid, true);
+ int ret = rados->create(root_pool, bucket, true);
if (ret < 0)
return ret;
- map<nstring, bufferlist>::iterator iter;
+ map<string, bufferlist>::iterator iter;
for (iter = attrs.begin(); iter != attrs.end(); ++iter) {
- nstring name = iter->first;
+ string name = iter->first;
bufferlist& bl = iter->second;
if (bl.length()) {
- ret = rados->setxattr(root_pool, bucket_oid, name.c_str(), bl);
+ ret = rados->setxattr(root_pool, bucket, name.c_str(), bl);
if (ret < 0) {
delete_bucket(id, bucket);
return ret;
* attrs: all the given attrs are written to bucket storage for the given object
* Returns: 0 on success, -ERR# otherwise.
*/
-int RGWRados::put_obj(std::string& id, std::string& bucket, std::string& obj, const char *data, size_t size,
+int RGWRados::put_obj(std::string& id, std::string& bucket, std::string& oid, const char *data, size_t size,
time_t *mtime,
- map<nstring, bufferlist>& attrs)
+ map<string, bufferlist>& attrs)
{
rados_pool_t pool;
if (r < 0)
return r;
- object_t oid(obj.c_str());
-
- map<nstring, bufferlist>::iterator iter;
+ map<string, bufferlist>::iterator iter;
for (iter = attrs.begin(); iter != attrs.end(); ++iter) {
- nstring name = iter->first;
+ const string& name = iter->first;
bufferlist& bl = iter->second;
if (bl.length()) {
const time_t *unmod_ptr,
const char *if_match,
const char *if_nomatch,
- map<nstring, bufferlist>& attrs, /* in/out */
+ map<string, bufferlist>& attrs, /* in/out */
struct rgw_err *err)
{
int ret;
cerr << "copy " << src_bucket << ":" << src_obj << " => " << dest_bucket << ":" << dest_obj << std::endl;
- map<nstring, bufferlist> attrset;
+ map<string, bufferlist> attrset;
ret = get_obj(src_bucket, src_obj, &data, 0, -1, &attrset,
mod_ptr, unmod_ptr, if_match, if_nomatch, true, err);
if (ret < 0)
return ret;
- map<nstring, bufferlist>::iterator iter;
+ map<string, bufferlist>::iterator iter;
for (iter = attrs.begin(); iter != attrs.end(); ++iter) {
attrset[iter->first] = iter->second;
}
* obj: name of the object to delete
* Returns: 0 on success, -ERR# otherwise.
*/
-int RGWRados::delete_obj(std::string& id, std::string& bucket, std::string& obj)
+int RGWRados::delete_obj(std::string& id, std::string& bucket, std::string& oid)
{
rados_pool_t pool;
if (r < 0)
return r;
- object_t oid(obj.c_str());
-
r = rados->remove(pool, oid);
if (r < 0)
return r;
if (r < 0)
return r;
- object_t oid(actual_obj.c_str());
- r = rados->getxattr(pool, oid, name, dest);
+ r = rados->getxattr(pool, actual_obj, name, dest);
if (r < 0)
return r;
* bl: the contents of the attr
* Returns: 0 on success, -ERR# otherwise.
*/
-int RGWRados::set_attr(std::string& bucket, std::string& obj,
+int RGWRados::set_attr(std::string& bucket, std::string& oid,
const char *name, bufferlist& bl)
{
rados_pool_t pool;
if (r < 0)
return r;
- object_t oid(obj.c_str());
r = rados->setxattr(pool, oid, name, bl);
if (r < 0)
* (if get_data==true) length of read data,
* (if get_data==false) length of the object
*/
-int RGWRados::get_obj(std::string& bucket, std::string& obj,
+int RGWRados::get_obj(std::string& bucket, std::string& oid,
char **data, off_t ofs, off_t end,
- map<nstring, bufferlist> *attrs,
+ map<string, bufferlist> *attrs,
const time_t *mod_ptr,
const time_t *unmod_ptr,
const char *if_match,
bufferlist bl;
rados_pool_t pool;
- map<nstring, bufferlist>::iterator iter;
+ map<string, bufferlist>::iterator iter;
r = open_pool(bucket, &pool);
if (r < 0)
return r;
- object_t oid(obj.c_str());
-
r = rados->stat(pool, oid, &size, &mtime);
if (r < 0)
return r;
}
}
if (if_match || if_nomatch) {
- r = get_attr(bucket, obj, RGW_ATTR_ETAG, etag);
+ r = get_attr(bucket, oid, RGW_ATTR_ETAG, etag);
if (r < 0)
goto done;
* create a bucket with name bucket and the given list of attrs
* returns 0 on success, -ERR# otherwise.
*/
- int create_bucket(std::string& id, std::string& bucket, map<nstring,
- bufferlist>& attrs, __u64 auid=0);
+ int create_bucket(std::string& id, std::string& bucket, map<std::string,bufferlist>& attrs, __u64 auid=0);
/** Write/overwrite an object to the bucket storage. */
int put_obj(std::string& id, std::string& bucket, std::string& obj, const char *data, size_t size,
time_t *mtime,
- map<nstring, bufferlist>& attrs);
+ map<std::string, bufferlist>& attrs);
/** Copy an object, with many extra options */
int copy_obj(std::string& id, std::string& dest_bucket, std::string& dest_obj,
std::string& src_bucket, std::string& src_obj,
const time_t *unmod_ptr,
const char *if_match,
const char *if_nomatch,
- map<nstring, bufferlist>& attrs,
+ map<std::string, bufferlist>& attrs,
struct rgw_err *err);
/** delete a bucket*/
int delete_bucket(std::string& id, std::string& bucket);
/** Get data about an object out of RADOS and into memory. */
int get_obj(std::string& bucket, std::string& obj,
char **data, off_t ofs, off_t end,
- map<nstring, bufferlist> *attrs,
+ map<string, bufferlist> *attrs,
const time_t *mod_ptr,
const time_t *unmod_ptr,
const char *if_match,
dump_content_length(s, len);
}
if (!ret) {
- map<nstring, bufferlist>::iterator iter = attrs.find(RGW_ATTR_ETAG);
+ map<string, bufferlist>::iterator iter = attrs.find(RGW_ATTR_ETAG);
if (iter != attrs.end()) {
bufferlist& bl = iter->second;
if (bl.length()) {
if (ret == 0) {
open_section(s, "CopyObjectResult");
dump_time(s, "LastModified", &mtime);
- map<nstring, bufferlist>::iterator iter = attrs.find(RGW_ATTR_ETAG);
+ map<string, bufferlist>::iterator iter = attrs.find(RGW_ATTR_ETAG);
if (iter != attrs.end()) {
bufferlist& bl = iter->second;
if (bl.length()) {
const char *data = bl.c_str();
string md5;
int ret;
- map<nstring,bufferlist> attrs;
+ map<string,bufferlist> attrs;
ret = rgwstore->put_obj(info.user_id, ui_bucket, info.user_id, data, bl.length(), NULL, attrs);
ui.encode(uid_bl);
ret = rgwstore->put_obj(info.user_id, ui_email_bucket, info.user_email, uid_bl.c_str(), uid_bl.length(), NULL, attrs);
if (ret == -ENOENT) {
- map<nstring, bufferlist> attrs;
+ map<string, bufferlist> attrs;
ret = rgwstore->create_bucket(info.user_id, ui_email_bucket, attrs);
if (ret >= 0)
ret = rgwstore->put_obj(info.user_id, ui_email_bucket, info.user_email, uid_bl.c_str(), uid_bl.length(), NULL, attrs);
snprintf(buf, 128, "%s", ctime(&tm));
bl.append(buf, strlen(buf));
- object_t oid("bar");
+ const char *oid = "bar";
rados_pool_t pool;
Rados::ListCtx ctx;
int entries;
do {
- list<object_t> vec;
+ list<string> vec;
r = rados.list(pool, 2, vec, ctx);
entries = vec.size();
cout << "list result=" << r << " entries=" << entries << std::endl;
- list<object_t>::iterator iter;
+ list<string>::iterator iter;
for (iter = vec.begin(); iter != vec.end(); ++iter) {
cout << *iter << std::endl;
}
} while (entries);
- map<nstring, bufferlist> attrset;
+ map<string, bufferlist> attrset;
rados.getxattrs(pool, oid, attrset);
- map<nstring, bufferlist>::iterator it;
+ map<string, bufferlist>::iterator it;
for (it = attrset.begin(); it != attrset.end(); ++it) {
cout << "xattr: " << it->first << std::endl;
}