home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Source Code 1992 March
/
Source_Code_CD-ROM_Walnut_Creek_March_1992.iso
/
usenet
/
altsrcs
/
3
/
3998
/
mem.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-09-08
|
2KB
|
142 lines
/*
* @(#)mem.c 1.5 91/09/05
*/
#include <stdio.h>
#include <sys/types.h>
#include <sys/ptrace.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/mman.h>
#include "defs.h"
int
sys_brk(tcp)
struct tcb *tcp;
{
if (entering(tcp)) {
fprintf(outf, "%x", tcp->u_args[0]);
}
return 0;
}
int
sys_sbrk(tcp)
struct tcb *tcp;
{
if (entering(tcp)) {
fprintf(outf, "%u", tcp->u_args[0]);
}
return RVAL_HEX;
}
static Xlat mmap_prot[] = {
PROT_READ, "READ",
PROT_WRITE, "WRITE",
PROT_EXEC, "EXEC",
PROT_NONE, "NONE",
0, NULL,
};
static Xlat mmap_flags[] = {
MAP_SHARED, "SHARED",
MAP_PRIVATE, "PRIVATE",
MAP_FIXED, "FIXED",
MAP_RENAME, "RENAME",
MAP_NORESERVE, "NORESERVE",
0, NULL,
};
int
sys_smmap(tcp)
struct tcb *tcp;
{
Xlat *x;
if (entering(tcp)) {
/* addr */
fprintf(outf, "%#x, ", tcp->u_args[0]);
/* len */
fprintf(outf, "%u, ", tcp->u_args[1]);
/* prot */
printflags(mmap_prot, tcp->u_args[2]);
fprintf(outf, ", ");
/* flags */
printxval(mmap_flags, tcp->u_args[3] & MAP_TYPE, "MAP_???");
addflags(mmap_flags,
tcp->u_args[3] & (~_MAP_NEW & ~MAP_TYPE));
/* fd */
fprintf(outf, ", %u, ", tcp->u_args[4]);
/* offset */
fprintf(outf, "%#x", tcp->u_args[5]);
}
return RVAL_HEX;
}
int
sys_munmap(tcp)
struct tcb *tcp;
{
if (entering(tcp)) {
/* addr */
fprintf(outf, "%#x, ", tcp->u_args[0]);
/* len */
fprintf(outf, ", %u, ", tcp->u_args[1]);
}
return 0;
}
int
sys_mprotect(tcp)
struct tcb *tcp;
{
if (entering(tcp)) {
/* addr */
fprintf(outf, "%#x", tcp->u_args[0]);
/* len */
fprintf(outf, ", %u, ", tcp->u_args[1]);
/* prot */
printflags(mmap_prot, tcp->u_args[2]);
}
return 0;
}
static Xlat mctl_funcs[] = {
MC_LOCK, "LOCK",
MC_LOCKAS, "LOCKAS",
MC_SYNC, "SYNC",
MC_UNLOCK, "UNLOCK",
MC_UNLOCKAS, "UNLOCKAS",
0, NULL,
};
int
sys_mctl(tcp)
struct tcb *tcp;
{
int arg, function;
if (entering(tcp)) {
/* addr */
fprintf(outf, "%#x", tcp->u_args[0]);
/* len */
fprintf(outf, ", %u, ", tcp->u_args[1]);
/* function */
function = tcp->u_args[2];
printflags(mctl_funcs, function);
/* arg */
arg = tcp->u_args[3];
if (function == MC_SYNC)
fprintf(outf, ", %s", arg==MS_ASYNC?"ASYNC":(
arg==MS_INVALIDATE?"INVALIDATE":
"MS_???"
)
);
else
fprintf(outf, ", %#x", arg);
}
return 0;
}