From 9e68497ec7f4e51f8b1f6df011a56d5a2236f217 Mon Sep 17 00:00:00 2001 From: Andrey Kuznetsov Date: Wed, 10 Jul 2013 14:25:49 -0700 Subject: libcephfs: add ceph_ll_lookup_root() Signed-off-by: Andrey Kuznetsov --- src/client/Client.cc | 6 ++++++ src/client/Client.h | 1 + src/include/cephfs/libcephfs.h | 9 +++++++++ src/libcephfs.cc | 9 +++++++++ 4 files changed, 25 insertions(+) diff --git a/src/client/Client.cc b/src/client/Client.cc index d6fcb0f51a1..8b9185165f1 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -256,6 +256,12 @@ inodeno_t Client::get_root_ino() return root->ino; } +Inode *Client::get_root() +{ + root->ll_get(); + return root; +} + // debug crapola diff --git a/src/client/Client.h b/src/client/Client.h index b9d83cc2a70..baeb8d5ebdb 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -419,6 +419,7 @@ protected: client_t get_nodeid() { return whoami; } inodeno_t get_root_ino(); + Inode *get_root(); int init() WARN_UNUSED_RESULT; void shutdown(); diff --git a/src/include/cephfs/libcephfs.h b/src/include/cephfs/libcephfs.h index 824f4be05be..4ba63069064 100644 --- a/src/include/cephfs/libcephfs.h +++ b/src/include/cephfs/libcephfs.h @@ -1207,6 +1207,15 @@ int ceph_debug_get_file_caps(class ceph_mount_info *cmount, const char *path); /* Low Level */ struct Inode *ceph_ll_get_inode(struct ceph_mount_info *cmount, vinodeno_t vino); +/** + * Get the root inode of FS. Increase counter of references for root Inode. You must call ceph_ll_forget for it! + * + * @param cmount the ceph mount handle to use. + * @param parent pointer to pointer to Inode struct. Pointer to root inode will be returned + * @returns 0 if all good + */ +int ceph_ll_lookup_root(struct ceph_mount_info *cmount, + Inode **parent); int ceph_ll_lookup(struct ceph_mount_info *cmount, struct Inode *parent, const char *name, struct stat *attr, Inode **out, int uid, int gid); diff --git a/src/libcephfs.cc b/src/libcephfs.cc index 58ad819dd1a..885ee02a288 100644 --- a/src/libcephfs.cc +++ b/src/libcephfs.cc @@ -1154,6 +1154,15 @@ extern "C" int ceph_get_pool_replication(class ceph_mount_info *cmount, } /* Low-level exports */ +extern "C" int ceph_ll_lookup_root(struct ceph_mount_info *cmount, + Inode **parent) +{ + *parent = cmount->get_client()->get_root(); + if (*parent) + return 0; + return EFAULT; +} + extern "C" struct Inode *ceph_ll_get_inode(class ceph_mount_info *cmount, vinodeno_t vino) { -- cgit v1.2.1