From: Patrick Donnelly Date: Wed, 12 Mar 2025 14:33:02 +0000 (-0400) Subject: libcephfs: getcwd after chdir for API constraint X-Git-Tag: v19.2.3~288^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f94bdb4ead271c17633d2405e63990fb182f4e0c;p=ceph.git libcephfs: getcwd after chdir for API constraint 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 (cherry picked from commit c7c5089ff95d6c68e009686bf4ff74772ad4ff67) --- diff --git a/src/libcephfs.cc b/src/libcephfs.cc index f1188dab080b..f492562c771e 100644 --- a/src/libcephfs.cc +++ b/src/libcephfs.cc @@ -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 {