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

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