提交 044fae83 编写于 作者: B balrog

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
上级 38cdea7c
...@@ -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)
char smb_dir[1024]; char smb_dir[1024];
static void smb_exit(void) static void erase_dir(char *dir_name)
{ {
DIR *d; DIR *d;
struct dirent *de; struct dirent *de;
char filename[1024]; char filename[1024];
/* erase all the files in the directory */ /* erase all the files in the directory */
d = opendir(smb_dir); if ((d = opendir(dir_name)) != 0) {
for(;;) { for(;;) {
de = readdir(d); de = readdir(d);
if (!de) if (!de)
break; break;
if (strcmp(de->d_name, ".") != 0 && if (strcmp(de->d_name, ".") != 0 &&
strcmp(de->d_name, "..") != 0) { strcmp(de->d_name, "..") != 0) {
snprintf(filename, sizeof(filename), "%s/%s", snprintf(filename, sizeof(filename), "%s/%s",
smb_dir, de->d_name); smb_dir, de->d_name);
unlink(filename); 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 */ /* automatic user mode samba server configuration */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册