diff --git a/fs/d_path.c b/fs/d_path.c index 4c28e0b38275..27ab27f57de8 100644 --- a/fs/d_path.c +++ b/fs/d_path.c @@ -249,9 +249,9 @@ static void get_fs_root_rcu(struct fs_struct *fs, struct path *root) * * "buflen" should be positive. */ -char *d_path_outlen(const struct path *path, char *buf, int *buflen) +char *d_path(const struct path *path, char *buf, int buflen) { - char *res = buf + *buflen; + char *res = buf + buflen; struct path root; int error; @@ -268,22 +268,17 @@ char *d_path_outlen(const struct path *path, char *buf, int *buflen) */ if (path->dentry->d_op && path->dentry->d_op->d_dname && (!IS_ROOT(path->dentry) || path->dentry != path->mnt->mnt_root)) - return path->dentry->d_op->d_dname(path->dentry, buf, *buflen); + return path->dentry->d_op->d_dname(path->dentry, buf, buflen); rcu_read_lock(); get_fs_root_rcu(current->fs, &root); - error = path_with_deleted(path, &root, &res, buflen); + error = path_with_deleted(path, &root, &res, &buflen); rcu_read_unlock(); if (error < 0) res = ERR_PTR(error); return res; } - -char *d_path(const struct path *path, char *buf, int buflen) -{ - return d_path_outlen(path, buf, &buflen); -} EXPORT_SYMBOL(d_path); /* diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 4e7e4e42a2bc..1f626270c18a 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -528,19 +528,16 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma) * program uses newlines in its paths then it can kick rocks. */ if (size > 1) { - const int inlen = size - 1; - int outlen = inlen; char *p; - p = d_path_outlen(&file->f_path, buf, &outlen); + p = d_path(&file->f_path, buf, size); if (!IS_ERR(p)) { size_t len; - if (outlen != inlen) - len = inlen - outlen - 1; - else - len = strlen(p); - memmove(buf, p, len); + /* Minus one to exclude the NUL character */ + len = size - (p - buf) - 1; + if (likely(p > buf)) + memmove(buf, p, len); buf[len] = '\n'; seq_commit(m, len + 1); return; diff --git a/include/linux/dcache.h b/include/linux/dcache.h index 7d1827283e90..7a75eeb21999 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h @@ -306,7 +306,6 @@ extern char *simple_dname(struct dentry *, char *, int); extern char *__d_path(const struct path *, const struct path *, char *, int); extern char *d_absolute_path(const struct path *, char *, int); extern char *d_path(const struct path *, char *, int); -extern char *d_path_outlen(const struct path *, char *, int *); extern char *dentry_path_raw(struct dentry *, char *, int); extern char *dentry_path(struct dentry *, char *, int);