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.
This commit is contained in:
mlelstv 2023-05-01 05:12:44 +00:00
parent 4bd1f9b56f
commit a5ac5faae0
2 changed files with 9 additions and 5 deletions

View File

@ -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, size_t *len)
* 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);

View File

@ -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.
*/