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 $
10 #ifndef _LINUX_QUOTAOPS_
11 #define _LINUX_QUOTAOPS_
13 #include <linux/config.h>
15 #if defined(CONFIG_QUOTA)
18 * declaration of quota_function calls in kernel.
20 extern void dquot_initialize(struct inode
*inode
, short type
);
21 extern void dquot_drop(struct inode
*inode
);
22 extern void invalidate_dquots(kdev_t dev
, short type
);
23 extern int quota_off(kdev_t dev
, short type
);
24 extern int sync_dquots(kdev_t dev
, short type
);
26 extern int dquot_alloc_block(const struct inode
*inode
, unsigned long number
,
27 uid_t initiator
, char warn
);
28 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 inode
*inode
, struct iattr
*iattr
,
35 char direction
, uid_t initiator
);
38 * Operations supported for diskquotas.
40 extern __inline__
void DQUOT_INIT(struct inode
*inode
)
42 if (inode
->i_sb
&& inode
->i_sb
->dq_op
)
43 inode
->i_sb
->dq_op
->initialize(inode
, -1);
46 extern __inline__
void DQUOT_DROP(struct inode
*inode
)
48 if (IS_QUOTAINIT(inode
)) {
49 if (inode
->i_sb
&& inode
->i_sb
->dq_op
)
50 inode
->i_sb
->dq_op
->drop(inode
);
54 extern __inline__
int DQUOT_PREALLOC_BLOCK(struct super_block
*sb
, const struct inode
*inode
, int nr
)
57 if (sb
->dq_op
->alloc_block(inode
, fs_to_dq_blocks(nr
, sb
->s_blocksize
),
58 current
->fsuid
, 0) == NO_QUOTA
)
64 extern __inline__
int DQUOT_ALLOC_BLOCK(struct super_block
*sb
, const struct inode
*inode
, int nr
)
67 if (sb
->dq_op
->alloc_block(inode
, fs_to_dq_blocks(nr
, sb
->s_blocksize
),
68 current
->fsuid
, 1) == NO_QUOTA
)
74 extern __inline__
int DQUOT_ALLOC_INODE(struct super_block
*sb
, struct inode
*inode
)
77 sb
->dq_op
->initialize (inode
, -1);
78 if (sb
->dq_op
->alloc_inode (inode
, 1, current
->fsuid
))
81 inode
->i_flags
|= S_QUOTA
;
85 extern __inline__
void DQUOT_FREE_BLOCK(struct super_block
*sb
, const struct inode
*inode
, int nr
)
88 sb
->dq_op
->free_block(inode
, fs_to_dq_blocks(nr
, sb
->s_blocksize
));
91 extern __inline__
void DQUOT_FREE_INODE(struct super_block
*sb
, struct inode
*inode
)
94 sb
->dq_op
->free_inode(inode
, 1);
97 extern __inline__
int DQUOT_TRANSFER(struct dentry
*dentry
, struct iattr
*iattr
)
101 if (dentry
->d_inode
->i_sb
->dq_op
) {
102 if (IS_QUOTAINIT(dentry
->d_inode
) == 0)
103 dentry
->d_inode
->i_sb
->dq_op
->initialize(dentry
->d_inode
, -1);
104 if (dentry
->d_inode
->i_sb
->dq_op
->transfer(dentry
->d_inode
, iattr
, 0, current
->fsuid
))
106 error
= notify_change(dentry
, iattr
);
108 dentry
->d_inode
->i_sb
->dq_op
->transfer(dentry
->d_inode
, iattr
, 1, current
->fsuid
);
110 error
= notify_change(dentry
, iattr
);
116 #define DQUOT_SYNC(dev) sync_dquots(dev, -1)
117 #define DQUOT_OFF(dev) quota_off(dev, -1)
122 * NO-OP when quota not configured.
124 #define DQUOT_INIT(inode) do { } while(0)
125 #define DQUOT_DROP(inode) do { } while(0)
126 #define DQUOT_PREALLOC_BLOCK(sb, inode, nr) (0)
127 #define DQUOT_ALLOC_BLOCK(sb, inode, nr) (0)
128 #define DQUOT_ALLOC_INODE(sb, inode) (0)
129 #define DQUOT_FREE_BLOCK(sb, inode, nr) do { } while(0)
130 #define DQUOT_FREE_INODE(sb, inode) do { } while(0)
131 #define DQUOT_SYNC(dev) do { } while(0)
132 #define DQUOT_OFF(dev) do { } while(0)
135 * Special case expands to a simple notify_change.
137 #define DQUOT_TRANSFER(dentry, iattr) notify_change(dentry, iattr)
139 #endif /* CONFIG_QUOTA */
140 #endif /* _LINUX_QUOTAOPS_ */