Improved output, now also accepts team 1 under BeOS (KERNEL SPACE).
Fixed warnings and style issues. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8274 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+45
-45
@@ -1,9 +1,9 @@
|
|||||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||||
//
|
//
|
||||||
// Copyright (c) 2001-2003, OpenBeOS
|
// Copyright (c) 2001-2004, Haiku
|
||||||
//
|
//
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
// This software is part of the Haiku distribution and is covered
|
||||||
// by the OpenBeOS license.
|
// by the Haiku license.
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// File: listarea.c
|
// File: listarea.c
|
||||||
@@ -12,34 +12,35 @@
|
|||||||
//
|
//
|
||||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
void list_area_info (team_id id);
|
|
||||||
void show_memory_totals (void);
|
|
||||||
|
|
||||||
|
void list_area_info(team_id id);
|
||||||
|
void show_memory_totals(void);
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
show_memory_totals();
|
show_memory_totals();
|
||||||
|
|
||||||
if (argc == 1) {
|
if (argc == 1) {
|
||||||
int32 cookie = 0;
|
int32 cookie = 0;
|
||||||
team_info info;
|
team_info info;
|
||||||
|
|
||||||
// list for all teams
|
// list for all teams
|
||||||
while (get_next_team_info(&cookie, &info) >= B_OK)
|
while (get_next_team_info(&cookie, &info) >= B_OK)
|
||||||
list_area_info(info.team);
|
list_area_info(info.team);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
// list for each team_id on the command line
|
// list for each team_id on the command line
|
||||||
while (--argc)
|
while (--argc)
|
||||||
list_area_info(atoi(*++argv));
|
list_area_info(atoi(*++argv));
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,47 +48,46 @@ main(int argc, char **argv)
|
|||||||
void
|
void
|
||||||
show_memory_totals()
|
show_memory_totals()
|
||||||
{
|
{
|
||||||
int32 max = 0, used = 0, left;
|
int32 max = 0, used = 0;
|
||||||
system_info sys;
|
|
||||||
|
system_info info;
|
||||||
if (get_system_info(&sys) == B_OK) {
|
if (get_system_info(&info) == B_OK) {
|
||||||
// pages are 4KB
|
// pages are 4KB
|
||||||
max = sys.max_pages * 4;
|
max = info.max_pages * 4;
|
||||||
used = sys.used_pages * 4;
|
used = info.used_pages * 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
left = max - used;
|
printf("memory: total: %4ldKB, used: %4ldKB, left: %4ldKB\n", max, used, max - used);
|
||||||
|
|
||||||
printf("memory: total: %4dKB, used: %4dKB, left: %4dKB\n", max, used, left);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
list_area_info(team_id id)
|
list_area_info(team_id id)
|
||||||
{
|
{
|
||||||
int32 cookie = 0;
|
int32 cookie = 0;
|
||||||
team_info this_team;
|
team_info teamInfo;
|
||||||
area_info this_area;
|
area_info areaInfo;
|
||||||
|
|
||||||
if (get_team_info(id, &this_team) == B_BAD_TEAM_ID) {
|
|
||||||
printf("\nteam %d unknown\n", id);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("\nTEAM %4d (%s):\n", id, this_team.args);
|
if (id != 1 && get_team_info(id, &teamInfo) == B_BAD_TEAM_ID) {
|
||||||
printf(" ID name address size alloc. #-cow #-in #-out\n");
|
printf("\nteam %ld unknown\n", id);
|
||||||
printf("--------------------------------------------------------------------------------\n");
|
return;
|
||||||
|
} else if (id == 1)
|
||||||
while (get_next_area_info(id, &cookie, &this_area) == B_OK) {
|
strcpy(teamInfo.args, "KERNEL SPACE");
|
||||||
printf("%5d %29s %.8x %8x %8x %5d %5d %5d\n",
|
|
||||||
this_area.area,
|
printf("\n%s (team %ld)\n", teamInfo.args, id);
|
||||||
this_area.name,
|
printf(" ID name address size alloc. #-cow #-in #-out\n");
|
||||||
this_area.address,
|
printf("------------------------------------------------------------------------------------\n");
|
||||||
this_area.size,
|
|
||||||
this_area.ram_size,
|
while (get_next_area_info(id, &cookie, &areaInfo) == B_OK) {
|
||||||
this_area.copy_count,
|
printf("%5ld %32s %08lx %8lx %8lx %5ld %5ld %5ld\n",
|
||||||
this_area.in_count,
|
areaInfo.area,
|
||||||
this_area.out_count);
|
areaInfo.name,
|
||||||
|
(addr_t)areaInfo.address,
|
||||||
|
areaInfo.size,
|
||||||
|
areaInfo.ram_size,
|
||||||
|
areaInfo.copy_count,
|
||||||
|
areaInfo.in_count,
|
||||||
|
areaInfo.out_count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user