OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [before_ORP/] [uclinux/] [uClinux-2.0.x/] [fs/] [proc/] [net.c] - Diff between revs 901 and 1765

Only display areas with differences | Details | Blame | View Log

Rev 901 Rev 1765
/*
/*
 *  linux/fs/proc/net.c
 *  linux/fs/proc/net.c
 *
 *
 *  Copyright (C) 1991, 1992 Linus Torvalds
 *  Copyright (C) 1991, 1992 Linus Torvalds
 *
 *
 *  gjh 3/'93 heim@peanuts.informatik.uni-tuebingen.de (Gerald J. Heim)
 *  gjh 3/'93 heim@peanuts.informatik.uni-tuebingen.de (Gerald J. Heim)
 *            most of this file is stolen from base.c
 *            most of this file is stolen from base.c
 *            it works, but you shouldn't use it as a guideline
 *            it works, but you shouldn't use it as a guideline
 *            for new proc-fs entries. once i'll make it better.
 *            for new proc-fs entries. once i'll make it better.
 * fvk 3/'93  waltje@uwalt.nl.mugnet.org (Fred N. van Kempen)
 * fvk 3/'93  waltje@uwalt.nl.mugnet.org (Fred N. van Kempen)
 *            cleaned up the whole thing, moved "net" specific code to
 *            cleaned up the whole thing, moved "net" specific code to
 *            the NET kernel layer (where it belonged in the first place).
 *            the NET kernel layer (where it belonged in the first place).
 * Michael K. Johnson (johnsonm@stolaf.edu) 3/93
 * Michael K. Johnson (johnsonm@stolaf.edu) 3/93
 *            Added support from my previous inet.c.  Cleaned things up
 *            Added support from my previous inet.c.  Cleaned things up
 *            quite a bit, modularized the code.
 *            quite a bit, modularized the code.
 * fvk 4/'93  waltje@uwalt.nl.mugnet.org (Fred N. van Kempen)
 * fvk 4/'93  waltje@uwalt.nl.mugnet.org (Fred N. van Kempen)
 *            Renamed "route_get_info()" to "rt_get_info()" for consistency.
 *            Renamed "route_get_info()" to "rt_get_info()" for consistency.
 * Alan Cox (gw4pts@gw4pts.ampr.org) 4/94
 * Alan Cox (gw4pts@gw4pts.ampr.org) 4/94
 *            Dusted off the code and added IPX. Fixed the 4K limit.
 *            Dusted off the code and added IPX. Fixed the 4K limit.
 * Erik Schoenfelder (schoenfr@ibr.cs.tu-bs.de)
 * Erik Schoenfelder (schoenfr@ibr.cs.tu-bs.de)
 *            /proc/net/snmp.
 *            /proc/net/snmp.
 * Alan Cox (gw4pts@gw4pts.ampr.org) 1/95
 * Alan Cox (gw4pts@gw4pts.ampr.org) 1/95
 *            Added Appletalk slots
 *            Added Appletalk slots
 *
 *
 *  proc net directory handling functions
 *  proc net directory handling functions
 */
 */
#include <linux/errno.h>
#include <linux/errno.h>
#include <linux/sched.h>
#include <linux/sched.h>
#include <linux/proc_fs.h>
#include <linux/proc_fs.h>
#include <linux/stat.h>
#include <linux/stat.h>
#include <linux/fcntl.h>
#include <linux/fcntl.h>
#include <linux/mm.h>
#include <linux/mm.h>
 
 
#include <asm/segment.h>
#include <asm/segment.h>
 
 
#define PROC_BLOCK_SIZE (3*1024)                /* 4K page size but our output routines use some slack for overruns */
#define PROC_BLOCK_SIZE (3*1024)                /* 4K page size but our output routines use some slack for overruns */
 
 
static int proc_readnet(struct inode * inode, struct file * file,
static int proc_readnet(struct inode * inode, struct file * file,
                        char * buf, int count)
                        char * buf, int count)
{
{
        char * page;
        char * page;
        int bytes=count;
        int bytes=count;
        int copied=0;
        int copied=0;
        char *start;
        char *start;
        struct proc_dir_entry * dp;
        struct proc_dir_entry * dp;
 
 
        if (count < 0)
        if (count < 0)
                return -EINVAL;
                return -EINVAL;
        dp = (struct proc_dir_entry *) inode->u.generic_ip;
        dp = (struct proc_dir_entry *) inode->u.generic_ip;
        if (!(page = (char*) __get_free_page(GFP_KERNEL)))
        if (!(page = (char*) __get_free_page(GFP_KERNEL)))
                return -ENOMEM;
                return -ENOMEM;
 
 
        while (bytes>0)
        while (bytes>0)
        {
        {
                int length, thistime=bytes;
                int length, thistime=bytes;
                if (bytes > PROC_BLOCK_SIZE)
                if (bytes > PROC_BLOCK_SIZE)
                        thistime=PROC_BLOCK_SIZE;
                        thistime=PROC_BLOCK_SIZE;
 
 
                length = dp->get_info(page, &start,
                length = dp->get_info(page, &start,
                                      file->f_pos,
                                      file->f_pos,
                                      thistime,
                                      thistime,
                                      (file->f_flags & O_ACCMODE) == O_RDWR);
                                      (file->f_flags & O_ACCMODE) == O_RDWR);
 
 
                /*
                /*
                 *      We have been given a non page aligned block of
                 *      We have been given a non page aligned block of
                 *      the data we asked for + a bit. We have been given
                 *      the data we asked for + a bit. We have been given
                 *      the start pointer and we know the length..
                 *      the start pointer and we know the length..
                 */
                 */
 
 
                if (length <= 0)
                if (length <= 0)
                        break;
                        break;
                /*
                /*
                 *      Copy the bytes
                 *      Copy the bytes
                 */
                 */
                memcpy_tofs(buf+copied, start, length);
                memcpy_tofs(buf+copied, start, length);
                file->f_pos += length;  /* Move down the file */
                file->f_pos += length;  /* Move down the file */
                bytes  -= length;
                bytes  -= length;
                copied += length;
                copied += length;
                if (length<thistime)
                if (length<thistime)
                        break;  /* End of file */
                        break;  /* End of file */
        }
        }
        free_page((unsigned long) page);
        free_page((unsigned long) page);
        return copied;
        return copied;
}
}
 
 
static struct file_operations proc_net_operations = {
static struct file_operations proc_net_operations = {
        NULL,                   /* lseek - default */
        NULL,                   /* lseek - default */
        proc_readnet,           /* read - bad */
        proc_readnet,           /* read - bad */
        NULL,                   /* write - bad */
        NULL,                   /* write - bad */
        NULL,                   /* readdir */
        NULL,                   /* readdir */
        NULL,                   /* select - default */
        NULL,                   /* select - default */
        NULL,                   /* ioctl - default */
        NULL,                   /* ioctl - default */
        NULL,                   /* mmap */
        NULL,                   /* mmap */
        NULL,                   /* no special open code */
        NULL,                   /* no special open code */
        NULL,                   /* no special release code */
        NULL,                   /* no special release code */
        NULL                    /* can't fsync */
        NULL                    /* can't fsync */
};
};
 
 
/*
/*
 * proc directories can do almost nothing..
 * proc directories can do almost nothing..
 */
 */
struct inode_operations proc_net_inode_operations = {
struct inode_operations proc_net_inode_operations = {
        &proc_net_operations,   /* default net file-ops */
        &proc_net_operations,   /* default net file-ops */
        NULL,                   /* create */
        NULL,                   /* create */
        NULL,                   /* lookup */
        NULL,                   /* lookup */
        NULL,                   /* link */
        NULL,                   /* link */
        NULL,                   /* unlink */
        NULL,                   /* unlink */
        NULL,                   /* symlink */
        NULL,                   /* symlink */
        NULL,                   /* mkdir */
        NULL,                   /* mkdir */
        NULL,                   /* rmdir */
        NULL,                   /* rmdir */
        NULL,                   /* mknod */
        NULL,                   /* mknod */
        NULL,                   /* rename */
        NULL,                   /* rename */
        NULL,                   /* readlink */
        NULL,                   /* readlink */
        NULL,                   /* follow_link */
        NULL,                   /* follow_link */
        NULL,                   /* readpage */
        NULL,                   /* readpage */
        NULL,                   /* writepage */
        NULL,                   /* writepage */
        NULL,                   /* bmap */
        NULL,                   /* bmap */
        NULL,                   /* truncate */
        NULL,                   /* truncate */
        NULL                    /* permission */
        NULL                    /* permission */
};
};
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.