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

Subversion Repositories or1k

[/] [or1k/] [tags/] [before_ORP/] [uclinux/] [uClinux-2.0.x/] [drivers/] [block/] [proc_array.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 199 simons
/*
2
 *  Taken from linux/fs/proc/net.c
3
 *
4
 *  Copyright (C) 1991, 1992 Linus Torvalds
5
 *
6
 *  gjh 3/'93 heim@peanuts.informatik.uni-tuebingen.de (Gerald J. Heim)
7
 *            most of this file is stolen from base.c
8
 *            it works, but you shouldn't use it as a guideline
9
 *            for new proc-fs entries. once i'll make it better.
10
 * fvk 3/'93  waltje@uwalt.nl.mugnet.org (Fred N. van Kempen)
11
 *            cleaned up the whole thing, moved "net" specific code to
12
 *            the NET kernel layer (where it belonged in the first place).
13
 * Michael K. Johnson (johnsonm@stolaf.edu) 3/93
14
 *            Added support from my previous inet.c.  Cleaned things up
15
 *            quite a bit, modularized the code.
16
 * fvk 4/'93  waltje@uwalt.nl.mugnet.org (Fred N. van Kempen)
17
 *            Renamed "route_get_info()" to "rt_get_info()" for consistency.
18
 * Alan Cox (gw4pts@gw4pts.ampr.org) 4/94
19
 *            Dusted off the code and added IPX. Fixed the 4K limit.
20
 * Erik Schoenfelder (schoenfr@ibr.cs.tu-bs.de)
21
 *            /proc/net/snmp.
22
 * Alan Cox (gw4pts@gw4pts.ampr.org) 1/95
23
 *            Added Appletalk slots
24
 *
25
 *  proc diskarray directory handling functions
26
 */
27
#include <linux/errno.h>
28
#include <linux/sched.h>
29
#include <linux/proc_fs.h>
30
#include <linux/stat.h>
31
#include <linux/fcntl.h>
32
#include <linux/mm.h>
33
 
34
#include <asm/segment.h>
35
 
36
#define PROC_BLOCK_SIZE (3*1024)                /* 4K page size but our output routines use some slack for overruns */
37
 
38
static int proc_readdiskarray(struct inode * inode, struct file * file,
39
                        char * buf, int count)
40
{
41
        char * page;
42
        int bytes=count;
43
        int copied=0;
44
        char *start;
45
        struct proc_dir_entry * dp;
46
 
47
        if (count < 0)
48
                return -EINVAL;
49
        dp = (struct proc_dir_entry *) inode->u.generic_ip;
50
        if (!(page = (char*) __get_free_page(GFP_KERNEL)))
51
                return -ENOMEM;
52
 
53
        while (bytes>0)
54
        {
55
                int length, thistime=bytes;
56
                if (bytes > PROC_BLOCK_SIZE)
57
                        thistime=PROC_BLOCK_SIZE;
58
 
59
                length = dp->get_info(page, &start,
60
                                      file->f_pos,
61
                                      thistime, (int)dp);
62
 
63
                /*
64
                 *      We have been given a non page aligned block of
65
                 *      the data we asked for + a bit. We have been given
66
                 *      the start pointer and we know the length..
67
                 */
68
 
69
                if (length <= 0)
70
                        break;
71
                /*
72
                 *      Copy the bytes
73
                 */
74
                memcpy_tofs(buf+copied, start, length);
75
                file->f_pos += length;  /* Move down the file */
76
                bytes  -= length;
77
                copied += length;
78
                if (length<thistime)
79
                        break;  /* End of file */
80
        }
81
        free_page((unsigned long) page);
82
        return copied;
83
}
84
 
85
static struct file_operations proc_diskarray_operations = {
86
        NULL,                   /* lseek - default */
87
        proc_readdiskarray,             /* read - bad */
88
        NULL,                   /* write - bad */
89
        NULL,                   /* readdir */
90
        NULL,                   /* select - default */
91
        NULL,                   /* ioctl - default */
92
        NULL,                   /* mmap */
93
        NULL,                   /* no special open code */
94
        NULL,                   /* no special release code */
95
        NULL                    /* can't fsync */
96
};
97
 
98
/*
99
 * proc directories can do almost nothing..
100
 */
101
struct inode_operations proc_diskarray_inode_operations = {
102
        &proc_diskarray_operations,     /* default diskarray file-ops */
103
        NULL,                   /* create */
104
        NULL,                   /* lookup */
105
        NULL,                   /* link */
106
        NULL,                   /* unlink */
107
        NULL,                   /* symlink */
108
        NULL,                   /* mkdir */
109
        NULL,                   /* rmdir */
110
        NULL,                   /* mknod */
111
        NULL,                   /* rename */
112
        NULL,                   /* readlink */
113
        NULL,                   /* follow_link */
114
        NULL,                   /* readpage */
115
        NULL,                   /* writepage */
116
        NULL,                   /* bmap */
117
        NULL,                   /* truncate */
118
        NULL                    /* permission */
119
};

powered by: WebSVN 2.1.0

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