quota-fs.c revision 5e4c116a411967f1a012ac4f79732a724b5f6cc1
/* Copyright (C) 2005-2006 Timo Sirainen */
/* Only for reporting filesystem quota */
#include "lib.h"
#include "array.h"
#include "str.h"
#include "mountpoint.h"
#include "quota-private.h"
#include "quota-fs.h"
#ifdef HAVE_FS_QUOTA
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#ifdef HAVE_LINUX_DQBLK_XFS_H
# include <linux/dqblk_xfs.h>
# define HAVE_XFS_QUOTA
#elif defined (HAVE_XFS_XQM_H)
# define HAVE_XFS_QUOTA
#endif
#ifndef DEV_BSIZE
# define DEV_BSIZE 512
#endif
#ifdef HAVE_STRUCT_DQBLK_CURSPACE
# define dqb_curblocks dqb_curspace
#endif
it supports only v1 quota */
#ifndef _LINUX_QUOTA_VERSION
# define _LINUX_QUOTA_VERSION 1
#endif
struct fs_quota_mountpoint {
char *mount_path;
char *device_path;
char *type;
#ifdef HAVE_Q_QUOTACTL
int fd;
char *path;
#endif
};
struct fs_quota_root {
struct quota_root root;
struct fs_quota_mountpoint *mount;
};
extern struct quota_backend quota_backend_fs;
static struct quota_root *fs_quota_alloc(void)
{
struct fs_quota_root *root;
}
{
#ifdef HAVE_Q_QUOTACTL
}
#endif
}
{
}
{
struct fs_quota_mountpoint *mount;
struct mountpoint point;
int ret;
if (ret <= 0)
return NULL;
return mount;
}
static struct fs_quota_root *
const struct fs_quota_mountpoint *mount)
{
struct quota_root *const *roots;
unsigned int i, count;
for (i = 0; i < count; i++) {
struct fs_quota_root *root =
(struct fs_quota_root *)roots[i];
mount->mount_path) == 0)
return root;
}
}
return empty;
}
struct mail_storage *storage)
{
struct fs_quota_mountpoint *mount;
struct quota_root *_root;
struct fs_quota_root *root;
const char *dir;
bool is_file;
}
/* already exists */
return;
}
/* create a new root for this mountpoint */
} else {
/* this is the default root. */
}
#ifdef HAVE_Q_QUOTACTL
}
#endif
}
static const char *const *
{
return resources;
}
static int
{
#ifdef HAVE_Q_QUOTACTL
#endif
*value_r = 0;
*limit_r = 0;
return 0;
#if defined (HAVE_QUOTACTL) && defined(HAVE_SYS_QUOTA_H)
/* Linux */
#ifdef HAVE_XFS_QUOTA
/* XFS */
struct fs_disk_quota xdqblk;
i_error("quotactl(Q_XGETQUOTA, %s) failed: %m",
return -1;
}
/* values always returned in 512 byte blocks */
} else
#endif
{
/* ext2, ext3 */
i_error("quotactl(Q_GETQUOTA, %s) failed: %m",
i_error("Dovecot was compiled with Linux quota "
"v%d support, try changing it "
"(--with-linux-quota configure option)",
}
return -1;
}
}
#elif defined(HAVE_QUOTACTL)
/* BSD, AIX */
i_error("quotactl(Q_GETQUOTA, %s) failed: %m",
return -1;
}
#else
/* Solaris */
return 0;
return -1;
}
#endif
return 1;
}
static int
{
return 0;
}
struct quota_backend quota_backend_fs = {
"fs",
{
NULL,
}
};
#endif