]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
libcephfs: getcwd after chdir for API constraint
authorPatrick Donnelly <pdonnell@ibm.com>
Wed, 12 Mar 2025 14:33:02 +0000 (10:33 -0400)
committerPatrick Donnelly <pdonnell@ibm.com>
Mon, 17 Mar 2025 19:43:24 +0000 (15:43 -0400)
libcephfs semantics require that the old path to the cwd be returned when
getcwd is encounters an unlinked directory in the current working directory.

Signed-off-by: Patrick Donnelly <pdonnell@ibm.com>
(cherry picked from commit c7c5089ff95d6c68e009686bf4ff74772ad4ff67)

src/libcephfs.cc

index f1188dab080b8f40c268bbb32e8eac1a3d1d134f..f492562c771e1bcfa6d2d8403f74c5b622ffb490 100644 (file)
@@ -322,7 +322,15 @@ public:
 
   int chdir(const char *to, const UserPerm& perms)
   {
-    return client->chdir(to, perms);
+    int rc = client->chdir(to, perms);
+    if (rc == 0) {
+      /* Current API requires "cwd" to be refreshed after every chdir so that
+       * getcwd on an unlinked cwd will still return the old path. Note:
+       * Client::getcwd now returns an error but leaves the "cwd" string
+       * unmodified for this purpose. */
+      client->getcwd(cwd, perms);
+    }
+    return rc;
   }
 
   CephContext *get_ceph_context() const {