2 #include <linux/buffer_head.h>
3 #include <linux/iso_fs.h>
4 #include <asm/unaligned.h>
6 enum isofs_file_format
{
9 isofs_file_compressed
= 2,
13 * iso fs inode data in memory
15 struct iso_inode_info
{
16 unsigned long i_iget5_block
;
17 unsigned long i_iget5_offset
;
18 unsigned int i_first_extent
;
19 unsigned char i_file_format
;
20 unsigned char i_format_parm
[3];
21 unsigned long i_next_section_block
;
22 unsigned long i_next_section_offset
;
24 struct inode vfs_inode
;
28 * iso9660 super-block data in memory
30 struct isofs_sb_info
{
31 unsigned long s_ninodes
;
32 unsigned long s_nzones
;
33 unsigned long s_firstdatazone
;
34 unsigned long s_log_zone_size
;
35 unsigned long s_max_size
;
37 unsigned char s_high_sierra
; /* A simple flag */
38 unsigned char s_mapping
;
39 int s_rock_offset
; /* offset of SUSP fields within SU area */
41 unsigned char s_joliet_level
;
43 unsigned char s_cruft
; /* Broken disks with high
44 byte of length containing
46 unsigned char s_unhide
;
47 unsigned char s_nosuid
;
48 unsigned char s_nodev
;
49 unsigned char s_nocompress
;
54 struct nls_table
*s_nls_iocharset
; /* Native language support table */
57 static inline struct isofs_sb_info
*ISOFS_SB(struct super_block
*sb
)
62 static inline struct iso_inode_info
*ISOFS_I(struct inode
*inode
)
64 return container_of(inode
, struct iso_inode_info
, vfs_inode
);
67 static inline int isonum_711(char *p
)
71 static inline int isonum_712(char *p
)
75 static inline unsigned int isonum_721(char *p
)
77 return le16_to_cpu(get_unaligned((__le16
*)p
));
79 static inline unsigned int isonum_722(char *p
)
81 return be16_to_cpu(get_unaligned((__le16
*)p
));
83 static inline unsigned int isonum_723(char *p
)
85 /* Ignore bigendian datum due to broken mastering programs */
86 return le16_to_cpu(get_unaligned((__le16
*)p
));
88 static inline unsigned int isonum_731(char *p
)
90 return le32_to_cpu(get_unaligned((__le32
*)p
));
92 static inline unsigned int isonum_732(char *p
)
94 return be32_to_cpu(get_unaligned((__le32
*)p
));
96 static inline unsigned int isonum_733(char *p
)
98 /* Ignore bigendian datum due to broken mastering programs */
99 return le32_to_cpu(get_unaligned((__le32
*)p
));
101 extern int iso_date(char *, int);
103 struct inode
; /* To make gcc happy */
105 extern int parse_rock_ridge_inode(struct iso_directory_record
*, struct inode
*);
106 extern int get_rock_ridge_filename(struct iso_directory_record
*, char *, struct inode
*);
107 extern int isofs_name_translate(struct iso_directory_record
*, char *, struct inode
*);
109 int get_joliet_filename(struct iso_directory_record
*, unsigned char *, struct inode
*);
110 int get_acorn_filename(struct iso_directory_record
*, char *, struct inode
*);
112 extern struct dentry
*isofs_lookup(struct inode
*, struct dentry
*, struct nameidata
*);
113 extern struct buffer_head
*isofs_bread(struct inode
*, sector_t
);
114 extern int isofs_get_blocks(struct inode
*, sector_t
, struct buffer_head
**, unsigned long);
116 extern struct inode
*isofs_iget(struct super_block
*sb
,
118 unsigned long offset
);
120 /* Because the inode number is no longer relevant to finding the
121 * underlying meta-data for an inode, we are free to choose a more
122 * convenient 32-bit number as the inode number. The inode numbering
123 * scheme was recommended by Sergey Vlasov and Eric Lammerts. */
124 static inline unsigned long isofs_get_ino(unsigned long block
,
125 unsigned long offset
,
126 unsigned long bufbits
)
128 return (block
<< (bufbits
- 5)) | (offset
>> 5);
131 /* Every directory can have many redundant directory entries scattered
132 * throughout the directory tree. First there is the directory entry
133 * with the name of the directory stored in the parent directory.
134 * Then, there is the "." directory entry stored in the directory
135 * itself. Finally, there are possibly many ".." directory entries
136 * stored in all the subdirectories.
138 * In order for the NFS get_parent() method to work and for the
139 * general consistency of the dcache, we need to make sure the
140 * "i_iget5_block" and "i_iget5_offset" all point to exactly one of
141 * the many redundant entries for each directory. We normalize the
142 * block and offset by always making them point to the "." directory.
144 * Notice that we do not use the entry for the directory with the name
145 * that is located in the parent directory. Even though choosing this
146 * first directory is more natural, it is much easier to find the "."
147 * entry in the NFS get_parent() method because it is implicitly
148 * encoded in the "extent + ext_attr_length" fields of _all_ the
149 * redundant entries for the directory. Thus, it can always be
150 * reached regardless of which directory entry you have in hand.
152 * This works because the "." entry is simply the first directory
153 * record when you start reading the file that holds all the directory
154 * records, and this file starts at "extent + ext_attr_length" blocks.
155 * Because the "." entry is always the first entry listed in the
156 * directories file, the normalized "offset" value is always 0.
158 * You should pass the directory entry in "de". On return, "block"
159 * and "offset" will hold normalized values. Only directories are
160 * affected making it safe to call even for non-directory file
163 isofs_normalize_block_and_offset(struct iso_directory_record
* de
,
164 unsigned long *block
,
165 unsigned long *offset
)
167 /* Only directories are normalized. */
168 if (de
->flags
[0] & 2) {
170 *block
= (unsigned long)isonum_733(de
->extent
)
171 + (unsigned long)isonum_711(de
->ext_attr_length
);
175 extern struct inode_operations isofs_dir_inode_operations
;
176 extern struct file_operations isofs_dir_operations
;
177 extern struct address_space_operations isofs_symlink_aops
;
178 extern struct export_operations isofs_export_ops
;
180 /* The following macros are used to check for memory leaks. */
182 #define free_s leak_check_free_s
183 #define malloc leak_check_malloc
184 #define sb_bread leak_check_bread
185 #define brelse leak_check_brelse
186 extern void * leak_check_malloc(unsigned int size
);
187 extern void leak_check_free_s(void * obj
, int size
);
188 extern struct buffer_head
* leak_check_bread(struct super_block
*sb
, int block
);
189 extern void leak_check_brelse(struct buffer_head
* bh
);
190 #endif /* LEAK_CHECK */