File: quotaio_meta.c

package info (click to toggle)
quota 4.00~pre1-6
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 2,460 kB
  • ctags: 1,264
  • sloc: ansic: 10,845; sh: 614; perl: 333; makefile: 193
file content (61 lines) | stat: -rw-r--r-- 1,283 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
 *	Implementation of handling of quotafiles which are hidden
 *
 *	Jan Kara <jack@suse.cz>
 */

#include "config.h"

#include <string.h>
#include <stdlib.h>

#include <sys/types.h>

#include "pot.h"
#include "common.h"
#include "quotasys.h"
#include "quotaio_generic.h"

static int meta_init_io(struct quota_handle *h)
{
	if (!QIO_ENABLED(h)) {
		errstr(_("Metadata init_io called when kernel support is not enabled.\n"));
		return -1;
	}
	if (kernel_iface != IFACE_GENERIC) {
		errstr(_("Metadata init_io called when kernel does not support generic quota interface!\n"));
		return -1;
	}
	return vfs_get_info(h);
}

static int meta_write_info(struct quota_handle *h)
{
	return vfs_set_info(h, IIF_BGRACE | IIF_IGRACE);
}

static struct dquot *meta_read_dquot(struct quota_handle *h, qid_t id)
{
	struct dquot *dquot = get_empty_dquot();

	dquot->dq_id = id;
	dquot->dq_h = h;
	memset(&dquot->dq_dqb, 0, sizeof(struct util_dqblk));
	if (vfs_get_dquot(dquot) < 0) {
		free(dquot);
		return NULL;
	}
	return dquot;
}

static int meta_commit_dquot(struct dquot *dquot, int flags)
{
	return vfs_set_dquot(dquot, flags);
}

struct quotafile_ops quotafile_ops_meta = {
init_io:	meta_init_io,
write_info:	meta_write_info,
read_dquot:	meta_read_dquot,
commit_dquot:	meta_commit_dquot,
};