Mercurial > dovecot > original-hg > dovecot-1.2
changeset 6204:8ab01c7b2927 HEAD
Use quota roots with mount path even if we never see a storage for them.
This is useful if e.g. INBOX is in different filesystem then other mails.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 07 Aug 2007 01:59:43 +0300 |
parents | d93098194ed4 |
children | 65e12fa51d4d |
files | src/plugins/quota/quota-fs.c |
diffstat | 1 files changed, 49 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/src/plugins/quota/quota-fs.c Tue Aug 07 01:51:50 2007 +0300 +++ b/src/plugins/quota/quota-fs.c Tue Aug 07 01:59:43 2007 +0300 @@ -182,30 +182,11 @@ return empty; } -static void fs_quota_storage_added(struct quota *quota, - struct mail_storage *storage) +static void fs_quota_mount_init(struct fs_quota_root *root, + struct fs_quota_mountpoint *mount) { - struct fs_quota_mountpoint *mount; - struct fs_quota_root *root; struct quota_root *const *roots; - const char *dir; unsigned int i, count; - bool is_file; - - dir = mail_storage_get_mailbox_path(storage, "", &is_file); - mount = fs_quota_mountpoint_get(dir); - if (getenv("DEBUG") != NULL) { - i_info("fs quota add storage dir = %s", dir); - i_info("fs quota block device = %s", mount->device_path); - i_info("fs quota mount point = %s", mount->mount_path); - } - - root = fs_quota_root_find_mountpoint(quota, mount); - if (root == NULL || (root != NULL && root->mount != NULL)) { - /* already exists */ - fs_quota_mountpoint_free(mount); - return; - } #ifdef FS_QUOTA_SOLARIS if (mount->path == NULL) { @@ -218,7 +199,7 @@ root->mount = mount; /* if there are more unused quota roots, copy this mount to them */ - roots = array_get("a->roots, &count); + roots = array_get(&root->root.quota->roots, &count); for (i = 0; i < count; i++) { struct fs_quota_root *root = (struct fs_quota_root *)roots[i]; if (QUOTA_ROOT_MATCH(root, mount) && root->mount == NULL) { @@ -228,6 +209,52 @@ } } +static void fs_quota_add_missing_mounts(struct quota *quota) +{ + struct fs_quota_mountpoint *mount; + struct quota_root *const *roots; + unsigned int i, count; + + roots = array_get("a->roots, &count); + for (i = 0; i < count; i++) { + struct fs_quota_root *root = (struct fs_quota_root *)roots[i]; + + if (root->root.backend.name != quota_backend_fs.name || + root->storage_mount_path == NULL || root->mount != NULL) + continue; + + mount = fs_quota_mountpoint_get(root->storage_mount_path); + fs_quota_mount_init(root, mount); + } +} + +static void fs_quota_storage_added(struct quota *quota, + struct mail_storage *storage) +{ + struct fs_quota_mountpoint *mount; + struct fs_quota_root *root; + const char *dir; + bool is_file; + + dir = mail_storage_get_mailbox_path(storage, "", &is_file); + mount = fs_quota_mountpoint_get(dir); + if (getenv("DEBUG") != NULL) { + i_info("fs quota add storage dir = %s", dir); + i_info("fs quota block device = %s", mount->device_path); + i_info("fs quota mount point = %s", mount->mount_path); + } + + root = fs_quota_root_find_mountpoint(quota, mount); + if (root != NULL && root->mount == NULL) + fs_quota_mount_init(root, mount); + else + fs_quota_mountpoint_free(mount); + + /* we would actually want to do this only once after all quota roots + are created, but there's no way to do this right now */ + fs_quota_add_missing_mounts(quota); +} + static const char *const * fs_quota_root_get_resources(struct quota_root *_root) {