Commit aae968ca authored by Andy Grover's avatar Andy Grover

Merge groveronline.com:/root/bk/linux-2.5

into groveronline.com:/root/bk/linux-acpi
parents d5fae5a0 dae01d33
...@@ -572,6 +572,7 @@ nfsd_get_raparms(dev_t dev, ino_t ino) ...@@ -572,6 +572,7 @@ nfsd_get_raparms(dev_t dev, ino_t ino)
return ra; return ra;
} }
#if 0 /* don't poke into fs code directly */
/* /*
* Grab and keep cached pages assosiated with a file in the svc_rqst * Grab and keep cached pages assosiated with a file in the svc_rqst
* so that they can be passed to the netowork sendmsg/sendpage routines * so that they can be passed to the netowork sendmsg/sendpage routines
...@@ -626,6 +627,7 @@ nfsd_getpages(struct file *filp, struct svc_rqst *rqstp, unsigned long count) ...@@ -626,6 +627,7 @@ nfsd_getpages(struct file *filp, struct svc_rqst *rqstp, unsigned long count)
retval = desc.error; retval = desc.error;
return retval; return retval;
} }
#endif
/* /*
* Read data from a file. count must contain the requested read count * Read data from a file. count must contain the requested read count
...@@ -658,13 +660,16 @@ nfsd_read(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t offset, ...@@ -658,13 +660,16 @@ nfsd_read(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t offset,
if (ra) if (ra)
file.f_ra = ra->p_ra; file.f_ra = ra->p_ra;
#if 0 /* don't poke into fs code directly */
if (inode->i_mapping->a_ops->readpage) { if (inode->i_mapping->a_ops->readpage) {
file.f_pos = offset; file.f_pos = offset;
err = nfsd_getpages(&file, rqstp, *count); err = nfsd_getpages(&file, rqstp, *count);
} else { } else
#endif
{
oldfs = get_fs(); oldfs = get_fs();
set_fs(KERNEL_DS); set_fs(KERNEL_DS);
err = vfs_readv(&file, vec, vlen, *count, &offset); err = vfs_readv(&file, vec, vlen, &offset);
set_fs(oldfs); set_fs(oldfs);
} }
...@@ -740,7 +745,7 @@ nfsd_write(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t offset, ...@@ -740,7 +745,7 @@ nfsd_write(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t offset,
/* Write the data. */ /* Write the data. */
oldfs = get_fs(); set_fs(KERNEL_DS); oldfs = get_fs(); set_fs(KERNEL_DS);
err = vfs_writev(&file, vec, vlen, cnt, &offset); err = vfs_writev(&file, vec, vlen, &offset);
if (err >= 0) if (err >= 0)
nfsdstats.io_write += cnt; nfsdstats.io_write += cnt;
set_fs(oldfs); set_fs(oldfs);
......
...@@ -207,53 +207,6 @@ ssize_t vfs_read(struct file *file, char *buf, size_t count, loff_t *pos) ...@@ -207,53 +207,6 @@ ssize_t vfs_read(struct file *file, char *buf, size_t count, loff_t *pos)
return ret; return ret;
} }
ssize_t vfs_readv(struct file *file, struct iovec *vec, int vlen, size_t count, loff_t *pos)
{
struct inode *inode = file->f_dentry->d_inode;
ssize_t ret;
if (!(file->f_mode & FMODE_READ))
return -EBADF;
if (!file->f_op || (!file->f_op->read && !file->f_op->aio_read))
return -EINVAL;
ret = locks_verify_area(FLOCK_VERIFY_READ, inode, file, *pos, count);
if (!ret) {
ret = security_ops->file_permission (file, MAY_READ);
if (!ret) {
if (file->f_op->readv)
ret = file->f_op->readv(file, vec, vlen, pos);
else {
/* do it by hand */
struct iovec *vector = vec;
ret = 0;
while (vlen > 0) {
void * base = vector->iov_base;
size_t len = vector->iov_len;
ssize_t nr;
vector++;
vlen--;
if (file->f_op->read)
nr = file->f_op->read(file, base, len, pos);
else
nr = do_sync_read(file, base, len, pos);
if (nr < 0) {
if (!ret) ret = nr;
break;
}
ret += nr;
if (nr != len)
break;
}
}
if (ret > 0)
dnotify_parent(file->f_dentry, DN_ACCESS);
}
}
return ret;
}
ssize_t do_sync_write(struct file *filp, const char *buf, size_t len, loff_t *ppos) ssize_t do_sync_write(struct file *filp, const char *buf, size_t len, loff_t *ppos)
{ {
struct kiocb kiocb; struct kiocb kiocb;
...@@ -294,53 +247,6 @@ ssize_t vfs_write(struct file *file, const char *buf, size_t count, loff_t *pos) ...@@ -294,53 +247,6 @@ ssize_t vfs_write(struct file *file, const char *buf, size_t count, loff_t *pos)
return ret; return ret;
} }
ssize_t vfs_writev(struct file *file, const struct iovec *vec, int vlen, size_t count, loff_t *pos)
{
struct inode *inode = file->f_dentry->d_inode;
ssize_t ret;
if (!(file->f_mode & FMODE_WRITE))
return -EBADF;
if (!file->f_op || (!file->f_op->write && !file->f_op->aio_write))
return -EINVAL;
ret = locks_verify_area(FLOCK_VERIFY_WRITE, inode, file, *pos, count);
if (!ret) {
ret = security_ops->file_permission (file, MAY_WRITE);
if (!ret) {
if (file->f_op->writev)
ret = file->f_op->writev(file, vec, vlen, pos);
else {
/* do it by hand */
const struct iovec *vector = vec;
ret = 0;
while (vlen > 0) {
void * base = vector->iov_base;
size_t len = vector->iov_len;
ssize_t nr;
vector++;
vlen--;
if (file->f_op->write)
nr = file->f_op->write(file, base, len, pos);
else
nr = do_sync_write(file, base, len, pos);
if (nr < 0) {
if (!ret) ret = nr;
break;
}
ret += nr;
if (nr != len)
break;
}
}
if (ret > 0)
dnotify_parent(file->f_dentry, DN_MODIFY);
}
}
return ret;
}
asmlinkage ssize_t sys_read(unsigned int fd, char * buf, size_t count) asmlinkage ssize_t sys_read(unsigned int fd, char * buf, size_t count)
{ {
struct file *file; struct file *file;
...@@ -427,7 +333,7 @@ unsigned long iov_shorten(struct iovec *iov, unsigned long nr_segs, size_t to) ...@@ -427,7 +333,7 @@ unsigned long iov_shorten(struct iovec *iov, unsigned long nr_segs, size_t to)
static ssize_t do_readv_writev(int type, struct file *file, static ssize_t do_readv_writev(int type, struct file *file,
const struct iovec * vector, const struct iovec * vector,
unsigned long nr_segs) unsigned long nr_segs, loff_t *pos)
{ {
typedef ssize_t (*io_fn_t)(struct file *, char *, size_t, loff_t *); typedef ssize_t (*io_fn_t)(struct file *, char *, size_t, loff_t *);
typedef ssize_t (*iov_fn_t)(struct file *, const struct iovec *, unsigned long, loff_t *); typedef ssize_t (*iov_fn_t)(struct file *, const struct iovec *, unsigned long, loff_t *);
...@@ -496,7 +402,7 @@ static ssize_t do_readv_writev(int type, struct file *file, ...@@ -496,7 +402,7 @@ static ssize_t do_readv_writev(int type, struct file *file,
/* VERIFY_WRITE actually means a read, as we write to user space */ /* VERIFY_WRITE actually means a read, as we write to user space */
ret = locks_verify_area((type == READ ret = locks_verify_area((type == READ
? FLOCK_VERIFY_READ : FLOCK_VERIFY_WRITE), ? FLOCK_VERIFY_READ : FLOCK_VERIFY_WRITE),
inode, file, file->f_pos, tot_len); inode, file, *pos, tot_len);
if (ret) if (ret)
goto out; goto out;
...@@ -509,7 +415,7 @@ static ssize_t do_readv_writev(int type, struct file *file, ...@@ -509,7 +415,7 @@ static ssize_t do_readv_writev(int type, struct file *file,
fnv = file->f_op->writev; fnv = file->f_op->writev;
} }
if (fnv) { if (fnv) {
ret = fnv(file, iov, nr_segs, &file->f_pos); ret = fnv(file, iov, nr_segs, pos);
goto out; goto out;
} }
...@@ -526,7 +432,7 @@ static ssize_t do_readv_writev(int type, struct file *file, ...@@ -526,7 +432,7 @@ static ssize_t do_readv_writev(int type, struct file *file,
vector++; vector++;
nr_segs--; nr_segs--;
nr = fn(file, base, len, &file->f_pos); nr = fn(file, base, len, pos);
if (nr < 0) { if (nr < 0) {
if (!ret) ret = nr; if (!ret) ret = nr;
...@@ -545,50 +451,56 @@ static ssize_t do_readv_writev(int type, struct file *file, ...@@ -545,50 +451,56 @@ static ssize_t do_readv_writev(int type, struct file *file,
return ret; return ret;
} }
ssize_t vfs_readv(struct file *file, const struct iovec *vec,
unsigned long vlen, loff_t *pos)
{
if (!(file->f_mode & FMODE_READ))
return -EBADF;
if (!file->f_op || (!file->f_op->readv && !file->f_op->read))
return -EINVAL;
asmlinkage ssize_t return do_readv_writev(READ, file, vec, vlen, pos);
sys_readv(unsigned long fd, const struct iovec *vector, unsigned long nr_segs) }
ssize_t vfs_writev(struct file *file, const struct iovec *vec,
unsigned long vlen, loff_t *pos)
{ {
struct file * file; if (!(file->f_mode & FMODE_WRITE))
ssize_t ret; return -EBADF;
if (!file->f_op || (!file->f_op->writev && !file->f_op->write))
return -EINVAL;
return do_readv_writev(WRITE, file, vec, vlen, pos);
}
asmlinkage ssize_t
sys_readv(unsigned long fd, const struct iovec *vec, unsigned long vlen)
{
struct file *file;
ssize_t ret = -EBADF;
ret = -EBADF;
file = fget(fd); file = fget(fd);
if (!file) if (file) {
goto bad_file; ret = vfs_readv(file, vec, vlen, &file->f_pos);
if (file->f_op && (file->f_mode & FMODE_READ) && fput(file);
(file->f_op->readv || file->f_op->read)) {
ret = security_ops->file_permission (file, MAY_READ);
if (!ret)
ret = do_readv_writev(READ, file, vector, nr_segs);
} }
fput(file);
bad_file:
return ret; return ret;
} }
asmlinkage ssize_t asmlinkage ssize_t
sys_writev(unsigned long fd, const struct iovec * vector, unsigned long nr_segs) sys_writev(unsigned long fd, const struct iovec *vec, unsigned long vlen)
{ {
struct file * file; struct file *file;
ssize_t ret; ssize_t ret = -EBADF;
ret = -EBADF;
file = fget(fd); file = fget(fd);
if (!file) if (file) {
goto bad_file; ret = vfs_writev(file, vec, vlen, &file->f_pos);
if (file->f_op && (file->f_mode & FMODE_WRITE) && fput(file);
(file->f_op->writev || file->f_op->write)) {
ret = security_ops->file_permission (file, MAY_WRITE);
if (!ret)
ret = do_readv_writev(WRITE, file, vector, nr_segs);
} }
fput(file);
bad_file:
return ret; return ret;
} }
......
...@@ -793,8 +793,10 @@ struct seq_file; ...@@ -793,8 +793,10 @@ struct seq_file;
extern ssize_t vfs_read(struct file *, char *, size_t, loff_t *); extern ssize_t vfs_read(struct file *, char *, size_t, loff_t *);
extern ssize_t vfs_write(struct file *, const char *, size_t, loff_t *); extern ssize_t vfs_write(struct file *, const char *, size_t, loff_t *);
extern ssize_t vfs_readv(struct file *, struct iovec *, int, size_t, loff_t *); extern ssize_t vfs_readv(struct file *, const struct iovec *,
extern ssize_t vfs_writev(struct file *, const struct iovec *, int, size_t, loff_t *); unsigned long, loff_t *);
extern ssize_t vfs_writev(struct file *, const struct iovec *,
unsigned long, loff_t *);
/* /*
* NOTE: write_inode, delete_inode, clear_inode, put_inode can be called * NOTE: write_inode, delete_inode, clear_inode, put_inode can be called
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment