]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
uclient/libceph: add a getcwd function
authorGreg Farnum <gregf@hq.newdream.net>
Tue, 28 Jul 2009 00:17:47 +0000 (17:17 -0700)
committerGreg Farnum <gregf@hq.newdream.net>
Tue, 28 Jul 2009 00:20:29 +0000 (17:20 -0700)
src/client/Client.cc
src/client/Client.h
src/client/libceph.cc
src/client/libceph.h

index 09899abc20241f15f309956a5431a5387976e31d..f0b3ede6fbd8d632738dbba5b89cd9b0c3c83421 100644 (file)
@@ -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);
index e4bc9b9a42138bec86dfe7d3be59d9339c5984af..fb189106c6ca05885a5ad9452c9cf8e67123bc70 100644 (file)
@@ -50,6 +50,7 @@ enum {
 
 
 // stl
+#include <string>
 #include <set>
 #include <map>
 #include <fstream>
@@ -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<string>& names);  // get the whole dir at once.
index 0d4b7967166719ba2e89eff72d6f4f2944821f7f..1144b273ae4a4742ff4938a7bdb104dfd665964e 100644 (file)
@@ -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);
index d737fb0db3f70b12658cebddc7f48929987d87b1..c23a5e73a5cb988496e6bc2f5955567b80897326 100644 (file)
@@ -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<std::string>& names); //not for C, sorry!
+//not for C, sorry!
+int ceph_getdir(const char *relpath, std::list<std::string>& names);
+void ceph_getcwd(std::string& cwd);
 }
 #endif