0001
0002 #ifndef _SYSV_H
0003 #define _SYSV_H
0004
0005 #include <linux/buffer_head.h>
0006
0007 typedef __u16 __bitwise __fs16;
0008 typedef __u32 __bitwise __fs32;
0009
0010 #include <linux/sysv_fs.h>
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 struct sysv_sb_info {
0023 struct super_block *s_sb;
0024 int s_type;
0025 char s_bytesex;
0026 unsigned int s_inodes_per_block;
0027 unsigned int s_inodes_per_block_1;
0028 unsigned int s_inodes_per_block_bits;
0029 unsigned int s_ind_per_block;
0030 unsigned int s_ind_per_block_bits;
0031 unsigned int s_ind_per_block_2;
0032 unsigned int s_toobig_block;
0033 unsigned int s_block_base;
0034 unsigned short s_fic_size;
0035 unsigned short s_flc_size;
0036
0037 struct buffer_head *s_bh1;
0038 struct buffer_head *s_bh2;
0039
0040
0041 char * s_sbd1;
0042 char * s_sbd2;
0043 __fs16 *s_sb_fic_count;
0044 sysv_ino_t *s_sb_fic_inodes;
0045 __fs16 *s_sb_total_free_inodes;
0046 __fs16 *s_bcache_count;
0047 sysv_zone_t *s_bcache;
0048 __fs32 *s_free_blocks;
0049 __fs32 *s_sb_time;
0050 __fs32 *s_sb_state;
0051
0052
0053 u32 s_firstinodezone;
0054 u32 s_firstdatazone;
0055 u32 s_ninodes;
0056 u32 s_ndatazones;
0057 u32 s_nzones;
0058 u16 s_namelen;
0059 int s_forced_ro;
0060 struct mutex s_lock;
0061 };
0062
0063
0064
0065
0066 struct sysv_inode_info {
0067 __fs32 i_data[13];
0068 u32 i_dir_start_lookup;
0069 struct inode vfs_inode;
0070 };
0071
0072
0073 static inline struct sysv_inode_info *SYSV_I(struct inode *inode)
0074 {
0075 return container_of(inode, struct sysv_inode_info, vfs_inode);
0076 }
0077
0078 static inline struct sysv_sb_info *SYSV_SB(struct super_block *sb)
0079 {
0080 return sb->s_fs_info;
0081 }
0082
0083
0084
0085 enum {
0086 FSTYPE_NONE = 0,
0087 FSTYPE_XENIX,
0088 FSTYPE_SYSV4,
0089 FSTYPE_SYSV2,
0090 FSTYPE_COH,
0091 FSTYPE_V7,
0092 FSTYPE_AFS,
0093 FSTYPE_END,
0094 };
0095
0096 #define SYSV_MAGIC_BASE 0x012FF7B3
0097
0098 #define XENIX_SUPER_MAGIC (SYSV_MAGIC_BASE+FSTYPE_XENIX)
0099 #define SYSV4_SUPER_MAGIC (SYSV_MAGIC_BASE+FSTYPE_SYSV4)
0100 #define SYSV2_SUPER_MAGIC (SYSV_MAGIC_BASE+FSTYPE_SYSV2)
0101 #define COH_SUPER_MAGIC (SYSV_MAGIC_BASE+FSTYPE_COH)
0102
0103
0104
0105 enum {
0106 XENIX_LINK_MAX = 126,
0107 SYSV_LINK_MAX = 126,
0108 V7_LINK_MAX = 126,
0109 COH_LINK_MAX = 10000,
0110 };
0111
0112
0113 static inline void dirty_sb(struct super_block *sb)
0114 {
0115 struct sysv_sb_info *sbi = SYSV_SB(sb);
0116
0117 mark_buffer_dirty(sbi->s_bh1);
0118 if (sbi->s_bh1 != sbi->s_bh2)
0119 mark_buffer_dirty(sbi->s_bh2);
0120 }
0121
0122
0123
0124 extern struct sysv_inode *sysv_raw_inode(struct super_block *, unsigned,
0125 struct buffer_head **);
0126 extern struct inode * sysv_new_inode(const struct inode *, umode_t);
0127 extern void sysv_free_inode(struct inode *);
0128 extern unsigned long sysv_count_free_inodes(struct super_block *);
0129
0130
0131 extern sysv_zone_t sysv_new_block(struct super_block *);
0132 extern void sysv_free_block(struct super_block *, sysv_zone_t);
0133 extern unsigned long sysv_count_free_blocks(struct super_block *);
0134
0135
0136 extern void sysv_truncate(struct inode *);
0137 extern int sysv_prepare_chunk(struct page *page, loff_t pos, unsigned len);
0138
0139
0140 extern struct inode *sysv_iget(struct super_block *, unsigned int);
0141 extern int sysv_write_inode(struct inode *, struct writeback_control *wbc);
0142 extern int sysv_sync_inode(struct inode *);
0143 extern void sysv_set_inode(struct inode *, dev_t);
0144 extern int sysv_getattr(struct user_namespace *, const struct path *,
0145 struct kstat *, u32, unsigned int);
0146 extern int sysv_init_icache(void);
0147 extern void sysv_destroy_icache(void);
0148
0149
0150
0151 extern struct sysv_dir_entry *sysv_find_entry(struct dentry *, struct page **);
0152 extern int sysv_add_link(struct dentry *, struct inode *);
0153 extern int sysv_delete_entry(struct sysv_dir_entry *, struct page *);
0154 extern int sysv_make_empty(struct inode *, struct inode *);
0155 extern int sysv_empty_dir(struct inode *);
0156 extern void sysv_set_link(struct sysv_dir_entry *, struct page *,
0157 struct inode *);
0158 extern struct sysv_dir_entry *sysv_dotdot(struct inode *, struct page **);
0159 extern ino_t sysv_inode_by_name(struct dentry *);
0160
0161
0162 extern const struct inode_operations sysv_file_inode_operations;
0163 extern const struct inode_operations sysv_dir_inode_operations;
0164 extern const struct file_operations sysv_file_operations;
0165 extern const struct file_operations sysv_dir_operations;
0166 extern const struct address_space_operations sysv_aops;
0167 extern const struct super_operations sysv_sops;
0168
0169
0170 enum {
0171 BYTESEX_LE,
0172 BYTESEX_PDP,
0173 BYTESEX_BE,
0174 };
0175
0176 static inline u32 PDP_swab(u32 x)
0177 {
0178 #ifdef __LITTLE_ENDIAN
0179 return ((x & 0xffff) << 16) | ((x & 0xffff0000) >> 16);
0180 #else
0181 #ifdef __BIG_ENDIAN
0182 return ((x & 0xff00ff) << 8) | ((x & 0xff00ff00) >> 8);
0183 #else
0184 #error BYTESEX
0185 #endif
0186 #endif
0187 }
0188
0189 static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
0190 {
0191 if (sbi->s_bytesex == BYTESEX_PDP)
0192 return PDP_swab((__force __u32)n);
0193 else if (sbi->s_bytesex == BYTESEX_LE)
0194 return le32_to_cpu((__force __le32)n);
0195 else
0196 return be32_to_cpu((__force __be32)n);
0197 }
0198
0199 static inline __fs32 cpu_to_fs32(struct sysv_sb_info *sbi, __u32 n)
0200 {
0201 if (sbi->s_bytesex == BYTESEX_PDP)
0202 return (__force __fs32)PDP_swab(n);
0203 else if (sbi->s_bytesex == BYTESEX_LE)
0204 return (__force __fs32)cpu_to_le32(n);
0205 else
0206 return (__force __fs32)cpu_to_be32(n);
0207 }
0208
0209 static inline __fs32 fs32_add(struct sysv_sb_info *sbi, __fs32 *n, int d)
0210 {
0211 if (sbi->s_bytesex == BYTESEX_PDP)
0212 *(__u32*)n = PDP_swab(PDP_swab(*(__u32*)n)+d);
0213 else if (sbi->s_bytesex == BYTESEX_LE)
0214 le32_add_cpu((__le32 *)n, d);
0215 else
0216 be32_add_cpu((__be32 *)n, d);
0217 return *n;
0218 }
0219
0220 static inline __u16 fs16_to_cpu(struct sysv_sb_info *sbi, __fs16 n)
0221 {
0222 if (sbi->s_bytesex != BYTESEX_BE)
0223 return le16_to_cpu((__force __le16)n);
0224 else
0225 return be16_to_cpu((__force __be16)n);
0226 }
0227
0228 static inline __fs16 cpu_to_fs16(struct sysv_sb_info *sbi, __u16 n)
0229 {
0230 if (sbi->s_bytesex != BYTESEX_BE)
0231 return (__force __fs16)cpu_to_le16(n);
0232 else
0233 return (__force __fs16)cpu_to_be16(n);
0234 }
0235
0236 static inline __fs16 fs16_add(struct sysv_sb_info *sbi, __fs16 *n, int d)
0237 {
0238 if (sbi->s_bytesex != BYTESEX_BE)
0239 le16_add_cpu((__le16 *)n, d);
0240 else
0241 be16_add_cpu((__be16 *)n, d);
0242 return *n;
0243 }
0244
0245 #endif