From: Mark Jonckheere <mark.jonckheere@easynet.be>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] Clean-up /tmp directory after -smb use
Date: Wed, 9 Jan 2008 18:31:14 +0000 [thread overview]
Message-ID: <200801091831.16449.mark.jonckheere@easynet.be> (raw)
When using the -smb option with samba-3.0.28 qemu fails to completely
remove the /tmp/qemu-smb.$pid directory at exit. Newer smbd versions
also create subdirectories at this place.
This patch removes recursively all files and subdirectories.
diff -ur qemu/vl.c qemu-patched/vl.c
--- qemu/vl.c 2008-01-08 20:32:16.000000000 +0100
+++ qemu-patched/vl.c 2008-01-09 18:01:33.000000000 +0100
@@ -3772,27 +3772,35 @@
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);
}
--
reply other threads:[~2008-01-09 18:31 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200801091831.16449.mark.jonckheere@easynet.be \
--to=mark.jonckheere@easynet.be \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).