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