Mercurial > dovecot > original-hg > dovecot-1.2
annotate src/plugins/quota/quota-fs.c @ 9432:439e14ff1467 HEAD
quota-fs: If mount=path isn't specified, don't fail with multiple quota roots.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 15 Oct 2009 13:51:00 -0400 |
parents | fe063e0d7109 |
children | 00cd9aacd03c |
rev | line source |
---|---|
8590
b9faf4db2a9f
Updated copyright notices to include year 2009.
Timo Sirainen <tss@iki.fi>
parents:
8096
diff
changeset
|
1 /* Copyright (c) 2005-2009 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; |
8039
ccf59801b63c
Solaris fs quota may have closed fd 0.
Timo Sirainen <tss@iki.fi>
parents:
8031
diff
changeset
|
163 #ifdef FS_QUOTA_SOLARIS |
ccf59801b63c
Solaris fs quota may have closed fd 0.
Timo Sirainen <tss@iki.fi>
parents:
8031
diff
changeset
|
164 mount->fd = -1; |
ccf59801b63c
Solaris fs quota may have closed fd 0.
Timo Sirainen <tss@iki.fi>
parents:
8031
diff
changeset
|
165 #endif |
8892
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
166 |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
167 if (strcmp(mount->type, "nfs") == 0) { |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
168 if (strchr(mount->device_path, ':') == NULL) { |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
169 i_error("quota-fs: %s is not a valid NFS device path", |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
170 mount->device_path); |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
171 fs_quota_mountpoint_free(mount); |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
172 return NULL; |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
173 } |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
174 } |
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
|
175 return mount; |
3751 | 176 } |
177 | |
6202
1b01ff0180a5
Removed autocreation of quota roots. Added mount=<path> parameter to map
Timo Sirainen <tss@iki.fi>
parents:
6201
diff
changeset
|
178 #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
|
179 ((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
|
180 ((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
|
181 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
|
182 |
4509
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
183 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
|
184 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
|
185 const struct fs_quota_mountpoint *mount) |
3751 | 186 { |
4509
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
187 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
|
188 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
|
189 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
|
190 |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
191 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
|
192 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
|
193 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
|
194 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
|
195 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
|
196 empty = root; |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
197 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
|
198 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
|
199 return root; |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
200 } |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
201 } |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
202 return empty; |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
203 } |
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
204 |
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
|
205 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
|
206 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
|
207 { |
6201
4a8a19fea50d
Added user and group parameters which allow forcing user/group quota
Timo Sirainen <tss@iki.fi>
parents:
6186
diff
changeset
|
208 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
|
209 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
|
210 |
6201
4a8a19fea50d
Added user and group parameters which allow forcing user/group quota
Timo Sirainen <tss@iki.fi>
parents:
6186
diff
changeset
|
211 #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
|
212 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
|
213 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
|
214 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
|
215 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
|
216 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
|
217 } |
4a8a19fea50d
Added user and group parameters which allow forcing user/group quota
Timo Sirainen <tss@iki.fi>
parents:
6186
diff
changeset
|
218 #endif |
4509
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
219 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
|
220 |
6201
4a8a19fea50d
Added user and group parameters which allow forcing user/group quota
Timo Sirainen <tss@iki.fi>
parents:
6186
diff
changeset
|
221 /* 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
|
222 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
|
223 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
|
224 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
|
225 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
|
226 mount->refcount++; |
1b01ff0180a5
Removed autocreation of quota roots. Added mount=<path> parameter to map
Timo Sirainen <tss@iki.fi>
parents:
6201
diff
changeset
|
227 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
|
228 } |
4063
f60237ad2edd
Support Solaris's ioctl(Q_QUOTACTL).
Timo Sirainen <tss@iki.fi>
parents:
4060
diff
changeset
|
229 } |
3751 | 230 } |
231 | |
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
|
232 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
|
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 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
|
235 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
|
236 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
|
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 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
|
239 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
|
240 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
|
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 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
|
243 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
|
244 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
|
245 |
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 mount = fs_quota_mountpoint_get(root->storage_mount_path); |
8031
be8550f51b02
fs quota: Don't crash if some mail storages are outside known mountpoints.
Timo Sirainen <tss@iki.fi>
parents:
8030
diff
changeset
|
247 if (mount != NULL) |
be8550f51b02
fs quota: Don't crash if some mail storages are outside known mountpoints.
Timo Sirainen <tss@iki.fi>
parents:
8030
diff
changeset
|
248 fs_quota_mount_init(root, mount); |
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
|
249 } |
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 } |
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 |
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 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
|
253 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
|
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 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
|
256 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
|
257 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
|
258 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
|
259 |
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 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
|
261 mount = fs_quota_mountpoint_get(dir); |
8031
be8550f51b02
fs quota: Don't crash if some mail storages are outside known mountpoints.
Timo Sirainen <tss@iki.fi>
parents:
8030
diff
changeset
|
262 if (mount != NULL) { |
8091
ceca59aaae89
quota-fs: compile fix for previous changes.
Timo Sirainen <tss@iki.fi>
parents:
8039
diff
changeset
|
263 if (quota->set->debug) { |
8031
be8550f51b02
fs quota: Don't crash if some mail storages are outside known mountpoints.
Timo Sirainen <tss@iki.fi>
parents:
8030
diff
changeset
|
264 i_info("fs quota add storage dir = %s", dir); |
be8550f51b02
fs quota: Don't crash if some mail storages are outside known mountpoints.
Timo Sirainen <tss@iki.fi>
parents:
8030
diff
changeset
|
265 i_info("fs quota block device = %s", mount->device_path); |
be8550f51b02
fs quota: Don't crash if some mail storages are outside known mountpoints.
Timo Sirainen <tss@iki.fi>
parents:
8030
diff
changeset
|
266 i_info("fs quota mount point = %s", mount->mount_path); |
be8550f51b02
fs quota: Don't crash if some mail storages are outside known mountpoints.
Timo Sirainen <tss@iki.fi>
parents:
8030
diff
changeset
|
267 } |
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
|
268 |
8031
be8550f51b02
fs quota: Don't crash if some mail storages are outside known mountpoints.
Timo Sirainen <tss@iki.fi>
parents:
8030
diff
changeset
|
269 root = fs_quota_root_find_mountpoint(quota, mount); |
be8550f51b02
fs quota: Don't crash if some mail storages are outside known mountpoints.
Timo Sirainen <tss@iki.fi>
parents:
8030
diff
changeset
|
270 if (root != NULL && root->mount == NULL) |
be8550f51b02
fs quota: Don't crash if some mail storages are outside known mountpoints.
Timo Sirainen <tss@iki.fi>
parents:
8030
diff
changeset
|
271 fs_quota_mount_init(root, mount); |
be8550f51b02
fs quota: Don't crash if some mail storages are outside known mountpoints.
Timo Sirainen <tss@iki.fi>
parents:
8030
diff
changeset
|
272 else |
be8550f51b02
fs quota: Don't crash if some mail storages are outside known mountpoints.
Timo Sirainen <tss@iki.fi>
parents:
8030
diff
changeset
|
273 fs_quota_mountpoint_free(mount); |
be8550f51b02
fs quota: Don't crash if some mail storages are outside known mountpoints.
Timo Sirainen <tss@iki.fi>
parents:
8030
diff
changeset
|
274 } |
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
|
275 |
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
|
276 /* 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
|
277 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
|
278 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
|
279 } |
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
|
280 |
3751 | 281 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
|
282 fs_quota_root_get_resources(struct quota_root *_root) |
3751 | 283 { |
6184
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
284 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
|
285 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
|
286 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
|
287 NULL |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
288 }; |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
289 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
|
290 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
|
291 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
|
292 NULL |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
293 }; |
3751 | 294 |
6184
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
295 return root->inode_per_mail ? resources_kb_messages : resources_kb; |
3751 | 296 } |
297 | |
6159
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
298 #ifdef HAVE_RQUOTA |
8892
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
299 static int do_rquota_user(struct fs_quota_root *root, bool bytes, |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
300 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
|
301 { |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
302 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
|
303 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
|
304 struct timeval timeout; |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
305 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
|
306 CLIENT *cl; |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
307 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
|
308 const char *host; |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
309 char *path; |
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 path = strchr(mount->device_path, ':'); |
8892
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
312 i_assert(path != NULL); |
6159
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
313 |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
314 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
|
315 path++; |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
316 |
8091
ceca59aaae89
quota-fs: compile fix for previous changes.
Timo Sirainen <tss@iki.fi>
parents:
8039
diff
changeset
|
317 if (root->root.quota->set->debug) { |
9045
1e9bb18eb439
quota-fs: Improved debug logging.
Timo Sirainen <tss@iki.fi>
parents:
8920
diff
changeset
|
318 i_info("quota-fs: host=%s, path=%s, uid=%s, %s", |
1e9bb18eb439
quota-fs: Improved debug logging.
Timo Sirainen <tss@iki.fi>
parents:
8920
diff
changeset
|
319 host, path, dec2str(root->uid), |
1e9bb18eb439
quota-fs: Improved debug logging.
Timo Sirainen <tss@iki.fi>
parents:
8920
diff
changeset
|
320 bytes ? "bytes" : "files"); |
6159
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
321 } |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
322 |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
323 /* 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
|
324 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
|
325 if (cl == NULL) { |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
326 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
|
327 host); |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
328 return -1; |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
329 } |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
330 |
6176
0f6d4f8dd587
Use authunix_create_default() with rquota. Patch by Steven Luo.
Timo Sirainen <tss@iki.fi>
parents:
6159
diff
changeset
|
331 /* Establish some RPC credentials */ |
0f6d4f8dd587
Use authunix_create_default() with rquota. Patch by Steven Luo.
Timo Sirainen <tss@iki.fi>
parents:
6159
diff
changeset
|
332 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
|
333 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
|
334 |
6159
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
335 /* 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
|
336 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
|
337 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
|
338 |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
339 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
|
340 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
|
341 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
|
342 (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
|
343 (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
|
344 timeout); |
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 /* 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
|
347 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
|
348 clnt_destroy(cl); |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
349 |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
350 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
|
351 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
|
352 |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
353 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
|
354 rpc_error_msg); |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
355 return -1; |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
356 } |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
357 |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
358 switch (result.status) { |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
359 case Q_OK: { |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
360 /* convert the results from blocks to bytes */ |
8892
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
361 const rquota *rq = &result.getquota_rslt_u.gqr_rquota; |
6159
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
362 |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
363 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
|
364 if (bytes) { |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
365 *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
|
366 (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
|
367 *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
|
368 (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
|
369 } else { |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
370 *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
|
371 *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
|
372 } |
6159
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
373 } |
8091
ceca59aaae89
quota-fs: compile fix for previous changes.
Timo Sirainen <tss@iki.fi>
parents:
8039
diff
changeset
|
374 if (root->root.quota->set->debug) { |
6159
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
375 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
|
376 "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
|
377 (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
|
378 (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
|
379 } |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
380 return 1; |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
381 } |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
382 case Q_NOQUOTA: |
8091
ceca59aaae89
quota-fs: compile fix for previous changes.
Timo Sirainen <tss@iki.fi>
parents:
8039
diff
changeset
|
383 if (root->root.quota->set->debug) { |
6159
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
384 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
|
385 dec2str(root->uid)); |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
386 } |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
387 return 1; |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
388 case Q_EPERM: |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
389 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
|
390 return -1; |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
391 default: |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
392 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
|
393 "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
|
394 return -1; |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
395 } |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
396 } |
8892
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
397 |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
398 static int do_rquota_group(struct fs_quota_root *root, bool bytes, |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
399 uint64_t *value_r, uint64_t *limit_r) |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
400 { |
8920
7bfbbfd2c32a
quota-fs: Compile fix for OSes without GRPQUOTA define.
Timo Sirainen <tss@iki.fi>
parents:
8892
diff
changeset
|
401 #if defined(EXT_RQUOTAVERS) && defined(GRPQUOTA) |
8892
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
402 struct getquota_rslt result; |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
403 ext_getquota_args args; |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
404 struct timeval timeout; |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
405 enum clnt_stat call_status; |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
406 CLIENT *cl; |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
407 struct fs_quota_mountpoint *mount = root->mount; |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
408 const char *host; |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
409 char *path; |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
410 |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
411 path = strchr(mount->device_path, ':'); |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
412 i_assert(path != NULL); |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
413 |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
414 host = t_strdup_until(mount->device_path, path); |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
415 path++; |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
416 |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
417 if (root->root.quota->set->debug) { |
9045
1e9bb18eb439
quota-fs: Improved debug logging.
Timo Sirainen <tss@iki.fi>
parents:
8920
diff
changeset
|
418 i_info("quota-fs: host=%s, path=%s, gid=%s, %s", |
1e9bb18eb439
quota-fs: Improved debug logging.
Timo Sirainen <tss@iki.fi>
parents:
8920
diff
changeset
|
419 host, path, dec2str(root->gid), |
1e9bb18eb439
quota-fs: Improved debug logging.
Timo Sirainen <tss@iki.fi>
parents:
8920
diff
changeset
|
420 bytes ? "bytes" : "files"); |
8892
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
421 } |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
422 |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
423 /* clnt_create() polls for a while to establish a connection */ |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
424 cl = clnt_create(host, RQUOTAPROG, EXT_RQUOTAVERS, "udp"); |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
425 if (cl == NULL) { |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
426 i_error("quota-fs: could not contact RPC service on %s (group)", |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
427 host); |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
428 return -1; |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
429 } |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
430 |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
431 /* Establish some RPC credentials */ |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
432 auth_destroy(cl->cl_auth); |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
433 cl->cl_auth = authunix_create_default(); |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
434 |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
435 /* make the rquota call on the remote host */ |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
436 args.gqa_pathp = path; |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
437 args.gqa_id = root->gid; |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
438 args.gqa_type = GRPQUOTA; |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
439 timeout.tv_sec = RQUOTA_GETQUOTA_TIMEOUT_SECS; |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
440 timeout.tv_usec = 0; |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
441 |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
442 call_status = clnt_call(cl, RQUOTAPROC_GETQUOTA, |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
443 (xdrproc_t)xdr_ext_getquota_args, (char *)&args, |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
444 (xdrproc_t)xdr_getquota_rslt, (char *)&result, |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
445 timeout); |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
446 |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
447 /* the result has been deserialized, let the client go */ |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
448 auth_destroy(cl->cl_auth); |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
449 clnt_destroy(cl); |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
450 |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
451 if (call_status != RPC_SUCCESS) { |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
452 const char *rpc_error_msg = clnt_sperrno(call_status); |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
453 |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
454 i_error("quota-fs: remote ext rquota call failed: %s", |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
455 rpc_error_msg); |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
456 return -1; |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
457 } |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
458 |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
459 switch (result.status) { |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
460 case Q_OK: { |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
461 /* convert the results from blocks to bytes */ |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
462 const rquota *rq = &result.getquota_rslt_u.gqr_rquota; |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
463 |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
464 if (rq->rq_active) { |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
465 if (bytes) { |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
466 *value_r = (uint64_t)rq->rq_curblocks * |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
467 (uint64_t)rq->rq_bsize; |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
468 *limit_r = (uint64_t)rq->rq_bsoftlimit * |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
469 (uint64_t)rq->rq_bsize; |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
470 } else { |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
471 *value_r = rq->rq_curfiles; |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
472 *limit_r = rq->rq_fsoftlimit; |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
473 } |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
474 } |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
475 if (root->root.quota->set->debug) { |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
476 i_info("quota-fs: gid=%s, value=%llu, " |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
477 "limit=%llu, active=%d", dec2str(root->gid), |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
478 (unsigned long long)*value_r, |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
479 (unsigned long long)*limit_r, rq->rq_active); |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
480 } |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
481 return 1; |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
482 } |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
483 case Q_NOQUOTA: |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
484 if (root->root.quota->set->debug) { |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
485 i_info("quota-fs: gid=%s, limit=unlimited", |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
486 dec2str(root->gid)); |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
487 } |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
488 return 1; |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
489 case Q_EPERM: |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
490 i_error("quota-fs: permission denied to ext rquota service"); |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
491 return -1; |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
492 default: |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
493 i_error("quota-fs: unrecognized status code (%d) " |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
494 "from ext rquota service", result.status); |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
495 return -1; |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
496 } |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
497 #else |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
498 i_error("quota-fs: rquota not compiled with group support"); |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
499 return -1; |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
500 #endif |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
501 } |
6159
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
502 #endif |
078d9dde99c8
Support for rquota with NFS mounts. Patch by HTK NetCommunication Oy.
Timo Sirainen <tss@iki.fi>
parents:
5704
diff
changeset
|
503 |
6186
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
504 #if defined(FS_QUOTA_LINUX) || defined(FS_QUOTA_BSDAIX) |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
505 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
|
506 { |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
507 if (group) |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
508 root->group_disabled = TRUE; |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
509 else |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
510 root->user_disabled = TRUE; |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
511 } |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
512 #endif |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
513 |
6185 | 514 #ifdef FS_QUOTA_LINUX |
3751 | 515 static int |
6186
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
516 fs_quota_get_linux(struct fs_quota_root *root, bool group, bool bytes, |
6185 | 517 uint64_t *value_r, uint64_t *limit_r) |
3751 | 518 { |
519 struct dqblk dqblk; | |
6186
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
520 int type, id; |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
521 |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
522 type = group ? GRPQUOTA : USRQUOTA; |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
523 id = group ? root->gid : root->uid; |
3751 | 524 |
4565
a54558861acc
Check for XFS quota also from xfs/xqm.h
Timo Sirainen <tss@iki.fi>
parents:
4552
diff
changeset
|
525 #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
|
526 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
|
527 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
|
528 |
6186
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
529 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
|
530 root->mount->device_path, |
6186
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
531 id, (caddr_t)&xdqblk) < 0) { |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
532 if (errno == ESRCH) { |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
533 fs_quota_root_disable(root, group); |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
534 return 0; |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
535 } |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
536 i_error("%d quotactl(Q_XGETQUOTA, %s) failed: %m", |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
537 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
|
538 return -1; |
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
539 } |
4448
cf334cc732e7
Attempting to fix quota block calculations to be correct.
Timo Sirainen <tss@iki.fi>
parents:
4387
diff
changeset
|
540 |
6184
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
541 if (bytes) { |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
542 /* 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
|
543 *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
|
544 *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
|
545 } else { |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
546 *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
|
547 *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
|
548 } |
4387
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
549 } else |
4192
26e028337e1e
quotactl() parameters were backwards for BSDs and AIX.
Timo Sirainen <tss@iki.fi>
parents:
4188
diff
changeset
|
550 #endif |
4387
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
551 { |
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
552 /* ext2, ext3 */ |
6186
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
553 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
|
554 root->mount->device_path, |
6186
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
555 id, (caddr_t)&dqblk) < 0) { |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
556 if (errno == ESRCH) { |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
557 fs_quota_root_disable(root, group); |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
558 return 0; |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
559 } |
4387
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
560 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
|
561 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
|
562 if (errno == EINVAL) { |
f598896bb40a
Added --with-linux-quota configure option to specify which Linux quota
Timo Sirainen <tss@iki.fi>
parents:
4514
diff
changeset
|
563 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
|
564 "v%d support, try changing it " |
9297
2910aba191ec
configure: Removed --with-linux-quota parameter.
Timo Sirainen <tss@iki.fi>
parents:
9192
diff
changeset
|
565 "(CPPFLAGS=-D_LINUX_QUOTA_VERSION=%d configure)", |
2910aba191ec
configure: Removed --with-linux-quota parameter.
Timo Sirainen <tss@iki.fi>
parents:
9192
diff
changeset
|
566 _LINUX_QUOTA_VERSION, |
2910aba191ec
configure: Removed --with-linux-quota parameter.
Timo Sirainen <tss@iki.fi>
parents:
9192
diff
changeset
|
567 _LINUX_QUOTA_VERSION == 1 ? 2 : 1); |
4530
f598896bb40a
Added --with-linux-quota configure option to specify which Linux quota
Timo Sirainen <tss@iki.fi>
parents:
4514
diff
changeset
|
568 } |
4387
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
569 return -1; |
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
570 } |
4448
cf334cc732e7
Attempting to fix quota block calculations to be correct.
Timo Sirainen <tss@iki.fi>
parents:
4387
diff
changeset
|
571 |
6184
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
572 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
|
573 #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
|
574 *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
|
575 #else |
6184
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
576 *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
|
577 #endif |
6184
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
578 *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
|
579 } else { |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
580 *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
|
581 *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
|
582 } |
4387
670dd15edbf3
Added support for XFS disk quotas. Patch by Pawel Jarosz
Timo Sirainen <tss@iki.fi>
parents:
4330
diff
changeset
|
583 } |
6185 | 584 return 1; |
585 } | |
586 #endif | |
587 | |
588 #ifdef FS_QUOTA_BSDAIX | |
589 static int | |
6186
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
590 fs_quota_get_bsdaix(struct fs_quota_root *root, bool group, bool bytes, |
6185 | 591 uint64_t *value_r, uint64_t *limit_r) |
592 { | |
593 struct dqblk dqblk; | |
6186
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
594 int type, id; |
6185 | 595 |
6186
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
596 type = group ? GRPQUOTA : USRQUOTA; |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
597 id = group ? root->gid : root->uid; |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
598 |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
599 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
|
600 id, (void *)&dqblk) < 0) { |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
601 if (errno == ESRCH) { |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
602 fs_quota_root_disable(root, group); |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
603 return 0; |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
604 } |
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
|
605 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
|
606 root->mount->mount_path); |
3751 | 607 return -1; |
608 } | |
6184
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
609 if (bytes) { |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
610 *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
|
611 *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
|
612 } else { |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
613 *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
|
614 *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
|
615 } |
6185 | 616 return 1; |
617 } | |
618 #endif | |
619 | |
7824
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
620 #ifdef FS_QUOTA_HPUX |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
621 static int |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
622 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
|
623 uint64_t *value_r, uint64_t *limit_r) |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
624 { |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
625 struct dqblk dqblk; |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
626 |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
627 if (quotactl(Q_GETQUOTA, root->mount->device_path, |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
628 root->uid, &dqblk) < 0) { |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
629 if (errno == ESRCH) { |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
630 root->user_disabled = TRUE; |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
631 return 0; |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
632 } |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
633 i_error("quotactl(Q_GETQUOTA, %s) failed: %m", |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
634 root->mount->device_path); |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
635 return -1; |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
636 } |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
637 |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
638 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
|
639 *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
|
640 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
|
641 *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
|
642 root->mount->block_size; |
7824
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
643 } else { |
7846
f4c53ad3610f
HP-UX: Fixed compiling problem in fs-quota.
Timo Sirainen <tss@iki.fi>
parents:
7845
diff
changeset
|
644 *value_r = dqblk.dqb_curfiles; |
f4c53ad3610f
HP-UX: Fixed compiling problem in fs-quota.
Timo Sirainen <tss@iki.fi>
parents:
7845
diff
changeset
|
645 *limit_r = dqblk.dqb_fsoftlimit; |
7824
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
646 } |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
647 return 1; |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
648 } |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
649 #endif |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
650 |
6185 | 651 #ifdef FS_QUOTA_SOLARIS |
652 static int | |
653 fs_quota_get_solaris(struct fs_quota_root *root, bool bytes, | |
654 uint64_t *value_r, uint64_t *limit_r) | |
655 { | |
656 struct dqblk dqblk; | |
657 struct quotctl ctl; | |
658 | |
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
|
659 if (root->mount->fd == -1) |
4063
f60237ad2edd
Support Solaris's ioctl(Q_QUOTACTL).
Timo Sirainen <tss@iki.fi>
parents:
4060
diff
changeset
|
660 return 0; |
f60237ad2edd
Support Solaris's ioctl(Q_QUOTACTL).
Timo Sirainen <tss@iki.fi>
parents:
4060
diff
changeset
|
661 |
f60237ad2edd
Support Solaris's ioctl(Q_QUOTACTL).
Timo Sirainen <tss@iki.fi>
parents:
4060
diff
changeset
|
662 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
|
663 ctl.uid = root->uid; |
4066 | 664 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
|
665 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
|
666 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
|
667 return -1; |
f60237ad2edd
Support Solaris's ioctl(Q_QUOTACTL).
Timo Sirainen <tss@iki.fi>
parents:
4060
diff
changeset
|
668 } |
6184
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
669 if (bytes) { |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
670 *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
|
671 *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
|
672 } else { |
cacb72a465c1
With maildir and cydir formats return inode limit as message count limit.
Timo Sirainen <tss@iki.fi>
parents:
6177
diff
changeset
|
673 *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
|
674 *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
|
675 } |
6185 | 676 return 1; |
677 } | |
4063
f60237ad2edd
Support Solaris's ioctl(Q_QUOTACTL).
Timo Sirainen <tss@iki.fi>
parents:
4060
diff
changeset
|
678 #endif |
6185 | 679 |
680 static int | |
6186
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
681 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
|
682 uint64_t *value_r, uint64_t *limit_r) |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
683 { |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
684 if (group) { |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
685 if (root->group_disabled) |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
686 return 0; |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
687 } else { |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
688 if (root->user_disabled) |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
689 return 0; |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
690 } |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
691 #ifdef FS_QUOTA_LINUX |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
692 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
|
693 #elif defined (FS_QUOTA_BSDAIX) |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
694 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
|
695 #else |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
696 if (group) { |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
697 /* not supported */ |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
698 return 0; |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
699 } |
7824
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
700 #ifdef FS_QUOTA_HPUX |
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
701 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
|
702 #else |
6186
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
703 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
|
704 #endif |
7824
c0ff3c147375
HP-UX: Fixed quota-fs compiling.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
705 #endif |
6186
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
706 } |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
707 |
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
|
708 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
|
709 { |
796307638449
FS quota: Handle quota only for the quota roots which apply to the mailbox
Timo Sirainen <tss@iki.fi>
parents:
7848
diff
changeset
|
710 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
|
711 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
|
712 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
|
713 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
|
714 |
9432
439e14ff1467
quota-fs: If mount=path isn't specified, don't fail with multiple quota roots.
Timo Sirainen <tss@iki.fi>
parents:
9380
diff
changeset
|
715 if (root->storage_mount_path == NULL) |
439e14ff1467
quota-fs: If mount=path isn't specified, don't fail with multiple quota roots.
Timo Sirainen <tss@iki.fi>
parents:
9380
diff
changeset
|
716 return TRUE; |
439e14ff1467
quota-fs: If mount=path isn't specified, don't fail with multiple quota roots.
Timo Sirainen <tss@iki.fi>
parents:
9380
diff
changeset
|
717 |
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
|
718 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
|
719 &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
|
720 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
|
721 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
|
722 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
|
723 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
|
724 } |
796307638449
FS quota: Handle quota only for the quota roots which apply to the mailbox
Timo Sirainen <tss@iki.fi>
parents:
7848
diff
changeset
|
725 if (stat(root->storage_mount_path, &rst) < 0) { |
8091
ceca59aaae89
quota-fs: compile fix for previous changes.
Timo Sirainen <tss@iki.fi>
parents:
8039
diff
changeset
|
726 if (_root->quota->set->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
|
727 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
|
728 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
|
729 } |
796307638449
FS quota: Handle quota only for the quota roots which apply to the mailbox
Timo Sirainen <tss@iki.fi>
parents:
7848
diff
changeset
|
730 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
|
731 } |
796307638449
FS quota: Handle quota only for the quota roots which apply to the mailbox
Timo Sirainen <tss@iki.fi>
parents:
7848
diff
changeset
|
732 match = CMP_DEV_T(mst.st_dev, rst.st_dev); |
8091
ceca59aaae89
quota-fs: compile fix for previous changes.
Timo Sirainen <tss@iki.fi>
parents:
8039
diff
changeset
|
733 if (_root->quota->set->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
|
734 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
|
735 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
|
736 } |
796307638449
FS quota: Handle quota only for the quota roots which apply to the mailbox
Timo Sirainen <tss@iki.fi>
parents:
7848
diff
changeset
|
737 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
|
738 } |
796307638449
FS quota: Handle quota only for the quota roots which apply to the mailbox
Timo Sirainen <tss@iki.fi>
parents:
7848
diff
changeset
|
739 |
6186
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
740 static int |
6185 | 741 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
|
742 uint64_t *value_r) |
6185 | 743 { |
744 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
|
745 uint64_t limit = 0; |
6185 | 746 bool bytes; |
6186
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
747 int ret; |
6185 | 748 |
749 *value_r = 0; | |
750 | |
751 if (root->mount == NULL || | |
752 (strcasecmp(name, QUOTA_NAME_STORAGE_BYTES) != 0 && | |
753 strcasecmp(name, QUOTA_NAME_MESSAGES) != 0)) | |
754 return 0; | |
755 bytes = strcasecmp(name, QUOTA_NAME_STORAGE_BYTES) == 0; | |
756 | |
757 #ifdef HAVE_RQUOTA | |
758 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
|
759 T_BEGIN { |
9192
534de78dbe84
quota-fs: Default to user quota with NFS, not group quota.
Timo Sirainen <tss@iki.fi>
parents:
9045
diff
changeset
|
760 ret = !root->user_disabled ? |
8892
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
761 do_rquota_user(root, bytes, value_r, &limit) : |
66a8cbe7f007
quota-fs: Added support for NFS group quota.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
762 do_rquota_group(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
|
763 } 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
|
764 } else |
6185 | 765 #endif |
7294
9e4c26471b19
Relative (%) limits in quota rules and warnings work now if the backend
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
766 { |
9e4c26471b19
Relative (%) limits in quota rules and warnings work now if the backend
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
767 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
|
768 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
|
769 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
|
770 /* 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
|
771 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
|
772 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
|
773 } |
9e4c26471b19
Relative (%) limits in quota rules and warnings work now if the backend
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
774 } |
9e4c26471b19
Relative (%) limits in quota rules and warnings work now if the backend
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
775 if (ret <= 0) |
6186
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
776 return ret; |
9a3a7ad297cf
Added support for group quotas.
Timo Sirainen <tss@iki.fi>
parents:
6185
diff
changeset
|
777 |
7294
9e4c26471b19
Relative (%) limits in quota rules and warnings work now if the backend
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
778 /* update limit */ |
9e4c26471b19
Relative (%) limits in quota rules and warnings work now if the backend
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
779 if (bytes) |
8096
f35a8a3dc06d
Fixed FS quota compiling and Maildir++ quota with multiple users.
Timo Sirainen <tss@iki.fi>
parents:
8091
diff
changeset
|
780 _root->bytes_limit = limit; |
7294
9e4c26471b19
Relative (%) limits in quota rules and warnings work now if the backend
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
781 else |
8096
f35a8a3dc06d
Fixed FS quota compiling and Maildir++ quota with multiple users.
Timo Sirainen <tss@iki.fi>
parents:
8091
diff
changeset
|
782 _root->count_limit = limit; |
7294
9e4c26471b19
Relative (%) limits in quota rules and warnings work now if the backend
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
783 return 1; |
3751 | 784 } |
785 | |
4509
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
786 static int |
6411
6a64e64fa3a3
Renamed __attr_*__ to ATTR_*. Renamed __attrs_used__ to ATTRS_DEFINED.
Timo Sirainen <tss@iki.fi>
parents:
6204
diff
changeset
|
787 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
|
788 struct quota_transaction_context *ctx ATTR_UNUSED) |
3751 | 789 { |
790 return 0; | |
791 } | |
792 | |
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
|
793 struct quota_backend quota_backend_fs = { |
3751 | 794 "fs", |
795 | |
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
|
796 { |
4509
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
797 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
|
798 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
|
799 fs_quota_deinit, |
5704
4bf8438b497f
Allow backend-specific quota rules with backend=<string>.
Timo Sirainen <tss@iki.fi>
parents:
5174
diff
changeset
|
800 NULL, |
9380
fe063e0d7109
maildir quota: Limits weren't read early enough from maildirsize file.
Timo Sirainen <tss@iki.fi>
parents:
9297
diff
changeset
|
801 NULL, |
3751 | 802 |
4509
e5e79558ac2d
Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4468
diff
changeset
|
803 fs_quota_storage_added, |
3751 | 804 |
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
|
805 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
|
806 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
|
807 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
|
808 |
796307638449
FS quota: Handle quota only for the quota roots which apply to the mailbox
Timo Sirainen <tss@iki.fi>
parents:
7848
diff
changeset
|
809 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
|
810 } |
3751 | 811 }; |
812 | |
813 #endif |