From: LaMont Jones Date: Mon, 9 Jul 2007 17:12:19 +0000 (-0600) Subject: add arch command X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=630e252a28049b7ab4d7c07eb8eb71b3cbf03ee8;p=util-linux add arch command --- diff --git a/sys-utils/Makefile.am b/sys-utils/Makefile.am index 339568f3..b0de383e 100644 --- a/sys-utils/Makefile.am +++ b/sys-utils/Makefile.am @@ -1,6 +1,6 @@ include $(top_srcdir)/config/include-Makefile.am -bin_PROGRAMS = dmesg +bin_PROGRAMS = dmesg arch usrbinexec_PROGRAMS = cytune flock ipcrm ipcs renice setsid setarch diff --git a/sys-utils/arch.1 b/sys-utils/arch.1 new file mode 100644 index 00000000..3eaf4f38 --- /dev/null +++ b/sys-utils/arch.1 @@ -0,0 +1,34 @@ +.\" arch.1 -- +.\" Copyright 1993 Rickard E. Faith (faith@cs.unc.edu) +.\" Public domain: may be freely distributed. +.TH ARCH 1 "4 July 1997" "Linux 2.0" "Linux Programmer's Manual" +.SH NAME +arch \- print machine architecture +.SH SYNOPSIS +.B arch +.SH DESCRIPTION +.B arch +is equivalent to +.BR "uname -m" . + +On current Linux systems, +.B arch +prints things such as "i386", "i486", "i586", "alpha", "sparc", +"arm", "m68k", "mips", "ppc". +.SH SEE ALSO +.BR uname (1), +.BR uname (2) +.\" +.\" Details: +.\" arch prints the machine part of the system_utsname struct +.\" This struct is defined in version.c, and this field is +.\" initialized with UTS_MACHINE, which is defined as $ARCH +.\" in the main Makefile. +.\" That gives the possibilities +.\" alpha arm i386 m68k mips ppc sparc sparc64 +.\" +.\" If Makefile is not edited, ARCH is guessed by +.\" ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/) +.\" Then how come we get these i586 values? +.\" Well, the routine check_bugs() does system_utsname.machine[1] = '0' + x86; +.\" (called in init/main.c, defined in ./include/asm-i386/bugs.h) diff --git a/sys-utils/arch.c b/sys-utils/arch.c new file mode 100644 index 00000000..33dff304 --- /dev/null +++ b/sys-utils/arch.c @@ -0,0 +1,35 @@ +/* arch -- print machine architecture information + * Created: Mon Dec 20 12:27:15 1993 by faith@cs.unc.edu + * Revised: Mon Dec 20 12:29:23 1993 by faith@cs.unc.edu + * Copyright 1993 Rickard E. Faith (faith@cs.unc.edu) + + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include +#include + +int main (void) +{ + struct utsname utsbuf; + + if (uname( &utsbuf )) { + perror( "arch" ); + return 1; + } + + printf( "%s\n", utsbuf.machine ); + + return 0; +}