Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MJRvF-0007WL-EK for qemu-devel@nongnu.org; Wed, 24 Jun 2009 08:49:53 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MJRvA-0007Tg-PO for qemu-devel@nongnu.org; Wed, 24 Jun 2009 08:49:52 -0400 Received: from [199.232.76.173] (port=53303 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MJRvA-0007Tb-Ac for qemu-devel@nongnu.org; Wed, 24 Jun 2009 08:49:48 -0400 Received: from gecko.sbs.de ([194.138.37.40]:18347) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MJRv9-0005bj-9P for qemu-devel@nongnu.org; Wed, 24 Jun 2009 08:49:47 -0400 Resent-To: Anthony Liguori Resent-Message-Id: <4A4220E9.7010406@siemens.com> From: Jan Kiszka Date: Wed, 24 Jun 2009 14:42:31 +0200 Message-ID: <20090624124231.29402.1307.stgit@mchn012c.ww002.siemens.net> In-Reply-To: <20090624124227.29402.750.stgit@mchn012c.ww002.siemens.net> References: <20090624124227.29402.750.stgit@mchn012c.ww002.siemens.net> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH 36/41] slirp: Use shell to erase smb directory List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Mark McLoughlin , qemu-devel@nongnu.org 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 --- net.c | 30 ++++-------------------------- 1 files changed, 4 insertions(+), 26 deletions(-) diff --git a/net.c b/net.c index 0c1a99b..edf7ca6 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,