Mirror of git://git.busybox.net/busybox with our patches on top
Source
ret = procps_read_smaps(pid, &total, print_smaprec, (void*)(uintptr_t)opt);
/*
* pmap implementation for busybox
*
* Copyright (C) 2010 Nokia Corporation. All rights reserved.
* Written by Alexander Shishkin <virtuoso@slind.org>
*
* Licensed under GPLv2 or later, see the LICENSE file in this source tree
* for details.
*/
//config:config PMAP
//config: bool "pmap"
//config: default y
//config: help
//config: Display processes' memory mappings.
//applet:IF_PMAP(APPLET(pmap, BB_DIR_USR_BIN, BB_SUID_DROP))
//kbuild:lib-$(CONFIG_PMAP) += pmap.o
//usage:#define pmap_trivial_usage
//usage: "[-xq] PID"
//usage:#define pmap_full_usage "\n\n"
//usage: "Display detailed process memory usage"
//usage: "\n"
//usage: "\n -x Show details"
//usage: "\n -q Quiet"
enum {
OPT_x = 1 << 0,
OPT_q = 1 << 1,
};
static void print_smaprec(struct smaprec *currec, void *data)
{
unsigned opt = (uintptr_t)data;
printf("%0" AFMT "lx ", currec->smap_start);
if (opt & OPT_x)
printf("%7lu %7lu %7lu %7lu ",
currec->smap_size,
currec->smap_pss,
currec->private_dirty,
currec->smap_swap);
else
printf("%7luK", currec->smap_size);
printf(" %.4s %s\n", currec->smap_mode, currec->smap_name);
}
static int procps_get_maps(pid_t pid, unsigned opt)