Mercurial > dovecot > original-hg > dovecot-1.2
annotate src/plugins/quota/quota-fs.c @ 8030:7fdb5f222d95 HEAD
Use quota->debug instead of getenv()ing it every time.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 20 Jul 2008 21:37:53 +0300 |
parents | 796307638449 |
children | be8550f51b02 |
rev | line source |
---|---|
7086
7ed926ed7aa4
Updated copyright notices to include year 2008.
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
1 /* Copyright (c) 2005-2008 Dovecot authors, see the included COPYING file */ |
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> |
4565
a54558861acc
Check for XFS quota also from xfs/xqm.h
Timo Sirainen <tss@iki.fi>
parents:
4552
diff
changeset
|
21 # define HAVE_XFS_QUOTA |
a54558861acc
Check for XFS quota also from xfs/xqm.h
Timo Sirainen <tss@iki.fi>
parents:
4552
diff
changeset
|
22 #elif defined (HAVE_XFS_XQM_H) |
a54558861acc
Check for XFS quota also from xfs/xqm.h
Timo Sirainen <tss@iki.fi>
parents:
4552
diff
changeset
|
23 # include <xfs/xqm.h> /* CentOS 4.x at least uses this */ |
a54558861acc
Check for XFS quota also from xfs/xqm.h
Timo Sirainen <tss@iki.fi>
parents:
4552
diff
changeset
|
24 # define HAVE_XFS_QUOTA |
4387
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
25 #endif |
3751 | 26 |
6159
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
27 #ifdef HAVE_RQUOTA |
6439
b951f3e42322
Yet another try at getting rquota code compiling properly with BSD make.
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
28 # include "rquota.h" |
6159
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
29 # define RQUOTA_GETQUOTA_TIMEOUT_SECS 10 |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
30 #endif |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
31 |
4530
f598896bb40a
Added --with-linux-quota configure option to specify which Linux quota
Timo Sirainen <tss@iki.fi>
parents:
4514
diff
changeset
|
32 #ifndef DEV_BSIZE |
8029
796307638449
FS quota: Handle quota only for the quota roots which apply to the mailbox
Timo Sirainen <tss@iki.fi>
parents:
7848
diff
changeset
|
33 # ifdef DQBSIZE |
796307638449
FS quota: Handle quota only for the quota roots which apply to the mailbox
Timo Sirainen <tss@iki.fi>
parents:
7848
diff
changeset
|
34 # define DEV_BSIZE DQBSIZE /* AIX */ |
796307638449
FS quota: Handle quota only for the quota roots which apply to the mailbox
Timo Sirainen <tss@iki.fi>
parents:
7848
diff
changeset
|
35 # else |
796307638449
FS quota: Handle quota only for the quota roots which apply to the mailbox
Timo Sirainen <tss@iki.fi>
parents:
7848
diff
changeset
|
36 # define DEV_BSIZE 512 |
796307638449
FS quota: Handle quota only for the quota roots which apply to the mailbox
Timo Sirainen <tss@iki.fi>
parents:
7848
diff
changeset
|
37 # endif |
3762
4d44a337ac08
Fixed to work with struct dqblk.dqb_curspace also which is apparently the
Timo Sirainen <tss@iki.fi>
parents:
3751
diff
changeset
|
38 #endif |
4d44a337ac08
Fixed to work with struct dqblk.dqb_curspace also which is apparently the
Timo Sirainen <tss@iki.fi>
parents:
3751
diff
changeset
|
39 |
4552
ef71b2fdd433
Put back specific checks for struct dqblk.dqb_curblocks vs curspace. The
Timo Sirainen <tss@iki.fi>
parents:
4547
diff
changeset
|
40 #ifdef HAVE_STRUCT_DQBLK_CURSPACE |
ef71b2fdd433
Put back specific checks for struct dqblk.dqb_curblocks vs curspace. The
Timo Sirainen <tss@iki.fi>
parents:
4547
diff
changeset
|
41 # define dqb_curblocks dqb_curspace |
ef71b2fdd433
Put back specific checks for struct dqblk.dqb_curblocks vs curspace. The
Timo Sirainen <tss@iki.fi>
parents:
4547
diff
changeset
|
42 #endif |
ef71b2fdd433
Put back specific checks for struct dqblk.dqb_curblocks vs curspace. The
Timo Sirainen <tss@iki.fi>
parents:
4547
diff
changeset
|
43 |
4547
912e6d3053e8
Default _LINUX_QUOTA_VERSION to 1 instead of 2, since older Linux v1
Timo Sirainen <tss@iki.fi>
parents:
4530
diff
changeset
|
44 /* Older sys/quota.h doesn't define _LINUX_QUOTA_VERSION at all, which means |
912e6d3053e8
Default _LINUX_QUOTA_VERSION to 1 instead of 2, since older Linux v1
Timo Sirainen <tss@iki.fi>
parents:
4530
diff
changeset
|
45 it supports only v1 quota */ |
4530
f598896bb40a
Added --with-linux-quota configure option to specify which Linux quota
Timo Sirainen <tss@iki.fi>
parents:
4514
diff
changeset
|
46 #ifndef _LINUX_QUOTA_VERSION |
4547
912e6d3053e8
Default _LINUX_QUOTA_VERSION to 1 instead of 2, since older Linux v1
Timo Sirainen <tss@iki.fi>
parents:
4530
diff
changeset
|
47 # define _LINUX_QUOTA_VERSION 1 |
4448
cf334cc732e7
Attempting to fix quota block calculations to be correct.
Timo Sirainen <tss@iki.fi>
parents:
4387
diff
changeset
|
48 #endif |
cf334cc732e7
Attempting to fix quota block calculations to be correct.
Timo Sirainen <tss@iki.fi>
parents:
4387
diff
changeset
|
49 |
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
|
50 struct fs_quota_mountpoint { |
6201
4a8a19fea50d
Added user and group parameters which allow forcing user/group quota
Timo Sirainen <tss@iki.fi>
parents:
6186
diff
changeset
|
51 int refcount; |
4a8a19fea50d
Added user and group parameters which allow forcing user/group quota
Timo Sirainen <tss@iki.fi>
parents:
6186
diff
changeset
|
52 |
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
|
53 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
|
54 char *device_path; |
4387
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
55 char *type; |
7848
a1fd8b29f629
HP-UX fs quota: Convert blocks to bytes using filesystem's actual block size
Timo Sirainen <tss@iki.fi>
parents:
7846
diff
changeset
|
56 unsigned int block_size; |
3751 | 57 |
6185 | 58 #ifdef FS_QUOTA_SOLARIS |
4063
f60237ad2edd
Support Solaris's ioctl(Q_QUOTACTL).
Timo Sirainen <tss@iki.fi>
parents:
4060
diff
changeset
|
59 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
|
60 char *path; |
4063
f60237ad2edd
Support Solaris's ioctl(Q_QUOTACTL).
Timo Sirainen <tss@iki.fi>
parents:
4060
diff
changeset
|
61 #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
|
62 }; |
4063
f60237ad2edd
Support Solaris's ioctl(Q_QUOTACTL).
Timo Sirainen <tss@iki.fi>
parents:
4060
diff
changeset
|
63 |
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
|
64 struct fs_quota_root { |
3751 | 65 struct quota_root root; |
6202
1b01ff0180a5
Removed autocreation of quota roots. Added mount=<path> parameter to map
Timo Sirainen <tss@iki.fi>
parents:
6201
diff
changeset
|
66 char *storage_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
|
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 uid_t uid; |
6186
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
69 gid_t gid; |
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
|
70 struct fs_quota_mountpoint *mount; |
6186
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
71 |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
72 unsigned int inode_per_mail:1; |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
73 unsigned int user_disabled:1; |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
74 unsigned int group_disabled:1; |
3751 | 75 }; |
76 | |
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
|
77 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
|
78 |
4509
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
79 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
|
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 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
|
82 |
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 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
|
84 root->uid = geteuid(); |
6186
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
85 root->gid = getegid(); |
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
|
86 |
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 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
|
88 } |
3751 | 89 |
6201
4a8a19fea50d
Added user and group parameters which allow forcing user/group quota
Timo Sirainen <tss@iki.fi>
parents:
6186
diff
changeset
|
90 static int fs_quota_init(struct quota_root *_root, const char *args) |
4a8a19fea50d
Added user and group parameters which allow forcing user/group quota
Timo Sirainen <tss@iki.fi>
parents:
6186
diff
changeset
|
91 { |
4a8a19fea50d
Added user and group parameters which allow forcing user/group quota
Timo Sirainen <tss@iki.fi>
parents:
6186
diff
changeset
|
92 struct fs_quota_root *root = (struct fs_quota_root *)_root; |
6202
1b01ff0180a5
Removed autocreation of quota roots. Added mount=<path> parameter to map
Timo Sirainen <tss@iki.fi>
parents:
6201
diff
changeset
|
93 const char *const *tmp; |
6201
4a8a19fea50d
Added user and group parameters which allow forcing user/group quota
Timo Sirainen <tss@iki.fi>
parents:
6186
diff
changeset
|
94 |
6202
1b01ff0180a5
Removed autocreation of quota roots. Added mount=<path> parameter to map
Timo Sirainen <tss@iki.fi>
parents:
6201
diff
changeset
|
95 if (args == NULL) |
1b01ff0180a5
Removed autocreation of quota roots. Added mount=<path> parameter to map
Timo Sirainen <tss@iki.fi>
parents:
6201
diff
changeset
|
96 return 0; |
1b01ff0180a5
Removed autocreation of quota roots. Added mount=<path> parameter to map
Timo Sirainen <tss@iki.fi>
parents:
6201
diff
changeset
|
97 |
1b01ff0180a5
Removed autocreation of quota roots. Added mount=<path> parameter to map
Timo Sirainen <tss@iki.fi>
parents:
6201
diff
changeset
|
98 for (tmp = t_strsplit(args, ":"); *tmp != NULL; tmp++) { |
1b01ff0180a5
Removed autocreation of quota roots. Added mount=<path> parameter to map
Timo Sirainen <tss@iki.fi>
parents:
6201
diff
changeset
|
99 if (strcmp(*tmp, "user") == 0) |
1b01ff0180a5
Removed autocreation of quota roots. Added mount=<path> parameter to map
Timo Sirainen <tss@iki.fi>
parents:
6201
diff
changeset
|
100 root->group_disabled = TRUE; |
1b01ff0180a5
Removed autocreation of quota roots. Added mount=<path> parameter to map
Timo Sirainen <tss@iki.fi>
parents:
6201
diff
changeset
|
101 else if (strcmp(*tmp, "group") == 0) |
1b01ff0180a5
Removed autocreation of quota roots. Added mount=<path> parameter to map
Timo Sirainen <tss@iki.fi>
parents:
6201
diff
changeset
|
102 root->user_disabled = TRUE; |
6203
d93098194ed4
inode_per_mail is now a parameter. We don't use it automatically.
Timo Sirainen <tss@iki.fi>
parents:
6202
diff
changeset
|
103 else if (strcmp(*tmp, "inode_per_mail") == 0) |
d93098194ed4
inode_per_mail is now a parameter. We don't use it automatically.
Timo Sirainen <tss@iki.fi>
parents:
6202
diff
changeset
|
104 root->inode_per_mail = TRUE; |
6874
1d0521b7151d
Added noenforcing option to fs quota backend.
Timo Sirainen <tss@iki.fi>
parents:
6439
diff
changeset
|
105 else if (strcmp(*tmp, "noenforcing") == 0) |
1d0521b7151d
Added noenforcing option to fs quota backend.
Timo Sirainen <tss@iki.fi>
parents:
6439
diff
changeset
|
106 _root->no_enforcing = TRUE; |
6202
1b01ff0180a5
Removed autocreation of quota roots. Added mount=<path> parameter to map
Timo Sirainen <tss@iki.fi>
parents:
6201
diff
changeset
|
107 else if (strncmp(*tmp, "mount=", 6) == 0) { |
1b01ff0180a5
Removed autocreation of quota roots. Added mount=<path> parameter to map
Timo Sirainen <tss@iki.fi>
parents:
6201
diff
changeset
|
108 i_free(root->storage_mount_path); |
1b01ff0180a5
Removed autocreation of quota roots. Added mount=<path> parameter to map
Timo Sirainen <tss@iki.fi>
parents:
6201
diff
changeset
|
109 root->storage_mount_path = i_strdup(*tmp + 6); |
1b01ff0180a5
Removed autocreation of quota roots. Added mount=<path> parameter to map
Timo Sirainen <tss@iki.fi>
parents:
6201
diff
changeset
|
110 } else { |
1b01ff0180a5
Removed autocreation of quota roots. Added mount=<path> parameter to map
Timo Sirainen <tss@iki.fi>
parents:
6201
diff
changeset
|
111 i_error("fs quota: Invalid parameter: %s", *tmp); |
1b01ff0180a5
Removed autocreation of quota roots. Added mount=<path> parameter to map
Timo Sirainen <tss@iki.fi>
parents:
6201
diff
changeset
|
112 return -1; |
1b01ff0180a5
Removed autocreation of quota roots. Added mount=<path> parameter to map
Timo Sirainen <tss@iki.fi>
parents:
6201
diff
changeset
|
113 } |
6201
4a8a19fea50d
Added user and group parameters which allow forcing user/group quota
Timo Sirainen <tss@iki.fi>
parents:
6186
diff
changeset
|
114 } |
4a8a19fea50d
Added user and group parameters which allow forcing user/group quota
Timo Sirainen <tss@iki.fi>
parents:
6186
diff
changeset
|
115 return 0; |
4a8a19fea50d
Added user and group parameters which allow forcing user/group quota
Timo Sirainen <tss@iki.fi>
parents:
6186
diff
changeset
|
116 } |
4a8a19fea50d
Added user and group parameters which allow forcing user/group quota
Timo Sirainen <tss@iki.fi>
parents:
6186
diff
changeset
|
117 |
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
|
118 static void fs_quota_mountpoint_free(struct fs_quota_mountpoint *mount) |
3751 | 119 { |
6201
4a8a19fea50d
Added user and group parameters which allow forcing user/group quota
Timo Sirainen <tss@iki.fi>
parents:
6186
diff
changeset
|
120 if (--mount->refcount > 0) |
4a8a19fea50d
Added user and group parameters which allow forcing user/group quota
Timo Sirainen <tss@iki.fi>
parents:
6186
diff
changeset
|
121 return; |
4a8a19fea50d
Added user and group parameters which allow forcing user/group quota
Timo Sirainen <tss@iki.fi>
parents:
6186
diff
changeset
|
122 |
6185 | 123 #ifdef FS_QUOTA_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
|
124 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
|
125 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
|
126 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
|
127 } |
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
|
128 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
|
129 #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
|
130 |
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
|
131 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
|
132 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
|
133 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
|
134 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
|
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 |
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
|
137 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
|
138 { |
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 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
|
140 |
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 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
|
142 fs_quota_mountpoint_free(root->mount); |
6202
1b01ff0180a5
Removed autocreation of quota roots. Added mount=<path> parameter to map
Timo Sirainen <tss@iki.fi>
parents:
6201
diff
changeset
|
143 i_free(root->storage_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
|
144 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
|
145 } |
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
|
146 |
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
|
147 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
|
148 { |
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
|
149 struct fs_quota_mountpoint *mount; |
4188
a3dc87033d2f
Use mountpoint_get() instead of doing it ourself.
Timo Sirainen <tss@iki.fi>
parents:
4151
diff
changeset
|
150 struct mountpoint point; |
a3dc87033d2f
Use mountpoint_get() instead of doing it ourself.
Timo Sirainen <tss@iki.fi>
parents:
4151
diff
changeset
|
151 int ret; |
3751 | 152 |
4188
a3dc87033d2f
Use mountpoint_get() instead of doing it ourself.
Timo Sirainen <tss@iki.fi>
parents:
4151
diff
changeset
|
153 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
|
154 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
|
155 return NULL; |
3751 | 156 |
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
|
157 mount = i_new(struct fs_quota_mountpoint, 1); |
6201
4a8a19fea50d
Added user and group parameters which allow forcing user/group quota
Timo Sirainen <tss@iki.fi>
parents:
6186
diff
changeset
|
158 mount->refcount = 1; |
4188
a3dc87033d2f
Use mountpoint_get() instead of doing it ourself.
Timo Sirainen <tss@iki.fi>
parents:
4151
diff
changeset
|
159 mount->device_path = point.device_path; |
a3dc87033d2f
Use mountpoint_get() instead of doing it ourself.
Timo Sirainen <tss@iki.fi>
parents:
4151
diff
changeset
|
160 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
|
161 mount->type = point.type; |
7848
a1fd8b29f629
HP-UX fs quota: Convert blocks to bytes using filesystem's actual block size
Timo Sirainen <tss@iki.fi>
parents:
7846
diff
changeset
|
162 mount->block_size = point.block_size; |
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
|
163 return mount; |
3751 | 164 } |
165 | |
6202
1b01ff0180a5
Removed autocreation of quota roots. Added mount=<path> parameter to map
Timo Sirainen <tss@iki.fi>
parents:
6201
diff
changeset
|
166 #define QUOTA_ROOT_MATCH(root, mount) \ |
1b01ff0180a5
Removed autocreation of quota roots. Added mount=<path> parameter to map
Timo Sirainen <tss@iki.fi>
parents:
6201
diff
changeset
|
167 ((root)->root.backend.name == quota_backend_fs.name && \ |
1b01ff0180a5
Removed autocreation of quota roots. Added mount=<path> parameter to map
Timo Sirainen <tss@iki.fi>
parents:
6201
diff
changeset
|
168 ((root)->storage_mount_path == NULL || \ |
1b01ff0180a5
Removed autocreation of quota roots. Added mount=<path> parameter to map
Timo Sirainen <tss@iki.fi>
parents:
6201
diff
changeset
|
169 strcmp((root)->storage_mount_path, (mount)->mount_path) == 0)) |
1b01ff0180a5
Removed autocreation of quota roots. Added mount=<path> parameter to map
Timo Sirainen <tss@iki.fi>
parents:
6201
diff
changeset
|
170 |
4509
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
171 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
|
172 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
|
173 const struct fs_quota_mountpoint *mount) |
3751 | 174 { |
4509
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
175 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
|
176 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
|
177 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
|
178 |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
179 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
|
180 for (i = 0; i < count; i++) { |
6202
1b01ff0180a5
Removed autocreation of quota roots. Added mount=<path> parameter to map
Timo Sirainen <tss@iki.fi>
parents:
6201
diff
changeset
|
181 struct fs_quota_root *root = (struct fs_quota_root *)roots[i]; |
1b01ff0180a5
Removed autocreation of quota roots. Added mount=<path> parameter to map
Timo Sirainen <tss@iki.fi>
parents:
6201
diff
changeset
|
182 if (QUOTA_ROOT_MATCH(root, mount)) { |
4509
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
183 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
|
184 empty = root; |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
185 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
|
186 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
|
187 return root; |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
188 } |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
189 } |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
190 return empty; |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
191 } |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
192 |
6204
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
193 static void fs_quota_mount_init(struct fs_quota_root *root, |
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
194 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
|
195 { |
6201
4a8a19fea50d
Added user and group parameters which allow forcing user/group quota
Timo Sirainen <tss@iki.fi>
parents:
6186
diff
changeset
|
196 struct quota_root *const *roots; |
4a8a19fea50d
Added user and group parameters which allow forcing user/group quota
Timo Sirainen <tss@iki.fi>
parents:
6186
diff
changeset
|
197 unsigned int i, count; |
4509
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
198 |
6201
4a8a19fea50d
Added user and group parameters which allow forcing user/group quota
Timo Sirainen <tss@iki.fi>
parents:
6186
diff
changeset
|
199 #ifdef FS_QUOTA_SOLARIS |
4a8a19fea50d
Added user and group parameters which allow forcing user/group quota
Timo Sirainen <tss@iki.fi>
parents:
6186
diff
changeset
|
200 if (mount->path == NULL) { |
4a8a19fea50d
Added user and group parameters which allow forcing user/group quota
Timo Sirainen <tss@iki.fi>
parents:
6186
diff
changeset
|
201 mount->path = i_strconcat(mount->mount_path, "/quotas", NULL); |
4a8a19fea50d
Added user and group parameters which allow forcing user/group quota
Timo Sirainen <tss@iki.fi>
parents:
6186
diff
changeset
|
202 mount->fd = open(mount->path, O_RDONLY); |
4a8a19fea50d
Added user and group parameters which allow forcing user/group quota
Timo Sirainen <tss@iki.fi>
parents:
6186
diff
changeset
|
203 if (mount->fd == -1 && errno != ENOENT) |
4a8a19fea50d
Added user and group parameters which allow forcing user/group quota
Timo Sirainen <tss@iki.fi>
parents:
6186
diff
changeset
|
204 i_error("open(%s) failed: %m", mount->path); |
4a8a19fea50d
Added user and group parameters which allow forcing user/group quota
Timo Sirainen <tss@iki.fi>
parents:
6186
diff
changeset
|
205 } |
4a8a19fea50d
Added user and group parameters which allow forcing user/group quota
Timo Sirainen <tss@iki.fi>
parents:
6186
diff
changeset
|
206 #endif |
4509
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
207 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
|
208 |
6201
4a8a19fea50d
Added user and group parameters which allow forcing user/group quota
Timo Sirainen <tss@iki.fi>
parents:
6186
diff
changeset
|
209 /* if there are more unused quota roots, copy this mount to them */ |
6204
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
210 roots = array_get(&root->root.quota->roots, &count); |
6201
4a8a19fea50d
Added user and group parameters which allow forcing user/group quota
Timo Sirainen <tss@iki.fi>
parents:
6186
diff
changeset
|
211 for (i = 0; i < count; i++) { |
7561
1a58b18652a6
Avoid using shadow variables. Unfortunately -Wshadow also complains about
Timo Sirainen <tss@iki.fi>
parents:
7294
diff
changeset
|
212 root = (struct fs_quota_root *)roots[i]; |
6202
1b01ff0180a5
Removed autocreation of quota roots. Added mount=<path> parameter to map
Timo Sirainen <tss@iki.fi>
parents:
6201
diff
changeset
|
213 if (QUOTA_ROOT_MATCH(root, mount) && root->mount == NULL) { |
1b01ff0180a5
Removed autocreation of quota roots. Added mount=<path> parameter to map
Timo Sirainen <tss@iki.fi>
parents:
6201
diff
changeset
|
214 mount->refcount++; |
1b01ff0180a5
Removed autocreation of quota roots. Added mount=<path> parameter to map
Timo Sirainen <tss@iki.fi>
parents:
6201
diff
changeset
|
215 root->mount = mount; |
6201
4a8a19fea50d
Added user and group parameters which allow forcing user/group quota
Timo Sirainen <tss@iki.fi>
parents:
6186
diff
changeset
|
216 } |
4063
f60237ad2edd
Support Solaris's ioctl(Q_QUOTACTL).
Timo Sirainen <tss@iki.fi>
parents:
4060
diff
changeset
|
217 } |
3751 | 218 } |
219 | |
6204
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
220 static void fs_quota_add_missing_mounts(struct quota *quota) |
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
221 { |
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
222 struct fs_quota_mountpoint *mount; |
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
223 struct quota_root *const *roots; |
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
224 unsigned int i, count; |
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
225 |
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
226 roots = array_get("a->roots, &count); |
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
227 for (i = 0; i < count; i++) { |
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
228 struct fs_quota_root *root = (struct fs_quota_root *)roots[i]; |
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
229 |
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
230 if (root->root.backend.name != quota_backend_fs.name || |
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
231 root->storage_mount_path == NULL || root->mount != NULL) |
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
232 continue; |
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
233 |
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
234 mount = fs_quota_mountpoint_get(root->storage_mount_path); |
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
235 fs_quota_mount_init(root, mount); |
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
236 } |
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
237 } |
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
238 |
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
239 static void fs_quota_storage_added(struct quota *quota, |
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
240 struct mail_storage *storage) |
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
241 { |
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
242 struct fs_quota_mountpoint *mount; |
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
243 struct fs_quota_root *root; |
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
244 const char *dir; |
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
245 bool is_file; |
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
246 |
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
247 dir = mail_storage_get_mailbox_path(storage, "", &is_file); |
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
248 mount = fs_quota_mountpoint_get(dir); |
8030
7fdb5f222d95
Use quota->debug instead of getenv()ing it every time.
Timo Sirainen <tss@iki.fi>
parents:
8029
diff
changeset
|
249 if (quota->debug) { |
6204
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
250 i_info("fs quota add storage dir = %s", dir); |
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
251 i_info("fs quota block device = %s", mount->device_path); |
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
252 i_info("fs quota mount point = %s", mount->mount_path); |
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
253 } |
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
254 |
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
255 root = fs_quota_root_find_mountpoint(quota, mount); |
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
256 if (root != NULL && root->mount == NULL) |
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
257 fs_quota_mount_init(root, mount); |
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
258 else |
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
259 fs_quota_mountpoint_free(mount); |
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
260 |
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
261 /* we would actually want to do this only once after all quota roots |
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
262 are created, but there's no way to do this right now */ |
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
263 fs_quota_add_missing_mounts(quota); |
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
264 } |
8ab01c7b2927
Use quota roots with mount path even if we never see a storage for them.
Timo Sirainen <tss@iki.fi>
parents:
6203
diff
changeset
|
265 |
3751 | 266 static const char *const * |
6184
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
267 fs_quota_root_get_resources(struct quota_root *_root) |
3751 | 268 { |
6184
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
269 struct fs_quota_root *root = (struct fs_quota_root *)_root; |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
270 static const char *resources_kb[] = { |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
271 QUOTA_NAME_STORAGE_KILOBYTES, |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
272 NULL |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
273 }; |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
274 static const char *resources_kb_messages[] = { |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
275 QUOTA_NAME_STORAGE_KILOBYTES, |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
276 QUOTA_NAME_MESSAGES, |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
277 NULL |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
278 }; |
3751 | 279 |
6184
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
280 return root->inode_per_mail ? resources_kb_messages : resources_kb; |
3751 | 281 } |
282 | |
6159
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
283 #ifdef HAVE_RQUOTA |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
284 /* retrieve user quota from a remote host */ |
6184
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
285 static int do_rquota(struct fs_quota_root *root, bool bytes, |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
286 uint64_t *value_r, uint64_t *limit_r) |
6159
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
287 { |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
288 struct getquota_rslt result; |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
289 struct getquota_args args; |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
290 struct timeval timeout; |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
291 enum clnt_stat call_status; |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
292 CLIENT *cl; |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
293 struct fs_quota_mountpoint *mount = root->mount; |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
294 const char *host; |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
295 char *path; |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
296 |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
297 path = strchr(mount->device_path, ':'); |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
298 if (path == NULL) { |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
299 i_error("quota-fs: %s is not a valid NFS device path", |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
300 mount->device_path); |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
301 return -1; |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
302 } |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
303 |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
304 host = t_strdup_until(mount->device_path, path); |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
305 path++; |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
306 |
8030
7fdb5f222d95
Use quota->debug instead of getenv()ing it every time.
Timo Sirainen <tss@iki.fi>
parents:
8029
diff
changeset
|
307 if (root->root.quota->debug) { |
6159
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
308 i_info("quota-fs: host=%s, path=%s, uid=%s", |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
309 host, path, dec2str(root->uid)); |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
310 } |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
311 |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
312 /* clnt_create() polls for a while to establish a connection */ |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
313 cl = clnt_create(host, RQUOTAPROG, RQUOTAVERS, "udp"); |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
314 if (cl == NULL) { |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
315 i_error("quota-fs: could not contact RPC service on %s", |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
316 host); |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
317 return -1; |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
318 } |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
319 |
6176
0f6d4f8dd587
Use authunix_create_default() with rquota. Patch by Steven Luo.
Timo Sirainen <tss@iki.fi>
parents:
6159
diff
changeset
|
320 /* Establish some RPC credentials */ |
0f6d4f8dd587
Use authunix_create_default() with rquota. Patch by Steven Luo.
Timo Sirainen <tss@iki.fi>
parents:
6159
diff
changeset
|
321 auth_destroy(cl->cl_auth); |
0f6d4f8dd587
Use authunix_create_default() with rquota. Patch by Steven Luo.
Timo Sirainen <tss@iki.fi>
parents:
6159
diff
changeset
|
322 cl->cl_auth = authunix_create_default(); |
0f6d4f8dd587
Use authunix_create_default() with rquota. Patch by Steven Luo.
Timo Sirainen <tss@iki.fi>
parents:
6159
diff
changeset
|
323 |
6159
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
324 /* make the rquota call on the remote host */ |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
325 args.gqa_pathp = path; |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
326 args.gqa_uid = root->uid; |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
327 |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
328 timeout.tv_sec = RQUOTA_GETQUOTA_TIMEOUT_SECS; |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
329 timeout.tv_usec = 0; |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
330 call_status = clnt_call(cl, RQUOTAPROC_GETQUOTA, |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
331 (xdrproc_t)xdr_getquota_args, (char *)&args, |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
332 (xdrproc_t)xdr_getquota_rslt, (char *)&result, |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
333 timeout); |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
334 |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
335 /* the result has been deserialized, let the client go */ |
6176
0f6d4f8dd587
Use authunix_create_default() with rquota. Patch by Steven Luo.
Timo Sirainen <tss@iki.fi>
parents:
6159
diff
changeset
|
336 auth_destroy(cl->cl_auth); |
6159
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
337 clnt_destroy(cl); |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
338 |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
339 if (call_status != RPC_SUCCESS) { |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
340 const char *rpc_error_msg = clnt_sperrno(call_status); |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
341 |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
342 i_error("quota-fs: remote rquota call failed: %s", |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
343 rpc_error_msg); |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
344 return -1; |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
345 } |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
346 |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
347 switch (result.status) { |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
348 case Q_OK: { |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
349 /* convert the results from blocks to bytes */ |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
350 rquota *rq = &result.getquota_rslt_u.gqr_rquota; |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
351 |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
352 if (rq->rq_active) { |
6184
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
353 if (bytes) { |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
354 *value_r = (uint64_t)rq->rq_curblocks * |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
355 (uint64_t)rq->rq_bsize; |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
356 *limit_r = (uint64_t)rq->rq_bsoftlimit * |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
357 (uint64_t)rq->rq_bsize; |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
358 } else { |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
359 *value_r = rq->rq_curfiles; |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
360 *limit_r = rq->rq_fsoftlimit; |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
361 } |
6159
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
362 } |
8030
7fdb5f222d95
Use quota->debug instead of getenv()ing it every time.
Timo Sirainen <tss@iki.fi>
parents:
8029
diff
changeset
|
363 if (root->root.quota->debug) { |
6159
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
364 i_info("quota-fs: uid=%s, value=%llu, " |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
365 "limit=%llu, active=%d", dec2str(root->uid), |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
366 (unsigned long long)*value_r, |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
367 (unsigned long long)*limit_r, rq->rq_active); |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
368 } |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
369 return 1; |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
370 } |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
371 case Q_NOQUOTA: |
8030
7fdb5f222d95
Use quota->debug instead of getenv()ing it every time.
Timo Sirainen <tss@iki.fi>
parents:
8029
diff
changeset
|
372 if (root->root.quota->debug) { |
6159
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
373 i_info("quota-fs: uid=%s, limit=unlimited", |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
374 dec2str(root->uid)); |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
375 } |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
376 return 1; |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
377 case Q_EPERM: |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
378 i_error("quota-fs: permission denied to rquota service"); |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
379 return -1; |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
380 default: |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
381 i_error("quota-fs: unrecognized status code (%d) " |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
382 "from rquota service", result.status); |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
383 return -1; |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
384 } |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
385 } |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
386 #endif |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
387 |
6186
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
388 #if defined(FS_QUOTA_LINUX) || defined(FS_QUOTA_BSDAIX) |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
389 static void fs_quota_root_disable(struct fs_quota_root *root, bool group) |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
390 { |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
391 if (group) |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
392 root->group_disabled = TRUE; |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
393 else |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
394 root->user_disabled = TRUE; |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
395 } |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
396 #endif |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
397 |
6185 | 398 #ifdef FS_QUOTA_LINUX |
3751 | 399 static int |
6186
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
400 fs_quota_get_linux(struct fs_quota_root *root, bool group, bool bytes, |
6185 | 401 uint64_t *value_r, uint64_t *limit_r) |
3751 | 402 { |
403 struct dqblk dqblk; | |
6186
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
404 int type, id; |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
405 |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
406 type = group ? GRPQUOTA : USRQUOTA; |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
407 id = group ? root->gid : root->uid; |
3751 | 408 |
4565
a54558861acc
Check for XFS quota also from xfs/xqm.h
Timo Sirainen <tss@iki.fi>
parents:
4552
diff
changeset
|
409 #ifdef HAVE_XFS_QUOTA |
4387
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
410 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
|
411 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
|
412 |
6186
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
413 if (quotactl(QCMD(Q_XGETQUOTA, type), |
4387
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
414 root->mount->device_path, |
6186
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
415 id, (caddr_t)&xdqblk) < 0) { |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
416 if (errno == ESRCH) { |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
417 fs_quota_root_disable(root, group); |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
418 return 0; |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
419 } |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
420 i_error("%d quotactl(Q_XGETQUOTA, %s) failed: %m", |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
421 errno, root->mount->device_path); |
4387
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
422 return -1; |
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
423 } |
4448
cf334cc732e7
Attempting to fix quota block calculations to be correct.
Timo Sirainen <tss@iki.fi>
parents:
4387
diff
changeset
|
424 |
6184
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
425 if (bytes) { |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
426 /* values always returned in 512 byte blocks */ |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
427 *value_r = xdqblk.d_bcount * 512; |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
428 *limit_r = xdqblk.d_blk_softlimit * 512; |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
429 } else { |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
430 *value_r = xdqblk.d_icount; |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
431 *limit_r = xdqblk.d_ino_softlimit; |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
432 } |
4387
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
433 } else |
4192
26e028337e1e
quotactl() parameters were backwards for BSDs and AIX.
Timo Sirainen <tss@iki.fi>
parents:
4188
diff
changeset
|
434 #endif |
4387
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
435 { |
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
436 /* ext2, ext3 */ |
6186
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
437 if (quotactl(QCMD(Q_GETQUOTA, type), |
4387
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
438 root->mount->device_path, |
6186
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
439 id, (caddr_t)&dqblk) < 0) { |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
440 if (errno == ESRCH) { |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
441 fs_quota_root_disable(root, group); |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
442 return 0; |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
443 } |
4387
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
444 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
|
445 root->mount->device_path); |
4530
f598896bb40a
Added --with-linux-quota configure option to specify which Linux quota
Timo Sirainen <tss@iki.fi>
parents:
4514
diff
changeset
|
446 if (errno == EINVAL) { |
f598896bb40a
Added --with-linux-quota configure option to specify which Linux quota
Timo Sirainen <tss@iki.fi>
parents:
4514
diff
changeset
|
447 i_error("Dovecot was compiled with Linux quota " |
f598896bb40a
Added --with-linux-quota configure option to specify which Linux quota
Timo Sirainen <tss@iki.fi>
parents:
4514
diff
changeset
|
448 "v%d support, try changing it " |
f598896bb40a
Added --with-linux-quota configure option to specify which Linux quota
Timo Sirainen <tss@iki.fi>
parents:
4514
diff
changeset
|
449 "(--with-linux-quota configure option)", |
f598896bb40a
Added --with-linux-quota configure option to specify which Linux quota
Timo Sirainen <tss@iki.fi>
parents:
4514
diff
changeset
|
450 _LINUX_QUOTA_VERSION); |
f598896bb40a
Added --with-linux-quota configure option to specify which Linux quota
Timo Sirainen <tss@iki.fi>
parents:
4514
diff
changeset
|
451 } |
4387
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
452 return -1; |
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
453 } |
4448
cf334cc732e7
Attempting to fix quota block calculations to be correct.
Timo Sirainen <tss@iki.fi>
parents:
4387
diff
changeset
|
454 |
6184
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
455 if (bytes) { |
5174
a911767f89c0
Linux quota v1 apparently returns current quota in kilobytes, not bytes as
Timo Sirainen <tss@iki.fi>
parents:
4844
diff
changeset
|
456 #if _LINUX_QUOTA_VERSION == 1 |
6184
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
457 *value_r = dqblk.dqb_curblocks * 1024; |
5174
a911767f89c0
Linux quota v1 apparently returns current quota in kilobytes, not bytes as
Timo Sirainen <tss@iki.fi>
parents:
4844
diff
changeset
|
458 #else |
6184
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
459 *value_r = dqblk.dqb_curblocks; |
5174
a911767f89c0
Linux quota v1 apparently returns current quota in kilobytes, not bytes as
Timo Sirainen <tss@iki.fi>
parents:
4844
diff
changeset
|
460 #endif |
6184
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
461 *limit_r = dqblk.dqb_bsoftlimit * 1024; |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
462 } else { |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
463 *value_r = dqblk.dqb_curinodes; |
7845
e4e9cc00d9ba
fs quota: message/inode values and limits were set wrong, except for Solaris
Timo Sirainen <tss@iki.fi>
parents:
7824
diff
changeset
|
464 *limit_r = dqblk.dqb_isoftlimit; |
6184
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
465 } |
4387
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
466 } |
6185 | 467 return 1; |
468 } | |
469 #endif | |
470 | |
471 #ifdef FS_QUOTA_BSDAIX | |
472 static int | |
6186
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
473 fs_quota_get_bsdaix(struct fs_quota_root *root, bool group, bool bytes, |
6185 | 474 uint64_t *value_r, uint64_t *limit_r) |
475 { | |
476 struct dqblk dqblk; | |
6186
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
477 int type, id; |
6185 | 478 |
6186
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
479 type = group ? GRPQUOTA : USRQUOTA; |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
480 id = group ? root->gid : root->uid; |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
481 |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
482 if (quotactl(root->mount->mount_path, QCMD(Q_GETQUOTA, type), |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
483 id, (void *)&dqblk) < 0) { |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
484 if (errno == ESRCH) { |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
485 fs_quota_root_disable(root, group); |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
486 return 0; |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
487 } |
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
|
488 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
|
489 root->mount->mount_path); |
3751 | 490 return -1; |
491 } | |
6184
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
492 if (bytes) { |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
493 *value_r = (uint64_t)dqblk.dqb_curblocks * DEV_BSIZE; |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
494 *limit_r = (uint64_t)dqblk.dqb_bsoftlimit * DEV_BSIZE; |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
495 } else { |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
496 *value_r = dqblk.dqb_curinodes; |
7845
e4e9cc00d9ba
fs quota: message/inode values and limits were set wrong, except for Solaris
Timo Sirainen <tss@iki.fi>
parents:
7824
diff
changeset
|
497 *limit_r = dqblk.dqb_isoftlimit; |
6184
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
498 } |
6185 | 499 return 1; |
500 } | |
501 #endif | |
502 | |
7824
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
503 #ifdef FS_QUOTA_HPUX |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
504 static int |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
505 fs_quota_get_hpux(struct fs_quota_root *root, bool bytes, |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
506 uint64_t *value_r, uint64_t *limit_r) |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
507 { |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
508 struct dqblk dqblk; |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
509 |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
510 if (quotactl(Q_GETQUOTA, root->mount->device_path, |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
511 root->uid, &dqblk) < 0) { |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
512 if (errno == ESRCH) { |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
513 root->user_disabled = TRUE; |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
514 return 0; |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
515 } |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
516 i_error("quotactl(Q_GETQUOTA, %s) failed: %m", |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
517 root->mount->device_path); |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
518 return -1; |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
519 } |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
520 |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
521 if (bytes) { |
7848
a1fd8b29f629
HP-UX fs quota: Convert blocks to bytes using filesystem's actual block size
Timo Sirainen <tss@iki.fi>
parents:
7846
diff
changeset
|
522 *value_r = (uint64_t)dqblk.dqb_curblocks * |
a1fd8b29f629
HP-UX fs quota: Convert blocks to bytes using filesystem's actual block size
Timo Sirainen <tss@iki.fi>
parents:
7846
diff
changeset
|
523 root->mount->block_size; |
a1fd8b29f629
HP-UX fs quota: Convert blocks to bytes using filesystem's actual block size
Timo Sirainen <tss@iki.fi>
parents:
7846
diff
changeset
|
524 *limit_r = (uint64_t)dqblk.dqb_bsoftlimit * |
a1fd8b29f629
HP-UX fs quota: Convert blocks to bytes using filesystem's actual block size
Timo Sirainen <tss@iki.fi>
parents:
7846
diff
changeset
|
525 root->mount->block_size; |
7824
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
526 } else { |
7846
f4c53ad3610f
HP-UX: Fixed compiling problem in fs-quota.
Timo Sirainen <tss@iki.fi>
parents:
7845
diff
changeset
|
527 *value_r = dqblk.dqb_curfiles; |
f4c53ad3610f
HP-UX: Fixed compiling problem in fs-quota.
Timo Sirainen <tss@iki.fi>
parents:
7845
diff
changeset
|
528 *limit_r = dqblk.dqb_fsoftlimit; |
7824
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
529 } |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
530 return 1; |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
531 } |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
532 #endif |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
533 |
6185 | 534 #ifdef FS_QUOTA_SOLARIS |
535 static int | |
536 fs_quota_get_solaris(struct fs_quota_root *root, bool bytes, | |
537 uint64_t *value_r, uint64_t *limit_r) | |
538 { | |
539 struct dqblk dqblk; | |
540 struct quotctl ctl; | |
541 | |
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
|
542 if (root->mount->fd == -1) |
4063
f60237ad2edd
Support Solaris's ioctl(Q_QUOTACTL).
Timo Sirainen <tss@iki.fi>
parents:
4060
diff
changeset
|
543 return 0; |
f60237ad2edd
Support Solaris's ioctl(Q_QUOTACTL).
Timo Sirainen <tss@iki.fi>
parents:
4060
diff
changeset
|
544 |
f60237ad2edd
Support Solaris's ioctl(Q_QUOTACTL).
Timo Sirainen <tss@iki.fi>
parents:
4060
diff
changeset
|
545 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
|
546 ctl.uid = root->uid; |
4066 | 547 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
|
548 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
|
549 i_error("ioctl(%s, Q_QUOTACTL) failed: %m", root->mount->path); |
4063
f60237ad2edd
Support Solaris's ioctl(Q_QUOTACTL).
Timo Sirainen <tss@iki.fi>
parents:
4060
diff
changeset
|
550 return -1; |
f60237ad2edd
Support Solaris's ioctl(Q_QUOTACTL).
Timo Sirainen <tss@iki.fi>
parents:
4060
diff
changeset
|
551 } |
6184
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
552 if (bytes) { |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
553 *value_r = (uint64_t)dqblk.dqb_curblocks * DEV_BSIZE; |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
554 *limit_r = (uint64_t)dqblk.dqb_bsoftlimit * DEV_BSIZE; |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
555 } else { |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
556 *value_r = dqblk.dqb_curfiles; |
7845
e4e9cc00d9ba
fs quota: message/inode values and limits were set wrong, except for Solaris
Timo Sirainen <tss@iki.fi>
parents:
7824
diff
changeset
|
557 *limit_r = dqblk.dqb_fsoftlimit; |
6184
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
558 } |
6185 | 559 return 1; |
560 } | |
4063
f60237ad2edd
Support Solaris's ioctl(Q_QUOTACTL).
Timo Sirainen <tss@iki.fi>
parents:
4060
diff
changeset
|
561 #endif |
6185 | 562 |
563 static int | |
6186
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
564 fs_quota_get_one_resource(struct fs_quota_root *root, bool group, bool bytes, |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
565 uint64_t *value_r, uint64_t *limit_r) |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
566 { |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
567 if (group) { |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
568 if (root->group_disabled) |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
569 return 0; |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
570 } else { |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
571 if (root->user_disabled) |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
572 return 0; |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
573 } |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
574 #ifdef FS_QUOTA_LINUX |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
575 return fs_quota_get_linux(root, group, bytes, value_r, limit_r); |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
576 #elif defined (FS_QUOTA_BSDAIX) |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
577 return fs_quota_get_bsdaix(root, group, bytes, value_r, limit_r); |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
578 #else |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
579 if (group) { |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
580 /* not supported */ |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
581 return 0; |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
582 } |
7824
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
583 #ifdef FS_QUOTA_HPUX |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
584 return fs_quota_get_hpux(root, bytes, value_r, limit_r); |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
585 #else |
6186
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
586 return fs_quota_get_solaris(root, bytes, value_r, limit_r); |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
587 #endif |
7824
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
588 #endif |
6186
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
589 } |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
590 |
8029
796307638449
FS quota: Handle quota only for the quota roots which apply to the mailbox
Timo Sirainen <tss@iki.fi>
parents:
7848
diff
changeset
|
591 static bool fs_quota_match_box(struct quota_root *_root, struct mailbox *box) |
796307638449
FS quota: Handle quota only for the quota roots which apply to the mailbox
Timo Sirainen <tss@iki.fi>
parents:
7848
diff
changeset
|
592 { |
796307638449
FS quota: Handle quota only for the quota roots which apply to the mailbox
Timo Sirainen <tss@iki.fi>
parents:
7848
diff
changeset
|
593 struct fs_quota_root *root = (struct fs_quota_root *)_root; |
796307638449
FS quota: Handle quota only for the quota roots which apply to the mailbox
Timo Sirainen <tss@iki.fi>
parents:
7848
diff
changeset
|
594 struct stat mst, rst; |
796307638449
FS quota: Handle quota only for the quota roots which apply to the mailbox
Timo Sirainen <tss@iki.fi>
parents:
7848
diff
changeset
|
595 const char *mailbox_path; |
796307638449
FS quota: Handle quota only for the quota roots which apply to the mailbox
Timo Sirainen <tss@iki.fi>
parents:
7848
diff
changeset
|
596 bool is_file, match; |
796307638449
FS quota: Handle quota only for the quota roots which apply to the mailbox
Timo Sirainen <tss@iki.fi>
parents:
7848
diff
changeset
|
597 |
796307638449
FS quota: Handle quota only for the quota roots which apply to the mailbox
Timo Sirainen <tss@iki.fi>
parents:
7848
diff
changeset
|
598 mailbox_path = mail_storage_get_mailbox_path(box->storage, box->name, |
796307638449
FS quota: Handle quota only for the quota roots which apply to the mailbox
Timo Sirainen <tss@iki.fi>
parents:
7848
diff
changeset
|
599 &is_file); |
796307638449
FS quota: Handle quota only for the quota roots which apply to the mailbox
Timo Sirainen <tss@iki.fi>
parents:
7848
diff
changeset
|
600 if (stat(mailbox_path, &mst) < 0) { |
796307638449
FS quota: Handle quota only for the quota roots which apply to the mailbox
Timo Sirainen <tss@iki.fi>
parents:
7848
diff
changeset
|
601 if (errno != ENOENT) |
796307638449
FS quota: Handle quota only for the quota roots which apply to the mailbox
Timo Sirainen <tss@iki.fi>
parents:
7848
diff
changeset
|
602 i_error("stat(%s) failed: %m", mailbox_path); |
796307638449
FS quota: Handle quota only for the quota roots which apply to the mailbox
Timo Sirainen <tss@iki.fi>
parents:
7848
diff
changeset
|
603 return FALSE; |
796307638449
FS quota: Handle quota only for the quota roots which apply to the mailbox
Timo Sirainen <tss@iki.fi>
parents:
7848
diff
changeset
|
604 } |
796307638449
FS quota: Handle quota only for the quota roots which apply to the mailbox
Timo Sirainen <tss@iki.fi>
parents:
7848
diff
changeset
|
605 if (stat(root->storage_mount_path, &rst) < 0) { |
8030
7fdb5f222d95
Use quota->debug instead of getenv()ing it every time.
Timo Sirainen <tss@iki.fi>
parents:
8029
diff
changeset
|
606 if (_root->quota->debug) { |
8029
796307638449
FS quota: Handle quota only for the quota roots which apply to the mailbox
Timo Sirainen <tss@iki.fi>
parents:
7848
diff
changeset
|
607 i_error("stat(%s) failed: %m", |
796307638449
FS quota: Handle quota only for the quota roots which apply to the mailbox
Timo Sirainen <tss@iki.fi>
parents:
7848
diff
changeset
|
608 root->storage_mount_path); |
796307638449
FS quota: Handle quota only for the quota roots which apply to the mailbox
Timo Sirainen <tss@iki.fi>
parents:
7848
diff
changeset
|
609 } |
796307638449
FS quota: Handle quota only for the quota roots which apply to the mailbox
Timo Sirainen <tss@iki.fi>
parents:
7848
diff
changeset
|
610 return FALSE; |
796307638449
FS quota: Handle quota only for the quota roots which apply to the mailbox
Timo Sirainen <tss@iki.fi>
parents:
7848
diff
changeset
|
611 } |
796307638449
FS quota: Handle quota only for the quota roots which apply to the mailbox
Timo Sirainen <tss@iki.fi>
parents:
7848
diff
changeset
|
612 match = CMP_DEV_T(mst.st_dev, rst.st_dev); |
8030
7fdb5f222d95
Use quota->debug instead of getenv()ing it every time.
Timo Sirainen <tss@iki.fi>
parents:
8029
diff
changeset
|
613 if (_root->quota->debug) { |
8029
796307638449
FS quota: Handle quota only for the quota roots which apply to the mailbox
Timo Sirainen <tss@iki.fi>
parents:
7848
diff
changeset
|
614 i_info("box=%s mount=%s match=%s", mailbox_path, |
796307638449
FS quota: Handle quota only for the quota roots which apply to the mailbox
Timo Sirainen <tss@iki.fi>
parents:
7848
diff
changeset
|
615 root->storage_mount_path, match ? "yes" : "no"); |
796307638449
FS quota: Handle quota only for the quota roots which apply to the mailbox
Timo Sirainen <tss@iki.fi>
parents:
7848
diff
changeset
|
616 } |
796307638449
FS quota: Handle quota only for the quota roots which apply to the mailbox
Timo Sirainen <tss@iki.fi>
parents:
7848
diff
changeset
|
617 return match; |
796307638449
FS quota: Handle quota only for the quota roots which apply to the mailbox
Timo Sirainen <tss@iki.fi>
parents:
7848
diff
changeset
|
618 } |
796307638449
FS quota: Handle quota only for the quota roots which apply to the mailbox
Timo Sirainen <tss@iki.fi>
parents:
7848
diff
changeset
|
619 |
6186
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
620 static int |
6185 | 621 fs_quota_get_resource(struct quota_root *_root, const char *name, |
7294
9e4c26471b19
Relative (%) limits in quota rules and warnings work now if the backend
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
622 uint64_t *value_r) |
6185 | 623 { |
624 struct fs_quota_root *root = (struct fs_quota_root *)_root; | |
7294
9e4c26471b19
Relative (%) limits in quota rules and warnings work now if the backend
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
625 uint64_t limit = 0; |
6185 | 626 bool bytes; |
6186
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
627 int ret; |
6185 | 628 |
629 *value_r = 0; | |
630 | |
631 if (root->mount == NULL || | |
632 (strcasecmp(name, QUOTA_NAME_STORAGE_BYTES) != 0 && | |
633 strcasecmp(name, QUOTA_NAME_MESSAGES) != 0)) | |
634 return 0; | |
635 bytes = strcasecmp(name, QUOTA_NAME_STORAGE_BYTES) == 0; | |
636 | |
637 #ifdef HAVE_RQUOTA | |
638 if (strcmp(root->mount->type, "nfs") == 0) { | |
7226
e6693a0ec8e1
Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
639 T_BEGIN { |
7294
9e4c26471b19
Relative (%) limits in quota rules and warnings work now if the backend
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
640 ret = do_rquota(root, bytes, value_r, &limit); |
7226
e6693a0ec8e1
Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
641 } T_END; |
7294
9e4c26471b19
Relative (%) limits in quota rules and warnings work now if the backend
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
642 } else |
6185 | 643 #endif |
7294
9e4c26471b19
Relative (%) limits in quota rules and warnings work now if the backend
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
644 { |
9e4c26471b19
Relative (%) limits in quota rules and warnings work now if the backend
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
645 ret = fs_quota_get_one_resource(root, FALSE, bytes, |
9e4c26471b19
Relative (%) limits in quota rules and warnings work now if the backend
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
646 value_r, &limit); |
9e4c26471b19
Relative (%) limits in quota rules and warnings work now if the backend
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
647 if (ret == 0) { |
9e4c26471b19
Relative (%) limits in quota rules and warnings work now if the backend
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
648 /* fallback to group quota */ |
9e4c26471b19
Relative (%) limits in quota rules and warnings work now if the backend
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
649 ret = fs_quota_get_one_resource(root, TRUE, bytes, |
9e4c26471b19
Relative (%) limits in quota rules and warnings work now if the backend
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
650 value_r, &limit); |
9e4c26471b19
Relative (%) limits in quota rules and warnings work now if the backend
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
651 } |
9e4c26471b19
Relative (%) limits in quota rules and warnings work now if the backend
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
652 } |
9e4c26471b19
Relative (%) limits in quota rules and warnings work now if the backend
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
653 if (ret <= 0) |
6186
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
654 return ret; |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
655 |
7294
9e4c26471b19
Relative (%) limits in quota rules and warnings work now if the backend
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
656 /* update limit */ |
9e4c26471b19
Relative (%) limits in quota rules and warnings work now if the backend
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
657 if (bytes) |
9e4c26471b19
Relative (%) limits in quota rules and warnings work now if the backend
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
658 _root->default_rule.bytes_limit = limit; |
9e4c26471b19
Relative (%) limits in quota rules and warnings work now if the backend
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
659 else |
9e4c26471b19
Relative (%) limits in quota rules and warnings work now if the backend
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
660 _root->default_rule.count_limit = limit; |
9e4c26471b19
Relative (%) limits in quota rules and warnings work now if the backend
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
661 return 1; |
3751 | 662 } |
663 | |
4509
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
664 static int |
6411
6a64e64fa3a3
Renamed __attr_*__ to ATTR_*. Renamed __attrs_used__ to ATTRS_DEFINED.
Timo Sirainen <tss@iki.fi>
parents:
6204
diff
changeset
|
665 fs_quota_update(struct quota_root *root ATTR_UNUSED, |
6a64e64fa3a3
Renamed __attr_*__ to ATTR_*. Renamed __attrs_used__ to ATTRS_DEFINED.
Timo Sirainen <tss@iki.fi>
parents:
6204
diff
changeset
|
666 struct quota_transaction_context *ctx ATTR_UNUSED) |
3751 | 667 { |
668 return 0; | |
669 } | |
670 | |
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
|
671 struct quota_backend quota_backend_fs = { |
3751 | 672 "fs", |
673 | |
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
|
674 { |
4509
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
675 fs_quota_alloc, |
6201
4a8a19fea50d
Added user and group parameters which allow forcing user/group quota
Timo Sirainen <tss@iki.fi>
parents:
6186
diff
changeset
|
676 fs_quota_init, |
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
|
677 fs_quota_deinit, |
5704
4bf8438b497f
Allow backend-specific quota rules with backend=<string>.
Timo Sirainen <tss@iki.fi>
parents:
5174
diff
changeset
|
678 NULL, |
3751 | 679 |
4509
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
680 fs_quota_storage_added, |
3751 | 681 |
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
|
682 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
|
683 fs_quota_get_resource, |
8029
796307638449
FS quota: Handle quota only for the quota roots which apply to the mailbox
Timo Sirainen <tss@iki.fi>
parents:
7848
diff
changeset
|
684 fs_quota_update, |
796307638449
FS quota: Handle quota only for the quota roots which apply to the mailbox
Timo Sirainen <tss@iki.fi>
parents:
7848
diff
changeset
|
685 |
796307638449
FS quota: Handle quota only for the quota roots which apply to the mailbox
Timo Sirainen <tss@iki.fi>
parents:
7848
diff
changeset
|
686 fs_quota_match_box |
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
|
687 } |
3751 | 688 }; |
689 | |
690 #endif |