root/net/unix/proc.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. unix_get_info

   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  * Fixes:
  19  *
  20  *              This program is free software; you can redistribute it and/or
  21  *              modify it under the terms of the GNU General Public License
  22  *              as published by the Free Software Foundation; either version
  23  *              2 of the License, or (at your option) any later version.
  24  */
  25 #include <linux/autoconf.h>
  26 #include <linux/sched.h>
  27 #include <linux/string.h>
  28 #include <linux/socket.h>
  29 #include <linux/net.h>
  30 #include <linux/ddi.h>
  31 #include <linux/un.h>
  32 #include <linux/param.h>
  33 #include "unix.h"
  34 
  35 
  36 /* Called from PROCfs. */
  37 int unix_get_info(char *buffer)
     /* [previous][next][first][last][top][bottom][index][help] */
  38 {
  39   char *pos;
  40   int i;
  41 
  42   pos = buffer;
  43   pos += sprintf(pos, "Num RefCount Protocol Flags    Type St Path\n");
  44 
  45   for(i = 0; i < NSOCKETS; i++) {
  46         if (unix_datas[i].refcnt) {
  47                 pos += sprintf(pos, "%2d: %08X %08X %08lX %04X %02X", i,
  48                         unix_datas[i].refcnt,
  49                         unix_datas[i].protocol,
  50                         unix_datas[i].socket->flags,
  51                         unix_datas[i].socket->type,
  52                         unix_datas[i].socket->state
  53                 );
  54 
  55                 /* If socket is bound to a filename, we'll print it. */
  56                 if(unix_datas[i].sockaddr_len>0) {
  57                         pos += sprintf(pos, " %s\n",
  58                                 unix_datas[i].sockaddr_un.sun_path);
  59                 } else { /* just add a newline */
  60                         *pos='\n';
  61                         pos++;
  62                         *pos='\0';
  63                 }
  64 
  65                 /*
  66                  * Check whether buffer _may_ overflow in the next loop.
  67                  * Since sockets may have very very long paths, we make
  68                  * PATH_MAX+80 the minimum space left for a new line.
  69                  */
  70                 if (pos > buffer+PAGE_SIZE-80-PATH_MAX) {
  71                         printk("UNIX: netinfo: oops, too many sockets.\n");
  72                         return(pos - buffer);
  73                 }
  74         }
  75   }
  76   return(pos - buffer);
  77 }

/* [previous][next][first][last][top][bottom][index][help] */