When opening a ttys files, try path.<machine> first. This helps
machine archs which have multiple ttys files (arm, mips, powerpc, m68k, sh3)
This commit is contained in:
parent
f304ff8667
commit
138bf8b9ef
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: getttyent.c,v 1.24 2011/10/15 23:00:01 christos Exp $ */
|
||||
/* $NetBSD: getttyent.c,v 1.25 2013/06/30 07:50:54 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993
|
||||
@ -34,7 +34,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)getttyent.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: getttyent.c,v 1.24 2011/10/15 23:00:01 christos Exp $");
|
||||
__RCSID("$NetBSD: getttyent.c,v 1.25 2013/06/30 07:50:54 matt Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
@ -49,6 +49,9 @@ __RCSID("$NetBSD: getttyent.c,v 1.24 2011/10/15 23:00:01 christos Exp $");
|
||||
#include <err.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/utsname.h>
|
||||
|
||||
#ifdef __weak_alias
|
||||
__weak_alias(endttyent,_endttyent)
|
||||
__weak_alias(getttyent,_getttyent)
|
||||
@ -223,7 +226,23 @@ setttyentpath(const char *path)
|
||||
if (tf) {
|
||||
rewind(tf);
|
||||
return 1;
|
||||
} else if ((tf = fopen(path, "re")) != NULL)
|
||||
}
|
||||
|
||||
/*
|
||||
* Try <path>.$MACHINE (e.g. etc/ttys.amd64)
|
||||
*/
|
||||
char machine[_SYS_NMLN];
|
||||
const int mib[] = { [0] = CTL_HW, [1] = HW_MACHINE, };
|
||||
size_t len = sizeof(machine);
|
||||
|
||||
if (sysctl(mib, __arraycount(mib), machine, &len, NULL, 0) != -1) {
|
||||
char npath[PATH_MAX];
|
||||
(void)snprintf(npath, sizeof(npath), "%s.%s", path, machine);
|
||||
if ((tf = fopen(npath, "re")) != NULL)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((tf = fopen(path, "re")) != NULL)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user