bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: coreutils-5.2.1 and coreutils-5.0


From: Warren L Dodge
Subject: Re: coreutils-5.2.1 and coreutils-5.0
Date: Thu, 31 Mar 2005 14:54:51 -0800 (PST)

Here is uname.c from the redhat release we use. Their coreutils-4.5.3
Also below are two patches that may be applied. They had uname mentioned in
them.

/* uname -- print system information

   Copyright 1989, 1992, 1993, 1996, 1997, 1999, 2000, 2001, 2002 Free
   Software Foundation, Inc.

   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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */

/* Written by David MacKenzie <address@hidden> */

#include <config.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/utsname.h>
#include <getopt.h>

#if HAVE_SYSINFO && HAVE_SYS_SYSTEMINFO_H
# include <sys/systeminfo.h>
#endif

#if HAVE_SYSCTL && HAVE_SYS_SYSCTL_H
# include <sys/param.h> /* needed for OpenBSD 3.0 */
# include <sys/sysctl.h>
# ifdef HW_MODEL
#  ifdef HW_MACHINE_ARCH
/* E.g., FreeBSD 4.5, NetBSD 1.5.2 */
#   define UNAME_HARDWARE_PLATFORM HW_MODEL
#   define UNAME_PROCESSOR HW_MACHINE_ARCH
#  else
/* E.g., OpenBSD 3.0 */
#   define UNAME_PROCESSOR HW_MODEL
#  endif
# endif
#endif

#include "system.h"
#include "error.h"
#include "closeout.h"

/* The official name of this program (e.g., no `g' prefix).  */
#define PROGRAM_NAME "uname"

#define AUTHORS "David MacKenzie"

/* Values that are bitwise or'd into `toprint'. */
/* Kernel name. */
#define PRINT_KERNEL_NAME 1

/* Node name on a communications network. */
#define PRINT_NODENAME 2

/* Kernel release. */
#define PRINT_KERNEL_RELEASE 4

/* Kernel version. */
#define PRINT_KERNEL_VERSION 8

/* Machine hardware name. */
#define PRINT_MACHINE 16

/* Processor type. */
#define PRINT_PROCESSOR 32

/* Hardware platform.  */
#define PRINT_HARDWARE_PLATFORM 64

/* Operating system.  */
#define PRINT_OPERATING_SYSTEM 128

/* The name this program was run with, for error messages. */
char *program_name;

static struct option const long_options[] =
{
  {"all", no_argument, NULL, 'a'},
  {"kernel-name", no_argument, NULL, 's'},
  {"sysname", no_argument, NULL, 's'},  /* Obsolescent.  */
  {"nodename", no_argument, NULL, 'n'},
  {"kernel-release", no_argument, NULL, 'r'},
  {"release", no_argument, NULL, 'r'},  /* Obsolescent.  */
  {"kernel-version", no_argument, NULL, 'v'},
  {"machine", no_argument, NULL, 'm'},
  {"processor", no_argument, NULL, 'p'},
  {"hardware-platform", no_argument, NULL, 'i'},
  {"operating-system", no_argument, NULL, 'o'},
  {GETOPT_HELP_OPTION_DECL},
  {GETOPT_VERSION_OPTION_DECL},
  {NULL, 0, NULL, 0}
};

void
usage (int status)
{
  if (status != 0)
    fprintf (stderr, _("Try `%s --help' for more information.\n"),
             program_name);
  else
    {
      printf (_("Usage: %s [OPTION]...\n"), program_name);
      fputs (_("\
Print certain system information.  With no OPTION, same as -s.\n\
\n\
  -a, --all                print all information, in the following order:\n\
  -s, --kernel-name        print the kernel name\n\
  -n, --nodename           print the network node hostname\n\
  -r, --kernel-release     print the kernel release\n\
"), stdout);
      fputs (_("\
  -v, --kernel-version     print the kernel version\n\
  -m, --machine            print the machine hardware name\n\
  -p, --processor          print the processor type\n\
  -i, --hardware-platform  print the hardware platform\n\
  -o, --operating-system   print the operating system\n\
"), stdout);
      fputs (HELP_OPTION_DESCRIPTION, stdout);
      fputs (VERSION_OPTION_DESCRIPTION, stdout);
      printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
    }
  exit (status);
}

/* Print ELEMENT, preceded by a space if something has already been
   printed.  */

static void
print_element (char const *element)
{
  static int printed;
  if (printed++)
    putchar (' ');
  fputs (element, stdout);
}

int
main (int argc, char **argv)
{
  int c;
  static char const unknown[] = "unknown";

  /* Mask indicating which elements to print. */
  unsigned toprint = 0;

  program_name = argv[0];
  setlocale (LC_ALL, "");
  bindtextdomain (PACKAGE, LOCALEDIR);
  textdomain (PACKAGE);

  atexit (close_stdout);

  while ((c = getopt_long (argc, argv, "asnrvmpio", long_options, NULL)) != -1)
    {
      switch (c)
        {
        case 0:
          break;

        case 'a':
          toprint = -1;
          break;

        case 's':
          toprint |= PRINT_KERNEL_NAME;
          break;

        case 'n':
          toprint |= PRINT_NODENAME;
          break;

        case 'r':
          toprint |= PRINT_KERNEL_RELEASE;
          break;

        case 'v':
          toprint |= PRINT_KERNEL_VERSION;
          break;

        case 'm':
          toprint |= PRINT_MACHINE;
          break;

        case 'p':
          toprint |= PRINT_PROCESSOR;
          break;

        case 'i':
          toprint |= PRINT_HARDWARE_PLATFORM;
          break;

        case 'o':
          toprint |= PRINT_OPERATING_SYSTEM;
          break;

        case_GETOPT_HELP_CHAR;

        case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);

        default:
          usage (EXIT_FAILURE);
        }
    }

  if (optind != argc)
    usage (EXIT_FAILURE);

  if (toprint == 0)
    toprint = PRINT_KERNEL_NAME;

  if (toprint
       & (PRINT_KERNEL_NAME | PRINT_NODENAME | PRINT_KERNEL_RELEASE
          | PRINT_KERNEL_VERSION | PRINT_MACHINE))
    {
      struct utsname name;

      if (uname (&name) == -1)
        error (EXIT_FAILURE, errno, _("cannot get system name"));

      if (toprint & PRINT_KERNEL_NAME)
        print_element (name.sysname);
      if (toprint & PRINT_NODENAME)
        print_element (name.nodename);
      if (toprint & PRINT_KERNEL_RELEASE)
        print_element (name.release);
      if (toprint & PRINT_KERNEL_VERSION)
        print_element (name.version);
      if (toprint & PRINT_MACHINE)
        print_element (name.machine);
    }

  if (toprint & PRINT_PROCESSOR)
    {
      char const *element = unknown;
#if HAVE_SYSINFO && defined SI_ARCHITECTURE
      {
        static char processor[257];
        if (0 <= sysinfo (SI_ARCHITECTURE, processor, sizeof processor))
          element = processor;
      }
#endif
#ifdef UNAME_PROCESSOR
      if (element == unknown)
        {
          static char processor[257];
          size_t s = sizeof processor;
          static int mib[] = { CTL_HW, UNAME_PROCESSOR };
          if (sysctl (mib, 2, processor, &s, 0, 0) >= 0)
            element = processor;
        }
#endif
      print_element (element);
    }

  if (toprint & PRINT_HARDWARE_PLATFORM)
    {
      char const *element = unknown;
#if HAVE_SYSINFO && defined SI_PLATFORM
      {
        static char hardware_platform[257];
        if (0 <= sysinfo (SI_PLATFORM,
                          hardware_platform, sizeof hardware_platform))
          element = hardware_platform;
      }
#endif
#ifdef UNAME_HARDWARE_PLATFORM
      if (element == unknown)
        {
          static char hardware_platform[257];
          size_t s = sizeof hardware_platform;
          static int mib[] = { CTL_HW, UNAME_HARDWARE_PLATFORM };
          if (sysctl (mib, 2, hardware_platform, &s, 0, 0) >= 0)
            element = hardware_platform;
        }
#endif
      print_element (element);
    }

  if (toprint & PRINT_OPERATING_SYSTEM)
    print_element (HOST_OPERATING_SYSTEM);

  putchar ('\n');

  exit (EXIT_SUCCESS);
}

_____________________________________________________________________________
coreutils-4.5.3-hname.patch

--- coreutils-4.5.3/src/Makefile.am.hname       2002-11-28 15:27:35.000000000 
+0000
+++ coreutils-4.5.3/src/Makefile.am     2002-11-28 17:52:32.000000000 +0000
@@ -11,7 +11,7 @@
   cat cksum comm csplit cut expand fmt fold head join md5sum \
   nl od paste pr ptx sha1sum sort split sum tac tail tr tsort unexpand uniq wc 
\
   basename date dirname echo env expr factor false \
-  hostname id kill logname pathchk printenv printf pwd seq sleep tee \
+  id kill logname pathchk printenv printf pwd seq sleep tee \
   test true tty whoami yes \
   @OPTIONAL_BIN_PROGS@ @DF_PROG@
 
--- coreutils-4.5.3/man/Makefile.am.hname       2002-08-09 07:12:29.000000000 
+0100
+++ coreutils-4.5.3/man/Makefile.am     2002-11-28 17:52:58.000000000 +0000
@@ -3,7 +3,7 @@
   basename.1 cat.1 chgrp.1 chmod.1 chown.1 chroot.1 cksum.1 comm.1 \
   cp.1 csplit.1 cut.1 date.1 dd.1 df.1 dir.1 dircolors.1 dirname.1 du.1 \
   echo.1 env.1 expand.1 expr.1 factor.1 false.1 fmt.1 fold.1 groups.1 \
-  head.1 hostid.1 hostname.1 id.1 install.1 join.1 link.1 ln.1 logname.1 \
+  head.1 hostid.1 id.1 install.1 join.1 link.1 ln.1 logname.1 \
   ls.1 md5sum.1 mkdir.1 mkfifo.1 mknod.1 mv.1 nice.1 nl.1 nohup.1 od.1 \
   paste.1 pathchk.1 pinky.1 pr.1 printenv.1 printf.1 ptx.1 pwd.1 rm.1 \
   rmdir.1 seq.1 sha1sum.1 shred.1 sleep.1 sort.1 split.1 stat.1 stty.1 \
@@ -51,7 +51,6 @@
 groups.1:      $(common_dep)   $(srcdir)/groups.x      ../src/groups.sh
 head.1:                $(common_dep)   $(srcdir)/head.x        ../src/head.c
 hostid.1:      $(common_dep)   $(srcdir)/hostid.x      ../src/hostid.c
-hostname.1:    $(common_dep)   $(srcdir)/hostname.x    ../src/hostname.c
 id.1:          $(common_dep)   $(srcdir)/id.x          ../src/id.c
 install.1:     $(common_dep)   $(srcdir)/install.x     ../src/install.c
 join.1:                $(common_dep)   $(srcdir)/join.x        ../src/join.c
--- coreutils-4.5.3/README.hname        2003-08-11 14:34:07.000000000 +0100
+++ coreutils-4.5.3/README      2003-08-11 14:34:17.000000000 +0100
@@ -9,7 +9,7 @@
 
   basename cat chgrp chmod chown chroot cksum comm cp csplit cut date dd
   df dir dircolors dirname du echo env expand expr factor false fmt fold
-  ginstall groups head hostid hostname id join kill link ln logname ls
+  ginstall groups head hostid id join kill link ln logname ls
   md5sum mkdir mkfifo mknod mv nice nl nohup od paste pathchk pinky pr
   printenv printf ptx pwd rm rmdir seq sha1sum shred sleep sort split
   stat stty su sum sync tac tail tee test touch tr true tsort tty uname

_____________________________________________________________________________
coreutils-4.5.3-sysinfo.patch

--- coreutils-4.5.3/src/Makefile.am.hname       2002-11-28 15:27:35.000000000 
+0000
+++ coreutils-4.5.3/src/Makefile.am     2002-11-28 17:52:32.000000000 +0000
@@ -11,7 +11,7 @@
   cat cksum comm csplit cut expand fmt fold head join md5sum \
   nl od paste pr ptx sha1sum sort split sum tac tail tr tsort unexpand uniq wc 
\
   basename date dirname echo env expr factor false \
-  hostname id kill logname pathchk printenv printf pwd seq sleep tee \
+  id kill logname pathchk printenv printf pwd seq sleep tee \
   test true tty whoami yes \
   @OPTIONAL_BIN_PROGS@ @DF_PROG@
 
--- coreutils-4.5.3/man/Makefile.am.hname       2002-08-09 07:12:29.000000000 
+0100
+++ coreutils-4.5.3/man/Makefile.am     2002-11-28 17:52:58.000000000 +0000
@@ -3,7 +3,7 @@
   basename.1 cat.1 chgrp.1 chmod.1 chown.1 chroot.1 cksum.1 comm.1 \
   cp.1 csplit.1 cut.1 date.1 dd.1 df.1 dir.1 dircolors.1 dirname.1 du.1 \
   echo.1 env.1 expand.1 expr.1 factor.1 false.1 fmt.1 fold.1 groups.1 \
-  head.1 hostid.1 hostname.1 id.1 install.1 join.1 link.1 ln.1 logname.1 \
+  head.1 hostid.1 id.1 install.1 join.1 link.1 ln.1 logname.1 \
   ls.1 md5sum.1 mkdir.1 mkfifo.1 mknod.1 mv.1 nice.1 nl.1 nohup.1 od.1 \
   paste.1 pathchk.1 pinky.1 pr.1 printenv.1 printf.1 ptx.1 pwd.1 rm.1 \
   rmdir.1 seq.1 sha1sum.1 shred.1 sleep.1 sort.1 split.1 stat.1 stty.1 \
@@ -51,7 +51,6 @@
 groups.1:      $(common_dep)   $(srcdir)/groups.x      ../src/groups.sh
 head.1:                $(common_dep)   $(srcdir)/head.x        ../src/head.c
 hostid.1:      $(common_dep)   $(srcdir)/hostid.x      ../src/hostid.c
-hostname.1:    $(common_dep)   $(srcdir)/hostname.x    ../src/hostname.c
 id.1:          $(common_dep)   $(srcdir)/id.x          ../src/id.c
 install.1:     $(common_dep)   $(srcdir)/install.x     ../src/install.c
 join.1:                $(common_dep)   $(srcdir)/join.x        ../src/join.c
--- coreutils-4.5.3/README.hname        2003-08-11 14:34:07.000000000 +0100
+++ coreutils-4.5.3/README      2003-08-11 14:34:17.000000000 +0100
@@ -9,7 +9,7 @@
 
   basename cat chgrp chmod chown chroot cksum comm cp csplit cut date dd
   df dir dircolors dirname du echo env expand expr factor false fmt fold
-  ginstall groups head hostid hostname id join kill link ln logname ls
+  ginstall groups head hostid id join kill link ln logname ls
   md5sum mkdir mkfifo mknod mv nice nl nohup od paste pathchk pinky pr
   printenv printf ptx pwd rm rmdir seq sha1sum shred sleep sort split
   stat stty su sum sync tac tail tee test touch tr true tsort tty uname





reply via email to

[Prev in Thread] Current Thread [Next in Thread]