patch-pre2.0.4 linux/fs/locks.c

Next file: linux/fs/proc/procfs_syms.c
Previous file: linux/fs/isofs/rock.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file pre2.0.3/linux/fs/locks.c linux/fs/locks.c
@@ -257,6 +257,7 @@
 	if (!(inode = filp->f_inode))
 		return (-EINVAL);
 	
+#ifdef CONFIG_LOCK_MANDATORY
 	/* Don't allow mandatory locks on files that may be memory mapped
 	 * and shared.
 	 */
@@ -268,6 +269,7 @@
 			vma = vma->vm_next_share;
 		} while (vma != inode->i_mmap);
 	}
+#endif
 
 	memcpy_fromfs(&flock, l, sizeof(flock));
 	if (!posix_make_lock(filp, &file_lock, &flock))
@@ -291,8 +293,8 @@
 	if (count < 5) {
 		count++;
 		printk(KERN_WARNING
-		       "fcntl_setlk() called by process %d with broken flock() emulation\n",
-		       current->pid);
+		       "fcntl_setlk() called by process %d (%s) with broken flock() emulation\n",
+		       current->pid, current->comm);
 	}
 }
 #endif
@@ -332,36 +334,23 @@
 
 int locks_verify_locked(struct inode *inode)
 {
+#ifdef CONFIG_LOCK_MANDATORY
 	/* Candidates for mandatory locking have the setgid bit set
 	 * but no group execute bit -  an otherwise meaningless combination.
 	 */
 	if ((inode->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID)
 		return (locks_mandatory_locked(inode));
-	return (0);
-}
-
-int locks_mandatory_locked(struct inode *inode)
-{
-#ifdef CONFIG_LOCK_MANDATORY
-	struct file_lock *fl;
-
-	/* Search the lock list for this inode for any POSIX locks.
-	 */
-	for (fl = inode->i_flock; fl != NULL; fl = fl->fl_next) {
-		if ((fl->fl_flags & F_POSIX) && (fl->fl_owner != current))
-			return (-EAGAIN);
-	}
-#endif	
+#endif
 	return (0);
 }
 
 int locks_verify_area(int read_write, struct inode *inode, struct file *filp,
 		      unsigned int offset, unsigned int count)
 {
+#ifdef CONFIG_LOCK_MANDATORY	 
 	/* Candidates for mandatory locking have the setgid bit set
 	 * but no group execute bit -  an otherwise meaningless combination.
 	 */
-#ifdef CONFIG_LOCK_MANDATORY	 
 	if ((inode->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID)
 		return (locks_mandatory_area(read_write, inode, filp, offset,
 					     count));
@@ -369,11 +358,24 @@
 	return (0);
 }
 
+#ifdef CONFIG_LOCK_MANDATORY	
+int locks_mandatory_locked(struct inode *inode)
+{
+	struct file_lock *fl;
+
+	/* Search the lock list for this inode for any POSIX locks.
+	 */
+	for (fl = inode->i_flock; fl != NULL; fl = fl->fl_next) {
+		if ((fl->fl_flags & F_POSIX) && (fl->fl_owner != current))
+			return (-EAGAIN);
+	}
+	return (0);
+}
+
 int locks_mandatory_area(int read_write, struct inode *inode,
 			 struct file *filp, unsigned int offset,
 			 unsigned int count)
 {
-#ifdef CONFIG_LOCK_MANDATORY	
 	struct file_lock *fl;
 
 repeat:
@@ -412,9 +414,9 @@
 			goto repeat;
 		}
 	}
-#endif
 	return (0);
 }
+#endif
 
 /* Verify a "struct flock" and copy it to a "struct file_lock" as a POSIX
  * style lock.
@@ -939,10 +941,15 @@
 
 	p += sprintf(p, "%d:%s ", id, pfx);
 	if (fl->fl_flags & F_POSIX) {
+#ifdef CONFIG_LOCK_MANDATORY	 
 		p += sprintf(p, "%s %s ",
 			     (fl->fl_flags & F_BROKEN) ? "BROKEN" : "POSIX ",
 			     ((fl->fl_file->f_inode->i_mode & (S_IXGRP | S_ISGID))
 			      == S_ISGID) ? "MANDATORY" : "ADVISORY ");
+#else
+		p += sprintf(p, "%s ADVISORY ",
+			     (fl->fl_flags & F_BROKEN) ? "BROKEN" : "POSIX ");
+#endif
 	}
 	else {
 		p += sprintf(p, "FLOCK  ADVISORY  ");

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this