aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2021-10-29 01:43:32 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2021-11-06 02:12:32 +0000
commitf61af036ab291b558e8632bc58290b3321c2bafc (patch)
treeff4c2b707519a677ecd30fda71d856f62d9be8bd
parent0303cc4be8538ae16c577cdeda30823ada76f802 (diff)
downloadsrc-f61af036ab291b558e8632bc58290b3321c2bafc.tar.gz
src-f61af036ab291b558e8632bc58290b3321c2bafc.zip
procfs: return right hardlink from /proc/curproc/file
PR: 248184 (cherry picked from commit e5248548f95ff1c89667847e0d945dea38adeca7)
-rw-r--r--sys/fs/procfs/procfs.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/sys/fs/procfs/procfs.c b/sys/fs/procfs/procfs.c
index c492533c52bb..697bbfc9877a 100644
--- a/sys/fs/procfs/procfs.c
+++ b/sys/fs/procfs/procfs.c
@@ -69,22 +69,17 @@
int
procfs_doprocfile(PFS_FILL_ARGS)
{
- char *fullpath;
- char *freepath;
- struct vnode *textvp;
+ char *fullpath, *freepath, *binpath;
int error;
freepath = NULL;
+ binpath = malloc(MAXPATHLEN, M_TEMP, M_WAITOK);
PROC_LOCK(p);
- textvp = p->p_textvp;
- vhold(textvp);
- PROC_UNLOCK(p);
- error = vn_fullpath(textvp, &fullpath, &freepath);
- vdrop(textvp);
+ error = proc_get_binpath(p, binpath, &fullpath, &freepath);
if (error == 0)
- sbuf_printf(sb, "%s", fullpath);
- if (freepath != NULL)
- free(freepath, M_TEMP);
+ sbuf_printf(sb, "%s", fullpath == NULL ? "" : fullpath);
+ free(binpath, M_TEMP);
+ free(freepath, M_TEMP);
return (error);
}