patch-2.1.23 linux/fs/ioctl.c
Next file: linux/fs/isofs/dir.c
Previous file: linux/fs/hpfs/hpfs_fs.c
Back to the patch index
Back to the overall index
- Lines: 76
- Date:
Sun Jan 26 12:07:44 1997
- Orig file:
v2.1.22/linux/fs/ioctl.c
- Orig date:
Sun Dec 22 16:37:38 1996
diff -u --recursive --new-file v2.1.22/linux/fs/ioctl.c linux/fs/ioctl.c
@@ -10,6 +10,8 @@
#include <linux/string.h>
#include <linux/stat.h>
#include <linux/termios.h>
+#include <linux/smp.h>
+#include <linux/smp_lock.h>
#include <linux/fcntl.h> /* for f_flags values */
#include <asm/uaccess.h>
@@ -48,22 +50,24 @@
{
struct file * filp;
unsigned int flag;
- int on, error;
+ int on, error = -EBADF;
+ lock_kernel();
if (fd >= NR_OPEN || !(filp = current->files->fd[fd]))
- return -EBADF;
+ goto out;
+ error = 0;
switch (cmd) {
case FIOCLEX:
FD_SET(fd, ¤t->files->close_on_exec);
- return 0;
+ break;
case FIONCLEX:
FD_CLR(fd, ¤t->files->close_on_exec);
- return 0;
+ break;
case FIONBIO:
if ((error = get_user(on, (int *)arg)) != 0)
- return error;
+ break;
flag = O_NONBLOCK;
#ifdef __sparc__
/* SunOS compatability item. */
@@ -74,25 +78,27 @@
filp->f_flags |= flag;
else
filp->f_flags &= ~flag;
- return 0;
+ break;
case FIOASYNC: /* O_SYNC is not yet implemented,
but it's here for completeness. */
if ((error = get_user(on, (int *)arg)) != 0)
- return error;
+ break;
if (on)
filp->f_flags |= O_SYNC;
else
filp->f_flags &= ~O_SYNC;
- return 0;
+ break;
default:
if (filp->f_inode && S_ISREG(filp->f_inode->i_mode))
- return file_ioctl(filp, cmd, arg);
-
- if (filp->f_op && filp->f_op->ioctl)
- return filp->f_op->ioctl(filp->f_inode, filp, cmd, arg);
-
- return -ENOTTY;
+ error = file_ioctl(filp, cmd, arg);
+ else if (filp->f_op && filp->f_op->ioctl)
+ error = filp->f_op->ioctl(filp->f_inode, filp, cmd, arg);
+ else
+ error = -ENOTTY;
}
+out:
+ unlock_kernel();
+ return error;
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov