亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? sock.c

?? <Linux1.0核心游記>電子書+書后源碼+Linux1.0源碼
?? C
?? 第 1 頁 / 共 2 頁
字號:
/* * 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. * * Version:	@(#)sock.c	1.0.5	05/25/93 * * Authors:	Orest Zborowski, <obz@Kodak.COM> *		Ross Biro, <bir7@leland.Stanford.Edu> *		Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> * * Fixes: *		Alan Cox	:	Verify Area *		NET2E Team	:	Page fault locks *	Dmitry Gorodchanin	:	/proc locking * * To Do: *	Some nice person is looking into Unix sockets done properly. NET3 *	will replace all of this and include datagram sockets and socket *	options - so please stop asking me for them 8-) * * *		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/config.h>#include <linux/kernel.h>#include <linux/major.h>#include <linux/signal.h>#include <linux/sched.h>#include <linux/errno.h>#include <linux/string.h>#include <linux/stat.h>#include <linux/socket.h>#include <linux/un.h>#include <linux/fcntl.h>#include <linux/termios.h>#include <linux/sockios.h>#include <linux/net.h>#include <linux/fs.h>#include <linux/ddi.h>#include <linux/malloc.h>#include <asm/system.h>#include <asm/segment.h>#include <stdarg.h>#include "unix.h"struct unix_proto_data unix_datas[NSOCKETS];static int unix_debug = 0;static int unix_proto_create(struct socket *sock, int protocol);static int unix_proto_dup(struct socket *newsock, struct socket *oldsock);static int unix_proto_release(struct socket *sock, struct socket *peer);static int unix_proto_bind(struct socket *sock, struct sockaddr *umyaddr,			   int sockaddr_len);static int unix_proto_connect(struct socket *sock, struct sockaddr *uservaddr,			      int sockaddr_len, int flags);static int unix_proto_socketpair(struct socket *sock1, struct socket *sock2);static int unix_proto_accept(struct socket *sock, struct socket *newsock, 			     int flags);static int unix_proto_getname(struct socket *sock, struct sockaddr *usockaddr,			      int *usockaddr_len, int peer);static int unix_proto_read(struct socket *sock, char *ubuf, int size,			   int nonblock);static int unix_proto_write(struct socket *sock, char *ubuf, int size,			    int nonblock);static int unix_proto_select(struct socket *sock, int sel_type, select_table * wait);static int unix_proto_ioctl(struct socket *sock, unsigned int cmd,			    unsigned long arg);static int unix_proto_listen(struct socket *sock, int backlog);static int unix_proto_send(struct socket *sock, void *buff, int len,			    int nonblock, unsigned flags);static int unix_proto_recv(struct socket *sock, void *buff, int len,			    int nonblock, unsigned flags);static int unix_proto_sendto(struct socket *sock, void *buff, int len,			      int nonblock, unsigned flags,			      struct sockaddr *addr, int addr_len);static int unix_proto_recvfrom(struct socket *sock, void *buff, int len,				int nonblock, unsigned flags,				struct sockaddr *addr, int *addr_len);static int unix_proto_shutdown(struct socket *sock, int how);static int unix_proto_setsockopt(struct socket *sock, int level, int optname,				  char *optval, int optlen);static int unix_proto_getsockopt(struct socket *sock, int level, int optname,				  char *optval, int *optlen);static voiddprintf(int level, char *fmt, ...){  va_list args;  char *buff;  extern int vsprintf(char * buf, const char * fmt, va_list args);  if (level != unix_debug) return;  buff = (char *) kmalloc(256, GFP_KERNEL);  if (buff != NULL) {	va_start(args, fmt);	vsprintf(buff, fmt, args);	va_end(args);	printk(buff);	kfree(buff);  }}static inline intmin(int a, int b){  if (a < b) return(a);  return(b);}voidsockaddr_un_printk(struct sockaddr_un *sockun, int sockaddr_len){  char buf[sizeof(sockun->sun_path) + 1];  if (unix_debug == 0) return;  sockaddr_len -= UN_PATH_OFFSET;  if (sockun->sun_family != AF_UNIX)	printk("UNIX: Badd addr family %d>\n", sockun->sun_family);    else if (sockaddr_len <= 0 || sockaddr_len >= sizeof(buf))	printk("UNIX: Bad addr len %d>\n", sockaddr_len);    else {	memcpy(buf, sockun->sun_path, sockaddr_len);	buf[sockaddr_len] = '\0';	printk("\"%s\"[%lu]\n", buf, sockaddr_len + UN_PATH_OFFSET);  }}  /* Support routines doing anti page fault locking  * FvK & Matt Dillon (borrowed From NET2E3) *//* * Locking for unix-domain sockets.  We don't use the socket structure's * wait queue because it is allowed to 'go away' outside of our control, * whereas unix_proto_data structures stick around. */void unix_lock(struct unix_proto_data *upd){	while (upd->lock_flag)		sleep_on(&upd->wait);	upd->lock_flag = 1;}void unix_unlock(struct unix_proto_data *upd){	upd->lock_flag = 0;	wake_up(&upd->wait);}/* don't have to do anything. */static intunix_proto_listen(struct socket *sock, int backlog){  return(0);}static intunix_proto_setsockopt(struct socket *sock, int level, int optname,		      char *optval, int optlen){  return(-EOPNOTSUPP);}static intunix_proto_getsockopt(struct socket *sock, int level, int optname,		      char *optval, int *optlen){  return(-EOPNOTSUPP);}static intunix_proto_sendto(struct socket *sock, void *buff, int len, int nonblock, 		  unsigned flags,  struct sockaddr *addr, int addr_len){  return(-EOPNOTSUPP);}     static intunix_proto_recvfrom(struct socket *sock, void *buff, int len, int nonblock, 		    unsigned flags, struct sockaddr *addr, int *addr_len){  return(-EOPNOTSUPP);}     static intunix_proto_shutdown(struct socket *sock, int how){  return(-EOPNOTSUPP);}/* This error needs to be checked. */static intunix_proto_send(struct socket *sock, void *buff, int len, int nonblock,		unsigned flags){  if (flags != 0) return(-EINVAL);  return(unix_proto_write(sock, (char *) buff, len, nonblock));}/* This error needs to be checked. */static intunix_proto_recv(struct socket *sock, void *buff, int len, int nonblock,		unsigned flags){  if (flags != 0) return(-EINVAL);  return(unix_proto_read(sock, (char *) buff, len, nonblock));}static struct unix_proto_data *unix_data_lookup(struct sockaddr_un *sockun, int sockaddr_len,		 struct inode *inode){  struct unix_proto_data *upd;  for(upd = unix_datas; upd <= last_unix_data; ++upd) {	if (upd->refcnt > 0 && upd->socket &&	    upd->socket->state == SS_UNCONNECTED &&	    upd->sockaddr_un.sun_family == sockun->sun_family &&	    upd->inode == inode) return(upd);  }  return(NULL);}static struct unix_proto_data *unix_data_alloc(void){  struct unix_proto_data *upd;  cli();  for(upd = unix_datas; upd <= last_unix_data; ++upd) {	if (!upd->refcnt) {		upd->refcnt = -1;	/* unix domain socket not yet initialised - bgm */		sti();		upd->socket = NULL;		upd->sockaddr_len = 0;		upd->sockaddr_un.sun_family = 0;		upd->buf = NULL;		upd->bp_head = upd->bp_tail = 0;		upd->inode = NULL;		upd->peerupd = NULL;		return(upd);	}  }  sti();  return(NULL);}static inline voidunix_data_ref(struct unix_proto_data *upd){  if (!upd) {    dprintf(1, "UNIX: data_ref: upd = NULL\n");    return;  }  ++upd->refcnt;  dprintf(1, "UNIX: data_ref: refing data 0x%x(%d)\n", upd, upd->refcnt);}static voidunix_data_deref(struct unix_proto_data *upd){  if (!upd) {    dprintf(1, "UNIX: data_deref: upd = NULL\n");    return;  }  if (upd->refcnt == 1) {	dprintf(1, "UNIX: data_deref: releasing data 0x%x\n", upd);	if (upd->buf) {		free_page((unsigned long)upd->buf);		upd->buf = NULL;		upd->bp_head = upd->bp_tail = 0;	}  }  --upd->refcnt;}/* * Upon a create, we allocate an empty protocol data, * and grab a page to buffer writes. */static intunix_proto_create(struct socket *sock, int protocol){  struct unix_proto_data *upd;  dprintf(1, "UNIX: create: socket 0x%x, proto %d\n", sock, protocol);  if (protocol != 0) {	dprintf(1, "UNIX: create: protocol != 0\n");	return(-EINVAL);  }  if (!(upd = unix_data_alloc())) {	printk("UNIX: create: can't allocate buffer\n");	return(-ENOMEM);  }  if (!(upd->buf = (char*) get_free_page(GFP_USER))) {	printk("UNIX: create: can't get page!\n");	unix_data_deref(upd);	return(-ENOMEM);  }  upd->protocol = protocol;  upd->socket = sock;  UN_DATA(sock) = upd;  upd->refcnt = 1;	/* Now its complete - bgm */  dprintf(1, "UNIX: create: allocated data 0x%x\n", upd);  return(0);}static intunix_proto_dup(struct socket *newsock, struct socket *oldsock){  struct unix_proto_data *upd = UN_DATA(oldsock);  return(unix_proto_create(newsock, upd->protocol));}static intunix_proto_release(struct socket *sock, struct socket *peer){  struct unix_proto_data *upd = UN_DATA(sock);  dprintf(1, "UNIX: release: socket 0x%x, unix_data 0x%x\n", sock, upd);  if (!upd) return(0);  if (upd->socket != sock) {	printk("UNIX: release: socket link mismatch!\n");	return(-EINVAL);  }  if (upd->inode) {	dprintf(1, "UNIX: release: releasing inode 0x%x\n", upd->inode);	iput(upd->inode);	upd->inode = NULL;  }  UN_DATA(sock) = NULL;  upd->socket = NULL;  if (upd->peerupd) unix_data_deref(upd->peerupd);  unix_data_deref(upd);  return(0);}/* * Bind a name to a socket. * This is where much of the work is done: we allocate a fresh page for * the buffer, grab the appropriate inode and set things up. * * FIXME: what should we do if an address is already bound? *	  Here we return EINVAL, but it may be necessary to re-bind. *	  I think thats what BSD does in the case of datagram sockets... */static intunix_proto_bind(struct socket *sock, struct sockaddr *umyaddr,		int sockaddr_len){  char fname[sizeof(((struct sockaddr_un *)0)->sun_path) + 1];  struct unix_proto_data *upd = UN_DATA(sock);  unsigned long old_fs;  int i;  int er;  dprintf(1, "UNIX: bind: socket 0x%x, len=%d\n", sock, sockaddr_len);  if (sockaddr_len <= UN_PATH_OFFSET ||      sockaddr_len > sizeof(struct sockaddr_un)) {	dprintf(1, "UNIX: bind: bad length %d\n", sockaddr_len);	return(-EINVAL);  }  if (upd->sockaddr_len || upd->inode) {	printk("UNIX: bind: already bound!\n");	return(-EINVAL);  }  er=verify_area(VERIFY_WRITE, umyaddr, sockaddr_len);  if(er)  	return er;  memcpy_fromfs(&upd->sockaddr_un, umyaddr, sockaddr_len);  upd->sockaddr_un.sun_path[sockaddr_len-UN_PATH_OFFSET] = '\0';  if (upd->sockaddr_un.sun_family != AF_UNIX) {	dprintf(1, "UNIX: bind: family is %d, not AF_UNIX(%d)\n",	       			upd->sockaddr_un.sun_family, AF_UNIX);	return(-EINVAL);  }  memcpy(fname, upd->sockaddr_un.sun_path, sockaddr_len-UN_PATH_OFFSET);  fname[sockaddr_len-UN_PATH_OFFSET] = '\0';  old_fs = get_fs();  set_fs(get_ds());  i = do_mknod(fname, S_IFSOCK | S_IRWXUGO, 0);  if (i == 0) i = open_namei(fname, 0, S_IFSOCK, &upd->inode, NULL);  set_fs(old_fs);  if (i < 0) {	printk("UNIX: bind: can't open socket %s\n", fname);	return(i);  }  upd->sockaddr_len = sockaddr_len;	/* now its legal */  dprintf(1, "UNIX: bind: bound socket address: ");  sockaddr_un_printk(&upd->sockaddr_un, upd->sockaddr_len);  dprintf(1, "to inode 0x%x\n", upd->inode);  return(0);}/* * Perform a connection. we can only connect to unix sockets * (I can't for the life of me find an application where that * wouldn't be the case!) */static intunix_proto_connect(struct socket *sock, struct sockaddr *uservaddr,		   int sockaddr_len, int flags){  char fname[sizeof(((struct sockaddr_un *)0)->sun_path) + 1];  struct sockaddr_un sockun;  struct unix_proto_data *serv_upd;  struct inode *inode;  unsigned long old_fs;  int i;  int er;  dprintf(1, "UNIX: connect: socket 0x%x, servlen=%d\n", sock, sockaddr_len);  if (sockaddr_len <= UN_PATH_OFFSET ||      sockaddr_len > sizeof(struct sockaddr_un)) {	dprintf(1, "UNIX: connect: bad length %d\n", sockaddr_len);	return(-EINVAL);  }  if (sock->state == SS_CONNECTING) return(-EINPROGRESS);  if (sock->state == SS_CONNECTED) return(-EISCONN);  er=verify_area(VERIFY_READ, uservaddr, sockaddr_len);  if(er)  	return er;  memcpy_fromfs(&sockun, uservaddr, sockaddr_len);  sockun.sun_path[sockaddr_len-UN_PATH_OFFSET] = '\0';  if (sockun.sun_family != AF_UNIX) {	dprintf(1, "UNIX: connect: family is %d, not AF_UNIX(%d)\n",	       					sockun.sun_family, AF_UNIX);	return(-EINVAL);  }  /*   * Try to open the name in the filesystem - this is how we   * identify ourselves and our server. Note that we don't   * hold onto the inode that long, just enough to find our   * server. When we're connected, we mooch off the server.   */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩视频免费观看高清在线视频| 91视频91自| 精品国产一区久久| 蜜臀久久99精品久久久久宅男| 日韩三级电影网址| 精品一区二区三区影院在线午夜| 久久精品这里都是精品| 国产成人a级片| 亚洲欧洲综合另类在线| 欧美另类久久久品| 激情小说亚洲一区| 亚洲天堂2014| 制服丝袜在线91| 韩日欧美一区二区三区| 中文字幕一区二区三区在线不卡| 欧美亚洲一区二区三区四区| 午夜精彩视频在线观看不卡| 精品乱人伦小说| 成人国产精品免费观看视频| 一区二区三区成人| 欧美一三区三区四区免费在线看| 精品一区二区三区视频在线观看| 国产精品高潮呻吟| 欧美亚洲国产一区二区三区 | 中文字幕av资源一区| 91麻豆视频网站| 午夜电影一区二区三区| 久久久久久久久久美女| 色综合天天视频在线观看| 免费在线看成人av| 自拍视频在线观看一区二区| 欧美一级精品在线| aaa国产一区| 久久精品99国产国产精| 国产精品乱码久久久久久| 欧美高清视频在线高清观看mv色露露十八| 免费成人在线观看视频| 18欧美亚洲精品| 欧美变态tickling挠脚心| 色综合天天做天天爱| 美女视频网站久久| 亚洲靠逼com| 国产欧美日韩另类一区| 欧美精品自拍偷拍| 99久久久精品| 国产精品自拍毛片| 免费观看在线色综合| 亚洲图片另类小说| 久久亚洲一区二区三区四区| 欧洲av一区二区嗯嗯嗯啊| 粉嫩一区二区三区在线看| 视频一区视频二区中文| 亚洲精品国产a| 国产精品久久久久9999吃药| 日韩美女主播在线视频一区二区三区 | 国产**成人网毛片九色| 日韩vs国产vs欧美| 一区二区三区在线观看网站| 国产女人18水真多18精品一级做| 日韩一区二区免费高清| 欧美日韩日本视频| 99久久99久久精品免费观看| 成人一区二区三区视频| 久久激五月天综合精品| 肉肉av福利一精品导航| 亚洲一区二区av在线| 亚洲免费av网站| 亚洲欧洲成人av每日更新| 国产色一区二区| 久久精品亚洲国产奇米99| 欧美不卡一区二区三区四区| 7777精品伊人久久久大香线蕉的 | 国产69精品久久777的优势| 久久国产尿小便嘘嘘| 午夜精品久久久久久久99水蜜桃| 亚洲视频免费在线| 亚洲欧美日韩久久| 一区在线中文字幕| 亚洲人成网站在线| 亚洲欧美视频在线观看视频| 亚洲卡通动漫在线| 亚洲精品欧美激情| 亚洲精品国产一区二区精华液| 18欧美亚洲精品| 亚洲免费视频中文字幕| 亚洲电影一级黄| 日韩成人av影视| 麻豆国产一区二区| 国模少妇一区二区三区| 国产成人精品免费| 成人深夜福利app| 色婷婷久久久久swag精品| 色婷婷综合久久久久中文 | 麻豆精品久久精品色综合| 美日韩一区二区三区| 国精产品一区一区三区mba视频 | 夜夜嗨av一区二区三区四季av | 日日摸夜夜添夜夜添精品视频 | 精品免费99久久| 日韩美一区二区三区| 国产午夜精品久久久久久久| 中文字幕av资源一区| 亚洲欧美日韩人成在线播放| 午夜国产精品影院在线观看| 美女任你摸久久| 成人深夜福利app| 欧美亚洲禁片免费| 精品欧美一区二区久久| 中文字幕欧美日韩一区| 亚洲成人www| 麻豆免费精品视频| 成人黄色综合网站| 欧美日韩大陆一区二区| 日韩三级视频在线观看| 中文字幕一区av| 免费国产亚洲视频| 91视视频在线观看入口直接观看www| 欧洲国内综合视频| 精品处破学生在线二十三| 中文字幕国产精品一区二区| 天天影视网天天综合色在线播放| 国产精品自拍网站| 欧美日韩高清一区二区| 国产精品网站在线播放| 午夜视频在线观看一区二区三区| 九色综合国产一区二区三区| 99精品欧美一区二区三区小说 | 欧美亚洲一区三区| 久久精品综合网| 亚洲18影院在线观看| 懂色av中文字幕一区二区三区| 欧美色图激情小说| 国产人成亚洲第一网站在线播放 | 日韩视频免费直播| 亚洲欧美日韩小说| 国产91色综合久久免费分享| 欧美日韩成人一区| 国产精品高潮呻吟久久| 久久国产人妖系列| 在线播放国产精品二区一二区四区| 国产午夜亚洲精品理论片色戒| 亚洲午夜免费电影| 91香蕉视频污在线| 中文字幕免费不卡在线| 久久国内精品自在自线400部| 91久久精品日日躁夜夜躁欧美| 久久精品一级爱片| 免费观看在线综合色| 欧美天天综合网| 自拍av一区二区三区| 成人av在线影院| 欧美精品一区二区蜜臀亚洲| 日韩一区精品字幕| 欧美性xxxxxxxx| 亚洲一区二区3| 色综合激情五月| 一区在线播放视频| 99久久婷婷国产综合精品电影| 久久精品亚洲麻豆av一区二区 | 欧美人狂配大交3d怪物一区| 亚洲色图欧洲色图婷婷| 成人av网站在线观看免费| 国产日韩欧美精品综合| 国产成人丝袜美腿| 久久久美女毛片| 国产精品99久久久久久有的能看| 日韩一区二区三区视频在线观看| 午夜av电影一区| 欧美一区二区三区四区久久 | 亚洲人成亚洲人成在线观看图片| 成人午夜激情在线| 国产精品美女视频| aa级大片欧美| 亚洲精品水蜜桃| 欧美无人高清视频在线观看| 夜夜嗨av一区二区三区中文字幕| 欧美影视一区在线| 日韩成人dvd| 精品国产一区二区三区久久影院 | 欧美成人一区二区三区| 国产一区视频在线看| 国产三级欧美三级日产三级99| 国产成人aaaa| 亚洲美女屁股眼交3| 欧美无砖专区一中文字| 秋霞影院一区二区| 久久久美女艺术照精彩视频福利播放| 国产一区二区三区在线看麻豆| 国产女同互慰高潮91漫画| 91在线精品一区二区| 亚洲综合色丁香婷婷六月图片| 欧美日韩一区二区三区在线| 免费在线观看精品| 国产欧美一二三区| 色婷婷av久久久久久久| 美女在线一区二区| 国产精品高清亚洲| 日韩午夜精品视频| 99精品视频一区| 美女一区二区三区|