Files
OrangePi_CM5/fs/9p/vfs_addr.c
T

80 lines
1.9 KiB
C
Raw Normal View History

2006-01-18 17:43:02 -08:00
/*
* linux/fs/9p/vfs_addr.c
*
* This file contians vfs address (mmap) ops for 9P2000.
*
* Copyright (C) 2005 by Eric Van Hensbergen <ericvh@gmail.com>
* Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
*
* This program is free software; you can redistribute it and/or modify
2006-03-25 03:07:28 -08:00
* it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
2006-01-18 17:43:02 -08:00
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to:
* Free Software Foundation
* 51 Franklin Street, Fifth Floor
* Boston, MA 02111-1301 USA
*
*/
#include <linux/module.h>
#include <linux/errno.h>
#include <linux/fs.h>
#include <linux/file.h>
#include <linux/stat.h>
#include <linux/string.h>
#include <linux/inet.h>
#include <linux/pagemap.h>
#include <linux/idr.h>
2007-05-21 01:22:52 +04:00
#include <linux/sched.h>
2007-07-10 17:57:28 -05:00
#include <net/9p/9p.h>
#include <net/9p/client.h>
2006-01-18 17:43:02 -08:00
#include "v9fs.h"
#include "v9fs_vfs.h"
#include "fid.h"
/**
* v9fs_vfs_readpage - read an entire page in from 9P
*
2008-03-05 07:08:09 -06:00
* @filp: file being read
2006-01-18 17:43:02 -08:00
* @page: structure to page
*
*/
static int v9fs_vfs_readpage(struct file *filp, struct page *page)
{
2007-07-10 17:57:28 -05:00
int retval;
loff_t offset;
char *buffer;
struct p9_fid *fid;
2007-02-11 13:21:39 -06:00
2007-07-10 17:57:28 -05:00
P9_DPRINTK(P9_DEBUG_VFS, "\n");
fid = filp->private_data;
2006-01-18 17:43:02 -08:00
buffer = kmap(page);
2007-07-10 17:57:28 -05:00
offset = page_offset(page);
2006-01-18 17:43:02 -08:00
2007-07-10 17:57:28 -05:00
retval = p9_client_readn(fid, buffer, offset, PAGE_CACHE_SIZE);
if (retval < 0)
goto done;
2006-01-18 17:43:02 -08:00
2007-07-10 17:57:28 -05:00
memset(buffer + retval, 0, PAGE_CACHE_SIZE - retval);
2006-01-18 17:43:02 -08:00
flush_dcache_page(page);
SetPageUptodate(page);
retval = 0;
2007-07-10 17:57:28 -05:00
done:
2006-01-18 17:43:02 -08:00
kunmap(page);
unlock_page(page);
return retval;
}
2006-06-28 04:26:44 -07:00
const struct address_space_operations v9fs_addr_operations = {
2006-01-18 17:43:02 -08:00
.readpage = v9fs_vfs_readpage,
};