~ubuntu-branches/ubuntu/trusty/linuxlogo/trusty

« back to all changes in this revision

Viewing changes to libsysinfo-0.1.0/AIX/sysinfo_aix.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2008-06-20 09:19:00 UTC
  • mfrom: (4.1.2 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080620091900-4xzuv7c7ntxvs7wt
Tags: 5.03-4
* Adding patch to fix FTBFS on s390x.
* Updating to standards 3.8.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* getsysinfo_aix.c                                               *\
2
 
\* I was trying to make this easier to add other platforms/       */
3
 
/* architectures.  Feel free to add yours, and send me the patch. *\
4
 
\*----------------------------------------------------------------*/
5
 
 
6
 
#include <stdio.h>
7
 
#include <ctype.h>
8
 
#include <unistd.h>
9
 
#include <sys/stat.h>
10
 
#include <sys/utsname.h>
11
 
#include <string.h>
12
 
 
13
 
#include "sysinfo_common.h"
14
 
#include "vmw_string.h"
15
 
 
16
 
int external_bogomips(char *bogomips_total);
17
 
 
18
 
void get_os_info(struct os_info_type *os_info)
19
 
{  
20
 
   struct utsname buf;
21
 
   
22
 
   clear_os_pointers(os_info);
23
 
   
24
 
   uname( &buf);
25
 
 
26
 
    os_info->os_name=strdup(buf.sysname);
27
 
    os_info->os_version=strdup(buf.version);  /* switched around, JSt */
28
 
    /*os_info->os_revision=strdup(buf.version);*/
29
 
    os_info->host_name=strdup(buf.nodename);
30
 
    os_info->uptime=strdup(utmp_get_uptime());/* Neither of below implemented*/
31
 
    os_info->load_average=strdup(get_loadavg_noproc());
32
 
 }
33
 
    
34
 
void get_hw_info(struct hw_info_type *hw_info,
35
 
                 struct linux_logo_info_type *logo_info)
36
 
 
37
 
{
38
 
   FILE *fff;
39
 
   int cpus=0;
40
 
   long long int mem;
41
 
   char temp_string2[BUFSIZ];
42
 
   char chip[BUFSIZ]="Unknown";
43
 
   char temp_string[BUFSIZ],bogomips_total[BUFSIZ]="???";
44
 
   char bogo_total[BUFSIZ];
45
 
   float megahertz=0.0;
46
 
      
47
 
/* Print CPU Type and BogoMips -- Handles SMP Correctly now            *\  
48
 
\* To debug other architectures, create copies of the  proc files and  */ 
49
 
/*   fopen() them.                                                    */
50
 
 
51
 
    clear_hw_pointers(hw_info);
52
 
   
53
 
       /*      sprintf(cpuinfo,"Unknown CPU");*/
54
 
    if ((fff=popen("lsattr -El proc0","r") )!=NULL) {
55
 
       while ( fscanf(fff,"%s",(char *)&temp_string2)!=EOF) {
56
 
          if ( !(strcmp(temp_string2,"type")) ) { 
57
 
/* moved &chip, JSt
58
 
   output of lsattr -El proc0 gives
59
 
state enable Processor state False
60
 
type  POWER2 Processor type  False
61
 
   on AIX 4.1.5 systems
62
 
 */
63
 
             fscanf(fff,"%s%s%s%s%s",(char *)&chip,(char *)&temp_string,
64
 
                   (char *)&temp_string,(char *)&temp_string,(char *)&temp_string);
65
 
          }
66
 
       }
67
 
    }
68
 
    pclose(fff);
69
 
 
70
 
/* count cpus ... ugly using wc, JSt */
71
 
    if ((fff=popen("lsdev -Cc processor -SA|wc -l","r") )!=NULL) {
72
 
             fscanf(fff,"%d",&cpus);
73
 
          }
74
 
    pclose(fff);
75
 
/* check mem, JSt */
76
 
    if ((fff=popen("lsattr -E -l sys0 -a realmem -F value","r") )!=NULL) {
77
 
             fscanf(fff,"%ld",&mem);
78
 
          }
79
 
    pclose(fff);
80
 
            
81
 
      if (!logo_info->skip_bogomips)
82
 
         if ( (external_bogomips( (char *)&bogomips_total))==-1 )
83
 
         sprintf(bogo_total," ");
84
 
         else sprintf(bogo_total,"%s Bogomips Total",bogomips_total);
85
 
      else sprintf(bogo_total," ");
86
 
 
87
 
/* Added for 3.0 best I could.. have no AIX box to test on --vmw */   
88
 
      sprintf(temp_string,"%ldM",(long int)mem/1024);
89
 
      hw_info->mem_size=strdup(temp_string);
90
 
   
91
 
      hw_info->bogo_total=strdup(bogo_total);
92
 
      
93
 
      hw_info->num_cpus=cpus;
94
 
   
95
 
      if (megahertz>1) {
96
 
               sprintf(temp_string,"%.0fMHz ",megahertz);
97
 
               hw_info->megahertz=strdup(temp_string);
98
 
      }
99
 
   
100
 
      hw_info->cpu_type=strdup(chip);
101
 
   
102
 
   
103
 
}
104