Skip to content

Commit c7c5089

Browse files
committed
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 <[email protected]>
1 parent cda2a6e commit c7c5089

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/libcephfs.cc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,15 @@ struct ceph_mount_info
322322

323323
int chdir(const char *to, const UserPerm& perms)
324324
{
325-
return client->chdir(to, perms);
325+
int rc = client->chdir(to, perms);
326+
if (rc == 0) {
327+
/* Current API requires "cwd" to be refreshed after every chdir so that
328+
* getcwd on an unlinked cwd will still return the old path. Note:
329+
* Client::getcwd now returns an error but leaves the "cwd" string
330+
* unmodified for this purpose. */
331+
client->getcwd(cwd, perms);
332+
}
333+
return rc;
326334
}
327335

328336
CephContext *get_ceph_context() const {

0 commit comments

Comments
 (0)