git: b75fa3a2de0c - main - procfs: Add self & exe symlinks like NetBSD does

From: Warner Losh <imp_at_FreeBSD.org>
Date: Sat, 03 Feb 2024 01:36:23 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=b75fa3a2de0c9c0854ebd9a2adc75ce9e8d39bd4

commit b75fa3a2de0c9c0854ebd9a2adc75ce9e8d39bd4
Author:     Ricardo Branco <rbranco@suse.de>
AuthorDate: 2024-02-03 00:17:52 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2024-02-03 01:34:59 +0000

    procfs: Add self & exe symlinks like NetBSD does
    
    NetBSD calls "curproc" "self" and "exe" "file" for proc. Reduce
    gratuitous differnces by including them as well.
    
    Reviewed by: imp
    Pull Request: https://github.com/freebsd/freebsd-src/pull/976
---
 share/man/man5/procfs.5 | 4 ++++
 sys/fs/procfs/procfs.c  | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/share/man/man5/procfs.5 b/share/man/man5/procfs.5
index d055faadf2c0..5977a8bced81 100644
--- a/share/man/man5/procfs.5
+++ b/share/man/man5/procfs.5
@@ -253,10 +253,14 @@ directory containing process information for process
 .Pa pid .
 .It Pa /proc/curproc
 directory containing process information for the current process
+.It Pa /proc/self
+directory containing process information for the current process
 .It Pa /proc/curproc/cmdline
 the process executable name
 .It Pa /proc/curproc/etype
 executable type
+.It Pa /proc/curproc/exe
+executable image
 .It Pa /proc/curproc/file
 executable image
 .It Pa /proc/curproc/fpregs
diff --git a/sys/fs/procfs/procfs.c b/sys/fs/procfs/procfs.c
index 97b04fa2bc06..ab60ba47f322 100644
--- a/sys/fs/procfs/procfs.c
+++ b/sys/fs/procfs/procfs.c
@@ -158,6 +158,8 @@ procfs_init(PFS_INIT_ARGS)
 
 	pfs_create_link(root, "curproc", procfs_docurproc,
 	    NULL, NULL, NULL, 0);
+	pfs_create_link(root, "self", procfs_docurproc,
+	    NULL, NULL, NULL, 0);
 
 	dir = pfs_create_dir(root, "pid",
 	    procfs_attr_all_rx, NULL, NULL, PFS_PROCDEP);
@@ -188,6 +190,8 @@ procfs_init(PFS_INIT_ARGS)
 
 	pfs_create_link(dir, "file", procfs_doprocfile,
 	    NULL, procfs_notsystem, NULL, 0);
+	pfs_create_link(dir, "exe", procfs_doprocfile,
+	    NULL, procfs_notsystem, NULL, 0);
 
 	return (0);
 }