dovecot-2.2: quota-fs: Support NetBSD 6.0 libquota.
dovecot at dovecot.org
dovecot at dovecot.org
Fri Feb 22 16:03:11 EET 2013
details: http://hg.dovecot.org/dovecot-2.2/rev/b3f890c4a41c
changeset: 15894:b3f890c4a41c
user: Timo Sirainen <tss at iki.fi>
date: Fri Feb 22 16:03:00 2013 +0200
description:
quota-fs: Support NetBSD 6.0 libquota.
Patch by Emmanuel Dreyfus.
diffstat:
configure.ac | 10 ++++++++-
src/plugins/quota/Makefile.am | 4 ++-
src/plugins/quota/quota-fs.c | 46 ++++++++++++++++++++++++++++++++++++++++++-
src/plugins/quota/quota-fs.h | 10 +++++++++
4 files changed, 67 insertions(+), 3 deletions(-)
diffs (150 lines):
diff -r bf817bc963f7 -r b3f890c4a41c configure.ac
--- a/configure.ac Fri Feb 22 15:34:59 2013 +0200
+++ b/configure.ac Fri Feb 22 16:03:00 2013 +0200
@@ -299,7 +299,8 @@
AC_CHECK_HEADERS(strings.h stdint.h unistd.h dirent.h malloc.h inttypes.h \
sys/uio.h sys/sysmacros.h sys/resource.h sys/select.h libgen.h \
- sys/quota.h sys/fs/ufs_quota.h ufs/ufs/quota.h jfs/quota.h sys/fs/quota_common.h \
+ sys/quota.h sys/fs/ufs_quota.h ufs/ufs/quota.h jfs/quota.h \
+ quota.h sys/fs/quota_common.h \
mntent.h sys/mnttab.h sys/event.h sys/time.h sys/mkdev.h linux/dqblk_xfs.h \
xfs/xqm.h execinfo.h ucontext.h malloc_np.h sys/utsname.h sys/vmount.h \
sys/utsname.h glob.h linux/falloc.h ucred.h sys/ucred.h)
@@ -2633,6 +2634,13 @@
fi
AM_CONDITIONAL(HAVE_RQUOTA, test "$have_rquota" = "yes")
+QUOTA_LIBS=""
+AC_SEARCH_LIBS(quota_open, quota, [
+ AC_DEFINE(HAVE_QUOTA_OPEN,, Define if you have quota_open())
+ QUOTA_LIBS="-lquota"
+])
+AC_SUBST(QUOTA_LIBS)
+
dnl
dnl ** Full text search
dnl
diff -r bf817bc963f7 -r b3f890c4a41c src/plugins/quota/Makefile.am
--- a/src/plugins/quota/Makefile.am Fri Feb 22 15:34:59 2013 +0200
+++ b/src/plugins/quota/Makefile.am Fri Feb 22 16:03:00 2013 +0200
@@ -43,6 +43,7 @@
lib10_quota_plugin_la_SOURCES = $(quota_dist_sources)
nodist_lib10_quota_plugin_la_SOURCES = $(RQUOTA_XDR)
+lib10_quota_plugin_la_LIBADD = $(QUOTA_LIBS)
doveadm_module_LTLIBRARIES = \
lib10_doveadm_quota_plugin.la
@@ -57,7 +58,8 @@
$(quota_common_objects) \
$(LIBDOVECOT_STORAGE) \
$(LIBDOVECOT) \
- $(MODULE_LIBS)
+ $(MODULE_LIBS) \
+ $(QUOTA_LIBS)
quota_status_DEPENDENCIES = \
$(quota_common_objects) \
$(LIBDOVECOT_STORAGE_DEPS) \
diff -r bf817bc963f7 -r b3f890c4a41c src/plugins/quota/quota-fs.c
--- a/src/plugins/quota/quota-fs.c Fri Feb 22 15:34:59 2013 +0200
+++ b/src/plugins/quota/quota-fs.c Fri Feb 22 16:03:00 2013 +0200
@@ -77,6 +77,9 @@
unsigned int inode_per_mail:1;
unsigned int user_disabled:1;
unsigned int group_disabled:1;
+#ifdef FS_QUOTA_NETBSD
+ struct quotahandle *qh;
+#endif
};
extern struct quota_backend quota_backend_fs;
@@ -527,7 +530,8 @@
}
#endif
-#if defined(FS_QUOTA_LINUX) || defined(FS_QUOTA_BSDAIX)
+#if defined(FS_QUOTA_LINUX) || defined(FS_QUOTA_BSDAIX) || \
+ defined(FS_QUOTA_NETBSD)
static void fs_quota_root_disable(struct fs_quota_root *root, bool group)
{
if (group)
@@ -661,6 +665,44 @@
}
#endif
+#ifdef FS_QUOTA_NETBSD
+static int
+fs_quota_get_netbsd(struct fs_quota_root *root, bool group, bool bytes,
+ uint64_t *value_r, uint64_t *limit_r)
+{
+ struct quotakey qk;
+ struct quotaval qv;
+
+ if (root->qh == NULL) {
+ if ((root->qh = quota_open(root->mount->mount_path)) == NULL) {
+ i_error("cannot open quota for %s: %m",
+ root->mount->mount_path);
+ fs_quota_root_disable(root, group);
+ return 0;
+ }
+ }
+
+ qk.qk_idtype = group ? QUOTA_IDTYPE_GROUP : QUOTA_IDTYPE_USER;
+ qk.qk_id = group ? root->gid : root->uid;
+ qk.qk_objtype = bytes ? QUOTA_OBJTYPE_BLOCKS : QUOTA_OBJTYPE_FILES;
+
+ if (quota_get(root->qh, &qk, &qv) != 0) {
+ if (errno == ESRCH) {
+ fs_quota_root_disable(root, group);
+ return 0;
+ }
+ i_error("quotactl(Q_GETQUOTA, %s) failed: %m",
+ root->mount->mount_path);
+ return -1;
+ }
+
+ *value_r = qv.qv_usage * DEV_BSIZE;
+ *limit_r = qv.qv_softlimit * DEV_BSIZE;
+
+ return 1;
+}
+#endif
+
#ifdef FS_QUOTA_HPUX
static int
fs_quota_get_hpux(struct fs_quota_root *root, bool bytes,
@@ -747,6 +789,8 @@
}
#ifdef FS_QUOTA_LINUX
return fs_quota_get_linux(root, group, bytes, value_r, limit_r);
+#elif defined (FS_QUOTA_NETBSD)
+ return fs_quota_get_netbsd(root, group, bytes, value_r, limit_r);
#elif defined (FS_QUOTA_BSDAIX)
return fs_quota_get_bsdaix(root, group, bytes, value_r, limit_r);
#else
diff -r bf817bc963f7 -r b3f890c4a41c src/plugins/quota/quota-fs.h
--- a/src/plugins/quota/quota-fs.h Fri Feb 22 15:34:59 2013 +0200
+++ b/src/plugins/quota/quota-fs.h Fri Feb 22 16:03:00 2013 +0200
@@ -6,6 +6,10 @@
# define HAVE_FS_QUOTA
#endif
+#ifdef HAVE_QUOTA_OPEN
+# include <quota.h> /* NetBSD with libquota */
+#endif
+
#ifdef HAVE_SYS_QUOTA_H
# include <sys/quota.h> /* Linux, HP-UX */
#elif defined(HAVE_SYS_FS_UFS_QUOTA_H)
@@ -37,4 +41,10 @@
# undef HAVE_FS_QUOTA
#endif
+#ifdef HAVE_QUOTA_OPEN /* NetBSD with libquota */
+# define FS_QUOTA_NETBSD
+# define HAVE_FS_QUOTA
+# undef FS_QUOTA_LINUX /* obtained because we also have <sys/quota.h> */
#endif
+
+#endif
More information about the dovecot-cvs
mailing list