18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (c) 1999 Al Smith 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Portions derived from work (c) 1995,1996 Christian Vogelgsang. 68c2ecf20Sopenharmony_ci * Portions derived from IRIX header files (c) 1988 Silicon Graphics 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci#ifndef _EFS_EFS_H_ 98c2ecf20Sopenharmony_ci#define _EFS_EFS_H_ 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#ifdef pr_fmt 128c2ecf20Sopenharmony_ci#undef pr_fmt 138c2ecf20Sopenharmony_ci#endif 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#include <linux/fs.h> 188c2ecf20Sopenharmony_ci#include <linux/uaccess.h> 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci#define EFS_VERSION "1.0a" 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_cistatic const char cprt[] = "EFS: "EFS_VERSION" - (c) 1999 Al Smith <Al.Smith@aeschi.ch.eu.org>"; 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci/* 1 block is 512 bytes */ 268c2ecf20Sopenharmony_ci#define EFS_BLOCKSIZE_BITS 9 278c2ecf20Sopenharmony_ci#define EFS_BLOCKSIZE (1 << EFS_BLOCKSIZE_BITS) 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_citypedef int32_t efs_block_t; 308c2ecf20Sopenharmony_citypedef uint32_t efs_ino_t; 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci#define EFS_DIRECTEXTENTS 12 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci/* 358c2ecf20Sopenharmony_ci * layout of an extent, in memory and on disk. 8 bytes exactly. 368c2ecf20Sopenharmony_ci */ 378c2ecf20Sopenharmony_citypedef union extent_u { 388c2ecf20Sopenharmony_ci unsigned char raw[8]; 398c2ecf20Sopenharmony_ci struct extent_s { 408c2ecf20Sopenharmony_ci unsigned int ex_magic:8; /* magic # (zero) */ 418c2ecf20Sopenharmony_ci unsigned int ex_bn:24; /* basic block */ 428c2ecf20Sopenharmony_ci unsigned int ex_length:8; /* numblocks in this extent */ 438c2ecf20Sopenharmony_ci unsigned int ex_offset:24; /* logical offset into file */ 448c2ecf20Sopenharmony_ci } cooked; 458c2ecf20Sopenharmony_ci} efs_extent; 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_citypedef struct edevs { 488c2ecf20Sopenharmony_ci __be16 odev; 498c2ecf20Sopenharmony_ci __be32 ndev; 508c2ecf20Sopenharmony_ci} efs_devs; 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci/* 538c2ecf20Sopenharmony_ci * extent based filesystem inode as it appears on disk. The efs inode 548c2ecf20Sopenharmony_ci * is exactly 128 bytes long. 558c2ecf20Sopenharmony_ci */ 568c2ecf20Sopenharmony_cistruct efs_dinode { 578c2ecf20Sopenharmony_ci __be16 di_mode; /* mode and type of file */ 588c2ecf20Sopenharmony_ci __be16 di_nlink; /* number of links to file */ 598c2ecf20Sopenharmony_ci __be16 di_uid; /* owner's user id */ 608c2ecf20Sopenharmony_ci __be16 di_gid; /* owner's group id */ 618c2ecf20Sopenharmony_ci __be32 di_size; /* number of bytes in file */ 628c2ecf20Sopenharmony_ci __be32 di_atime; /* time last accessed */ 638c2ecf20Sopenharmony_ci __be32 di_mtime; /* time last modified */ 648c2ecf20Sopenharmony_ci __be32 di_ctime; /* time created */ 658c2ecf20Sopenharmony_ci __be32 di_gen; /* generation number */ 668c2ecf20Sopenharmony_ci __be16 di_numextents; /* # of extents */ 678c2ecf20Sopenharmony_ci u_char di_version; /* version of inode */ 688c2ecf20Sopenharmony_ci u_char di_spare; /* spare - used by AFS */ 698c2ecf20Sopenharmony_ci union di_addr { 708c2ecf20Sopenharmony_ci efs_extent di_extents[EFS_DIRECTEXTENTS]; 718c2ecf20Sopenharmony_ci efs_devs di_dev; /* device for IFCHR/IFBLK */ 728c2ecf20Sopenharmony_ci } di_u; 738c2ecf20Sopenharmony_ci}; 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci/* efs inode storage in memory */ 768c2ecf20Sopenharmony_cistruct efs_inode_info { 778c2ecf20Sopenharmony_ci int numextents; 788c2ecf20Sopenharmony_ci int lastextent; 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_ci efs_extent extents[EFS_DIRECTEXTENTS]; 818c2ecf20Sopenharmony_ci struct inode vfs_inode; 828c2ecf20Sopenharmony_ci}; 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci#include <linux/efs_fs_sb.h> 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ci#define EFS_DIRBSIZE_BITS EFS_BLOCKSIZE_BITS 878c2ecf20Sopenharmony_ci#define EFS_DIRBSIZE (1 << EFS_DIRBSIZE_BITS) 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_cistruct efs_dentry { 908c2ecf20Sopenharmony_ci __be32 inode; 918c2ecf20Sopenharmony_ci unsigned char namelen; 928c2ecf20Sopenharmony_ci char name[3]; 938c2ecf20Sopenharmony_ci}; 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci#define EFS_DENTSIZE (sizeof(struct efs_dentry) - 3 + 1) 968c2ecf20Sopenharmony_ci#define EFS_MAXNAMELEN ((1 << (sizeof(char) * 8)) - 1) 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ci#define EFS_DIRBLK_HEADERSIZE 4 998c2ecf20Sopenharmony_ci#define EFS_DIRBLK_MAGIC 0xbeef /* moo */ 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_cistruct efs_dir { 1028c2ecf20Sopenharmony_ci __be16 magic; 1038c2ecf20Sopenharmony_ci unsigned char firstused; 1048c2ecf20Sopenharmony_ci unsigned char slots; 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ci unsigned char space[EFS_DIRBSIZE - EFS_DIRBLK_HEADERSIZE]; 1078c2ecf20Sopenharmony_ci}; 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ci#define EFS_MAXENTS \ 1108c2ecf20Sopenharmony_ci ((EFS_DIRBSIZE - EFS_DIRBLK_HEADERSIZE) / \ 1118c2ecf20Sopenharmony_ci (EFS_DENTSIZE + sizeof(char))) 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ci#define EFS_SLOTAT(dir, slot) EFS_REALOFF((dir)->space[slot]) 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_ci#define EFS_REALOFF(offset) ((offset << 1)) 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_cistatic inline struct efs_inode_info *INODE_INFO(struct inode *inode) 1198c2ecf20Sopenharmony_ci{ 1208c2ecf20Sopenharmony_ci return container_of(inode, struct efs_inode_info, vfs_inode); 1218c2ecf20Sopenharmony_ci} 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_cistatic inline struct efs_sb_info *SUPER_INFO(struct super_block *sb) 1248c2ecf20Sopenharmony_ci{ 1258c2ecf20Sopenharmony_ci return sb->s_fs_info; 1268c2ecf20Sopenharmony_ci} 1278c2ecf20Sopenharmony_ci 1288c2ecf20Sopenharmony_cistruct statfs; 1298c2ecf20Sopenharmony_cistruct fid; 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_ciextern const struct inode_operations efs_dir_inode_operations; 1328c2ecf20Sopenharmony_ciextern const struct file_operations efs_dir_operations; 1338c2ecf20Sopenharmony_ciextern const struct address_space_operations efs_symlink_aops; 1348c2ecf20Sopenharmony_ci 1358c2ecf20Sopenharmony_ciextern struct inode *efs_iget(struct super_block *, unsigned long); 1368c2ecf20Sopenharmony_ciextern efs_block_t efs_map_block(struct inode *, efs_block_t); 1378c2ecf20Sopenharmony_ciextern int efs_get_block(struct inode *, sector_t, struct buffer_head *, int); 1388c2ecf20Sopenharmony_ci 1398c2ecf20Sopenharmony_ciextern struct dentry *efs_lookup(struct inode *, struct dentry *, unsigned int); 1408c2ecf20Sopenharmony_ciextern struct dentry *efs_fh_to_dentry(struct super_block *sb, struct fid *fid, 1418c2ecf20Sopenharmony_ci int fh_len, int fh_type); 1428c2ecf20Sopenharmony_ciextern struct dentry *efs_fh_to_parent(struct super_block *sb, struct fid *fid, 1438c2ecf20Sopenharmony_ci int fh_len, int fh_type); 1448c2ecf20Sopenharmony_ciextern struct dentry *efs_get_parent(struct dentry *); 1458c2ecf20Sopenharmony_ciextern int efs_bmap(struct inode *, int); 1468c2ecf20Sopenharmony_ci 1478c2ecf20Sopenharmony_ci#endif /* _EFS_EFS_H_ */ 148