aboutsummaryrefslogtreecommitdiffstats
path: root/net.c
diff options
context:
space:
mode:
authorJan Kiszka <jan.kiszka@siemens.com>2009-06-24 14:42:31 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2009-06-29 08:52:50 -0500
commit09c18925761f932a59f0838c889f31e2d3aa3fcb (patch)
tree39a1bf65a977044f5bb65d2bd79153bd8b5ea183 /net.c
parent0a1f851eb7f3eee5f980a0bdb6687eeee1b60a71 (diff)
downloadqemu-kvm-09c18925761f932a59f0838c889f31e2d3aa3fcb.tar.gz
slirp: Use shell to erase smb directory
Instead of open-coding this, we can use the power of the shell to remove the smb_dir on exit. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'net.c')
-rw-r--r--net.c30
1 files changed, 4 insertions, 26 deletions
diff --git a/net.c b/net.c
index f180b33c718..bfc63178bb3 100644
--- a/net.c
+++ b/net.c
@@ -1014,35 +1014,13 @@ void net_slirp_redir(const char *redir_str)
static char smb_dir[1024];
-static void erase_dir(char *dir_name)
-{
- DIR *d;
- struct dirent *de;
- char filename[1024];
-
- /* erase all the files in the directory */
- if ((d = opendir(dir_name)) != NULL) {
- for(;;) {
- de = readdir(d);
- if (!de)
- break;
- if (strcmp(de->d_name, ".") != 0 &&
- strcmp(de->d_name, "..") != 0) {
- snprintf(filename, sizeof(filename), "%s/%s",
- smb_dir, de->d_name);
- if (unlink(filename) != 0) /* is it a directory? */
- erase_dir(filename);
- }
- }
- closedir(d);
- rmdir(dir_name);
- }
-}
-
/* automatic user mode samba server configuration */
static void smb_exit(void)
{
- erase_dir(smb_dir);
+ char cmd[1024];
+
+ snprintf(cmd, sizeof(cmd), "rm -rf %s", smb_dir);
+ system(cmd);
}
static void slirp_smb(SlirpState* s, const char *exported_dir,