Module Name:    src
Committed By:   mlelstv
Date:           Mon May  1 05:12:44 UTC 2023

Modified Files:
        src/sys/kern: vfs_lookup.c
        src/sys/sys: proc.h

Log Message:
Default PROC_MACHINE_ARCH to machine_arch and use this for magic
symlinks to resolve "@machine_arch".

This keeps behaviour of magic symlinks and 'uname -p' output the same.
Fixes PR 57320.


To generate a diff of this commit:
cvs rdiff -u -r1.233 -r1.234 src/sys/kern/vfs_lookup.c
cvs rdiff -u -r1.370 -r1.371 src/sys/sys/proc.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/vfs_lookup.c
diff -u src/sys/kern/vfs_lookup.c:1.233 src/sys/kern/vfs_lookup.c:1.234
--- src/sys/kern/vfs_lookup.c:1.233	Sun Apr  9 09:18:09 2023
+++ src/sys/kern/vfs_lookup.c	Mon May  1 05:12:44 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_lookup.c,v 1.233 2023/04/09 09:18:09 riastradh Exp $	*/
+/*	$NetBSD: vfs_lookup.c,v 1.234 2023/05/01 05:12:44 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.233 2023/04/09 09:18:09 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.234 2023/05/01 05:12:44 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_magiclinks.h"
@@ -137,8 +137,8 @@ symlink_magic(struct proc *p, char *cp, 
 		 * to frequency of use.
 		 */
 		if (MATCH("machine_arch")) {
-			slen = VNL(MACHINE_ARCH);
-			SUBSTITUTE("machine_arch", MACHINE_ARCH, slen);
+			slen = strlen(PROC_MACHINE_ARCH(p));
+			SUBSTITUTE("machine_arch", PROC_MACHINE_ARCH(p), slen);
 		} else if (MATCH("machine")) {
 			slen = VNL(MACHINE);
 			SUBSTITUTE("machine", MACHINE, slen);

Index: src/sys/sys/proc.h
diff -u src/sys/sys/proc.h:1.370 src/sys/sys/proc.h:1.371
--- src/sys/sys/proc.h:1.370	Mon May  9 13:27:24 2022
+++ src/sys/sys/proc.h	Mon May  1 05:12:44 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: proc.h,v 1.370 2022/05/09 13:27:24 wiz Exp $	*/
+/*	$NetBSD: proc.h,v 1.371 2023/05/01 05:12:44 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2007, 2008, 2020 The NetBSD Foundation, Inc.
@@ -593,6 +593,10 @@ _proclist_skipmarker(struct proc *p0)
 #define PROC_DBREGSZ(p) (((p)->p_flag & PK_32) ? \
     sizeof(process_dbreg32) : sizeof(struct dbreg))
 
+#ifndef PROC_MACHINE_ARCH
+#define PROC_MACHINE_ARCH(p) machine_arch
+#endif
+
 /*
  * PROCLIST_FOREACH: iterate on the given proclist, skipping PK_MARKER ones.
  */

Reply via email to