patch-2.1.97 linux/arch/sparc64/solaris/fs.c
Next file: linux/arch/sparc64/solaris/ioctl.c
Previous file: linux/arch/sparc64/solaris/entry64.S
Back to the patch index
Back to the overall index
- Lines: 107
- Date:
Tue Apr 14 17:44:21 1998
- Orig file:
v2.1.96/linux/arch/sparc64/solaris/fs.c
- Orig date:
Mon Jan 12 15:15:44 1998
diff -u --recursive --new-file v2.1.96/linux/arch/sparc64/solaris/fs.c linux/arch/sparc64/solaris/fs.c
@@ -1,11 +1,13 @@
-/* $Id: fs.c,v 1.6 1997/10/13 03:54:05 davem Exp $
+/* $Id: fs.c,v 1.8 1998/03/29 10:11:02 davem Exp $
* fs.c: fs related syscall emulation for Solaris
*
* Copyright (C) 1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
*/
#include <linux/types.h>
+#include <linux/sched.h>
#include <linux/fs.h>
+#include <linux/file.h>
#include <linux/stat.h>
#include <linux/smp_lock.h>
#include <linux/limits.h>
@@ -339,9 +341,12 @@
int error;
lock_kernel();
- if (fd >= NR_OPEN || !(file = current->files->fd[fd]))
- error = -EBADF;
- else if (!(dentry = file->f_dentry))
+ error = -EBADF;
+ file = fget(fd);
+ if (!file)
+ goto out;
+
+ if (!(dentry = file->f_dentry))
error = -ENOENT;
else if (!(inode = dentry->d_inode))
error = -ENOENT;
@@ -351,6 +356,8 @@
error = -ENOSYS;
else
error = report_statvfs(inode, buf);
+ fput(file);
+out:
unlock_kernel();
return error;
}
@@ -516,7 +523,7 @@
newattrs.ia_mode &= ~S_ISGID;
newattrs.ia_valid |= ATTR_MODE;
}
- DQUOT_TRANSFER(inode, newattrs);
+ DQUOT_TRANSFER(dentry, newattrs);
out:
return error;
}
@@ -563,13 +570,15 @@
lock_kernel();
retval = -EBADF;
- if (fd >= NR_OPEN ||
- !(file = current->files->fd[fd]))
+ file = fget(fd);
+ if (!file)
goto bad;
+
temp = file->f_pos;
if (temp != offset) {
retval = sys_lseek(fd, offset, 0);
- if (retval < 0) goto bad;
+ if (retval < 0)
+ goto out_putf;
}
retval = sys_read(fd, (char *)A(buf), nbyte);
if (file->f_pos != temp) {
@@ -578,6 +587,9 @@
else
sys_lseek(fd, temp, 0);
}
+
+out_putf:
+ fput(file);
bad:
unlock_kernel();
return retval;
@@ -595,13 +607,15 @@
lock_kernel();
retval = -EBADF;
- if (fd >= NR_OPEN ||
- !(file = current->files->fd[fd]))
+ file = fget(fd);
+ if (!file)
goto bad;
+
temp = file->f_pos;
if (temp != offset) {
retval = sys_lseek(fd, offset, 0);
- if (retval < 0) goto bad;
+ if (retval < 0)
+ goto out_putf;
}
retval = sys_write(fd, (char *)A(buf), nbyte);
if (file->f_pos != temp) {
@@ -610,6 +624,9 @@
else
sys_lseek(fd, temp, 0);
}
+
+out_putf:
+ fput(file);
bad:
unlock_kernel();
return retval;
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov