Bug 2208048 - uname -i returns unknown
Summary: uname -i returns unknown
Keywords:
Status: CLOSED DUPLICATE of bug 2126206
Alias: None
Product: Fedora
Classification: Fedora
Component: coreutils
Version: 38
Hardware: Unspecified
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Lukáš Zaoral
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-05-17 19:29 UTC by Ben Woodard
Modified: 2023-05-17 20:28 UTC (History)
10 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-05-17 20:28:32 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Ben Woodard 2023-05-17 19:29:53 UTC
$ rpm -q coreutils
coreutils-9.1-12.fc38.x86_64
$ uname -i
unknown

debugging the code in GDB the problem seems to be a configuration problem at build time. The problem is this little block of code:

            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
                if (! (toprint == UINT_MAX && element == unknown))
          =>      print_element (element);
              }
         

What is happening is both: 
 #if HAVE_SYSINFO && defined SI_PLATFORM
and 
  #ifdef UNAME_HARDWARE_PLATFORM
are false and so neither sysinfo nor sysctl are being called.

Reproducible: Always

Actual Results:  
unknown

Expected Results:  
x86_64 (or whatever the arch is)

also seems to affect: coreutils-9.3-1.fc39

Comment 1 Ben Woodard 2023-05-17 19:31:16 UTC
This worked properly on Fedora 37

Comment 2 Kamil Dudka 2023-05-17 20:28:32 UTC
Please use `uname -m` for this.

The -i and -p options of uname have been documented as non-portable since 2015:
http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=commitdiff;h=v8.24-7-g6d67649

*** This bug has been marked as a duplicate of bug 2126206 ***


Note You need to log in before you can comment on or make changes to this bug.