summaryrefslogtreecommitdiff
path: root/vl.c
diff options
context:
space:
mode:
authorbalrog <balrog@c046a42c-6fe2-441c-8c8c-71466251a162>2008-01-14 03:11:16 +0000
committerbalrog <balrog@c046a42c-6fe2-441c-8c8c-71466251a162>2008-01-14 03:11:16 +0000
commit044fae83ad1882d9b5919ce02037eb2967824a8d (patch)
tree317ed64e7a9771b9041d320950533addf23dbf7f /vl.c
parent38cdea7ccf34ad81a9129b46db914ca3291ad193 (diff)
downloadqemu-044fae83ad1882d9b5919ce02037eb2967824a8d.zip
Clean-up /tmp directory after -smb use (Mark Jonckheere).
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3911 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'vl.c')
-rw-r--r--vl.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/vl.c b/vl.c
index a28858bbb2..fc6fbf9a60 100644
--- a/vl.c
+++ b/vl.c
@@ -3775,27 +3775,35 @@ static void net_slirp_redir(const char *redir_str)
char smb_dir[1024];
-static void smb_exit(void)
+static void erase_dir(char *dir_name)
{
DIR *d;
struct dirent *de;
char filename[1024];
/* erase all the files in the directory */
- d = opendir(smb_dir);
- 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);
- unlink(filename);
+ if ((d = opendir(dir_name)) != 0) {
+ 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);
}
- closedir(d);
- rmdir(smb_dir);
+}
+
+/* automatic user mode samba server configuration */
+static void smb_exit(void)
+{
+ erase_dir(smb_dir);
}
/* automatic user mode samba server configuration */