From: Yan, Zheng Date: Tue, 29 Sep 2015 07:24:41 +0000 (+0800) Subject: client: use fuse_req_getgroups() to get group list X-Git-Tag: v10.0.3~48^2~3^2~13 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0eb6d0ba1b65ac0aaffc72a82f07857cc65a6b88;p=ceph.git client: use fuse_req_getgroups() to get group list Signed-off-by: Yan, Zheng --- diff --git a/src/client/Client.cc b/src/client/Client.cc index f93936113a4..e64e42a874a 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -4779,7 +4779,7 @@ int Client::_getgrouplist(gid_t** sgids, int uid, int gid) gid_t *sgid_buf; if (getgroups_cb) { - sgid_count = getgroups_cb(callback_handle, uid, &sgid_buf); + sgid_count = getgroups_cb(callback_handle, &sgid_buf); if (sgid_count > 0) { *sgids = sgid_buf; return sgid_count; diff --git a/src/client/Client.h b/src/client/Client.h index c684ecd9ce3..16f525ad9ae 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -140,7 +140,7 @@ typedef void (*client_dentry_callback_t)(void *handle, vinodeno_t dirino, vinodeno_t ino, string& name); typedef int (*client_remount_callback_t)(void *handle); -typedef int (*client_getgroups_callback_t)(void *handle, uid_t uid, gid_t **sgids); +typedef int (*client_getgroups_callback_t)(void *handle, gid_t **sgids); typedef void(*client_switch_interrupt_callback_t)(void *handle, void *data); struct client_callback_args { diff --git a/src/client/fuse_ll.cc b/src/client/fuse_ll.cc index b2e3d3daa70..866a9ffd20b 100644 --- a/src/client/fuse_ll.cc +++ b/src/client/fuse_ll.cc @@ -738,12 +738,14 @@ static void fuse_ll_flock(fuse_req_t req, fuse_ino_t ino, } #endif -#if 0 -static int getgroups_cb(void *handle, uid_t uid, gid_t **sgids) +static int getgroups_cb(void *handle, gid_t **sgids) { -#ifdef HAVE_FUSE_GETGROUPS +#if FUSE_VERSION >= FUSE_MAKE_VERSION(2, 8) + CephFuse::Handle *cfuse = (CephFuse::Handle *)handle; + fuse_req_t req = cfuse->get_fuse_req(); + assert(sgids); - int c = fuse_getgroups(0, NULL); + int c = fuse_req_getgroups(req, 0, NULL); if (c < 0) { return c; } @@ -755,16 +757,16 @@ static int getgroups_cb(void *handle, uid_t uid, gid_t **sgids) if (!*sgids) { return -ENOMEM; } - c = fuse_getgroups(c, *sgids); + c = fuse_req_getgroups(req, c, *sgids); if (c < 0) { free(*sgids); return c; } return c; +#else + return -ENOSYS; #endif - return 0; } -#endif static void ino_invalidate_cb(void *handle, vinodeno_t vino, int64_t off, int64_t len) @@ -1005,17 +1007,7 @@ int CephFuse::Handle::start() #if defined(__linux__) remount_cb: remount_cb, #endif - /* - * this is broken: - * - * - the cb needs the request handle to be useful; we should get the - * gids in the method here in fuse_ll.c and pass the gid list in, - * not use a callback. - * - the callback mallocs the list but it is not free()'d - * - * so disable it for now... - getgroups_cb: getgroups_cb, - */ + getgroups_cb: getgroups_cb, }; client->ll_register_callbacks(&args);