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

📄 proc.c

📁 LINUX1.0内核源代码,学习LINUX编程的一定要看。
💻 C
字号:
/* * UNIX		An implementation of the AF_UNIX network domain for the *		LINUX operating system.  UNIX is implemented using the *		BSD Socket interface as the means of communication with *		the user level. * *		The functions in this file provide an interface between *		the PROC file system and the "unix" family of networking *		protocols. It is mainly used for debugging and statistics. * * Version:	@(#)proc.c	1.0.4	05/23/93 * * Authors:	Ross Biro, <bir7@leland.Stanford.Edu> *		Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> *		Gerald J. Heim, <heim@peanuts.informatik.uni-tuebingen.de> *		Fred Baumgarten, <dc6iq@insu1.etec.uni-kalrsruhe.de> * * Fixes: *		Dmitry Gorodchanin	:	/proc locking fix * *		This program is free software; you can redistribute it and/or *		modify it under the terms of the GNU General Public License *		as published by the Free Software Foundation; either version *		2 of the License, or (at your option) any later version. */#include <linux/autoconf.h>#include <linux/sched.h>#include <linux/string.h>#include <linux/socket.h>#include <linux/net.h>#include <linux/ddi.h>#include <linux/un.h>#include <linux/param.h>#include "unix.h"/* Called from PROCfs. */int unix_get_info(char *buffer){  char *pos;  int i;  pos = buffer;  pos += sprintf(pos, "Num RefCount Protocol Flags    Type St Path\n");  for(i = 0; i < NSOCKETS; i++) {	if (unix_datas[i].refcnt>0) {		pos += sprintf(pos, "%2d: %08X %08X %08lX %04X %02X", i,			unix_datas[i].refcnt,			unix_datas[i].protocol,			unix_datas[i].socket->flags,			unix_datas[i].socket->type,			unix_datas[i].socket->state		);		/* If socket is bound to a filename, we'll print it. */		if(unix_datas[i].sockaddr_len>0) {			pos += sprintf(pos, " %s\n",				unix_datas[i].sockaddr_un.sun_path);		} else { /* just add a newline */			*pos='\n';			pos++;			*pos='\0';		}		/*		 * Check whether buffer _may_ overflow in the next loop.		 * Since sockets may have very very long paths, we make		 * PATH_MAX+80 the minimum space left for a new line.		 */		if (pos > buffer+PAGE_SIZE-80-PATH_MAX) {			printk("UNIX: netinfo: oops, too many sockets.\n");			return(pos - buffer);		}	}  }  return(pos - buffer);}

⌨️ 快捷键说明

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