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
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);
-------------------------------------------------------------------------
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=/
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

Reply via email to