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>
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 {