^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #ifndef _SYSV_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define _SYSV_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <linux/buffer_head.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) typedef __u16 __bitwise __fs16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) typedef __u32 __bitwise __fs32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/sysv_fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * SystemV/V7/Coherent super-block data in memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * The SystemV/V7/Coherent superblock contains dynamic data (it gets modified
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * while the system is running). This is in contrast to the Minix and Berkeley
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * filesystems (where the superblock is never modified). This affects the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * sync() operation: we must keep the superblock in a disk buffer and use this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * one as our "working copy".
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) struct sysv_sb_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) struct super_block *s_sb; /* VFS superblock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) int s_type; /* file system type: FSTYPE_{XENIX|SYSV|COH} */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) char s_bytesex; /* bytesex (le/be/pdp) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) unsigned int s_inodes_per_block; /* number of inodes per block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) unsigned int s_inodes_per_block_1; /* inodes_per_block - 1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) unsigned int s_inodes_per_block_bits; /* log2(inodes_per_block) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) unsigned int s_ind_per_block; /* number of indirections per block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) unsigned int s_ind_per_block_bits; /* log2(ind_per_block) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) unsigned int s_ind_per_block_2; /* ind_per_block ^ 2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) unsigned int s_toobig_block; /* 10 + ipb + ipb^2 + ipb^3 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) unsigned int s_block_base; /* physical block number of block 0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) unsigned short s_fic_size; /* free inode cache size, NICINOD */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) unsigned short s_flc_size; /* free block list chunk size, NICFREE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) /* The superblock is kept in one or two disk buffers: */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) struct buffer_head *s_bh1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) struct buffer_head *s_bh2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) /* These are pointers into the disk buffer, to compensate for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) different superblock layout. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) char * s_sbd1; /* entire superblock data, for part 1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) char * s_sbd2; /* entire superblock data, for part 2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) __fs16 *s_sb_fic_count; /* pointer to s_sbd->s_ninode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) sysv_ino_t *s_sb_fic_inodes; /* pointer to s_sbd->s_inode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) __fs16 *s_sb_total_free_inodes; /* pointer to s_sbd->s_tinode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) __fs16 *s_bcache_count; /* pointer to s_sbd->s_nfree */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) sysv_zone_t *s_bcache; /* pointer to s_sbd->s_free */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) __fs32 *s_free_blocks; /* pointer to s_sbd->s_tfree */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) __fs32 *s_sb_time; /* pointer to s_sbd->s_time */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) __fs32 *s_sb_state; /* pointer to s_sbd->s_state, only FSTYPE_SYSV */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) /* We keep those superblock entities that don't change here;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) this saves us an indirection and perhaps a conversion. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) u32 s_firstinodezone; /* index of first inode zone */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) u32 s_firstdatazone; /* same as s_sbd->s_isize */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) u32 s_ninodes; /* total number of inodes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) u32 s_ndatazones; /* total number of data zones */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) u32 s_nzones; /* same as s_sbd->s_fsize */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) u16 s_namelen; /* max length of dir entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) int s_forced_ro;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) struct mutex s_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) * SystemV/V7/Coherent FS inode data in memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) struct sysv_inode_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) __fs32 i_data[13];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) u32 i_dir_start_lookup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) struct inode vfs_inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) static inline struct sysv_inode_info *SYSV_I(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) return container_of(inode, struct sysv_inode_info, vfs_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) static inline struct sysv_sb_info *SYSV_SB(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) return sb->s_fs_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) /* identify the FS in memory */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) FSTYPE_NONE = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) FSTYPE_XENIX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) FSTYPE_SYSV4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) FSTYPE_SYSV2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) FSTYPE_COH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) FSTYPE_V7,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) FSTYPE_AFS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) FSTYPE_END,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) #define SYSV_MAGIC_BASE 0x012FF7B3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) #define XENIX_SUPER_MAGIC (SYSV_MAGIC_BASE+FSTYPE_XENIX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) #define SYSV4_SUPER_MAGIC (SYSV_MAGIC_BASE+FSTYPE_SYSV4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) #define SYSV2_SUPER_MAGIC (SYSV_MAGIC_BASE+FSTYPE_SYSV2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) #define COH_SUPER_MAGIC (SYSV_MAGIC_BASE+FSTYPE_COH)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) /* Admissible values for i_nlink: 0.._LINK_MAX */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) XENIX_LINK_MAX = 126, /* ?? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) SYSV_LINK_MAX = 126, /* 127? 251? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) V7_LINK_MAX = 126, /* ?? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) COH_LINK_MAX = 10000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) static inline void dirty_sb(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) struct sysv_sb_info *sbi = SYSV_SB(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) mark_buffer_dirty(sbi->s_bh1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) if (sbi->s_bh1 != sbi->s_bh2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) mark_buffer_dirty(sbi->s_bh2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) /* ialloc.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) extern struct sysv_inode *sysv_raw_inode(struct super_block *, unsigned,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) struct buffer_head **);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) extern struct inode * sysv_new_inode(const struct inode *, umode_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) extern void sysv_free_inode(struct inode *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) extern unsigned long sysv_count_free_inodes(struct super_block *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) /* balloc.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) extern sysv_zone_t sysv_new_block(struct super_block *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) extern void sysv_free_block(struct super_block *, sysv_zone_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) extern unsigned long sysv_count_free_blocks(struct super_block *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) /* itree.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) extern void sysv_truncate(struct inode *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) extern int sysv_prepare_chunk(struct page *page, loff_t pos, unsigned len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) /* inode.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) extern struct inode *sysv_iget(struct super_block *, unsigned int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) extern int sysv_write_inode(struct inode *, struct writeback_control *wbc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) extern int sysv_sync_inode(struct inode *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) extern void sysv_set_inode(struct inode *, dev_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) extern int sysv_getattr(const struct path *, struct kstat *, u32, unsigned int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) extern int sysv_init_icache(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) extern void sysv_destroy_icache(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) /* dir.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) extern struct sysv_dir_entry *sysv_find_entry(struct dentry *, struct page **);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) extern int sysv_add_link(struct dentry *, struct inode *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) extern int sysv_delete_entry(struct sysv_dir_entry *, struct page *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) extern int sysv_make_empty(struct inode *, struct inode *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) extern int sysv_empty_dir(struct inode *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) extern void sysv_set_link(struct sysv_dir_entry *, struct page *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) struct inode *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) extern struct sysv_dir_entry *sysv_dotdot(struct inode *, struct page **);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) extern ino_t sysv_inode_by_name(struct dentry *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) extern const struct inode_operations sysv_file_inode_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) extern const struct inode_operations sysv_dir_inode_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) extern const struct file_operations sysv_file_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) extern const struct file_operations sysv_dir_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) extern const struct address_space_operations sysv_aops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) extern const struct super_operations sysv_sops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) BYTESEX_LE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) BYTESEX_PDP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) BYTESEX_BE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) static inline u32 PDP_swab(u32 x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) #ifdef __LITTLE_ENDIAN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) return ((x & 0xffff) << 16) | ((x & 0xffff0000) >> 16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) #ifdef __BIG_ENDIAN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) return ((x & 0xff00ff) << 8) | ((x & 0xff00ff00) >> 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) #error BYTESEX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) if (sbi->s_bytesex == BYTESEX_PDP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) return PDP_swab((__force __u32)n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) else if (sbi->s_bytesex == BYTESEX_LE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) return le32_to_cpu((__force __le32)n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) return be32_to_cpu((__force __be32)n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) static inline __fs32 cpu_to_fs32(struct sysv_sb_info *sbi, __u32 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) if (sbi->s_bytesex == BYTESEX_PDP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) return (__force __fs32)PDP_swab(n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) else if (sbi->s_bytesex == BYTESEX_LE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) return (__force __fs32)cpu_to_le32(n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) return (__force __fs32)cpu_to_be32(n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) static inline __fs32 fs32_add(struct sysv_sb_info *sbi, __fs32 *n, int d)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) if (sbi->s_bytesex == BYTESEX_PDP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) *(__u32*)n = PDP_swab(PDP_swab(*(__u32*)n)+d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) else if (sbi->s_bytesex == BYTESEX_LE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) le32_add_cpu((__le32 *)n, d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) be32_add_cpu((__be32 *)n, d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) return *n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) static inline __u16 fs16_to_cpu(struct sysv_sb_info *sbi, __fs16 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) if (sbi->s_bytesex != BYTESEX_BE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) return le16_to_cpu((__force __le16)n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) return be16_to_cpu((__force __be16)n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) static inline __fs16 cpu_to_fs16(struct sysv_sb_info *sbi, __u16 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) if (sbi->s_bytesex != BYTESEX_BE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) return (__force __fs16)cpu_to_le16(n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) return (__force __fs16)cpu_to_be16(n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) static inline __fs16 fs16_add(struct sysv_sb_info *sbi, __fs16 *n, int d)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) if (sbi->s_bytesex != BYTESEX_BE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) le16_add_cpu((__le16 *)n, d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) be16_add_cpu((__be16 *)n, d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) return *n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) #endif /* _SYSV_H */