⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 system.c

📁 linux进程跟踪的工具和源代码
💻 C
📖 第 1 页 / 共 4 页
字号:
	{ SGI_PIDSINASH,	"SGI_PIDSINASH"		},#endif#ifdef SGI_ULI				{ SGI_ULI,		"SGI_ULI"		},#endif#ifdef SGI_LPG_SHMGET          	{ SGI_LPG_SHMGET,	"SGI_LPG_SHMGET"	},#endif#ifdef SGI_LPG_MAP             	{ SGI_LPG_MAP,		"SGI_LPG_MAP"		},#endif#ifdef SGI_CACHEFS_SYS			{ SGI_CACHEFS_SYS,	"SGI_CACHEFS_SYS"	},#endif#ifdef SGI_NFSNOTIFY			{ SGI_NFSNOTIFY,	"SGI_NFSNOTIFY"		},#endif#ifdef SGI_LOCKDSYS			{ SGI_LOCKDSYS,		"SGI_LOCKDSYS"		},#endif#ifdef SGI_EVENTCTR            	{ SGI_EVENTCTR,		"SGI_EVENTCTR"		},#endif#ifdef SGI_GETPRUSAGE          	{ SGI_GETPRUSAGE,	"SGI_GETPRUSAGE"	},#endif#ifdef SGI_PROCMASK_LOCATION		{ SGI_PROCMASK_LOCATION,"SGI_PROCMASK_LOCATION"	},#endif#ifdef SGI_UNUSED			{ SGI_UNUSED,		"SGI_UNUSED"		},#endif#ifdef SGI_CKPT_SYS			{ SGI_CKPT_SYS,		"SGI_CKPT_SYS"		},#endif#ifdef SGI_CKPT_SYS			{ SGI_CKPT_SYS,		"SGI_CKPT_SYS"		},#endif#ifdef SGI_GETGRPPID			{ SGI_GETGRPPID,	"SGI_GETGRPPID"		},#endif#ifdef SGI_GETSESPID			{ SGI_GETSESPID,	"SGI_GETSESPID"		},#endif#ifdef SGI_ENUMASHS			{ SGI_ENUMASHS,		"SGI_ENUMASHS"		},#endif#ifdef SGI_SETASMACHID			{ SGI_SETASMACHID,	"SGI_SETASMACHID"	},#endif#ifdef SGI_GETASMACHID			{ SGI_GETASMACHID,	"SGI_GETASMACHID"	},#endif#ifdef SGI_GETARSESS			{ SGI_GETARSESS,	"SGI_GETARSESS"		},#endif#ifdef SGI_JOINARRAYSESS		{ SGI_JOINARRAYSESS,	"SGI_JOINARRAYSESS"	},#endif#ifdef SGI_SPROC_KILL			{ SGI_SPROC_KILL,	"SGI_SPROC_KILL"	},#endif#ifdef SGI_DBA_CONFIG			{ SGI_DBA_CONFIG,	"SGI_DBA_CONFIG"	},#endif#ifdef SGI_RELEASE_NAME		{ SGI_RELEASE_NAME,	"SGI_RELEASE_NAME"	},#endif#ifdef SGI_SYNCH_CACHE_HANDLER 	{ SGI_SYNCH_CACHE_HANDLER,"SGI_SYNCH_CACHE_HANDLER"},#endif#ifdef SGI_SWASH_INIT			{ SGI_SWASH_INIT,	"SGI_SWASH_INIT"	},#endif#ifdef SGI_NUMA_MIGR_PAGE		{ SGI_NUMA_MIGR_PAGE,	"SGI_NUMA_MIGR_PAGE"	},#endif#ifdef SGI_NUMA_MIGR_PAGE_ALT		{ SGI_NUMA_MIGR_PAGE_ALT,"SGI_NUMA_MIGR_PAGE_ALT"},#endif#ifdef SGI_KAIO_USERINIT		{ SGI_KAIO_USERINIT,	"SGI_KAIO_USERINIT"	},#endif#ifdef SGI_KAIO_READ			{ SGI_KAIO_READ,	"SGI_KAIO_READ"		},#endif#ifdef SGI_KAIO_WRITE			{ SGI_KAIO_WRITE,	"SGI_KAIO_WRITE"	},#endif#ifdef SGI_KAIO_SUSPEND		{ SGI_KAIO_SUSPEND,	"SGI_KAIO_SUSPEND"	},#endif#ifdef SGI_KAIO_STATS			{ SGI_KAIO_STATS,	"SGI_KAIO_STATS"	},#endif#ifdef SGI_INITIAL_PT_SPROC		{ SGI_INITIAL_PT_SPROC,	"SGI_INITIAL_PT_SPROC"	},#endif	{ 0,			NULL			},};intsys_syssgi(tcp)struct tcb *tcp;{	int i;	if (entering(tcp)) {		printxval(syssgi_options, tcp->u_arg[0], "SGI_???");		switch (tcp->u_arg[0]) {		default:			for (i = 1; i < tcp->u_nargs; i++)				tprintf(", %#lx", tcp->u_arg[i]);			break;		}	}	return 0;}#include <sys/types.h>#include <rpc/rpc.h>struct cred;struct uio;#include <sys/fsid.h>#include <sys/vnode.h>#include <sys/fs/nfs.h>#include <sys/fs/nfs_clnt.h>static struct xlat mount_flags[] = {	{ MS_RDONLY,	"MS_RDONLY"	},	{ MS_FSS,	"MS_FSS"	},	{ MS_DATA,	"MS_DATA"	},	{ MS_NOSUID,	"MS_NOSUID"	},	{ MS_REMOUNT,	"MS_REMOUNT"	},	{ MS_NOTRUNC,	"MS_NOTRUNC"	},	{ MS_GRPID,	"MS_GRPID"	},	{ MS_NODEV,	"MS_NODEV"	},	{ MS_BEFORE,	"MS_BEFORE"	},	{ MS_AFTER,	"MS_AFTER"	},	{ 0,		NULL		},};static struct xlat nfs_flags[] = {	{ NFSMNT_SOFT,		"NFSMNT_SOFT"		},	{ NFSMNT_WSIZE,		"NFSMNT_WSIZE"		},	{ NFSMNT_RSIZE,		"NFSMNT_RSIZE"		},	{ NFSMNT_TIMEO,		"NFSMNT_TIMEO"		},	{ NFSMNT_RETRANS,	"NFSMNT_RETRANS"	},	{ NFSMNT_HOSTNAME,	"NFSMNT_HOSTNAME"	},#ifdef NFSMNT_NOINT	/* IRIX 6 */	{ NFSMNT_NOINT,		"NFSMNT_NOINT"		},#endif#ifdef NFSMNT_INT	/* IRIX 5 */	{ NFSMNT_INT,		"NFSMNT_INT"		},#endif	{ NFSMNT_NOAC,		"NFSMNT_NOAC"		},	{ NFSMNT_ACREGMIN,	"NFSMNT_ACREGMIN"	},	{ NFSMNT_ACREGMAX,	"NFSMNT_ACREGMAX"	},	{ NFSMNT_ACDIRMIN,	"NFSMNT_ACDIRMIN"	},	{ NFSMNT_ACDIRMAX,	"NFSMNT_ACDIRMAX"	},	{ NFSMNT_PRIVATE,	"NFSMNT_PRIVATE"	},	{ NFSMNT_SYMTTL,	"NFSMNT_SYMTTL"		},	{ NFSMNT_LOOPBACK,	"NFSMNT_LOOPBACK"	},	{ NFSMNT_BASETYPE,	"NFSMNT_BASETYPE"	},	{ NFSMNT_NAMEMAX,	"NFSMNT_NAMEMAX"	},#ifdef NFSMNT_SHORTUID	/* IRIX 6 */	{ NFSMNT_SHORTUID,	"NFSMNT_SHORTUID"	},#endif#ifdef NFSMNT_ASYNCNLM	/* IRIX 6 */	{ NFSMNT_ASYNCNLM,	"NFSMNT_ASYNCNLM"	},#endif	{ 0,			NULL			},};intsys_mount(tcp)struct tcb *tcp;{	if (entering(tcp)) {		printpath(tcp, tcp->u_arg[0]);		tprintf(", ");		printpath(tcp, tcp->u_arg[1]);		tprintf(", ");		printflags(mount_flags, tcp->u_arg[2]);		if (tcp->u_arg[2] & (MS_FSS | MS_DATA)) {			tprintf(", ");			tprintf("%ld", tcp->u_arg[3]);		}		if (tcp->u_arg[2] & MS_DATA) {			int nfs_type = sysfs(GETFSIND, FSID_NFS);			tprintf(", ");			if (tcp->u_arg[3] == nfs_type) {				struct nfs_args args;				if (umove(tcp, tcp->u_arg[4], &args) < 0)					tprintf("%#lx", tcp->u_arg[4]);				else {					tprintf("addr=");					printsock(tcp, (int) args.addr);					tprintf(", flags=");					if (!printflags(nfs_flags, args.flags))						tprintf("NFSMNT_???");					tprintf(", hostname=");					printstr(tcp, (int) args.hostname, -1);					tprintf(", ...}");				}			}			else				tprintf("%#lx", tcp->u_arg[4]);			tprintf(", %ld", tcp->u_arg[5]);		}	}	return 0;}#else /* !MIPS */#if UNIXWARE#include <sys/types.h>#include <sys/fstyp.h>#include <sys/mount.h>#include <sys/xti.h>#define NFSCLIENT	1#include <nfs/mount.h>#include <sys/fs/vx_ioctl.h>static struct xlat mount_flags[] = {	{ MS_RDONLY,	"MS_RDONLY"	},	{ MS_FSS,	"MS_FSS"	},	{ MS_DATA,	"MS_DATA"	},	{ MS_HADBAD,	"MS_HADBAD"	},	{ MS_NOSUID,	"MS_NOSUID"	},	{ MS_REMOUNT,	"MS_REMOUNT"	},	{ MS_NOTRUNC,	"MS_NOTRUNC"	},	{ MS_SOFTMNT,	"MS_SOFTMNT"	},	{ MS_SYSSPACE,	"MS_SYSSPACE"	},	{ 0,		NULL		},};#ifdef VX_MS_MASKstatic struct xlat vxfs_flags[] = {	{ VX_MS_NOLOG,		"VX_MS_NOLOG"		},	{ VX_MS_BLKCLEAR,	"VX_MS_BLKCLEAR"	},	{ VX_MS_SNAPSHOT,	"VX_MS_SNAPSHOT"	},	{ VX_MS_NODATAINLOG,	"VX_MS_NODATAINLOG"	},	{ VX_MS_DELAYLOG,	"VX_MS_DELAYLOG"	},	{ VX_MS_TMPLOG,		"VX_MS_TMPLOG"		},	{ VX_MS_FILESET,	"VX_MS_FILESET"		},	{ VX_MS_CACHE_DIRECT,	"VX_MS_CACHE_DIRECT"	},	{ VX_MS_CACHE_DSYNC,	"VX_MS_CACHE_DSYNC"	},	{ VX_MS_CACHE_CLOSESYNC,"VX_MS_CACHE_CLOSESYNC"	},	{ VX_MS_CACHE_TMPCACHE,	"VX_MS_CACHE_TMPCACHE"	},	{ VX_MS_OSYNC_DIRECT,	"VX_MS_OSYNC_DIRECT"	},	{ VX_MS_OSYNC_DSYNC,	"VX_MS_OSYNC_DSYNC"	},	{ VX_MS_OSYNC_CLOSESYNC,"VX_MS_OSYNC_CLOSESYNC"	},	{ VX_MS_OSYNC_DELAY,	"VX_MS_OSYNC_DELAY"	},	{ 0,			NULL,			},};#endifstatic struct xlat nfs_flags[] = {	{ NFSMNT_SOFT,		"NFSMNT_SOFT"		},	{ NFSMNT_WSIZE,		"NFSMNT_WSIZE"		},	{ NFSMNT_RSIZE,		"NFSMNT_RSIZE"		},	{ NFSMNT_TIMEO,		"NFSMNT_TIMEO"		},	{ NFSMNT_RETRANS,	"NFSMNT_RETRANS"	},	{ NFSMNT_HOSTNAME,	"NFSMNT_HOSTNAME"	},	{ NFSMNT_INT,		"NFSMNT_INT"		},	{ NFSMNT_NOAC,		"NFSMNT_NOAC"		},	{ NFSMNT_ACREGMIN,	"NFSMNT_ACREGMIN"	},	{ NFSMNT_ACREGMAX,	"NFSMNT_ACREGMAX"	},	{ NFSMNT_ACDIRMIN,	"NFSMNT_ACDIRMIN"	},	{ NFSMNT_ACDIRMAX,	"NFSMNT_ACDIRMAX"	},	{ NFSMNT_SECURE,	"NFSMNT_SECURE"		},	{ NFSMNT_NOCTO,		"NFSMNT_NOCTO"		},	{ NFSMNT_GRPID,		"NFSMNT_GRPID"		},	{ NFSMNT_RPCTIMESYNC,	"NFSMNT_RPCTIMESYNC"	},	{ NFSMNT_LWPSMAX,	"NFSMNT_LWPSMAX"	},	{ 0,			NULL			},};intsys_mount(tcp)struct tcb *tcp;{	if (entering(tcp)) {		char fstyp [FSTYPSZ];		printpath(tcp, tcp->u_arg[0]);		tprintf(", ");		printpath(tcp, tcp->u_arg[1]);		tprintf(", ");		printflags(mount_flags, tcp->u_arg[2]);		/* The doc sez that the file system type is given as a		   fsindex, and we should use sysfs to work out the name.		   This appears to be untrue for UW.  Maybe it's untrue		   for all SVR4's? */		if (tcp->u_arg[2] & (MS_FSS | MS_DATA)) {			if (umovestr(tcp, tcp->u_arg[3], FSTYPSZ, fstyp) < 0) {				*fstyp = 0;				tprintf(", %ld", tcp->u_arg[3]);			}			else				tprintf(", \"%s\"", fstyp);		}		if (tcp->u_arg[2] & MS_DATA) {			tprintf(", ");#ifdef VX_MS_MASK			/* On UW7 they don't give us the defines and structs			   we need to see what is going on.  Bummer. */			if (strcmp (fstyp, "vxfs") == 0) {				struct vx_mountargs5 args;				if (umove(tcp, tcp->u_arg[4], &args) < 0)					tprintf("%#lx", tcp->u_arg[4]);				else {					tprintf("{ flags=");					if (!printflags(vxfs_flags, args.mflags))						tprintf("0x%08x", args.mflags);					if (args.mflags & VX_MS_SNAPSHOT) {						tprintf (", snapof=");						printstr (tcp,							  (long) args.primaryspec, 							  -1);						if (args.snapsize > 0)							tprintf (", snapsize=%ld", args.snapsize);					}					tprintf(" }");				}			}			else#endif			if (strcmp (fstyp, "specfs") == 0) {				tprintf ("dev=");				printstr (tcp, tcp->u_arg[4], -1);			}			else			if (strcmp (fstyp, "nfs") == 0) {				struct nfs_args args;				if (umove(tcp, tcp->u_arg[4], &args) < 0)					tprintf("%#lx", tcp->u_arg[4]);				else {					struct netbuf addr;					tprintf("{ addr=");					if (umove (tcp, (int) args.addr, &addr) < 0) {						tprintf ("%#lx", (long) args.addr);					}					else {						printsock(tcp, (int) addr.buf, addr.len);					}					tprintf(", flags=");					if (!printflags(nfs_flags, args.flags))						tprintf("NFSMNT_???");					tprintf(", hostname=");					printstr(tcp, (int) args.hostname, -1);					tprintf(", ...}");				}			}			else				tprintf("%#lx", tcp->u_arg[4]);			tprintf(", %ld", tcp->u_arg[5]);		}	}	return 0;}#else /* !UNIXWARE */intsys_mount(tcp)struct tcb *tcp;{	if (entering(tcp)) {		printpath(tcp, tcp->u_arg[0]);		tprintf(", ");		printpath(tcp, tcp->u_arg[1]);		tprintf(", ...");	}	return 0;}#endif /* !UNIXWARE */#endif /* !MIPS */#endif /* SVR4 */#ifdef SYS_capgetstatic struct xlat capabilities[] = {	{ 1<<CAP_CHOWN,		"CAP_CHOWN"	},	{ 1<<CAP_DAC_OVERRIDE,	"CAP_DAC_OVERRIDE"},	{ 1<<CAP_DAC_READ_SEARCH,"CAP_DAC_READ_SEARCH"},	{ 1<<CAP_FOWNER,	"CAP_FOWNER"	},	{ 1<<CAP_FSETID,	"CAP_FSETID"	},	{ 1<<CAP_KILL,		"CAP_KILL"	},	{ 1<<CAP_SETGID,	"CAP_SETGID"	},	{ 1<<CAP_SETUID,	"CAP_SETUID"	},	{ 1<<CAP_SETPCAP,	"CAP_SETPCAP"	},	{ 1<<CAP_LINUX_IMMUTABLE,"CAP_LINUX_IMMUTABLE"},	{ 1<<CAP_NET_BIND_SERVICE,"CAP_NET_BIND_SERVICE"},	{ 1<<CAP_NET_BROADCAST,	"CAP_NET_BROADCAST"},	{ 1<<CAP_NET_ADMIN,	"CAP_NET_ADMIN"	},	{ 1<<CAP_NET_RAW,	"CAP_NET_RAW"	},	{ 1<<CAP_IPC_LOCK,	"CAP_IPC_LOCK"	},	{ 1<<CAP_IPC_OWNER,	"CAP_IPC_OWNER"	},	{ 1<<CAP_SYS_MODULE,	"CAP_SYS_MODULE"},	{ 1<<CAP_SYS_RAWIO,	"CAP_SYS_RAWIO"	},	{ 1<<CAP_SYS_CHROOT,	"CAP_SYS_CHROOT"},	{ 1<<CAP_SYS_PTRACE,	"CAP_SYS_PTRACE"},	{ 1<<CAP_SYS_PACCT,	"CAP_SYS_PACCT"	},	{ 1<<CAP_SYS_ADMIN,	"CAP_SYS_ADMIN"	},	{ 1<<CAP_SYS_BOOT,	"CAP_SYS_BOOT"	},	{ 1<<CAP_SYS_NICE,	"CAP_SYS_NICE"	},	{ 1<<CAP_SYS_RESOURCE,	"CAP_SYS_RESOURCE"},	{ 1<<CAP_SYS_TIME,	"CAP_SYS_TIME"	},	{ 1<<CAP_SYS_TTY_CONFIG,"CAP_SYS_TTY_CONFIG"},	{ 0,                    NULL            },};intsys_capget(tcp)struct tcb *tcp;{	static cap_user_header_t       arg0 = NULL;	static cap_user_data_t         arg1 = NULL;	if(!entering(tcp)) {		if (!arg0) {			if ((arg0 = malloc(sizeof(*arg0))) == NULL) {				fprintf(stderr, "sys_capget: no memory\n");				tprintf("%#lx, %#lx", tcp->u_arg[0], tcp->u_arg[1]);				return -1;			}		}		if (!arg1) {			if ((arg1 = malloc(sizeof(*arg1))) == NULL) {				fprintf(stderr, "sys_capget: no memory\n");				tprintf("%#lx, %#lx", tcp->u_arg[0], tcp->u_arg[1]);				return -1;			}		}		if (!tcp->u_arg[0])			tprintf("NULL");		else if (!verbose(tcp))			tprintf("%#lx", tcp->u_arg[0]);		else if (umoven(tcp, tcp->u_arg[0], sizeof(*arg0), (char *) arg0) < 0)			tprintf("???");		else {			tprintf("%#x, %d", arg0->version, arg0->pid);		}		tprintf(", ");		if (!tcp->u_arg[1])			tprintf("NULL");		else if (!verbose(tcp))			tprintf("%#lx", tcp->u_arg[1]);		else if (umoven(tcp, tcp->u_arg[1], sizeof(*arg1), (char *) arg1) < 0)			tprintf("???");		else {			tprintf("{");			printflags(capabilities, arg1->effective);			tprintf(", ");			printflags(capabilities, arg1->permitted);			tprintf(", ");			printflags(capabilities, arg1->inheritable);			tprintf("}");		} 	}	return 0;}intsys_capset(tcp)struct tcb *tcp;{	static cap_user_header_t       arg0 = NULL;	static cap_user_data_t         arg1 = NULL;	if(entering(tcp)) {		if (!arg0) {			if ((arg0 = malloc(sizeof(*arg0))) == NULL) {				fprintf(stderr, "sys_capset: no memory\n");				tprintf("%#lx, %#lx", tcp->u_arg[0], tcp->u_arg[1]);				return -1;			}		}		if (!arg1) {			if ((arg1 = malloc(sizeof(*arg1))) == NULL) {				fprintf(stderr, "sys_capset: no memory\n");				tprintf("%#lx, %#lx", tcp->u_arg[0], tcp->u_arg[1]);				return -1;			}		}		if (!tcp->u_arg[0])			tprintf("NULL");		else if (!verbose(tcp))			tprintf("%#lx", tcp->u_arg[0]);		else if (umoven(tcp, tcp->u_arg[0], sizeof(*arg0), (char *) arg0) < 0)			tprintf("???");		else {			tprintf("%#x, %d", arg0->version, arg0->pid);		}		tprintf(", ");		if (!tcp->u_arg[1])			tprintf("NULL");		else if (!verbose(tcp))

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -