2
* Copyright (c) 2003-2006 Erez Zadok
3
* Copyright (c) 2003-2006 Charles P. Wright
4
* Copyright (c) 2005-2006 Josef Sipek
5
* Copyright (c) 2005 Arun M. Krishnakumar
6
* Copyright (c) 2005-2006 David P. Quigley
7
* Copyright (c) 2003-2004 Mohammad Nayyer Zubair
8
* Copyright (c) 2003 Puja Gupta
9
* Copyright (c) 2003 Harikesavan Krishnan
10
* Copyright (c) 2003-2006 Stony Brook University
11
* Copyright (c) 2003-2006 The Research Foundation of State University of New York
13
* For specific licensing information, see the COPYING file distributed with
16
* This Copyright notice must be kept intact and distributed with all sources.
19
* $Id: unionfs_macros.h,v 1.13 2006/06/01 03:11:03 jsipek Exp $
23
#error This file should only be included from unionfs.h!
26
/* Inode to private data */
27
static inline struct unionfs_inode_info *itopd(const struct inode *inode)
30
&(container_of(inode, struct unionfs_inode_container, vfs_inode)->
34
#define itohi_ptr(ino) (itopd(ino)->uii_inode)
35
#define ibstart(ino) (itopd(ino)->b_start)
36
#define ibend(ino) (itopd(ino)->b_end)
38
/* Superblock to private data */
39
#define stopd(super) ((struct unionfs_sb_info *)(super)->s_fs_info)
40
#define stopd_lhs(super) ((super)->s_fs_info)
42
#define sbend(sb) stopd(sb)->b_end
43
#define sbmax(sb) (stopd(sb)->b_end + 1)
45
/* File to private Data */
46
#define ftopd(file) ((struct unionfs_file_info *)((file)->private_data))
47
#define ftopd_lhs(file) ((file)->private_data)
48
#define ftohf_ptr(file) (ftopd(file)->ufi_file)
49
#define fbstart(file) (ftopd(file)->b_start)
50
#define fbend(file) (ftopd(file)->b_end)
52
/* File to hidden file. */
53
static inline struct file *ftohf(struct file *f)
55
return ftopd(f)->ufi_file[fbstart(f)];
58
static inline struct file *ftohf_index(const struct file *f, int index)
60
return ftopd(f)->ufi_file[index];
63
static inline void set_ftohf_index(struct file *f, int index, struct file *val)
65
ftopd(f)->ufi_file[index] = val;
68
static inline void set_ftohf(struct file *f, struct file *val)
70
ftopd(f)->ufi_file[fbstart(f)] = val;
73
/* Inode to hidden inode. */
74
static inline struct inode *itohi(const struct inode *i)
76
return itopd(i)->uii_inode[ibstart(i)];
79
static inline struct inode *itohi_index(const struct inode *i, int index)
81
return itopd(i)->uii_inode[index];
84
static inline void set_itohi_index(struct inode *i, int index,
87
itopd(i)->uii_inode[index] = val;
90
static inline void set_itohi(struct inode *i, struct inode *val)
92
itopd(i)->uii_inode[ibstart(i)] = val;
95
/* Superblock to hidden superblock. */
96
static inline struct super_block *stohs(const struct super_block *o)
98
return stopd(o)->usi_data[sbstart(o)].sb;
101
static inline struct super_block *stohs_index(const struct super_block *o, int index)
103
return stopd(o)->usi_data[index].sb;
106
static inline void set_stohs_index(struct super_block *o, int index,
107
struct super_block *val)
109
stopd(o)->usi_data[index].sb = val;
112
static inline void set_stohs(struct super_block *o, struct super_block *val)
114
stopd(o)->usi_data[sbstart(o)].sb = val;
117
/* Super to hidden mount. */
118
static inline struct vfsmount *stohiddenmnt_index(struct super_block *o,
121
return stopd(o)->usi_data[index].hidden_mnt;
124
static inline void set_stohiddenmnt_index(struct super_block *o, int index,
125
struct vfsmount *val)
127
stopd(o)->usi_data[index].hidden_mnt = val;
130
/* Branch count macros. */
131
static inline int branch_count(struct super_block *o, int index)
133
return atomic_read(&stopd(o)->usi_data[index].sbcount);
136
static inline void set_branch_count(struct super_block *o, int index, int val)
138
atomic_set(&stopd(o)->usi_data[index].sbcount, val);
141
static inline void branchget(struct super_block *o, int index)
143
atomic_inc(&stopd(o)->usi_data[index].sbcount);
146
static inline void branchput(struct super_block *o, int index)
148
atomic_dec(&stopd(o)->usi_data[index].sbcount);
152
static inline struct unionfs_dentry_info *dtopd(const struct dentry *dent)
154
return (struct unionfs_dentry_info *)dent->d_fsdata;
157
#define dtopd_lhs(dent) ((dent)->d_fsdata)
158
#define dtopd_nocheck(dent) dtopd(dent)
159
#define dbstart(dent) (dtopd(dent)->udi_bstart)
160
#define set_dbstart(dent, val) do { dtopd(dent)->udi_bstart = val; } while(0)
161
#define dbend(dent) (dtopd(dent)->udi_bend)
162
#define set_dbend(dent, val) do { dtopd(dent)->udi_bend = val; } while(0)
163
#define dbopaque(dent) (dtopd(dent)->udi_bopaque)
164
#define set_dbopaque(dent, val) do { dtopd(dent)->udi_bopaque = val; } while (0)
166
static inline void set_dtohd_index(struct dentry *dent, int index,
169
dtopd(dent)->udi_dentry[index] = val;
172
static inline struct dentry *dtohd_index(const struct dentry *dent, int index)
174
return dtopd(dent)->udi_dentry[index];
177
static inline struct dentry *dtohd(const struct dentry *dent)
179
return dtopd(dent)->udi_dentry[dbstart(dent)];
182
#define set_dtohd_index_nocheck(dent, index, val) set_dtohd_index(dent, index, val)
183
#define dtohd_index_nocheck(dent, index) dtohd_index(dent, index)
185
#define dtohd_ptr(dent) (dtopd_nocheck(dent)->udi_dentry)
187
/* Macros for locking a dentry. */
188
#define lock_dentry(d) down(&dtopd(d)->udi_sem)
189
#define unlock_dentry(d) up(&dtopd(d)->udi_sem)
190
#define verify_locked(d)
200
* c-comment-only-line-offset: 0
201
* c-offsets-alist: ((statement-block-intro . +) (knr-argdecl-intro . 0)
202
* (substatement-open . 0) (label . 0) (statement-cont . +))
203
* indent-tabs-mode: t