[PATCH] vmailmgr-tools-0.2: fix vcheckquota for vmailmgr 0.97
Dale Woolridge <[email protected]> Fri, 9 Sep 2005 12:28:32 -0400
| Newsgroups | gmane.mail.vmailmgr |
|---|---|
| Message-ID | <[email protected]> |
--pyE8wggRBhVBcj8z
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
The vcheckquota in vmailmgr 0.96.9 gracefully handled non-maildir
subdirectories (e.g. given Maildir .../users/X, dovecot creates
status info in .../users/X/.INBOX/). The vcheckquota in
vmailmgr-tools 0.2 does not handle it so gracefully. Attached
is a patch to handle non-existent /new and /cur subdirectories.
thanks.
--
-dale
--pyE8wggRBhVBcj8z
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="vmailmgr-tools-0.2.dw.patch"
diff -audr x/vmailmgr-tools-0.2/vcheckquota.c vmailmgr-tools-0.2/vcheckquota.c
--- x/vmailmgr-tools-0.2/vcheckquota.c Fri May 10 17:00:37 2002
+++ vmailmgr-tools-0.2/vcheckquota.c Fri Sep 9 12:11:43 2005
@@ -33,10 +33,10 @@
const char program[] = "vcheckquota";
const int msg_show_pid = 0;
const char cli_help_prefix[] = "vmailmgr quota enforcement program\n";
-const char cli_help_suffix[] = "
-Warning: the soft-message is linked into the users maildir once for each
-message that is received while the account is over its soft quota. This may
-result in multiple warning messages.\n";
+const char cli_help_suffix[] = "\n"
+"Warning: the soft-message is linked into the users maildir once for each\n"
+"message that is received while the account is over its soft quota. This may\n"
+"result in multiple warning messages.\n";
const char cli_args_usage[] = "";
const int cli_args_min = 0;
const int cli_args_max = 0;
@@ -56,16 +56,21 @@
/* ========================================================================= */
/* Determine the size of a maildir, recursively */
static struct stat st;
-static void wrap_stat(const char* path)
+static int wrap_stat(const char* path)
{
- if (stat(path, &st) == -1)
- die3sys(111, "Cannot stat '", path, "'");
+ if (stat(path, &st) == -1) {
+ if (errno == ENOENT)
+ return -1;
+ else
+ die3sys(111, "Cannot stat '", path, "'");
+ }
+ return 0;
}
static unsigned long stat_size(const char* path)
{
- wrap_stat(path);
- return st.st_blocks * 512;
+ if (!wrap_stat(path)) return st.st_blocks * 512;
+ return 0;
}
static void scan_dir(const char* path,
@@ -77,8 +82,10 @@
DIR* dir;
direntry* entry;
- if ((dir = opendir(path)) == 0)
+ if ((dir = opendir(path)) == 0) {
+ if (errno == ENOENT) return;
die3sys(111, "Could not open directory '", path, "'");
+ }
while((entry = readdir(dir)) != 0) {
const char* name = entry->d_name;
--pyE8wggRBhVBcj8z
Content-Type: text/plain; charset=us-ascii
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
--pyE8wggRBhVBcj8z--