From c2e7eed6c746daf5f8bd0f2805b64c9183aa8148 Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Tue, 23 Mar 2010 13:41:01 -0700 Subject: [PATCH] librados: add change_pool_auid functions --- src/librados.cc | 41 +++++++++++++++++++++++++++++++++++++++++ src/osdc/librados.h | 2 ++ 2 files changed, 43 insertions(+) diff --git a/src/librados.cc b/src/librados.cc index e9b9c05eb9328..83ae953677df7 100644 --- a/src/librados.cc +++ b/src/librados.cc @@ -131,6 +131,7 @@ public: int create_pool(string& name, __u64 auid=0); int delete_pool(const rados_pool_t& pool); + int change_pool_auid(const rados_pool_t& pool, __u64 auid); int list(PoolCtx& pool, int max_entries, std::list& entries, Objecter::ListContext *context); @@ -570,6 +571,34 @@ int RadosClient::delete_pool(const rados_pool_t& pool) return reply; } +/** + * Attempt to change a pool's associated auid "owner." Requires that you + * have write permission on both the current and new auid. + * pool: reference to the pool to change. + * auid: the auid you wish the pool to have. + * Returns: 0 on success, or -ERROR# on failure. + */ +int RadosClient::change_pool_auid(const rados_pool_t& pool, __u64 auid) +{ + int reply; + + int poolID = ((PoolCtx *)pool)->poolid; + + Mutex mylock("RadosClient::change_pool_auid::mylock"); + Cond cond; + bool done; + lock.Lock(); + objecter->change_pool_auid(poolID, + new C_SafeCond(&mylock, &cond, &done, &reply), + auid); + lock.Unlock(); + + mylock.Lock(); + while (!done) cond.Wait(mylock); + mylock.Unlock(); + return reply; +} + int RadosClient::snap_list(PoolCtx *pool, vector *snaps) { Mutex::Locker l(lock); @@ -1096,6 +1125,12 @@ int Rados::delete_pool(const rados_pool_t& pool) return client->delete_pool(pool); } +int Rados::change_pool_auid(const rados_pool_t& pool, __u64 auid) +{ + if (!client) return -EINVAL; + return client->change_pool_auid(pool, auid); +} + int Rados::get_fs_stats(rados_statfs_t& result) { if(!client) return -EINVAL; return client->get_fs_stats(result); @@ -1460,6 +1495,12 @@ extern "C" int rados_delete_pool(const rados_pool_t pool) { return radosp->delete_pool(pool); } + +extern "C" int rados_change_pool_auid(const rados_pool_t pool, __u64 auid) +{ + return radosp->change_pool_auid(pool, auid); +} + // snaps extern "C" int rados_snap_create(const rados_pool_t pool, const char *snapname) diff --git a/src/osdc/librados.h b/src/osdc/librados.h index cee9935c52e17..ad0da7eb68a90 100644 --- a/src/osdc/librados.h +++ b/src/osdc/librados.h @@ -55,6 +55,7 @@ int rados_pool_list_next(rados_pool_t pool, const char **entry, rados_list_ctx_t int rados_create_pool(const char *name); int rados_create_pool_with_auid(const char *name, __u64 auid); int rados_delete_pool(const rados_pool_t pool); +int rados_change_pool_auid(const rados_pool_t pool, __u64 auid); /* snapshots */ int rados_snap_create(const rados_pool_t pool, const char *snapname); @@ -135,6 +136,7 @@ public: int create_pool(const char *name, __u64 auid=0); int delete_pool(const rados_pool_t& pool); + int change_pool_auid(const rados_pool_t& pool, __u64 auid); int snap_create(const rados_pool_t pool, const char *snapname); int snap_remove(const rados_pool_t pool, const char *snapname); -- 2.39.5