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:
parent
a82a66749c
commit
7bb4bc0ca9
@ -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
|
||||
// by the OpenBeOS license.
|
||||
// This software is part of the Haiku distribution and is covered
|
||||
// by the Haiku license.
|
||||
//
|
||||
//
|
||||
// File: listarea.c
|
||||
@ -12,34 +12,35 @@
|
||||
//
|
||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.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
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
show_memory_totals();
|
||||
|
||||
|
||||
if (argc == 1) {
|
||||
int32 cookie = 0;
|
||||
int32 cookie = 0;
|
||||
team_info info;
|
||||
|
||||
|
||||
// list for all teams
|
||||
while (get_next_team_info(&cookie, &info) >= B_OK)
|
||||
list_area_info(info.team);
|
||||
}
|
||||
else
|
||||
} else {
|
||||
// list for each team_id on the command line
|
||||
while (--argc)
|
||||
list_area_info(atoi(*++argv));
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -47,47 +48,46 @@ main(int argc, char **argv)
|
||||
void
|
||||
show_memory_totals()
|
||||
{
|
||||
int32 max = 0, used = 0, left;
|
||||
system_info sys;
|
||||
|
||||
if (get_system_info(&sys) == B_OK) {
|
||||
int32 max = 0, used = 0;
|
||||
|
||||
system_info info;
|
||||
if (get_system_info(&info) == B_OK) {
|
||||
// pages are 4KB
|
||||
max = sys.max_pages * 4;
|
||||
used = sys.used_pages * 4;
|
||||
max = info.max_pages * 4;
|
||||
used = info.used_pages * 4;
|
||||
}
|
||||
|
||||
left = max - used;
|
||||
|
||||
printf("memory: total: %4dKB, used: %4dKB, left: %4dKB\n", max, used, left);
|
||||
|
||||
printf("memory: total: %4ldKB, used: %4ldKB, left: %4ldKB\n", max, used, max - used);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
list_area_info(team_id id)
|
||||
{
|
||||
int32 cookie = 0;
|
||||
team_info this_team;
|
||||
area_info this_area;
|
||||
|
||||
if (get_team_info(id, &this_team) == B_BAD_TEAM_ID) {
|
||||
printf("\nteam %d unknown\n", id);
|
||||
return;
|
||||
}
|
||||
int32 cookie = 0;
|
||||
team_info teamInfo;
|
||||
area_info areaInfo;
|
||||
|
||||
printf("\nTEAM %4d (%s):\n", id, this_team.args);
|
||||
printf(" ID name address size alloc. #-cow #-in #-out\n");
|
||||
printf("--------------------------------------------------------------------------------\n");
|
||||
|
||||
while (get_next_area_info(id, &cookie, &this_area) == B_OK) {
|
||||
printf("%5d %29s %.8x %8x %8x %5d %5d %5d\n",
|
||||
this_area.area,
|
||||
this_area.name,
|
||||
this_area.address,
|
||||
this_area.size,
|
||||
this_area.ram_size,
|
||||
this_area.copy_count,
|
||||
this_area.in_count,
|
||||
this_area.out_count);
|
||||
if (id != 1 && get_team_info(id, &teamInfo) == B_BAD_TEAM_ID) {
|
||||
printf("\nteam %ld unknown\n", id);
|
||||
return;
|
||||
} else if (id == 1)
|
||||
strcpy(teamInfo.args, "KERNEL SPACE");
|
||||
|
||||
printf("\n%s (team %ld)\n", teamInfo.args, id);
|
||||
printf(" ID name address size alloc. #-cow #-in #-out\n");
|
||||
printf("------------------------------------------------------------------------------------\n");
|
||||
|
||||
while (get_next_area_info(id, &cookie, &areaInfo) == B_OK) {
|
||||
printf("%5ld %32s %08lx %8lx %8lx %5ld %5ld %5ld\n",
|
||||
areaInfo.area,
|
||||
areaInfo.name,
|
||||
(addr_t)areaInfo.address,
|
||||
areaInfo.size,
|
||||
areaInfo.ram_size,
|
||||
areaInfo.copy_count,
|
||||
areaInfo.in_count,
|
||||
areaInfo.out_count);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user