^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) #include <linux/buffer_head.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) #include <linux/adfs_fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) /* Internal data structures for ADFS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #define ADFS_FREE_FRAG 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #define ADFS_BAD_FRAG 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #define ADFS_ROOT_FRAG 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #define ADFS_FILETYPE_NONE ((u16)~0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) /* RISC OS 12-bit filetype is stored in load_address[19:8] */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) static inline u16 adfs_filetype(u32 loadaddr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) return (loadaddr & 0xfff00000) == 0xfff00000 ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) (loadaddr >> 8) & 0xfff : ADFS_FILETYPE_NONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #define ADFS_NDA_OWNER_READ (1 << 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #define ADFS_NDA_OWNER_WRITE (1 << 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #define ADFS_NDA_LOCKED (1 << 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #define ADFS_NDA_DIRECTORY (1 << 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #define ADFS_NDA_EXECUTE (1 << 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #define ADFS_NDA_PUBLIC_READ (1 << 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #define ADFS_NDA_PUBLIC_WRITE (1 << 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * adfs file system inode data in memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) struct adfs_inode_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) loff_t mmu_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) __u32 parent_id; /* parent indirect disc address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) __u32 indaddr; /* object indirect disc address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) __u32 loadaddr; /* RISC OS load address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) __u32 execaddr; /* RISC OS exec address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) unsigned int attr; /* RISC OS permissions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) struct inode vfs_inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) static inline struct adfs_inode_info *ADFS_I(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) return container_of(inode, struct adfs_inode_info, vfs_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) static inline bool adfs_inode_is_stamped(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) return (ADFS_I(inode)->loadaddr & 0xfff00000) == 0xfff00000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) * Forward-declare this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) struct adfs_discmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) struct adfs_dir_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) * ADFS file system superblock data in memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) struct adfs_sb_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) union { struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) struct adfs_discmap *s_map; /* bh list containing map */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) const struct adfs_dir_ops *s_dir; /* directory operations */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) struct rcu_head rcu; /* used only at shutdown time */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) kuid_t s_uid; /* owner uid */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) kgid_t s_gid; /* owner gid */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) umode_t s_owner_mask; /* ADFS owner perm -> unix perm */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) umode_t s_other_mask; /* ADFS other perm -> unix perm */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) int s_ftsuffix; /* ,xyz hex filetype suffix option */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) __u32 s_ids_per_zone; /* max. no ids in one zone */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) __u32 s_idlen; /* length of ID in map */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) __u32 s_map_size; /* sector size of a map */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) signed int s_map2blk; /* shift left by this for map->sector*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) unsigned int s_log2sharesize;/* log2 share size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) unsigned int s_namelen; /* maximum number of characters in name */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) static inline struct adfs_sb_info *ADFS_SB(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) return sb->s_fs_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) * Directory handling
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) struct adfs_dir {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) struct super_block *sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) int nr_buffers;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) struct buffer_head *bh[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) struct buffer_head **bhs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) unsigned int pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) __u32 parent_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) struct adfs_dirheader *dirhead;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) struct adfs_bigdirheader *bighead;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) struct adfs_newdirtail *newtail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) struct adfs_bigdirtail *bigtail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) * This is the overall maximum name length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) #define ADFS_MAX_NAME_LEN (256 + 4) /* +4 for ,xyz hex filetype suffix */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) struct object_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) __u32 parent_id; /* parent object id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) __u32 indaddr; /* indirect disc addr */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) __u32 loadaddr; /* load address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) __u32 execaddr; /* execution address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) __u32 size; /* size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) __u8 attr; /* RISC OS attributes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) unsigned int name_len; /* name length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) char name[ADFS_MAX_NAME_LEN];/* file name */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) struct adfs_dir_ops {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) int (*read)(struct super_block *sb, unsigned int indaddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) unsigned int size, struct adfs_dir *dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) int (*iterate)(struct adfs_dir *dir, struct dir_context *ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) int (*setpos)(struct adfs_dir *dir, unsigned int fpos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) int (*getnext)(struct adfs_dir *dir, struct object_info *obj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) int (*update)(struct adfs_dir *dir, struct object_info *obj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) int (*create)(struct adfs_dir *dir, struct object_info *obj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) int (*remove)(struct adfs_dir *dir, struct object_info *obj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) int (*commit)(struct adfs_dir *dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) struct adfs_discmap {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) struct buffer_head *dm_bh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) __u32 dm_startblk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) unsigned int dm_startbit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) unsigned int dm_endbit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) /* Inode stuff */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) struct inode *adfs_iget(struct super_block *sb, struct object_info *obj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) int adfs_write_inode(struct inode *inode, struct writeback_control *wbc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) int adfs_notify_change(struct dentry *dentry, struct iattr *attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) /* map.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) int adfs_map_lookup(struct super_block *sb, u32 frag_id, unsigned int offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) void adfs_map_statfs(struct super_block *sb, struct kstatfs *buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) struct adfs_discmap *adfs_read_map(struct super_block *sb, struct adfs_discrecord *dr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) void adfs_free_map(struct super_block *sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) /* Misc */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) __printf(3, 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) void __adfs_error(struct super_block *sb, const char *function,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) const char *fmt, ...);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) #define adfs_error(sb, fmt...) __adfs_error(sb, __func__, fmt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) void adfs_msg(struct super_block *sb, const char *pfx, const char *fmt, ...);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) /* super.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) * Inodes and file operations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) /* dir_*.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) extern const struct inode_operations adfs_dir_inode_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) extern const struct file_operations adfs_dir_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) extern const struct dentry_operations adfs_dentry_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) extern const struct adfs_dir_ops adfs_f_dir_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) extern const struct adfs_dir_ops adfs_fplus_dir_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) int adfs_dir_copyfrom(void *dst, struct adfs_dir *dir, unsigned int offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) size_t len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) int adfs_dir_copyto(struct adfs_dir *dir, unsigned int offset, const void *src,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) size_t len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) void adfs_dir_relse(struct adfs_dir *dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) int adfs_dir_read_buffers(struct super_block *sb, u32 indaddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) unsigned int size, struct adfs_dir *dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) void adfs_object_fixup(struct adfs_dir *dir, struct object_info *obj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) extern int adfs_dir_update(struct super_block *sb, struct object_info *obj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) int wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) /* file.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) extern const struct inode_operations adfs_file_inode_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) extern const struct file_operations adfs_file_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) static inline __u32 signed_asl(__u32 val, signed int shift)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) if (shift >= 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) val <<= shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) val >>= -shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) return val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) * Calculate the address of a block in an object given the block offset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) * and the object identity.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) * The root directory ID should always be looked up in the map [3.4]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) static inline int __adfs_block_map(struct super_block *sb, u32 indaddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) unsigned int block)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) if (indaddr & 255) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) unsigned int off;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) off = (indaddr & 255) - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) block += off << ADFS_SB(sb)->s_log2sharesize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) return adfs_map_lookup(sb, indaddr >> 8, block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) /* Return the disc record from the map */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) struct adfs_discrecord *adfs_map_discrecord(struct adfs_discmap *dm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) return (void *)(dm[0].dm_bh->b_data + 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) static inline u64 adfs_disc_size(const struct adfs_discrecord *dr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) return (u64)le32_to_cpu(dr->disc_size_high) << 32 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) le32_to_cpu(dr->disc_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) }