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

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

?? sock.c

?? linux 1.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一区二区三区免费野_久草精品视频
欧美日韩综合在线免费观看| 日本一区二区三区四区在线视频| 成人性生交大片免费看视频在线| 国产精品成人免费在线| 在线看日本不卡| 国产呦精品一区二区三区网站| 国产欧美日韩中文久久| 欧美中文字幕亚洲一区二区va在线 | 中文字幕日韩精品一区| 欧美熟乱第一页| av电影一区二区| 国产剧情av麻豆香蕉精品| 中文字幕色av一区二区三区| 欧美丰满高潮xxxx喷水动漫| 国产很黄免费观看久久| 亚洲国产精品嫩草影院| 欧美va亚洲va| 欧美在线一二三| av色综合久久天堂av综合| 麻豆精品视频在线观看视频| 国产精品美女久久久久久久 | 色噜噜狠狠成人网p站| 免费精品99久久国产综合精品| 亚洲三级理论片| 亚洲日本韩国一区| 亚洲国产另类av| 日本视频免费一区| 国产乱码精品1区2区3区| 成人福利视频网站| 91成人看片片| 91麻豆国产福利精品| 欧美丰满嫩嫩电影| 日韩欧美高清在线| 久久久久久一二三区| 欧美精品一区在线观看| 国产精品系列在线| 亚洲国产成人高清精品| 日韩国产高清影视| 激情另类小说区图片区视频区| 韩日av一区二区| 在线一区二区三区四区| 欧美一区欧美二区| 日韩一区日韩二区| 蜜臀av一区二区在线观看| 国产xxx精品视频大全| 欧美日韩中文国产| 欧美国产日韩一二三区| 亚瑟在线精品视频| 风间由美一区二区av101 | 久久精品久久99精品久久| 国产在线一区二区| 欧美日韩一区二区三区四区五区| 久久久99免费| 老司机一区二区| 欧美日韩亚洲综合| 成人欧美一区二区三区小说| 久久电影国产免费久久电影| 欧美亚洲动漫精品| 亚洲人一二三区| 国产高清精品在线| 精品99一区二区| 国内精品自线一区二区三区视频| 欧美日韩精品福利| 亚洲美女区一区| 在线视频国内一区二区| 国产精品福利一区| 91在线观看高清| 亚洲国产综合色| 91精品国产综合久久久蜜臀图片| 日韩国产欧美在线播放| 欧美日韩精品一区二区天天拍小说| 亚洲欧美激情插| 欧美性三三影院| 麻豆一区二区在线| 国产视频一区不卡| www.日韩在线| 亚洲成人第一页| 中文字幕精品—区二区四季| 99久久99久久精品国产片果冻| 中文字幕佐山爱一区二区免费| 色婷婷亚洲综合| 国产91对白在线观看九色| 中文字幕欧美激情一区| 欧美日韩中文精品| 国产一区二三区好的| 亚洲国产精品黑人久久久| 在线观看av不卡| 国产一区二区三区在线观看精品 | 美女网站视频久久| 国产精品毛片无遮挡高清| 欧洲av在线精品| 成人在线视频一区二区| 日韩电影在线一区| 国产精品国产成人国产三级 | 丝袜美腿成人在线| 中文字幕视频一区| 久久色在线观看| 欧美精品在线观看播放| 色综合久久综合网欧美综合网 | 亚洲va欧美va人人爽午夜| 亚洲三级电影全部在线观看高清| 日韩欧美在线网站| 欧美美女视频在线观看| 色综合天天性综合| 欧美午夜精品免费| 国产成人a级片| 国产麻豆成人精品| 激情五月婷婷综合网| 日本免费新一区视频 | 久久69国产一区二区蜜臀| 日本怡春院一区二区| 奇米在线7777在线精品| 美日韩一区二区| 国产在线精品免费| 国产成人三级在线观看| 91亚洲精品久久久蜜桃网站| av一区二区不卡| 欧美三级欧美一级| 7777精品伊人久久久大香线蕉| 欧美日本不卡视频| 欧美va亚洲va| 亚洲视频网在线直播| 亚洲高清视频中文字幕| 久久99国产精品免费| 国产精品亚洲视频| 欧美三级在线视频| 日韩午夜三级在线| 亚洲人成小说网站色在线| 婷婷国产在线综合| 国产91丝袜在线播放九色| 日本精品免费观看高清观看| 日韩午夜激情av| 亚洲精品日韩专区silk| 奇米色一区二区| 在线精品视频免费播放| 久久一区二区视频| 日本vs亚洲vs韩国一区三区二区 | 日韩av一级电影| 在线亚洲精品福利网址导航| 精品国产乱码久久久久久久久| 国产色产综合产在线视频| 蜜臀久久久99精品久久久久久| jizz一区二区| 亚洲国产精华液网站w| 国产乱码精品1区2区3区| 在线播放欧美女士性生活| 亚洲一区二区综合| 色婷婷av一区二区三区大白胸| 国产日韩视频一区二区三区| 久久97超碰国产精品超碰| 欧美不卡一二三| 极品美女销魂一区二区三区| 欧美精品在线一区二区| 日本欧美久久久久免费播放网| 欧美一区二区三区免费| 美女视频黄免费的久久| 91精品久久久久久蜜臀| 久久se精品一区精品二区| 精品国产凹凸成av人网站| 激情另类小说区图片区视频区| 久久你懂得1024| 高清不卡一二三区| 亚洲综合无码一区二区| 欧美日韩免费高清一区色橹橹| 婷婷六月综合网| 精品国产乱码91久久久久久网站| 精品一区二区三区免费| 亚洲欧美日韩国产综合在线| 欧美电影一区二区| 国产激情视频一区二区在线观看 | 99精品久久99久久久久| 亚洲chinese男男1069| www久久久久| 欧美日本一道本在线视频| 精品一区二区三区不卡| 亚洲欧美日韩综合aⅴ视频| 欧美va亚洲va| 欧美在线小视频| av不卡一区二区三区| 青青草伊人久久| 亚洲第一福利视频在线| 国产精品二三区| 国产日产欧美一区二区视频| 欧美日韩日日夜夜| 99精品久久免费看蜜臀剧情介绍| 极品少妇xxxx精品少妇偷拍| 一区二区三区在线观看网站| 国产视频一区二区在线| 久久综合九色综合欧美98| 宅男噜噜噜66一区二区66| 一本色道久久综合狠狠躁的推荐| 国产一区二区按摩在线观看| 狠狠色综合日日| 久久国产视频网| 国产福利一区二区三区在线视频| 狠狠色狠狠色综合系列| 精品中文字幕一区二区小辣椒| 天堂av在线一区| 蜜臀va亚洲va欧美va天堂| 激情文学综合插|