Skip to content

Commit fb244ba

Browse files
authored
Merge pull request #1 from git-user-cpp/development
displaying rom info for linux
2 parents 6813957 + 88a130a commit fb244ba

File tree

5 files changed

+37
-23
lines changed

5 files changed

+37
-23
lines changed

src/main.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
#include "sys/system_info.h"
1+
#include "sys/sys_info.h"
22
#include "ram/ram_info.h"
33
#include "cpu/cpu_info.h"
4+
#include "rom/rom_info.h"
45

56
int main() {
6-
struct utsname system_info;
7-
struct sysinfo mem_info;
8-
9-
print_system_info(&system_info);
10-
print_ram_info(&mem_info);
7+
print_sys_info();
118
print_cpu_info();
9+
print_ram_info();
10+
print_rom_info();
1211

1312
return 0;
1413
}

src/ram/ram_info.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#include <stdio.h>
22
#include <sys/sysinfo.h>
33

4-
void print_ram_info(struct sysinfo *sys_info) {
5-
sysinfo(sys_info);
6-
7-
printf("Uptime: %ld Hours\n", sys_info->uptime / 60 / 60);
8-
printf("Total RAM: %ld MiB\n", sys_info->totalram * sys_info->mem_unit /
4+
void print_ram_info() {
5+
struct sysinfo sys_info;
6+
sysinfo(&sys_info);
7+
printf("Uptime: %ld Hours\n", sys_info.uptime / 60 / 60);
8+
printf("Total RAM: %ld MiB\n", sys_info.totalram * sys_info.mem_unit /
99
1024 / 1024);
10-
printf("Free RAM: %ld MiB\n", sys_info->freeram * sys_info->mem_unit / 1024
10+
printf("Free RAM: %ld MiB\n", sys_info.freeram * sys_info.mem_unit / 1024
1111
/ 1024);
1212
}

src/rom/rom_info.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,15 @@
1+
#include <stdio.h>
2+
#include <sys/statvfs.h>
13

4+
void print_rom_info() {
5+
printf("\nDisk Information:\n");
6+
struct statvfs fs_info;
7+
if (statvfs("/", &fs_info) == 0) {
8+
printf("Total Disk Space: %ld MiB\n", fs_info.f_blocks * fs_info.f_bsize
9+
/ 1024 / 1024);
10+
printf("Free Disk Space: %ld MiB\n", fs_info.f_bfree * fs_info.f_bsize /
11+
1024 / 1024);
12+
printf("Used Disk Space: %ld MiB\n", (fs_info.f_blocks -
13+
fs_info.f_bfree) * fs_info.f_bsize / 1024 / 1024);
14+
}
15+
}

src/sys/sys_info.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include <stdio.h>
2+
#include <sys/utsname.h>
3+
4+
void print_sys_info() {
5+
struct utsname sys_info;
6+
uname(&sys_info);
7+
printf("System Name: %s\n", sys_info.sysname);
8+
printf("Host Name: %s\n", sys_info.nodename);
9+
printf("Kernel Release: %s\n", sys_info.release);
10+
printf("System Version: %s\n", sys_info.version);
11+
printf("Machine Type: %s\n", sys_info.machine);
12+
}

src/sys/system_info.h

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)