quota-dirsize.c revision f6f94063c4c3080280b87ab47ac2bb756ba002f9
/* Copyright (C) 2005-2006 Timo Sirainen */
/* Quota reporting based on simply summing sizes of all files in mailbox
together. */
#include "lib.h"
#include "array.h"
#include "str.h"
#include "quota-private.h"
#include <stdlib.h>
#include <unistd.h>
#include <dirent.h>
struct dirsize_quota_root {
struct quota_root root;
};
extern struct quota_backend quota_backend_dirsize;
static struct quota_root *
{
struct dirsize_quota_root *root;
const char *const *args;
t_push();
}
t_pop();
i_info("dirsize quota limit = %llukB",
(unsigned long long)root->storage_limit);
}
}
{
}
static bool
{
return TRUE;
}
static void
{
}
static const char *const *
{
return resources;
}
{
struct dirent *d;
unsigned int path_pos;
int ret;
return 0;
return -1;
}
ret = 0;
if (d->d_name[0] == '.' &&
/* skip . and .. */
continue;
}
continue;
ret = -1;
break;
ret = -1;
break;
}
} else {
}
}
return ret;
}
{
if (is_file) {
return 0;
return -1;
}
} else {
"Internal quota calculation error");
return -1;
}
}
return 0;
}
struct quota_count_path {
const char *path;
bool is_file;
};
{
struct quota_count_path *count_path;
unsigned int i, count;
for (i = 0; i < count; i++) {
/* this path is already being counted */
return;
}
/* the new path contains the existing path */
count_path += i;
break;
}
}
if (i == count)
}
static int
{
struct mail_storage *const *storages;
const struct quota_count_path *count_paths;
unsigned int i, count;
const char *path;
bool is_file;
t_push();
struct quota_count_path, 8);
for (i = 0; i < count; i++) {
/* INBOX may be in different path. */
&is_file);
}
/* now sum up the found paths */
for (i = 0; i < count; i++) {
value_r) < 0) {
t_pop();
return -1;
}
}
t_pop();
return 0;
}
static int
{
*value_r = 0;
*limit_r = 0;
return 0;
return -1;
*value_r /= 1024;
return 1;
}
static int
const char *name __attr_unused__,
{
return -1;
}
static struct quota_root_transaction_context *
struct quota_transaction_context *_ctx)
{
struct quota_root_transaction_context *ctx;
/* Get dir usage only once at the beginning of transaction.
entire directory structure after each mail. */
"Internal quota calculation error");
}
return ctx;
}
static int
{
return ret;
}
struct quota_backend quota_backend_dirsize = {
"dirsize",
{
}
};