2 #include <linux/buffer_head.h>
3 #include <linux/exportfs.h>
4 #include <linux/iso_fs.h>
5 #include <asm/unaligned.h>
7 enum isofs_file_format
{
10 isofs_file_compressed
= 2,
14 * iso fs inode data in memory
16 struct iso_inode_info
{
17 unsigned long i_iget5_block
;
18 unsigned long i_iget5_offset
;
19 unsigned int i_first_extent
;
20 unsigned char i_file_format
;
21 unsigned char i_format_parm
[3];
22 unsigned long i_next_section_block
;
23 unsigned long i_next_section_offset
;
25 struct inode vfs_inode
;
29 * iso9660 super-block data in memory
31 struct isofs_sb_info
{
32 unsigned long s_ninodes
;
33 unsigned long s_nzones
;
34 unsigned long s_firstdatazone
;
35 unsigned long s_log_zone_size
;
36 unsigned long s_max_size
;
38 int s_rock_offset
; /* offset of SUSP fields within SU area */
40 unsigned char s_joliet_level
;
41 unsigned char s_mapping
;
42 unsigned char s_check
;
43 unsigned char s_session
;
44 unsigned int s_high_sierra
:1;
45 unsigned int s_rock
:2;
46 unsigned int s_utf8
:1;
47 unsigned int s_cruft
:1; /* Broken disks with high byte of length
49 unsigned int s_nocompress
:1;
50 unsigned int s_hide
:1;
51 unsigned int s_showassoc
:1;
52 unsigned int s_overriderockperm
:1;
53 unsigned int s_uid_set
:1;
54 unsigned int s_gid_set
:1;
60 struct nls_table
*s_nls_iocharset
; /* Native language support table */
63 #define ISOFS_INVALID_MODE ((umode_t) -1)
65 static inline struct isofs_sb_info
*ISOFS_SB(struct super_block
*sb
)
70 static inline struct iso_inode_info
*ISOFS_I(struct inode
*inode
)
72 return container_of(inode
, struct iso_inode_info
, vfs_inode
);
75 static inline int isonum_711(char *p
)
79 static inline int isonum_712(char *p
)
83 static inline unsigned int isonum_721(char *p
)
85 return get_unaligned_le16(p
);
87 static inline unsigned int isonum_722(char *p
)
89 return get_unaligned_be16(p
);
91 static inline unsigned int isonum_723(char *p
)
93 /* Ignore bigendian datum due to broken mastering programs */
94 return get_unaligned_le16(p
);
96 static inline unsigned int isonum_731(char *p
)
98 return get_unaligned_le32(p
);
100 static inline unsigned int isonum_732(char *p
)
102 return get_unaligned_be32(p
);
104 static inline unsigned int isonum_733(char *p
)
106 /* Ignore bigendian datum due to broken mastering programs */
107 return get_unaligned_le32(p
);
109 extern int iso_date(char *, int);
111 struct inode
; /* To make gcc happy */
113 extern int parse_rock_ridge_inode(struct iso_directory_record
*, struct inode
*, int relocated
);
114 extern int get_rock_ridge_filename(struct iso_directory_record
*, char *, struct inode
*);
115 extern int isofs_name_translate(struct iso_directory_record
*, char *, struct inode
*);
117 int get_joliet_filename(struct iso_directory_record
*, unsigned char *, struct inode
*);
118 int get_acorn_filename(struct iso_directory_record
*, char *, struct inode
*);
120 extern struct dentry
*isofs_lookup(struct inode
*, struct dentry
*, unsigned int flags
);
121 extern struct buffer_head
*isofs_bread(struct inode
*, sector_t
);
122 extern int isofs_get_blocks(struct inode
*, sector_t
, struct buffer_head
**, unsigned long);
124 struct inode
*__isofs_iget(struct super_block
*sb
,
126 unsigned long offset
,
129 static inline struct inode
*isofs_iget(struct super_block
*sb
,
131 unsigned long offset
)
133 return __isofs_iget(sb
, block
, offset
, 0);
136 static inline struct inode
*isofs_iget_reloc(struct super_block
*sb
,
138 unsigned long offset
)
140 return __isofs_iget(sb
, block
, offset
, 1);
143 /* Because the inode number is no longer relevant to finding the
144 * underlying meta-data for an inode, we are free to choose a more
145 * convenient 32-bit number as the inode number. The inode numbering
146 * scheme was recommended by Sergey Vlasov and Eric Lammerts. */
147 static inline unsigned long isofs_get_ino(unsigned long block
,
148 unsigned long offset
,
149 unsigned long bufbits
)
151 return (block
<< (bufbits
- 5)) | (offset
>> 5);
154 /* Every directory can have many redundant directory entries scattered
155 * throughout the directory tree. First there is the directory entry
156 * with the name of the directory stored in the parent directory.
157 * Then, there is the "." directory entry stored in the directory
158 * itself. Finally, there are possibly many ".." directory entries
159 * stored in all the subdirectories.
161 * In order for the NFS get_parent() method to work and for the
162 * general consistency of the dcache, we need to make sure the
163 * "i_iget5_block" and "i_iget5_offset" all point to exactly one of
164 * the many redundant entries for each directory. We normalize the
165 * block and offset by always making them point to the "." directory.
167 * Notice that we do not use the entry for the directory with the name
168 * that is located in the parent directory. Even though choosing this
169 * first directory is more natural, it is much easier to find the "."
170 * entry in the NFS get_parent() method because it is implicitly
171 * encoded in the "extent + ext_attr_length" fields of _all_ the
172 * redundant entries for the directory. Thus, it can always be
173 * reached regardless of which directory entry you have in hand.
175 * This works because the "." entry is simply the first directory
176 * record when you start reading the file that holds all the directory
177 * records, and this file starts at "extent + ext_attr_length" blocks.
178 * Because the "." entry is always the first entry listed in the
179 * directories file, the normalized "offset" value is always 0.
181 * You should pass the directory entry in "de". On return, "block"
182 * and "offset" will hold normalized values. Only directories are
183 * affected making it safe to call even for non-directory file
186 isofs_normalize_block_and_offset(struct iso_directory_record
* de
,
187 unsigned long *block
,
188 unsigned long *offset
)
190 /* Only directories are normalized. */
191 if (de
->flags
[0] & 2) {
193 *block
= (unsigned long)isonum_733(de
->extent
)
194 + (unsigned long)isonum_711(de
->ext_attr_length
);
198 extern const struct inode_operations isofs_dir_inode_operations
;
199 extern const struct file_operations isofs_dir_operations
;
200 extern const struct address_space_operations isofs_symlink_aops
;
201 extern const struct export_operations isofs_export_ops
;