Commit 679345da authored by Jeff Dike's avatar Jeff Dike Committed by Linus Torvalds

[PATCH] uml: close host file descriptors properly

This process closes some file descriptors which were left open incorrectly.
These are the initrd descriptor, the temporary test file used for testing /tmp
for execution permission, and a descriptor used by the netork to connect to
the switch.  In the network case, we add network devices to the opened list as
soon as they are added to UML, rather than when they are configured.  This
ensures that close_devices will remove the device properly on shutdown.
Signed-off-by: default avatarJeff Dike <jdike@addtoit.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 00748298
......@@ -126,10 +126,6 @@ static int uml_net_open(struct net_device *dev)
lp->tl.data = (unsigned long) &lp->user;
netif_start_queue(dev);
spin_lock(&opened_lock);
list_add(&lp->list, &opened);
spin_unlock(&opened_lock);
/* clear buffer - it can happen that the host side of the interface
* is full when we get here. In this case, new data is never queued,
* SIGIOs never arrive, and the net never works.
......@@ -150,11 +146,9 @@ static int uml_net_close(struct net_device *dev)
free_irq_by_irq_and_dev(dev->irq, dev);
free_irq(dev->irq, dev);
if(lp->close != NULL) (*lp->close)(lp->fd, &lp->user);
if(lp->close != NULL)
(*lp->close)(lp->fd, &lp->user);
lp->fd = -1;
spin_lock(&opened_lock);
list_del(&lp->list);
spin_unlock(&opened_lock);
spin_unlock(&lp->lock);
return 0;
......@@ -397,6 +391,11 @@ static int eth_configure(int n, void *init, char *mac,
if (device->have_mac)
set_ether_mac(dev, device->mac);
spin_lock(&opened_lock);
list_add(&lp->list, &opened);
spin_unlock(&opened_lock);
return(0);
}
......@@ -705,7 +704,7 @@ __initcall(uml_net_init);
static void close_devices(void)
{
struct list_head *ele;
struct uml_net_private *lp;
struct uml_net_private *lp;
list_for_each(ele, &opened){
lp = list_entry(ele, struct uml_net_private, list);
......
......@@ -29,6 +29,8 @@ int load_initrd(char *filename, void *buf, int size)
filename, -n);
return(-1);
}
os_close_file(fd);
return(0);
}
......
......@@ -101,6 +101,8 @@ void check_tmpexec(void)
}
printf("OK\n");
munmap(addr, UM_KERN_PAGE_SIZE);
os_close_file(fd);
}
static int have_devanon = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment