Mercurial > dovecot > original-hg > dovecot-1.2
annotate src/plugins/quota/quota-fs.c @ 4509:e5e79558ac2d HEAD
Added support for multiple quota roots, rules and storages. The configuration
has changed, userdb now needs to return "quota_rule" settings instead. Much
of the code changes were done by Tianyan Liu.
author | Timo Sirainen <timo.sirainen@movial.fi> |
---|---|
date | Sun, 30 Jul 2006 20:58:38 +0300 |
parents | ce47b2f84cdb |
children | 511f1f5c76fa |
rev | line source |
---|---|
4084
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
1 /* Copyright (C) 2005-2006 Timo Sirainen */ |
3751 | 2 |
3 /* Only for reporting filesystem quota */ | |
4 | |
5 #include "lib.h" | |
4084
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
6 #include "array.h" |
3751 | 7 #include "str.h" |
4188
a3dc87033d2f
Use mountpoint_get() instead of doing it ourself.
Timo Sirainen <tss@iki.fi>
parents:
4151
diff
changeset
|
8 #include "mountpoint.h" |
3751 | 9 #include "quota-private.h" |
10 #include "quota-fs.h" | |
11 | |
12 #ifdef HAVE_FS_QUOTA | |
13 | |
14 #include <stdio.h> | |
15 #include <stdlib.h> | |
4063
f60237ad2edd
Support Solaris's ioctl(Q_QUOTACTL).
Timo Sirainen <tss@iki.fi>
parents:
4060
diff
changeset
|
16 #include <fcntl.h> |
3751 | 17 #include <unistd.h> |
18 #include <sys/stat.h> | |
4387
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
19 #ifdef HAVE_LINUX_DQBLK_XFS_H |
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
20 # include <linux/dqblk_xfs.h> |
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
21 #endif |
3751 | 22 |
3762
4d44a337ac08
Fixed to work with struct dqblk.dqb_curspace also which is apparently the
Timo Sirainen <tss@iki.fi>
parents:
3751
diff
changeset
|
23 #ifdef HAVE_STRUCT_DQBLK_CURSPACE |
4d44a337ac08
Fixed to work with struct dqblk.dqb_curspace also which is apparently the
Timo Sirainen <tss@iki.fi>
parents:
3751
diff
changeset
|
24 # define dqb_curblocks dqb_curspace |
4d44a337ac08
Fixed to work with struct dqblk.dqb_curspace also which is apparently the
Timo Sirainen <tss@iki.fi>
parents:
3751
diff
changeset
|
25 #endif |
4d44a337ac08
Fixed to work with struct dqblk.dqb_curspace also which is apparently the
Timo Sirainen <tss@iki.fi>
parents:
3751
diff
changeset
|
26 |
4448
cf334cc732e7
Attempting to fix quota block calculations to be correct.
Timo Sirainen <tss@iki.fi>
parents:
4387
diff
changeset
|
27 #ifndef DEV_BSIZE |
cf334cc732e7
Attempting to fix quota block calculations to be correct.
Timo Sirainen <tss@iki.fi>
parents:
4387
diff
changeset
|
28 # define DEV_BSIZE 512 |
cf334cc732e7
Attempting to fix quota block calculations to be correct.
Timo Sirainen <tss@iki.fi>
parents:
4387
diff
changeset
|
29 #endif |
cf334cc732e7
Attempting to fix quota block calculations to be correct.
Timo Sirainen <tss@iki.fi>
parents:
4387
diff
changeset
|
30 |
4084
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
31 struct fs_quota_mountpoint { |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
32 char *mount_path; |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
33 char *device_path; |
4387
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
34 char *type; |
3751 | 35 |
4063
f60237ad2edd
Support Solaris's ioctl(Q_QUOTACTL).
Timo Sirainen <tss@iki.fi>
parents:
4060
diff
changeset
|
36 #ifdef HAVE_Q_QUOTACTL |
f60237ad2edd
Support Solaris's ioctl(Q_QUOTACTL).
Timo Sirainen <tss@iki.fi>
parents:
4060
diff
changeset
|
37 int fd; |
4084
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
38 char *path; |
4063
f60237ad2edd
Support Solaris's ioctl(Q_QUOTACTL).
Timo Sirainen <tss@iki.fi>
parents:
4060
diff
changeset
|
39 #endif |
4084
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
40 }; |
4063
f60237ad2edd
Support Solaris's ioctl(Q_QUOTACTL).
Timo Sirainen <tss@iki.fi>
parents:
4060
diff
changeset
|
41 |
4084
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
42 struct fs_quota_root { |
3751 | 43 struct quota_root root; |
4084
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
44 |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
45 uid_t uid; |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
46 struct fs_quota_mountpoint *mount; |
3751 | 47 }; |
48 | |
4084
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
49 extern struct quota_backend quota_backend_fs; |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
50 |
4509
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
51 static struct quota_root *fs_quota_alloc(void) |
4084
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
52 { |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
53 struct fs_quota_root *root; |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
54 |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
55 root = i_new(struct fs_quota_root, 1); |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
56 root->uid = geteuid(); |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
57 |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
58 return &root->root; |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
59 } |
3751 | 60 |
4084
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
61 static void fs_quota_mountpoint_free(struct fs_quota_mountpoint *mount) |
3751 | 62 { |
4084
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
63 #ifdef HAVE_Q_QUOTACTL |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
64 if (mount->fd != -1) { |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
65 if (close(mount->fd) < 0) |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
66 i_error("close(%s) failed: %m", mount->path); |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
67 } |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
68 i_free(mount->path); |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
69 #endif |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
70 |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
71 i_free(mount->device_path); |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
72 i_free(mount->mount_path); |
4387
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
73 i_free(mount->type); |
4084
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
74 i_free(mount); |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
75 } |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
76 |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
77 static void fs_quota_deinit(struct quota_root *_root) |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
78 { |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
79 struct fs_quota_root *root = (struct fs_quota_root *)_root; |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
80 |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
81 if (root->mount != NULL) |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
82 fs_quota_mountpoint_free(root->mount); |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
83 i_free(root); |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
84 } |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
85 |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
86 static struct fs_quota_mountpoint *fs_quota_mountpoint_get(const char *dir) |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
87 { |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
88 struct fs_quota_mountpoint *mount; |
4188
a3dc87033d2f
Use mountpoint_get() instead of doing it ourself.
Timo Sirainen <tss@iki.fi>
parents:
4151
diff
changeset
|
89 struct mountpoint point; |
a3dc87033d2f
Use mountpoint_get() instead of doing it ourself.
Timo Sirainen <tss@iki.fi>
parents:
4151
diff
changeset
|
90 int ret; |
3751 | 91 |
4188
a3dc87033d2f
Use mountpoint_get() instead of doing it ourself.
Timo Sirainen <tss@iki.fi>
parents:
4151
diff
changeset
|
92 ret = mountpoint_get(dir, default_pool, &point); |
a3dc87033d2f
Use mountpoint_get() instead of doing it ourself.
Timo Sirainen <tss@iki.fi>
parents:
4151
diff
changeset
|
93 if (ret <= 0) |
4084
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
94 return NULL; |
3751 | 95 |
4084
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
96 mount = i_new(struct fs_quota_mountpoint, 1); |
4188
a3dc87033d2f
Use mountpoint_get() instead of doing it ourself.
Timo Sirainen <tss@iki.fi>
parents:
4151
diff
changeset
|
97 mount->device_path = point.device_path; |
a3dc87033d2f
Use mountpoint_get() instead of doing it ourself.
Timo Sirainen <tss@iki.fi>
parents:
4151
diff
changeset
|
98 mount->mount_path = point.mount_path; |
4387
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
99 mount->type = point.type; |
4084
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
100 return mount; |
3751 | 101 } |
102 | |
4509
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
103 static struct fs_quota_root * |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
104 fs_quota_root_find_mountpoint(struct quota *quota, |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
105 const struct fs_quota_mountpoint *mount) |
3751 | 106 { |
4509
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
107 struct quota_root *const *roots; |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
108 struct fs_quota_root *empty = NULL; |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
109 unsigned int i, count; |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
110 |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
111 roots = array_get("a->roots, &count); |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
112 for (i = 0; i < count; i++) { |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
113 if (roots[i]->backend == "a_backend_fs) { |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
114 struct fs_quota_root *root = |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
115 (struct fs_quota_root *)roots[i]; |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
116 |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
117 if (root->mount == NULL) |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
118 empty = root; |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
119 else if (strcmp(root->mount->mount_path, |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
120 mount->mount_path) == 0) |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
121 return root; |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
122 } |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
123 } |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
124 return empty; |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
125 } |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
126 |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
127 static void fs_quota_storage_added(struct quota *quota, |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
128 struct mail_storage *storage) |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
129 { |
4084
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
130 struct fs_quota_mountpoint *mount; |
4509
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
131 struct quota_root *_root; |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
132 struct fs_quota_root *root; |
4084
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
133 const char *dir; |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
134 bool is_file; |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
135 |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
136 dir = mail_storage_get_mailbox_path(storage, "", &is_file); |
4509
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
137 mount = fs_quota_mountpoint_get(dir); |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
138 if (getenv("DEBUG") != NULL) { |
4084
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
139 i_info("fs quota add storage dir = %s", dir); |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
140 i_info("fs quota block device = %s", mount->device_path); |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
141 i_info("fs quota mount point = %s", mount->mount_path); |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
142 } |
3751 | 143 |
4509
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
144 root = fs_quota_root_find_mountpoint(quota, mount); |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
145 if (root != NULL && root->mount != NULL) { |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
146 /* already exists */ |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
147 fs_quota_mountpoint_free(mount); |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
148 return; |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
149 } |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
150 |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
151 if (root == NULL) { |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
152 /* create a new root for this mountpoint */ |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
153 _root = quota_root_init(quota, quota_backend_fs.name); |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
154 root = (struct fs_quota_root *)_root; |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
155 root->root.name = |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
156 p_strdup_printf(root->root.pool, "%s%d", |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
157 quota_backend_fs.name, |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
158 array_count("a->roots)); |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
159 } else { |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
160 /* this is the default root. */ |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
161 } |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
162 root->mount = mount; |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
163 |
4063
f60237ad2edd
Support Solaris's ioctl(Q_QUOTACTL).
Timo Sirainen <tss@iki.fi>
parents:
4060
diff
changeset
|
164 #ifdef HAVE_Q_QUOTACTL |
4084
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
165 if (mount->path == NULL) { |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
166 mount->path = i_strconcat(mount->mount_path, "/quotas", NULL); |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
167 mount->fd = open(mount->path, O_RDONLY); |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
168 if (mount->fd == -1 && errno != ENOENT) |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
169 i_error("open(%s) failed: %m", mount->path); |
4063
f60237ad2edd
Support Solaris's ioctl(Q_QUOTACTL).
Timo Sirainen <tss@iki.fi>
parents:
4060
diff
changeset
|
170 } |
f60237ad2edd
Support Solaris's ioctl(Q_QUOTACTL).
Timo Sirainen <tss@iki.fi>
parents:
4060
diff
changeset
|
171 #endif |
3751 | 172 } |
173 | |
174 static const char *const * | |
175 fs_quota_root_get_resources(struct quota_root *root __attr_unused__) | |
176 { | |
177 static const char *resources[] = { QUOTA_NAME_STORAGE, NULL }; | |
178 | |
179 return resources; | |
180 } | |
181 | |
182 static int | |
4084
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
183 fs_quota_get_resource(struct quota_root *_root, const char *name, |
3751 | 184 uint64_t *value_r, uint64_t *limit_r) |
185 { | |
4084
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
186 struct fs_quota_root *root = (struct fs_quota_root *)_root; |
3751 | 187 struct dqblk dqblk; |
4063
f60237ad2edd
Support Solaris's ioctl(Q_QUOTACTL).
Timo Sirainen <tss@iki.fi>
parents:
4060
diff
changeset
|
188 #ifdef HAVE_Q_QUOTACTL |
f60237ad2edd
Support Solaris's ioctl(Q_QUOTACTL).
Timo Sirainen <tss@iki.fi>
parents:
4060
diff
changeset
|
189 struct quotctl ctl; |
f60237ad2edd
Support Solaris's ioctl(Q_QUOTACTL).
Timo Sirainen <tss@iki.fi>
parents:
4060
diff
changeset
|
190 #endif |
3751 | 191 |
192 *value_r = 0; | |
193 *limit_r = 0; | |
194 | |
4084
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
195 if (strcasecmp(name, QUOTA_NAME_STORAGE) != 0 || root->mount == NULL) |
3751 | 196 return 0; |
197 | |
4387
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
198 #if defined (HAVE_QUOTACTL) && defined(HAVE_SYS_QUOTA_H) |
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
199 /* Linux */ |
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
200 #ifdef HAVE_LINUX_DQBLK_XFS_H |
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
201 if (strcmp(root->mount->type, "xfs") == 0) { |
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
202 /* XFS */ |
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
203 struct fs_disk_quota xdqblk; |
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
204 |
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
205 if (quotactl(QCMD(Q_XGETQUOTA, USRQUOTA), |
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
206 root->mount->device_path, |
4448
cf334cc732e7
Attempting to fix quota block calculations to be correct.
Timo Sirainen <tss@iki.fi>
parents:
4387
diff
changeset
|
207 root->uid, (caddr_t)&xdqblk) < 0) { |
4387
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
208 i_error("quotactl(Q_XGETQUOTA, %s) failed: %m", |
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
209 root->mount->device_path); |
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
210 return -1; |
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
211 } |
4448
cf334cc732e7
Attempting to fix quota block calculations to be correct.
Timo Sirainen <tss@iki.fi>
parents:
4387
diff
changeset
|
212 |
cf334cc732e7
Attempting to fix quota block calculations to be correct.
Timo Sirainen <tss@iki.fi>
parents:
4387
diff
changeset
|
213 /* values always returned in 512 byte blocks */ |
cf334cc732e7
Attempting to fix quota block calculations to be correct.
Timo Sirainen <tss@iki.fi>
parents:
4387
diff
changeset
|
214 *value_r = xdqblk.d_bcount >> 1; |
cf334cc732e7
Attempting to fix quota block calculations to be correct.
Timo Sirainen <tss@iki.fi>
parents:
4387
diff
changeset
|
215 *limit_r = xdqblk.d_blk_softlimit >> 1; |
4387
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
216 } else |
4192
26e028337e1e
quotactl() parameters were backwards for BSDs and AIX.
Timo Sirainen <tss@iki.fi>
parents:
4188
diff
changeset
|
217 #endif |
4387
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
218 { |
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
219 /* ext2, ext3 */ |
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
220 if (quotactl(QCMD(Q_GETQUOTA, USRQUOTA), |
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
221 root->mount->device_path, |
4448
cf334cc732e7
Attempting to fix quota block calculations to be correct.
Timo Sirainen <tss@iki.fi>
parents:
4387
diff
changeset
|
222 root->uid, (caddr_t)&dqblk) < 0) { |
4387
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
223 i_error("quotactl(Q_GETQUOTA, %s) failed: %m", |
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
224 root->mount->device_path); |
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
225 return -1; |
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
226 } |
4448
cf334cc732e7
Attempting to fix quota block calculations to be correct.
Timo Sirainen <tss@iki.fi>
parents:
4387
diff
changeset
|
227 |
cf334cc732e7
Attempting to fix quota block calculations to be correct.
Timo Sirainen <tss@iki.fi>
parents:
4387
diff
changeset
|
228 *value_r = dqblk.dqb_curblocks / 1024; |
cf334cc732e7
Attempting to fix quota block calculations to be correct.
Timo Sirainen <tss@iki.fi>
parents:
4387
diff
changeset
|
229 *limit_r = dqblk.dqb_bsoftlimit; |
4387
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
230 } |
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
231 #elif defined(HAVE_QUOTACTL) |
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
232 /* BSD, AIX */ |
4468
ce47b2f84cdb
BSD's quotactl() wants a file path, not a device path.
Timo Sirainen <tss@iki.fi>
parents:
4448
diff
changeset
|
233 if (quotactl(root->mount->mount_path, QCMD(Q_GETQUOTA, USRQUOTA), |
4084
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
234 root->uid, (void *)&dqblk) < 0) { |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
235 i_error("quotactl(Q_GETQUOTA, %s) failed: %m", |
4468
ce47b2f84cdb
BSD's quotactl() wants a file path, not a device path.
Timo Sirainen <tss@iki.fi>
parents:
4448
diff
changeset
|
236 root->mount->mount_path); |
4084
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
237 quota_set_error(_root->setup->quota, "Internal quota error"); |
3751 | 238 return -1; |
239 } | |
4448
cf334cc732e7
Attempting to fix quota block calculations to be correct.
Timo Sirainen <tss@iki.fi>
parents:
4387
diff
changeset
|
240 *value_r = (uint64_t)dqblk.dqb_curblocks * 1024 / DEV_BSIZE; |
cf334cc732e7
Attempting to fix quota block calculations to be correct.
Timo Sirainen <tss@iki.fi>
parents:
4387
diff
changeset
|
241 *limit_r = (uint64_t)dqblk.dqb_bsoftlimit * 1024 / DEV_BSIZE; |
4063
f60237ad2edd
Support Solaris's ioctl(Q_QUOTACTL).
Timo Sirainen <tss@iki.fi>
parents:
4060
diff
changeset
|
242 #else |
f60237ad2edd
Support Solaris's ioctl(Q_QUOTACTL).
Timo Sirainen <tss@iki.fi>
parents:
4060
diff
changeset
|
243 /* Solaris */ |
4084
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
244 if (root->mount->fd == -1) |
4063
f60237ad2edd
Support Solaris's ioctl(Q_QUOTACTL).
Timo Sirainen <tss@iki.fi>
parents:
4060
diff
changeset
|
245 return 0; |
f60237ad2edd
Support Solaris's ioctl(Q_QUOTACTL).
Timo Sirainen <tss@iki.fi>
parents:
4060
diff
changeset
|
246 |
f60237ad2edd
Support Solaris's ioctl(Q_QUOTACTL).
Timo Sirainen <tss@iki.fi>
parents:
4060
diff
changeset
|
247 ctl.op = Q_GETQUOTA; |
4084
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
248 ctl.uid = root->uid; |
4066 | 249 ctl.addr = (caddr_t)&dqblk; |
4084
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
250 if (ioctl(root->mount->fd, Q_QUOTACTL, &ctl) < 0) { |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
251 i_error("ioctl(%s, Q_QUOTACTL) failed: %m", root->mount->path); |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
252 quota_set_error(_root->setup->quota, "Internal quota error"); |
4063
f60237ad2edd
Support Solaris's ioctl(Q_QUOTACTL).
Timo Sirainen <tss@iki.fi>
parents:
4060
diff
changeset
|
253 return -1; |
f60237ad2edd
Support Solaris's ioctl(Q_QUOTACTL).
Timo Sirainen <tss@iki.fi>
parents:
4060
diff
changeset
|
254 } |
4448
cf334cc732e7
Attempting to fix quota block calculations to be correct.
Timo Sirainen <tss@iki.fi>
parents:
4387
diff
changeset
|
255 *value_r = (uint64_t)dqblk.dqb_curblocks * 1024 / DEV_BSIZE; |
cf334cc732e7
Attempting to fix quota block calculations to be correct.
Timo Sirainen <tss@iki.fi>
parents:
4387
diff
changeset
|
256 *limit_r = (uint64_t)dqblk.dqb_bsoftlimit * 1024 / DEV_BSIZE; |
4063
f60237ad2edd
Support Solaris's ioctl(Q_QUOTACTL).
Timo Sirainen <tss@iki.fi>
parents:
4060
diff
changeset
|
257 #endif |
3751 | 258 return 1; |
259 } | |
260 | |
4509
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
261 static int |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
262 fs_quota_update(struct quota_root *root __attr_unused__, |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
263 struct quota_transaction_context *ctx __attr_unused__) |
3751 | 264 { |
265 return 0; | |
266 } | |
267 | |
4084
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
268 struct quota_backend quota_backend_fs = { |
3751 | 269 "fs", |
270 | |
4084
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
271 { |
4509
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
272 fs_quota_alloc, |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
273 NULL, |
4084
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
274 fs_quota_deinit, |
3751 | 275 |
4509
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
276 fs_quota_storage_added, |
3751 | 277 |
4084
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
278 fs_quota_root_get_resources, |
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
279 fs_quota_get_resource, |
4509
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
280 fs_quota_update |
4084
51306837698b
Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4066
diff
changeset
|
281 } |
3751 | 282 }; |
283 | |
284 #endif |