]> git.hungrycats.org Git - linux/commitdiff
[PATCH] add steal_locks helper
authorAndrew Morton <akpm@osdl.org>
Mon, 29 Dec 2003 13:41:34 +0000 (05:41 -0800)
committerLinus Torvalds <torvalds@home.osdl.org>
Mon, 29 Dec 2003 13:41:34 +0000 (05:41 -0800)
From: Chris Wright <chrisw@osdl.org>

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.

fs/locks.c
include/linux/fs.h

index 6ba8af8a7f3862ecadeb3dc59a91e0f2ebfc9ff5..e7bd3ffda64a94835e84039b6a4f64c50b1dbc3d 100644 (file)
@@ -1983,6 +1983,24 @@ int lock_may_write(struct inode *inode, loff_t start, unsigned long len)
 
 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",
index dbe66b2858701d196e4a839105a52fd182124741..ab962f0b00c24b7d57d47a6281a7270fb7d4cdd4 100644 (file)
@@ -630,6 +630,7 @@ extern int __break_lease(struct inode *inode, unsigned int flags);
 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;