patch-2.1.45 linux/fs/read_write.c
Next file: linux/fs/readdir.c
Previous file: linux/fs/proc/root.c
Back to the patch index
Back to the overall index
- Lines: 173
- Date:
Sun Jul 13 21:20:10 1997
- Orig file:
v2.1.44/linux/fs/read_write.c
- Orig date:
Mon Jun 16 16:35:59 1997
diff -u --recursive --new-file v2.1.44/linux/fs/read_write.c linux/fs/read_write.c
@@ -60,13 +60,15 @@
{
long retval;
struct file * file;
+ struct dentry * dentry;
struct inode * inode;
lock_kernel();
retval = -EBADF;
if (fd >= NR_OPEN ||
!(file = current->files->fd[fd]) ||
- !(inode = file->f_inode))
+ !(dentry = file->f_dentry) ||
+ !(inode = dentry->d_inode))
goto bad;
retval = -EINVAL;
if (origin > 2)
@@ -83,6 +85,7 @@
{
long retval;
struct file * file;
+ struct dentry * dentry;
struct inode * inode;
long long offset;
@@ -90,7 +93,8 @@
retval = -EBADF;
if (fd >= NR_OPEN ||
!(file = current->files->fd[fd]) ||
- !(inode = file->f_inode))
+ !(dentry = file->f_dentry) ||
+ !(inode = dentry->d_inode))
goto bad;
retval = -EINVAL;
if (origin > 2)
@@ -115,6 +119,7 @@
{
int error;
struct file * file;
+ struct dentry * dentry;
struct inode * inode;
long (*read)(struct inode *, struct file *, char *, unsigned long);
@@ -123,7 +128,10 @@
file = fget(fd);
if (!file)
goto bad_file;
- inode = file->f_inode;
+ dentry = file->f_dentry;
+ if (!dentry)
+ goto bad_file;
+ inode = dentry->d_inode;
if (!inode)
goto out;
error = -EBADF;
@@ -137,7 +145,7 @@
goto out;
error = read(inode,file,buf,count);
out:
- fput(file, inode);
+ fput(file);
bad_file:
unlock_kernel();
return error;
@@ -147,6 +155,7 @@
{
int error;
struct file * file;
+ struct dentry * dentry;
struct inode * inode;
long (*write)(struct inode *, struct file *, const char *, unsigned long);
@@ -155,7 +164,10 @@
file = fget(fd);
if (!file)
goto bad_file;
- inode = file->f_inode;
+ dentry = file->f_dentry;
+ if (!dentry)
+ goto out;
+ inode = dentry->d_inode;
if (!inode)
goto out;
if (!(file->f_mode & 2))
@@ -168,10 +180,9 @@
goto out;
down(&inode->i_sem);
error = write(inode,file,buf,count);
- inode->i_status |= ST_MODIFIED;
up(&inode->i_sem);
out:
- fput(file, inode);
+ fput(file);
bad_file:
unlock_kernel();
return error;
@@ -264,8 +275,6 @@
if (nr != len)
break;
}
- if(fn == (IO_fn_t) file->f_op->write)
- inode->i_status |= ST_MODIFIED;
if (iov != iovstack)
kfree(iov);
return retval;
@@ -274,14 +283,30 @@
asmlinkage long sys_readv(unsigned long fd, const struct iovec * vector, unsigned long count)
{
struct file * file;
+ struct dentry * dentry;
struct inode * inode;
- long err = -EBADF;
+ long err;
lock_kernel();
- if (fd >= NR_OPEN || !(file = current->files->fd[fd]) || !(inode=file->f_inode))
+ err = -EBADF;
+ if (fd >= NR_OPEN)
+ goto out;
+
+ file = current->files->fd[fd];
+ if (!file)
goto out;
+
if (!(file->f_mode & 1))
goto out;
+
+ dentry = file->f_dentry;
+ if (!dentry)
+ goto out;
+
+ inode = dentry->d_inode;
+ if (!inode)
+ goto out;
+
err = do_readv_writev(VERIFY_WRITE, inode, file, vector, count);
out:
unlock_kernel();
@@ -290,15 +315,32 @@
asmlinkage long sys_writev(unsigned long fd, const struct iovec * vector, unsigned long count)
{
- int error = -EBADF;
+ long error;
struct file * file;
+ struct dentry * dentry;
struct inode * inode;
lock_kernel();
- if (fd >= NR_OPEN || !(file = current->files->fd[fd]) || !(inode=file->f_inode))
+ error = -EBADF;
+
+ if (fd >= NR_OPEN)
+ goto out;
+
+ file = current->files->fd[fd];
+ if (!file)
goto out;
+
if (!(file->f_mode & 2))
goto out;
+
+ dentry = file->f_dentry;
+ if (!dentry)
+ goto out;
+
+ inode = dentry->d_inode;
+ if (!inode)
+ goto out;
+
down(&inode->i_sem);
error = do_readv_writev(VERIFY_READ, inode, file, vector, count);
up(&inode->i_sem);
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov