patch-2.1.23 linux/fs/locks.c
Next file: linux/fs/minix/dir.c
Previous file: linux/fs/isofs/file.c
Back to the patch index
Back to the overall index
- Lines: 65
- Date:
Sun Jan 26 12:07:44 1997
- Orig file:
v2.1.22/linux/fs/locks.c
- Orig date:
Thu Jan 2 15:55:23 1997
diff -u --recursive --new-file v2.1.22/linux/fs/locks.c linux/fs/locks.c
@@ -105,6 +105,8 @@
#include <linux/errno.h>
#include <linux/stat.h>
#include <linux/fcntl.h>
+#include <linux/smp.h>
+#include <linux/smp_lock.h>
#include <asm/uaccess.h>
@@ -240,17 +242,20 @@
{
struct file_lock file_lock;
struct file *filp;
+ int err;
+ lock_kernel();
if ((fd >= NR_OPEN) || !(filp = current->files->fd[fd]))
- return (-EBADF);
-
- if (!flock_make_lock(filp, &file_lock, cmd))
- return (-EINVAL);
-
- if ((file_lock.fl_type != F_UNLCK) && !(filp->f_mode & 3))
- return (-EBADF);
-
- return (flock_lock_file(filp, &file_lock, (cmd & (LOCK_UN | LOCK_NB)) ? 0 : 1));
+ err = -EBADF;
+ else if (!flock_make_lock(filp, &file_lock, cmd))
+ err = -EINVAL;
+ else if ((file_lock.fl_type != F_UNLCK) && !(filp->f_mode & 3))
+ err = -EBADF;
+ else
+ err = flock_lock_file(filp, &file_lock,
+ (cmd & (LOCK_UN | LOCK_NB)) ? 0 : 1);
+ unlock_kernel();
+ return err;
}
/* Report the first existing lock that would conflict with l.
@@ -342,11 +347,23 @@
break;
case F_SHLCK:
case F_EXLCK:
+#ifdef __sparc__
+/* warn a bit for now, but don't overdo it */
+{
+ static int count = 0;
+ if (!count) {
+ count=1;
printk(KERN_WARNING
- "fcntl_setlk(): process %d (%s) requested broken flock() emulation\n",
+ "fcntl_setlk() called by process %d (%s) with broken flock() emulation\n",
current->pid, current->comm);
+ }
+}
+ if (!(filp->f_mode & 3))
+ return (-EBADF);
+ break;
+#endif
default:
- return (-EINVAL);
+ return -EINVAL;
}
return (posix_lock_file(filp, &file_lock, cmd == F_SETLKW));
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov