## Automatically generated incremental diff
## From:   linux-2.4.21-bk17
## To:     linux-2.4.21-bk18
## Robot:  $Id: make-incremental-diff,v 1.11 2002/02/20 02:59:33 hpa Exp $

diff -urN linux-2.4.21-bk17/Makefile linux-2.4.21-bk18/Makefile
--- linux-2.4.21-bk17/Makefile	2003-07-25 02:54:47.000000000 -0700
+++ linux-2.4.21-bk18/Makefile	2003-07-25 02:54:52.000000000 -0700
@@ -1,7 +1,7 @@
 VERSION = 2
 PATCHLEVEL = 4
 SUBLEVEL = 21
-EXTRAVERSION = -bk17
+EXTRAVERSION = -bk18
 
 KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 
diff -urN linux-2.4.21-bk17/fs/binfmt_elf.c linux-2.4.21-bk18/fs/binfmt_elf.c
--- linux-2.4.21-bk17/fs/binfmt_elf.c	2003-07-25 02:54:50.000000000 -0700
+++ linux-2.4.21-bk18/fs/binfmt_elf.c	2003-07-25 02:54:55.000000000 -0700
@@ -798,6 +798,9 @@
 		send_sig(SIGTRAP, current, 0);
 	retval = 0;
 out:
+	if (!retval)
+		steal_locks(files, current->files);
+
 	return retval;
 
 	/* error cleanup */
diff -urN linux-2.4.21-bk17/fs/exec.c linux-2.4.21-bk18/fs/exec.c
--- linux-2.4.21-bk17/fs/exec.c	2003-07-25 02:54:50.000000000 -0700
+++ linux-2.4.21-bk18/fs/exec.c	2003-07-25 02:54:56.000000000 -0700
@@ -582,6 +582,7 @@
 	retval = unshare_files();
 	if(retval)
 		goto flush_failed;
+	steal_locks(files, current->files);
 	put_files_struct(files);
 	
 	/* 
diff -urN linux-2.4.21-bk17/fs/locks.c linux-2.4.21-bk18/fs/locks.c
--- linux-2.4.21-bk17/fs/locks.c	2003-06-13 07:51:37.000000000 -0700
+++ linux-2.4.21-bk18/fs/locks.c	2003-07-25 02:54:56.000000000 -0700
@@ -1937,6 +1937,23 @@
 	return length;
 }
 
+void steal_locks(fl_owner_t from, fl_owner_t to)
+{
+	struct list_head *tmp;
+
+	if (from == to)
+		return;
+
+	lock_kernel();
+	list_for_each(tmp, &file_lock_list) {
+		struct file_lock *fl = list_entry(tmp, struct file_lock,
+						  fl_link);
+		if (fl->fl_owner == from)
+			fl->fl_owner = to;
+	}
+	unlock_kernel();
+}
+
 #ifdef MSNFS
 /**
  *	lock_may_read - checks that the region is free of locks
diff -urN linux-2.4.21-bk17/include/linux/fs.h linux-2.4.21-bk18/include/linux/fs.h
--- linux-2.4.21-bk17/include/linux/fs.h	2003-07-25 02:54:51.000000000 -0700
+++ linux-2.4.21-bk18/include/linux/fs.h	2003-07-25 02:54:56.000000000 -0700
@@ -673,6 +673,7 @@
 extern time_t lease_get_mtime(struct inode *);
 extern int lock_may_read(struct inode *, loff_t start, unsigned long count);
 extern int lock_may_write(struct inode *, loff_t start, unsigned long count);
+extern void steal_locks(fl_owner_t from, fl_owner_t to);
 
 struct fasync_struct {
 	int	magic;
