quota-fs.c revision 58c010e24d114004c411dba9b39f8e416e3712e6
/* Copyright (C) 2005-2006 Timo Sirainen */
/* Only for reporting filesystem quota */
#include "lib.h"
#include "array.h"
#include "str.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_STRUCT_DQBLK_CURSPACE
# define dqb_curblocks dqb_curspace
#endif
/* AIX doesn't have these defined */
#ifndef MNTTYPE_SWAP
# define MNTTYPE_SWAP "swap"
#endif
#ifndef MNTTYPE_IGNORE
# define MNTTYPE_IGNORE "ignore"
#endif
struct fs_quota_mountpoint {
char *mount_path;
char *device_path;
unsigned int blk_size;
#ifdef HAVE_Q_QUOTACTL
int fd;
char *path;
#endif
};
struct fs_quota_root {
struct quota_root root;
struct fs_quota_mountpoint *mount;
};
struct fs_quota_root_iter {
struct quota_root_iter iter;
bool sent;
};
extern struct quota_backend quota_backend_fs;
static struct quota_root *
{
struct fs_quota_root *root;
}
{
#ifdef HAVE_Q_QUOTACTL
}
#endif
}
{
}
{
struct fs_quota_mountpoint *mount;
#ifdef HAVE_STATFS_MNTFROMNAME
return NULL;
}
return mount;
#else
#ifdef HAVE_SYS_MNTTAB_H
#else
#endif
unsigned int blk_size;
FILE *f;
return NULL;
}
#ifdef HAVE_SYS_MNTTAB_H
if (f == NULL) {
return NULL;
}
continue;
break;
}
}
fclose(f);
#else
if (f == NULL) {
return NULL;
}
continue;
break;
}
}
endmntent(f);
#endif
if (device_path == NULL) {
i_info("fs quota: mount path for %s not found from %s",
}
return NULL;
}
return mount;
#endif
}
struct mail_storage *storage)
{
struct fs_quota_mountpoint *mount;
const char *dir;
bool is_file;
/* Not found */
return TRUE;
}
} else {
mount->mount_path) == 0;
if (!match) {
/* different mountpoints, can't use this */
return FALSE;
}
}
}
#ifdef HAVE_Q_QUOTACTL
}
#endif
return TRUE;
}
static void
{
}
static const char *const *
{
return resources;
}
static int
{
#ifdef HAVE_Q_QUOTACTL
#endif
*value_r = 0;
*limit_r = 0;
return 0;
#ifdef HAVE_QUOTACTL
i_error("quotactl(Q_GETQUOTA, %s) failed: %m",
return -1;
}
#else
/* Solaris */
return 0;
return -1;
}
#endif
return 1;
}
static int
const char *name __attr_unused__,
{
return -1;
}
static struct quota_root_transaction_context *
struct quota_transaction_context *ctx)
{
struct quota_root_transaction_context *root_ctx;
return root_ctx;
}
static int
{
return 0;
}
struct quota_backend quota_backend_fs = {
"fs",
{
}
};
#endif