Make getcwd() fail with -ENOENT if the current working directory is disconnected: the process is not asking for some previous name of that directory but for the current name; returning a path meaningless in the context of that process makes no sense. Signed-off-by: Andreas Gruenbacher --- fs/dcache.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/fs/dcache.c +++ b/fs/dcache.c @@ -1910,10 +1910,12 @@ asmlinkage long sys_getcwd(char __user * read_unlock(¤t->fs->lock); cwd = __d_path(pwd, pwdmnt, root, rootmnt, page, PAGE_SIZE, 1); - cwd = __connect_d_path(cwd, page); error = PTR_ERR(cwd); if (IS_ERR(cwd)) goto out; + error = -ENOENT; + if (*cwd != '/') + goto out; error = -ERANGE; len = PAGE_SIZE + page - cwd; -- Andreas Gruenbacher SUSE Labs, SUSE LINUX Products GmbH GF: Markus Rex, HRB 16746 (AG Nuernberg) GPG: AF77 FAD1 1819 D442 400F 4BC8 409A 6903 4FDD EE02 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/