From: Greg Farnum Date: Tue, 28 Jul 2009 00:17:47 +0000 (-0700) Subject: uclient/libceph: add a getcwd function X-Git-Tag: v0.12~83 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2a36c63b85df408ea7a0ffc1f87863984ec299d1;p=ceph.git uclient/libceph: add a getcwd function --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 09899abc2024..f0b3ede6fbd8 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -4239,6 +4239,13 @@ int Client::chdir(const char *relpath) return 0; } +void Client::getcwd(string& dir) +{ + filepath path; + cwd->make_path(path); + dir = path.get_path(); +} + int Client::statfs(const char *path, struct statvfs *stbuf) { Mutex::Locker l(client_lock); diff --git a/src/client/Client.h b/src/client/Client.h index e4bc9b9a4213..fb189106c6ca 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -50,6 +50,7 @@ enum { // stl +#include #include #include #include @@ -1056,7 +1057,7 @@ public: // crap int chdir(const char *s); - const char *getcwd(); + void getcwd(std::string& cwd); // namespace ops int getdir(const char *relpath, list& names); // get the whole dir at once. diff --git a/src/client/libceph.cc b/src/client/libceph.cc index 0d4b79671667..1144b273ae4a 100644 --- a/src/client/libceph.cc +++ b/src/client/libceph.cc @@ -87,6 +87,14 @@ extern "C" int ceph_chdir (const char *s) return client->chdir(s); } +/*if we want to extern C this, we need to convert it to const char*, +which will mean storing it somewhere or else making the caller +responsible for delete-ing a c-string they didn't create*/ +void ceph_getcwd(string& cwd) +{ + client->getcwd(cwd); +} + extern "C" int ceph_opendir(const char *name, DIR **dirpp) { return client->opendir(name, dirpp); diff --git a/src/client/libceph.h b/src/client/libceph.h index d737fb0db3f7..c23a5e73a5cb 100644 --- a/src/client/libceph.h +++ b/src/client/libceph.h @@ -25,7 +25,6 @@ int ceph_umount(); int ceph_statfs(const char *path, struct statvfs *stbuf); int ceph_chdir (const char *s); -const char *ceph_getcwd(); int ceph_opendir(const char *name, DIR **dirpp); int ceph_closedir(DIR *dirp); @@ -71,7 +70,9 @@ int ceph_fstat(int fd, struct stat *stbuf); int ceph_sync_fs(); int ceph_get_stripe_unit(int fh); #ifdef __cplusplus -int ceph_getdir(const char *relpath, std::list& names); //not for C, sorry! +//not for C, sorry! +int ceph_getdir(const char *relpath, std::list& names); +void ceph_getcwd(std::string& cwd); } #endif