From: Patrick Donnelly Date: Wed, 12 Mar 2025 14:33:02 +0000 (-0400) Subject: libcephfs: getcwd after chdir for API constraint X-Git-Tag: v20.3.0~363^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F62228%2Fhead;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 --- diff --git a/src/libcephfs.cc b/src/libcephfs.cc index 9fc20f731c523..ce1b6ccd0b05a 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 {