efs.h (3910B)
1/* SPDX-License-Identifier: GPL-2.0 */ 2/* 3 * Copyright (c) 1999 Al Smith 4 * 5 * Portions derived from work (c) 1995,1996 Christian Vogelgsang. 6 * Portions derived from IRIX header files (c) 1988 Silicon Graphics 7 */ 8#ifndef _EFS_EFS_H_ 9#define _EFS_EFS_H_ 10 11#ifdef pr_fmt 12#undef pr_fmt 13#endif 14 15#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 16 17#include <linux/fs.h> 18#include <linux/uaccess.h> 19 20#define EFS_VERSION "1.0a" 21 22static const char cprt[] = "EFS: "EFS_VERSION" - (c) 1999 Al Smith <Al.Smith@aeschi.ch.eu.org>"; 23 24 25/* 1 block is 512 bytes */ 26#define EFS_BLOCKSIZE_BITS 9 27#define EFS_BLOCKSIZE (1 << EFS_BLOCKSIZE_BITS) 28 29typedef int32_t efs_block_t; 30typedef uint32_t efs_ino_t; 31 32#define EFS_DIRECTEXTENTS 12 33 34/* 35 * layout of an extent, in memory and on disk. 8 bytes exactly. 36 */ 37typedef union extent_u { 38 unsigned char raw[8]; 39 struct extent_s { 40 unsigned int ex_magic:8; /* magic # (zero) */ 41 unsigned int ex_bn:24; /* basic block */ 42 unsigned int ex_length:8; /* numblocks in this extent */ 43 unsigned int ex_offset:24; /* logical offset into file */ 44 } cooked; 45} efs_extent; 46 47typedef struct edevs { 48 __be16 odev; 49 __be32 ndev; 50} efs_devs; 51 52/* 53 * extent based filesystem inode as it appears on disk. The efs inode 54 * is exactly 128 bytes long. 55 */ 56struct efs_dinode { 57 __be16 di_mode; /* mode and type of file */ 58 __be16 di_nlink; /* number of links to file */ 59 __be16 di_uid; /* owner's user id */ 60 __be16 di_gid; /* owner's group id */ 61 __be32 di_size; /* number of bytes in file */ 62 __be32 di_atime; /* time last accessed */ 63 __be32 di_mtime; /* time last modified */ 64 __be32 di_ctime; /* time created */ 65 __be32 di_gen; /* generation number */ 66 __be16 di_numextents; /* # of extents */ 67 u_char di_version; /* version of inode */ 68 u_char di_spare; /* spare - used by AFS */ 69 union di_addr { 70 efs_extent di_extents[EFS_DIRECTEXTENTS]; 71 efs_devs di_dev; /* device for IFCHR/IFBLK */ 72 } di_u; 73}; 74 75/* efs inode storage in memory */ 76struct efs_inode_info { 77 int numextents; 78 int lastextent; 79 80 efs_extent extents[EFS_DIRECTEXTENTS]; 81 struct inode vfs_inode; 82}; 83 84#include <linux/efs_fs_sb.h> 85 86#define EFS_DIRBSIZE_BITS EFS_BLOCKSIZE_BITS 87#define EFS_DIRBSIZE (1 << EFS_DIRBSIZE_BITS) 88 89struct efs_dentry { 90 __be32 inode; 91 unsigned char namelen; 92 char name[3]; 93}; 94 95#define EFS_DENTSIZE (sizeof(struct efs_dentry) - 3 + 1) 96#define EFS_MAXNAMELEN ((1 << (sizeof(char) * 8)) - 1) 97 98#define EFS_DIRBLK_HEADERSIZE 4 99#define EFS_DIRBLK_MAGIC 0xbeef /* moo */ 100 101struct efs_dir { 102 __be16 magic; 103 unsigned char firstused; 104 unsigned char slots; 105 106 unsigned char space[EFS_DIRBSIZE - EFS_DIRBLK_HEADERSIZE]; 107}; 108 109#define EFS_MAXENTS \ 110 ((EFS_DIRBSIZE - EFS_DIRBLK_HEADERSIZE) / \ 111 (EFS_DENTSIZE + sizeof(char))) 112 113#define EFS_SLOTAT(dir, slot) EFS_REALOFF((dir)->space[slot]) 114 115#define EFS_REALOFF(offset) ((offset << 1)) 116 117 118static inline struct efs_inode_info *INODE_INFO(struct inode *inode) 119{ 120 return container_of(inode, struct efs_inode_info, vfs_inode); 121} 122 123static inline struct efs_sb_info *SUPER_INFO(struct super_block *sb) 124{ 125 return sb->s_fs_info; 126} 127 128struct statfs; 129struct fid; 130 131extern const struct inode_operations efs_dir_inode_operations; 132extern const struct file_operations efs_dir_operations; 133extern const struct address_space_operations efs_symlink_aops; 134 135extern struct inode *efs_iget(struct super_block *, unsigned long); 136extern efs_block_t efs_map_block(struct inode *, efs_block_t); 137extern int efs_get_block(struct inode *, sector_t, struct buffer_head *, int); 138 139extern struct dentry *efs_lookup(struct inode *, struct dentry *, unsigned int); 140extern struct dentry *efs_fh_to_dentry(struct super_block *sb, struct fid *fid, 141 int fh_len, int fh_type); 142extern struct dentry *efs_fh_to_parent(struct super_block *sb, struct fid *fid, 143 int fh_len, int fh_type); 144extern struct dentry *efs_get_parent(struct dentry *); 145extern int efs_bmap(struct inode *, int); 146 147#endif /* _EFS_EFS_H_ */