1 /* 2 * UNIX An implementation of the AF_UNIX network domain for the 3 * LINUX operating system. UNIX is implemented using the 4 * BSD Socket interface as the means of communication with 5 * the user level. 6 * 7 * The functions in this file provide an interface between 8 * the PROC file system and the "unix" family of networking 9 * protocols. It is mainly used for debugging and statistics. 10 * 11 * Version: @(#)proc.c 1.0.4 05/23/93 12 * 13 * Authors: Ross Biro, <bir7@leland.Stanford.Edu> 14 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 15 * Gerald J. Heim, <heim@peanuts.informatik.uni-tuebingen.de> 16 * Fred Baumgarten, <dc6iq@insu1.etec.uni-kalrsruhe.de> 17 * 18 * This program is free software; you can redistribute it and/or 19 * modify it under the terms of the GNU General Public License 20 * as published by the Free Software Foundation; either version 21 * 2 of the License, or (at your option) any later version. 22 */ 23 #include <linux/autoconf.h>
24 #include <linux/sched.h>
25 #include <linux/string.h>
26 #include <linux/socket.h>
27 #include <linux/net.h>
28 #include <linux/ddi.h>
29 #include <linux/un.h>
30 #include <linux/param.h>
31 #include "unix.h"
32
33
34 /* Called from PROCfs. */ 35 intunix_get_info(char *buffer)
/* */ 36 { 37 char *pos;
38 inti;
39
40 pos = buffer;
41 pos += sprintf(pos, "Num RefCount Protocol Flags Type St Path\n");
42
43 for(i = 0; i < NSOCKETS; i++) { 44 if (unix_datas[i].refcnt) { 45 pos += sprintf(pos, "%2d: %08X %08X %08X %04X %02X", i,
46 unix_datas[i].refcnt,
47 unix_datas[i].protocol,
48 unix_datas[i].socket->flags,
49 unix_datas[i].socket->type,
50 unix_datas[i].socket->state 51 );
52
53 /* If socket is bound to a filename, we'll print it. */ 54 if(unix_datas[i].sockaddr_len>0) { 55 pos += sprintf(pos, " %s\n",
56 unix_datas[i].sockaddr_un.sun_path);
57 }else{/* just add a newline */ 58 *pos='\n';
59 pos++;
60 *pos='\0';
61 } 62
63 /* 64 * Check wether buffer _may_ overflow in the next loop. 65 * Since sockets may have very very long paths, we make 66 * PATH_MAX+100 the minimum space left for a new line. 67 */ 68 if (pos > buffer+PAGE_SIZE-80-PATH_MAX) { 69 printk("UNIX: netinfo: oops, too many sockets.\n");
70 return(pos - buffer);
71 } 72 } 73 } 74 return(pos - buffer);
75 }