Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/fs/hpfs/map.c |
| 3 | * |
| 4 | * Mikulas Patocka (mikulas@artax.karlin.mff.cuni.cz), 1998-1999 |
| 5 | * |
| 6 | * mapping structures to memory with some minimal checks |
| 7 | */ |
| 8 | |
| 9 | #include "hpfs_fn.h" |
| 10 | |
Al Viro | 52576da | 2012-04-17 15:28:51 -0400 | [diff] [blame] | 11 | __le32 *hpfs_map_dnode_bitmap(struct super_block *s, struct quad_buffer_head *qbh) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | { |
| 13 | return hpfs_map_4sectors(s, hpfs_sb(s)->sb_dmap, qbh, 0); |
| 14 | } |
| 15 | |
Al Viro | 52576da | 2012-04-17 15:28:51 -0400 | [diff] [blame] | 16 | __le32 *hpfs_map_bitmap(struct super_block *s, unsigned bmp_block, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | struct quad_buffer_head *qbh, char *id) |
| 18 | { |
| 19 | secno sec; |
Mikulas Patocka | 275f495 | 2013-07-04 19:04:01 +0200 | [diff] [blame] | 20 | __le32 *ret; |
Mikulas Patocka | 3ebacb0 | 2013-07-04 18:42:29 +0200 | [diff] [blame] | 21 | unsigned n_bands = (hpfs_sb(s)->sb_fs_size + 0x3fff) >> 14; |
| 22 | if (hpfs_sb(s)->sb_chk) if (bmp_block >= n_bands) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | hpfs_error(s, "hpfs_map_bitmap called with bad parameter: %08x at %s", bmp_block, id); |
| 24 | return NULL; |
| 25 | } |
Mikulas Patocka | 0b69760 | 2011-05-08 20:44:26 +0200 | [diff] [blame] | 26 | sec = le32_to_cpu(hpfs_sb(s)->sb_bmp_dir[bmp_block]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | if (!sec || sec > hpfs_sb(s)->sb_fs_size-4) { |
| 28 | hpfs_error(s, "invalid bitmap block pointer %08x -> %08x at %s", bmp_block, sec, id); |
| 29 | return NULL; |
| 30 | } |
Mikulas Patocka | 275f495 | 2013-07-04 19:04:01 +0200 | [diff] [blame] | 31 | ret = hpfs_map_4sectors(s, sec, qbh, 4); |
| 32 | if (ret) hpfs_prefetch_bitmap(s, bmp_block + 1); |
| 33 | return ret; |
| 34 | } |
| 35 | |
| 36 | void hpfs_prefetch_bitmap(struct super_block *s, unsigned bmp_block) |
| 37 | { |
| 38 | unsigned to_prefetch, next_prefetch; |
| 39 | unsigned n_bands = (hpfs_sb(s)->sb_fs_size + 0x3fff) >> 14; |
| 40 | if (unlikely(bmp_block >= n_bands)) |
| 41 | return; |
| 42 | to_prefetch = le32_to_cpu(hpfs_sb(s)->sb_bmp_dir[bmp_block]); |
| 43 | if (unlikely(bmp_block + 1 >= n_bands)) |
| 44 | next_prefetch = 0; |
| 45 | else |
| 46 | next_prefetch = le32_to_cpu(hpfs_sb(s)->sb_bmp_dir[bmp_block + 1]); |
| 47 | hpfs_prefetch_sectors(s, to_prefetch, 4 + 4 * (to_prefetch + 4 == next_prefetch)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | /* |
| 51 | * Load first code page into kernel memory, return pointer to 256-byte array, |
| 52 | * first 128 bytes are uppercasing table for chars 128-255, next 128 bytes are |
| 53 | * lowercasing table |
| 54 | */ |
| 55 | |
Al Viro | 7e7742e | 2010-01-31 17:09:29 -0500 | [diff] [blame] | 56 | unsigned char *hpfs_load_code_page(struct super_block *s, secno cps) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | { |
| 58 | struct buffer_head *bh; |
| 59 | secno cpds; |
| 60 | unsigned cpi; |
| 61 | unsigned char *ptr; |
| 62 | unsigned char *cp_table; |
| 63 | int i; |
| 64 | struct code_page_data *cpd; |
| 65 | struct code_page_directory *cp = hpfs_map_sector(s, cps, &bh, 0); |
| 66 | if (!cp) return NULL; |
Mikulas Patocka | 0b69760 | 2011-05-08 20:44:26 +0200 | [diff] [blame] | 67 | if (le32_to_cpu(cp->magic) != CP_DIR_MAGIC) { |
Fabian Frederick | a19189e | 2014-06-06 14:36:36 -0700 | [diff] [blame] | 68 | pr_err("Code page directory magic doesn't match (magic = %08x)\n", |
Fabian Frederick | b7cb1ce | 2014-06-06 14:36:34 -0700 | [diff] [blame] | 69 | le32_to_cpu(cp->magic)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | brelse(bh); |
| 71 | return NULL; |
| 72 | } |
Mikulas Patocka | 0b69760 | 2011-05-08 20:44:26 +0200 | [diff] [blame] | 73 | if (!le32_to_cpu(cp->n_code_pages)) { |
Fabian Frederick | a19189e | 2014-06-06 14:36:36 -0700 | [diff] [blame] | 74 | pr_err("n_code_pages == 0\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | brelse(bh); |
| 76 | return NULL; |
| 77 | } |
Mikulas Patocka | 0b69760 | 2011-05-08 20:44:26 +0200 | [diff] [blame] | 78 | cpds = le32_to_cpu(cp->array[0].code_page_data); |
| 79 | cpi = le16_to_cpu(cp->array[0].index); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | brelse(bh); |
| 81 | |
| 82 | if (cpi >= 3) { |
Fabian Frederick | a19189e | 2014-06-06 14:36:36 -0700 | [diff] [blame] | 83 | pr_err("Code page index out of array\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | return NULL; |
| 85 | } |
| 86 | |
| 87 | if (!(cpd = hpfs_map_sector(s, cpds, &bh, 0))) return NULL; |
Mikulas Patocka | 0b69760 | 2011-05-08 20:44:26 +0200 | [diff] [blame] | 88 | if (le16_to_cpu(cpd->offs[cpi]) > 0x178) { |
Fabian Frederick | a19189e | 2014-06-06 14:36:36 -0700 | [diff] [blame] | 89 | pr_err("Code page index out of sector\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | brelse(bh); |
| 91 | return NULL; |
| 92 | } |
Mikulas Patocka | 0b69760 | 2011-05-08 20:44:26 +0200 | [diff] [blame] | 93 | ptr = (unsigned char *)cpd + le16_to_cpu(cpd->offs[cpi]) + 6; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | if (!(cp_table = kmalloc(256, GFP_KERNEL))) { |
Fabian Frederick | a19189e | 2014-06-06 14:36:36 -0700 | [diff] [blame] | 95 | pr_err("out of memory for code page table\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | brelse(bh); |
| 97 | return NULL; |
| 98 | } |
| 99 | memcpy(cp_table, ptr, 128); |
| 100 | brelse(bh); |
| 101 | |
| 102 | /* Try to build lowercasing table from uppercasing one */ |
| 103 | |
| 104 | for (i=128; i<256; i++) cp_table[i]=i; |
| 105 | for (i=128; i<256; i++) if (cp_table[i-128]!=i && cp_table[i-128]>=128) |
| 106 | cp_table[cp_table[i-128]] = i; |
| 107 | |
| 108 | return cp_table; |
| 109 | } |
| 110 | |
Al Viro | 28fe3c1 | 2012-04-17 16:41:13 -0400 | [diff] [blame] | 111 | __le32 *hpfs_load_bitmap_directory(struct super_block *s, secno bmp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | { |
| 113 | struct buffer_head *bh; |
| 114 | int n = (hpfs_sb(s)->sb_fs_size + 0x200000 - 1) >> 21; |
| 115 | int i; |
Al Viro | 28fe3c1 | 2012-04-17 16:41:13 -0400 | [diff] [blame] | 116 | __le32 *b; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | if (!(b = kmalloc(n * 512, GFP_KERNEL))) { |
Fabian Frederick | a19189e | 2014-06-06 14:36:36 -0700 | [diff] [blame] | 118 | pr_err("can't allocate memory for bitmap directory\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | return NULL; |
| 120 | } |
| 121 | for (i=0;i<n;i++) { |
Al Viro | 28fe3c1 | 2012-04-17 16:41:13 -0400 | [diff] [blame] | 122 | __le32 *d = hpfs_map_sector(s, bmp+i, &bh, n - i - 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | if (!d) { |
| 124 | kfree(b); |
| 125 | return NULL; |
| 126 | } |
| 127 | memcpy((char *)b + 512 * i, d, 512); |
| 128 | brelse(bh); |
| 129 | } |
| 130 | return b; |
| 131 | } |
| 132 | |
| 133 | /* |
| 134 | * Load fnode to memory |
| 135 | */ |
| 136 | |
| 137 | struct fnode *hpfs_map_fnode(struct super_block *s, ino_t ino, struct buffer_head **bhp) |
| 138 | { |
| 139 | struct fnode *fnode; |
| 140 | if (hpfs_sb(s)->sb_chk) if (hpfs_chk_sectors(s, ino, 1, "fnode")) { |
| 141 | return NULL; |
| 142 | } |
| 143 | if ((fnode = hpfs_map_sector(s, ino, bhp, FNODE_RD_AHEAD))) { |
| 144 | if (hpfs_sb(s)->sb_chk) { |
| 145 | struct extended_attribute *ea; |
| 146 | struct extended_attribute *ea_end; |
Mikulas Patocka | 0b69760 | 2011-05-08 20:44:26 +0200 | [diff] [blame] | 147 | if (le32_to_cpu(fnode->magic) != FNODE_MAGIC) { |
Randy Dunlap | 18debbb | 2006-12-06 20:37:05 -0800 | [diff] [blame] | 148 | hpfs_error(s, "bad magic on fnode %08lx", |
| 149 | (unsigned long)ino); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 150 | goto bail; |
| 151 | } |
Al Viro | c4c9954 | 2012-04-06 14:30:07 -0400 | [diff] [blame] | 152 | if (!fnode_is_dir(fnode)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | if ((unsigned)fnode->btree.n_used_nodes + (unsigned)fnode->btree.n_free_nodes != |
Al Viro | ddc19e6 | 2012-04-17 15:59:35 -0400 | [diff] [blame] | 154 | (bp_internal(&fnode->btree) ? 12 : 8)) { |
Randy Dunlap | 18debbb | 2006-12-06 20:37:05 -0800 | [diff] [blame] | 155 | hpfs_error(s, |
| 156 | "bad number of nodes in fnode %08lx", |
| 157 | (unsigned long)ino); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | goto bail; |
| 159 | } |
Mikulas Patocka | 0b69760 | 2011-05-08 20:44:26 +0200 | [diff] [blame] | 160 | if (le16_to_cpu(fnode->btree.first_free) != |
Al Viro | ddc19e6 | 2012-04-17 15:59:35 -0400 | [diff] [blame] | 161 | 8 + fnode->btree.n_used_nodes * (bp_internal(&fnode->btree) ? 8 : 12)) { |
Randy Dunlap | 18debbb | 2006-12-06 20:37:05 -0800 | [diff] [blame] | 162 | hpfs_error(s, |
| 163 | "bad first_free pointer in fnode %08lx", |
| 164 | (unsigned long)ino); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | goto bail; |
| 166 | } |
| 167 | } |
Mikulas Patocka | 0b69760 | 2011-05-08 20:44:26 +0200 | [diff] [blame] | 168 | if (le16_to_cpu(fnode->ea_size_s) && (le16_to_cpu(fnode->ea_offs) < 0xc4 || |
| 169 | le16_to_cpu(fnode->ea_offs) + le16_to_cpu(fnode->acl_size_s) + le16_to_cpu(fnode->ea_size_s) > 0x200)) { |
Randy Dunlap | 18debbb | 2006-12-06 20:37:05 -0800 | [diff] [blame] | 170 | hpfs_error(s, |
| 171 | "bad EA info in fnode %08lx: ea_offs == %04x ea_size_s == %04x", |
| 172 | (unsigned long)ino, |
Mikulas Patocka | 0b69760 | 2011-05-08 20:44:26 +0200 | [diff] [blame] | 173 | le16_to_cpu(fnode->ea_offs), le16_to_cpu(fnode->ea_size_s)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | goto bail; |
| 175 | } |
| 176 | ea = fnode_ea(fnode); |
| 177 | ea_end = fnode_end_ea(fnode); |
| 178 | while (ea != ea_end) { |
| 179 | if (ea > ea_end) { |
Randy Dunlap | 18debbb | 2006-12-06 20:37:05 -0800 | [diff] [blame] | 180 | hpfs_error(s, "bad EA in fnode %08lx", |
| 181 | (unsigned long)ino); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | goto bail; |
| 183 | } |
| 184 | ea = next_ea(ea); |
| 185 | } |
| 186 | } |
| 187 | } |
| 188 | return fnode; |
| 189 | bail: |
| 190 | brelse(*bhp); |
| 191 | return NULL; |
| 192 | } |
| 193 | |
| 194 | struct anode *hpfs_map_anode(struct super_block *s, anode_secno ano, struct buffer_head **bhp) |
| 195 | { |
| 196 | struct anode *anode; |
| 197 | if (hpfs_sb(s)->sb_chk) if (hpfs_chk_sectors(s, ano, 1, "anode")) return NULL; |
| 198 | if ((anode = hpfs_map_sector(s, ano, bhp, ANODE_RD_AHEAD))) |
| 199 | if (hpfs_sb(s)->sb_chk) { |
Mikulas Patocka | 0b69760 | 2011-05-08 20:44:26 +0200 | [diff] [blame] | 200 | if (le32_to_cpu(anode->magic) != ANODE_MAGIC) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | hpfs_error(s, "bad magic on anode %08x", ano); |
| 202 | goto bail; |
| 203 | } |
Mikulas Patocka | 0b69760 | 2011-05-08 20:44:26 +0200 | [diff] [blame] | 204 | if (le32_to_cpu(anode->self) != ano) { |
| 205 | hpfs_error(s, "self pointer invalid on anode %08x", ano); |
| 206 | goto bail; |
| 207 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 | if ((unsigned)anode->btree.n_used_nodes + (unsigned)anode->btree.n_free_nodes != |
Al Viro | ddc19e6 | 2012-04-17 15:59:35 -0400 | [diff] [blame] | 209 | (bp_internal(&anode->btree) ? 60 : 40)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 210 | hpfs_error(s, "bad number of nodes in anode %08x", ano); |
| 211 | goto bail; |
| 212 | } |
Mikulas Patocka | 0b69760 | 2011-05-08 20:44:26 +0200 | [diff] [blame] | 213 | if (le16_to_cpu(anode->btree.first_free) != |
Al Viro | ddc19e6 | 2012-04-17 15:59:35 -0400 | [diff] [blame] | 214 | 8 + anode->btree.n_used_nodes * (bp_internal(&anode->btree) ? 8 : 12)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | hpfs_error(s, "bad first_free pointer in anode %08x", ano); |
| 216 | goto bail; |
| 217 | } |
| 218 | } |
| 219 | return anode; |
| 220 | bail: |
| 221 | brelse(*bhp); |
| 222 | return NULL; |
| 223 | } |
| 224 | |
| 225 | /* |
| 226 | * Load dnode to memory and do some checks |
| 227 | */ |
| 228 | |
| 229 | struct dnode *hpfs_map_dnode(struct super_block *s, unsigned secno, |
| 230 | struct quad_buffer_head *qbh) |
| 231 | { |
| 232 | struct dnode *dnode; |
| 233 | if (hpfs_sb(s)->sb_chk) { |
| 234 | if (hpfs_chk_sectors(s, secno, 4, "dnode")) return NULL; |
| 235 | if (secno & 3) { |
| 236 | hpfs_error(s, "dnode %08x not byte-aligned", secno); |
| 237 | return NULL; |
| 238 | } |
| 239 | } |
| 240 | if ((dnode = hpfs_map_4sectors(s, secno, qbh, DNODE_RD_AHEAD))) |
| 241 | if (hpfs_sb(s)->sb_chk) { |
| 242 | unsigned p, pp = 0; |
Al Viro | 7e7742e | 2010-01-31 17:09:29 -0500 | [diff] [blame] | 243 | unsigned char *d = (unsigned char *)dnode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 244 | int b = 0; |
Mikulas Patocka | 0b69760 | 2011-05-08 20:44:26 +0200 | [diff] [blame] | 245 | if (le32_to_cpu(dnode->magic) != DNODE_MAGIC) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 246 | hpfs_error(s, "bad magic on dnode %08x", secno); |
| 247 | goto bail; |
| 248 | } |
Mikulas Patocka | 0b69760 | 2011-05-08 20:44:26 +0200 | [diff] [blame] | 249 | if (le32_to_cpu(dnode->self) != secno) |
| 250 | hpfs_error(s, "bad self pointer on dnode %08x self = %08x", secno, le32_to_cpu(dnode->self)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 251 | /* Check dirents - bad dirents would cause infinite |
| 252 | loops or shooting to memory */ |
Mikulas Patocka | 0b69760 | 2011-05-08 20:44:26 +0200 | [diff] [blame] | 253 | if (le32_to_cpu(dnode->first_free) > 2048) { |
| 254 | hpfs_error(s, "dnode %08x has first_free == %08x", secno, le32_to_cpu(dnode->first_free)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | goto bail; |
| 256 | } |
Mikulas Patocka | 0b69760 | 2011-05-08 20:44:26 +0200 | [diff] [blame] | 257 | for (p = 20; p < le32_to_cpu(dnode->first_free); p += d[p] + (d[p+1] << 8)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 | struct hpfs_dirent *de = (struct hpfs_dirent *)((char *)dnode + p); |
Mikulas Patocka | 0b69760 | 2011-05-08 20:44:26 +0200 | [diff] [blame] | 259 | if (le16_to_cpu(de->length) > 292 || (le16_to_cpu(de->length) < 32) || (le16_to_cpu(de->length) & 3) || p + le16_to_cpu(de->length) > 2048) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | hpfs_error(s, "bad dirent size in dnode %08x, dirent %03x, last %03x", secno, p, pp); |
| 261 | goto bail; |
| 262 | } |
Mikulas Patocka | 0b69760 | 2011-05-08 20:44:26 +0200 | [diff] [blame] | 263 | if (((31 + de->namelen + de->down*4 + 3) & ~3) != le16_to_cpu(de->length)) { |
| 264 | if (((31 + de->namelen + de->down*4 + 3) & ~3) < le16_to_cpu(de->length) && s->s_flags & MS_RDONLY) goto ok; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 265 | hpfs_error(s, "namelen does not match dirent size in dnode %08x, dirent %03x, last %03x", secno, p, pp); |
| 266 | goto bail; |
| 267 | } |
| 268 | ok: |
| 269 | if (hpfs_sb(s)->sb_chk >= 2) b |= 1 << de->down; |
| 270 | if (de->down) if (de_down_pointer(de) < 0x10) { |
| 271 | hpfs_error(s, "bad down pointer in dnode %08x, dirent %03x, last %03x", secno, p, pp); |
| 272 | goto bail; |
| 273 | } |
| 274 | pp = p; |
| 275 | |
| 276 | } |
Mikulas Patocka | 0b69760 | 2011-05-08 20:44:26 +0200 | [diff] [blame] | 277 | if (p != le32_to_cpu(dnode->first_free)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 | hpfs_error(s, "size on last dirent does not match first_free; dnode %08x", secno); |
| 279 | goto bail; |
| 280 | } |
| 281 | if (d[pp + 30] != 1 || d[pp + 31] != 255) { |
| 282 | hpfs_error(s, "dnode %08x does not end with \\377 entry", secno); |
| 283 | goto bail; |
| 284 | } |
Fabian Frederick | b7cb1ce | 2014-06-06 14:36:34 -0700 | [diff] [blame] | 285 | if (b == 3) |
Fabian Frederick | a19189e | 2014-06-06 14:36:36 -0700 | [diff] [blame] | 286 | pr_err("unbalanced dnode tree, dnode %08x; see hpfs.txt 4 more info\n", |
Fabian Frederick | b7cb1ce | 2014-06-06 14:36:34 -0700 | [diff] [blame] | 287 | secno); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | } |
| 289 | return dnode; |
| 290 | bail: |
| 291 | hpfs_brelse4(qbh); |
| 292 | return NULL; |
| 293 | } |
| 294 | |
| 295 | dnode_secno hpfs_fnode_dno(struct super_block *s, ino_t ino) |
| 296 | { |
| 297 | struct buffer_head *bh; |
| 298 | struct fnode *fnode; |
| 299 | dnode_secno dno; |
| 300 | |
| 301 | fnode = hpfs_map_fnode(s, ino, &bh); |
| 302 | if (!fnode) |
| 303 | return 0; |
| 304 | |
Mikulas Patocka | 0b69760 | 2011-05-08 20:44:26 +0200 | [diff] [blame] | 305 | dno = le32_to_cpu(fnode->u.external[0].disk_secno); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | brelse(bh); |
| 307 | return dno; |
| 308 | } |