Bug 2208048

Summary: uname -i returns unknown
Product: [Fedora] Fedora Reporter: Ben Woodard <woodard>
Component: coreutilsAssignee: Lukáš Zaoral <lzaoral>
Status: CLOSED DUPLICATE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 38CC: admiller, jamartis, jarodwilson, kdudka, kzak, lzaoral, ovasik, p, svashisht, vmihalko
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-05-17 20:28:32 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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 ***