More Makefile cleanups, otherwise mainly noticeable are the netfilter fix
[davej-history.git] / include / linux / quotaops.h
blob8dea93d1aae0d467dd37a2b6c4fb439de6c6a1a9
1 /*
2 * Definitions for diskquota-operations. When diskquota is configured these
3 * macros expand to the right source-code.
5 * Author: Marco van Wieringen <mvw@planets.elm.net>
7 * Version: $Id: quotaops.h,v 1.2 1998/01/15 16:22:26 ecd Exp $
9 */
10 #ifndef _LINUX_QUOTAOPS_
11 #define _LINUX_QUOTAOPS_
13 #include <linux/config.h>
15 #if defined(CONFIG_QUOTA)
17 #include <linux/smp_lock.h>
20 * declaration of quota_function calls in kernel.
22 extern void dquot_initialize(struct inode *inode, short type);
23 extern void dquot_drop(struct inode *inode);
24 extern void invalidate_dquots(kdev_t dev, short type);
25 extern int quota_off(struct super_block *sb, short type);
26 extern int sync_dquots(kdev_t dev, short type);
28 extern int dquot_alloc_block(const struct inode *inode, unsigned long number, char prealloc);
29 extern int dquot_alloc_inode(const struct inode *inode, unsigned long number);
31 extern void dquot_free_block(const struct inode *inode, unsigned long number);
32 extern void dquot_free_inode(const struct inode *inode, unsigned long number);
34 extern int dquot_transfer(struct dentry *dentry, struct iattr *iattr);
37 * Operations supported for diskquotas.
39 extern __inline__ void DQUOT_INIT(struct inode *inode)
41 if (inode->i_sb && inode->i_sb->dq_op)
42 inode->i_sb->dq_op->initialize(inode, -1);
45 extern __inline__ void DQUOT_DROP(struct inode *inode)
47 if (IS_QUOTAINIT(inode)) {
48 if (inode->i_sb && inode->i_sb->dq_op)
49 inode->i_sb->dq_op->drop(inode);
53 extern __inline__ int DQUOT_PREALLOC_BLOCK(struct super_block *sb, const struct inode *inode, int nr)
55 if (sb->dq_op) {
56 if (sb->dq_op->alloc_block(inode, fs_to_dq_blocks(nr, sb->s_blocksize), 1) == NO_QUOTA)
57 return 1;
59 return 0;
62 extern __inline__ int DQUOT_ALLOC_BLOCK(struct super_block *sb, const struct inode *inode, int nr)
64 if (sb->dq_op) {
65 if (sb->dq_op->alloc_block(inode, fs_to_dq_blocks(nr, sb->s_blocksize), 0) == NO_QUOTA)
66 return 1;
68 return 0;
71 extern __inline__ int DQUOT_ALLOC_INODE(struct super_block *sb, struct inode *inode)
73 if (sb->dq_op) {
74 sb->dq_op->initialize (inode, -1);
75 if (sb->dq_op->alloc_inode (inode, 1))
76 return 1;
78 inode->i_flags |= S_QUOTA;
79 return 0;
82 extern __inline__ void DQUOT_FREE_BLOCK(struct super_block *sb, const struct inode *inode, int nr)
84 if (sb->dq_op)
85 sb->dq_op->free_block(inode, fs_to_dq_blocks(nr, sb->s_blocksize));
88 extern __inline__ void DQUOT_FREE_INODE(struct super_block *sb, struct inode *inode)
90 if (sb->dq_op)
91 sb->dq_op->free_inode(inode, 1);
94 extern __inline__ int DQUOT_TRANSFER(struct dentry *dentry, struct iattr *iattr)
96 int error = -EDQUOT;
98 if (dentry->d_inode->i_sb->dq_op) {
99 dentry->d_inode->i_sb->dq_op->initialize(dentry->d_inode, -1);
100 error = dentry->d_inode->i_sb->dq_op->transfer(dentry, iattr);
101 } else {
102 error = notify_change(dentry, iattr);
104 return error;
107 #define DQUOT_SYNC(dev) sync_dquots(dev, -1)
108 #define DQUOT_OFF(sb) quota_off(sb, -1)
110 #else
113 * NO-OP when quota not configured.
115 #define DQUOT_INIT(inode) do { } while(0)
116 #define DQUOT_DROP(inode) do { } while(0)
117 #define DQUOT_PREALLOC_BLOCK(sb, inode, nr) (0)
118 #define DQUOT_ALLOC_BLOCK(sb, inode, nr) (0)
119 #define DQUOT_ALLOC_INODE(sb, inode) (0)
120 #define DQUOT_FREE_BLOCK(sb, inode, nr) do { } while(0)
121 #define DQUOT_FREE_INODE(sb, inode) do { } while(0)
122 #define DQUOT_SYNC(dev) do { } while(0)
123 #define DQUOT_OFF(sb) do { } while(0)
126 * Special case expands to a simple notify_change.
128 #define DQUOT_TRANSFER(dentry, iattr) notify_change(dentry, iattr)
130 #endif /* CONFIG_QUOTA */
131 #endif /* _LINUX_QUOTAOPS_ */