lkml.org 
[lkml]   [2007]   [Apr]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[d_path 4/7] Make getcwd() only return valid paths
    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 <agruen@suse.de>

    ---
    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(&current->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 <agruen@suse.de>
    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/

    \
     
     \ /
      Last update: 2007-04-20 01:59    [W:4.400 / U:0.344 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site