linux-um archives
 help / color / mirror / Atom feed
* [uml-devel] hostfs leaks file descriptors
@ 2008-11-04 14:53 Ingo van Lil
  0 siblings, 0 replies; only message in thread
From: Ingo van Lil @ 2008-11-04 14:53 UTC (permalink / raw)
  To: user-mode-linux-devel

[-- Attachment #1: Type: text/plain, Size: 409 bytes --]

Hi there,

when hostfs is used as the UML's root filesystem its file descriptors 
aren't closed when the kernel is rebooted. Subsequently, after a couple 
of reboots the guest will reach the maximum number of allowed file 
descriptors (usually 1024) and fail to open any more files.

I tried to fix the problem myself, see patch. It works for me, but I'm 
not sure if it's the correct solution.

Cheers,
Ingo

[-- Attachment #2: hostfs-close-files-on-exit.patch --]
[-- Type: text/plain, Size: 806 bytes --]

Index: hostfs_kern.c
===================================================================
--- hostfs_kern.c	(revision 8135)
+++ hostfs_kern.c	(working copy)
@@ -16,6 +16,7 @@
 #include <linux/list.h>
 #include <linux/statfs.h>
 #include <linux/kdev_t.h>
+#include <linux/mount.h>
 #include <asm/uaccess.h>
 #include "hostfs.h"
 #include "kern_util.h"
@@ -1037,3 +1038,17 @@
 module_init(init_hostfs)
 module_exit(exit_hostfs)
 MODULE_LICENSE("GPL");
+
+static void hostfs_exitcall(void)
+{
+	struct super_block *root_sb = current->fs->rootmnt->mnt_sb;
+	if (root_sb->s_type == &hostfs_type) {
+		struct inode *inode;
+		list_for_each_entry(inode, &root_sb->s_inodes, i_sb_list) {
+			if(HOSTFS_I(inode)->fd != -1) {
+				close_file(&HOSTFS_I(inode)->fd);
+			}
+		}
+	}
+}
+__uml_exitcall(hostfs_exitcall);

[-- Attachment #3: Type: text/plain, Size: 363 bytes --]

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/

[-- Attachment #4: Type: text/plain, Size: 194 bytes --]

_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-11-04 14:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-04 14:53 [uml-devel] hostfs leaks file descriptors Ingo van Lil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox