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  *              Dmitry Gorodchanin      :       /proc locking fix
  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 #include <linux/autoconf.h>
  27 #include <linux/sched.h>
  28 #include <linux/string.h>
  29 #include <linux/socket.h>
  30 #include <linux/net.h>
  31 #include <linux/ddi.h>
  32 #include <linux/un.h>
  33 #include <linux/param.h>
  34 #include "unix.h"
  35 
  36 
  37 /* Called from PROCfs. */
  38 int unix_get_info(char *buffer, char **start, off_t offset, int length)
     /* [previous][next][first][last][top][bottom][index][help] */
  39 {
  40         off_t pos=0;
  41         off_t begin=0;
  42         int len=0;
  43         int i;
  44 
  45         len += sprintf(buffer, "Num RefCount Protocol Flags    Type St Path\n");
  46 
  47         for(i = 0; i < NSOCKETS; i++) 
  48         {
  49                 if (unix_datas[i].refcnt>0) 
  50                 {
  51                         len += sprintf(buffer+len, "%2d: %08X %08X %08lX %04X %02X", i,
  52                                 unix_datas[i].refcnt,
  53                                 unix_datas[i].protocol,
  54                                 unix_datas[i].socket->flags,
  55                                 unix_datas[i].socket->type,
  56                                 unix_datas[i].socket->state
  57                         );
  58 
  59                         /* If socket is bound to a filename, we'll print it. */
  60                         if(unix_datas[i].sockaddr_len>0) 
  61                         {
  62                                 len += sprintf(buffer+len, " %s\n",
  63                                 unix_datas[i].sockaddr_un.sun_path);
  64                         } 
  65                         else 
  66                         { /* just add a newline */
  67                                 buffer[len++]='\n';
  68                                 buffer[len++]='\0';
  69                         }
  70                         
  71                         pos=begin+len;
  72                         if(pos<offset)
  73                         {
  74                                 len=0;
  75                                 begin=pos;
  76                         }
  77                         if(pos>offset+length)
  78                                 break;
  79                 }
  80         }
  81         
  82         *start=buffer+(offset-begin);
  83         len-=(offset-begin);
  84         if(len>length)
  85                 len=length;
  86         return len;
  87 }

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