Commit 044fae83ad1882d9b5919ce02037eb2967824a8d
1 parent
38cdea7c
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
Showing
1 changed file
with
21 additions
and
13 deletions
vl.c
@@ -3775,27 +3775,35 @@ static void net_slirp_redir(const char *redir_str) | @@ -3775,27 +3775,35 @@ static void net_slirp_redir(const char *redir_str) | ||
3775 | 3775 | ||
3776 | char smb_dir[1024]; | 3776 | char smb_dir[1024]; |
3777 | 3777 | ||
3778 | -static void smb_exit(void) | 3778 | +static void erase_dir(char *dir_name) |
3779 | { | 3779 | { |
3780 | DIR *d; | 3780 | DIR *d; |
3781 | struct dirent *de; | 3781 | struct dirent *de; |
3782 | char filename[1024]; | 3782 | char filename[1024]; |
3783 | 3783 | ||
3784 | /* erase all the files in the directory */ | 3784 | /* erase all the files in the directory */ |
3785 | - d = opendir(smb_dir); | ||
3786 | - for(;;) { | ||
3787 | - de = readdir(d); | ||
3788 | - if (!de) | ||
3789 | - break; | ||
3790 | - if (strcmp(de->d_name, ".") != 0 && | ||
3791 | - strcmp(de->d_name, "..") != 0) { | ||
3792 | - snprintf(filename, sizeof(filename), "%s/%s", | ||
3793 | - smb_dir, de->d_name); | ||
3794 | - unlink(filename); | 3785 | + if ((d = opendir(dir_name)) != 0) { |
3786 | + for(;;) { | ||
3787 | + de = readdir(d); | ||
3788 | + if (!de) | ||
3789 | + break; | ||
3790 | + if (strcmp(de->d_name, ".") != 0 && | ||
3791 | + strcmp(de->d_name, "..") != 0) { | ||
3792 | + snprintf(filename, sizeof(filename), "%s/%s", | ||
3793 | + smb_dir, de->d_name); | ||
3794 | + if (unlink(filename) != 0) /* is it a directory? */ | ||
3795 | + erase_dir(filename); | ||
3796 | + } | ||
3795 | } | 3797 | } |
3798 | + closedir(d); | ||
3799 | + rmdir(dir_name); | ||
3796 | } | 3800 | } |
3797 | - closedir(d); | ||
3798 | - rmdir(smb_dir); | 3801 | +} |
3802 | + | ||
3803 | +/* automatic user mode samba server configuration */ | ||
3804 | +static void smb_exit(void) | ||
3805 | +{ | ||
3806 | + erase_dir(smb_dir); | ||
3799 | } | 3807 | } |
3800 | 3808 | ||
3801 | /* automatic user mode samba server configuration */ | 3809 | /* automatic user mode samba server configuration */ |