Al Viro | 94f2f715 | 2005-04-25 18:32:12 -0700 | [diff] [blame] | 1 | #include <linux/fs.h> |
| 2 | #include <linux/buffer_head.h> |
| 3 | #include <linux/iso_fs.h> |
| 4 | #include <asm/unaligned.h> |
| 5 | |
| 6 | enum isofs_file_format { |
| 7 | isofs_file_normal = 0, |
| 8 | isofs_file_sparse = 1, |
| 9 | isofs_file_compressed = 2, |
| 10 | }; |
| 11 | |
| 12 | /* |
| 13 | * iso fs inode data in memory |
| 14 | */ |
| 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; |
| 23 | off_t i_section_size; |
| 24 | struct inode vfs_inode; |
| 25 | }; |
| 26 | |
| 27 | /* |
| 28 | * iso9660 super-block data in memory |
| 29 | */ |
| 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; |
| 36 | |
| 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 */ |
| 40 | unsigned char s_rock; |
| 41 | unsigned char s_joliet_level; |
| 42 | unsigned char s_utf8; |
| 43 | unsigned char s_cruft; /* Broken disks with high |
| 44 | byte of length containing |
| 45 | junk */ |
| 46 | unsigned char s_unhide; |
| 47 | unsigned char s_nosuid; |
| 48 | unsigned char s_nodev; |
| 49 | unsigned char s_nocompress; |
Jeremy White | 9769f4e | 2005-06-21 17:16:53 -0700 | [diff] [blame] | 50 | unsigned char s_hide; |
| 51 | unsigned char s_showassoc; |
Al Viro | 94f2f715 | 2005-04-25 18:32:12 -0700 | [diff] [blame] | 52 | |
| 53 | mode_t s_mode; |
| 54 | gid_t s_gid; |
| 55 | uid_t s_uid; |
| 56 | struct nls_table *s_nls_iocharset; /* Native language support table */ |
| 57 | }; |
| 58 | |
| 59 | static inline struct isofs_sb_info *ISOFS_SB(struct super_block *sb) |
| 60 | { |
| 61 | return sb->s_fs_info; |
| 62 | } |
| 63 | |
| 64 | static inline struct iso_inode_info *ISOFS_I(struct inode *inode) |
| 65 | { |
| 66 | return container_of(inode, struct iso_inode_info, vfs_inode); |
| 67 | } |
| 68 | |
| 69 | static inline int isonum_711(char *p) |
| 70 | { |
| 71 | return *(u8 *)p; |
| 72 | } |
| 73 | static inline int isonum_712(char *p) |
| 74 | { |
| 75 | return *(s8 *)p; |
| 76 | } |
| 77 | static inline unsigned int isonum_721(char *p) |
| 78 | { |
| 79 | return le16_to_cpu(get_unaligned((__le16 *)p)); |
| 80 | } |
| 81 | static inline unsigned int isonum_722(char *p) |
| 82 | { |
| 83 | return be16_to_cpu(get_unaligned((__le16 *)p)); |
| 84 | } |
| 85 | static inline unsigned int isonum_723(char *p) |
| 86 | { |
| 87 | /* Ignore bigendian datum due to broken mastering programs */ |
| 88 | return le16_to_cpu(get_unaligned((__le16 *)p)); |
| 89 | } |
| 90 | static inline unsigned int isonum_731(char *p) |
| 91 | { |
| 92 | return le32_to_cpu(get_unaligned((__le32 *)p)); |
| 93 | } |
| 94 | static inline unsigned int isonum_732(char *p) |
| 95 | { |
| 96 | return be32_to_cpu(get_unaligned((__le32 *)p)); |
| 97 | } |
| 98 | static inline unsigned int isonum_733(char *p) |
| 99 | { |
| 100 | /* Ignore bigendian datum due to broken mastering programs */ |
| 101 | return le32_to_cpu(get_unaligned((__le32 *)p)); |
| 102 | } |
| 103 | extern int iso_date(char *, int); |
| 104 | |
| 105 | struct inode; /* To make gcc happy */ |
| 106 | |
| 107 | extern int parse_rock_ridge_inode(struct iso_directory_record *, struct inode *); |
| 108 | extern int get_rock_ridge_filename(struct iso_directory_record *, char *, struct inode *); |
| 109 | extern int isofs_name_translate(struct iso_directory_record *, char *, struct inode *); |
| 110 | |
| 111 | int get_joliet_filename(struct iso_directory_record *, unsigned char *, struct inode *); |
| 112 | int get_acorn_filename(struct iso_directory_record *, char *, struct inode *); |
| 113 | |
| 114 | extern struct dentry *isofs_lookup(struct inode *, struct dentry *, struct nameidata *); |
| 115 | extern struct buffer_head *isofs_bread(struct inode *, sector_t); |
| 116 | extern int isofs_get_blocks(struct inode *, sector_t, struct buffer_head **, unsigned long); |
| 117 | |
| 118 | extern struct inode *isofs_iget(struct super_block *sb, |
| 119 | unsigned long block, |
| 120 | unsigned long offset); |
| 121 | |
| 122 | /* Because the inode number is no longer relevant to finding the |
| 123 | * underlying meta-data for an inode, we are free to choose a more |
| 124 | * convenient 32-bit number as the inode number. The inode numbering |
| 125 | * scheme was recommended by Sergey Vlasov and Eric Lammerts. */ |
| 126 | static inline unsigned long isofs_get_ino(unsigned long block, |
| 127 | unsigned long offset, |
| 128 | unsigned long bufbits) |
| 129 | { |
| 130 | return (block << (bufbits - 5)) | (offset >> 5); |
| 131 | } |
| 132 | |
| 133 | /* Every directory can have many redundant directory entries scattered |
| 134 | * throughout the directory tree. First there is the directory entry |
| 135 | * with the name of the directory stored in the parent directory. |
| 136 | * Then, there is the "." directory entry stored in the directory |
| 137 | * itself. Finally, there are possibly many ".." directory entries |
| 138 | * stored in all the subdirectories. |
| 139 | * |
| 140 | * In order for the NFS get_parent() method to work and for the |
| 141 | * general consistency of the dcache, we need to make sure the |
| 142 | * "i_iget5_block" and "i_iget5_offset" all point to exactly one of |
| 143 | * the many redundant entries for each directory. We normalize the |
| 144 | * block and offset by always making them point to the "." directory. |
| 145 | * |
| 146 | * Notice that we do not use the entry for the directory with the name |
| 147 | * that is located in the parent directory. Even though choosing this |
| 148 | * first directory is more natural, it is much easier to find the "." |
| 149 | * entry in the NFS get_parent() method because it is implicitly |
| 150 | * encoded in the "extent + ext_attr_length" fields of _all_ the |
| 151 | * redundant entries for the directory. Thus, it can always be |
| 152 | * reached regardless of which directory entry you have in hand. |
| 153 | * |
| 154 | * This works because the "." entry is simply the first directory |
| 155 | * record when you start reading the file that holds all the directory |
| 156 | * records, and this file starts at "extent + ext_attr_length" blocks. |
| 157 | * Because the "." entry is always the first entry listed in the |
| 158 | * directories file, the normalized "offset" value is always 0. |
| 159 | * |
| 160 | * You should pass the directory entry in "de". On return, "block" |
| 161 | * and "offset" will hold normalized values. Only directories are |
| 162 | * affected making it safe to call even for non-directory file |
| 163 | * types. */ |
| 164 | static inline void |
| 165 | isofs_normalize_block_and_offset(struct iso_directory_record* de, |
| 166 | unsigned long *block, |
| 167 | unsigned long *offset) |
| 168 | { |
| 169 | /* Only directories are normalized. */ |
| 170 | if (de->flags[0] & 2) { |
| 171 | *offset = 0; |
| 172 | *block = (unsigned long)isonum_733(de->extent) |
| 173 | + (unsigned long)isonum_711(de->ext_attr_length); |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | extern struct inode_operations isofs_dir_inode_operations; |
Arjan van de Ven | 4b6f5d2 | 2006-03-28 01:56:42 -0800 | [diff] [blame] | 178 | extern const struct file_operations isofs_dir_operations; |
Christoph Hellwig | f5e54d6 | 2006-06-28 04:26:44 -0700 | [diff] [blame] | 179 | extern const struct address_space_operations isofs_symlink_aops; |
Al Viro | 94f2f715 | 2005-04-25 18:32:12 -0700 | [diff] [blame] | 180 | extern struct export_operations isofs_export_ops; |