From: Chris Wright Add steal_locks helper for use in conjunction with unshare_files to make sure POSIX file lock semantics aren't broken due to unshare_files. 25-akpm/fs/locks.c | 18 ++++++++++++++++++ 25-akpm/include/linux/fs.h | 1 + 2 files changed, 19 insertions(+) diff -puN fs/locks.c~add-steal_locks fs/locks.c --- 25/fs/locks.c~add-steal_locks Thu Dec 18 13:57:26 2003 +++ 25-akpm/fs/locks.c Thu Dec 18 13:57:26 2003 @@ -1983,6 +1983,24 @@ int lock_may_write(struct inode *inode, EXPORT_SYMBOL(lock_may_write); +void steal_locks(fl_owner_t from) +{ + struct list_head *tmp; + + if (from == current->files) + 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 = current->files; + } + unlock_kernel(); +} + +EXPORT_SYMBOL(steal_locks); + static int __init filelock_init(void) { filelock_cache = kmem_cache_create("file_lock_cache", diff -puN include/linux/fs.h~add-steal_locks include/linux/fs.h --- 25/include/linux/fs.h~add-steal_locks Thu Dec 18 13:57:26 2003 +++ 25-akpm/include/linux/fs.h Thu Dec 18 13:57:26 2003 @@ -634,6 +634,7 @@ extern int __break_lease(struct inode *i extern void lease_get_mtime(struct inode *, struct timespec *time); 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); struct fasync_struct { int magic; _