kernels/linux-2.4.0/net/wanrouter/wanproc.c
/*
 *	Read router proc directory entry.
 *	This is universal routine for reading all entries in /proc/net/wanrouter
 *	directory.  Each directory entry contains a pointer to the 'method' for
 *	preparing data for that entry.
 *	o verify arguments
 *	o allocate kernel buffer
 *	o call get_info() to prepare data
 *	o copy data to user space
 *	o release kernel buffer
 *
 *	Return:	number of bytes copied to user space (0, if no data)
 *		<0	error
 */
Read router proc directory entry.
This is universal routine for reading all entries in /proc/net/wanrouter
directory.  Each directory entry contains a pointer to the 'method' for
preparing data for that entry.
o verify arguments
o allocate kernel buffer
o call get_info() to prepare data
o copy data to user space
o release kernel buffer

number of bytes copied to user space (0, if no data)
<0      error
Read router proc directory entry . This is universal routine for reading all entries in / proc / net / wanrouter directory . Each directory entry contains a pointer to the ' method ' for preparing data for that entry . o verify arguments o allocate kernel buffer o call get_info () to prepare data o copy data to user space o release kernel buffer number of bytes copied to user space ( 0 if no data ) <0 error
static ssize_t router_proc_read(struct file* file, char* buf, size_t count,
				loff_t *ppos)
{
	struct inode *inode = file->f_dentry->d_inode;
	struct proc_dir_entry* dent;
	char* page;
	int pos, offs, len;
	if (count <= 0)
		return 0;
	dent = inode->u.generic_ip;
	if ((dent == NULL) || (dent->get_info == NULL))
		return 0;
	page = kmalloc(PROC_BUFSZ, GFP_KERNEL);
	if (page == NULL)
		return -ENOBUFS;
	pos = dent->get_info(page, dent->data, 0, 0);
	offs = file->f_pos;
	if (offs < pos) {
		len = min(pos - offs, count);
		if(copy_to_user(buf, (page + offs), len))
			return -EFAULT;
		file->f_pos += len;
	}
	else
		len = 0;
	kfree(page);
	return len;
}
static ssize_t router_proc_read ( struct file * file , char * buf , size_t count , loff_t * ppos ) { struct inode * inode = file -> f_dentry -> d_inode ; struct proc_dir_entry * dent ; char * page ; int pos , offs , len ; if ( count <= 0 ) return 0 ; dent = inode -> u . generic_ip ; if ( ( dent == NULL ) || ( dent -> get_info == NULL ) ) return 0 ; page = kmalloc ( PROC_BUFSZ , GFP_KERNEL ) ; if ( page == NULL ) return - ENOBUFS ; pos = dent -> get_info ( page , dent -> data , 0 , 0 ) ; offs = file -> f_pos ; if ( offs < pos ) { len = min ( pos - offs , count ) ; if ( copy_to_user ( buf , ( page + offs ) , len ) ) return - EFAULT ; file -> f_pos += len ; } else len = 0 ; kfree ( page ) ; return len ; }
Read router proc directory entry.
Read router proc directory entry .