Lines Matching full:sb

32 static int hfs_get_last_session(struct super_block *sb,  in hfs_get_last_session()  argument
35 struct cdrom_device_info *cdi = disk_to_cdi(sb->s_bdev->bd_disk); in hfs_get_last_session()
39 *size = bdev_nr_sectors(sb->s_bdev); in hfs_get_last_session()
41 if (HFS_SB(sb)->session >= 0) { in hfs_get_last_session()
47 te.cdte_track = HFS_SB(sb)->session; in hfs_get_last_session()
73 int hfs_mdb_get(struct super_block *sb) in hfs_mdb_get() argument
85 size = sb_min_blocksize(sb, HFS_SECTOR_SIZE); in hfs_mdb_get()
89 if (hfs_get_last_session(sb, &part_start, &part_size)) in hfs_mdb_get()
93 bh = sb_bread512(sb, part_start + HFS_MDB_BLK, mdb); in hfs_mdb_get()
104 if (hfs_part_find(sb, &part_start, &part_size)) in hfs_mdb_get()
108 HFS_SB(sb)->alloc_blksz = size = be32_to_cpu(mdb->drAlBlkSiz); in hfs_mdb_get()
114 size = min(HFS_SB(sb)->alloc_blksz, (u32)PAGE_SIZE); in hfs_mdb_get()
123 while (HFS_SB(sb)->alloc_blksz & (size - 1)) in hfs_mdb_get()
126 if (!sb_set_blocksize(sb, size)) { in hfs_mdb_get()
131 bh = sb_bread512(sb, part_start + HFS_MDB_BLK, mdb); in hfs_mdb_get()
137 HFS_SB(sb)->mdb_bh = bh; in hfs_mdb_get()
138 HFS_SB(sb)->mdb = mdb; in hfs_mdb_get()
141 HFS_SB(sb)->part_start = part_start; in hfs_mdb_get()
142 HFS_SB(sb)->fs_ablocks = be16_to_cpu(mdb->drNmAlBlks); in hfs_mdb_get()
143 HFS_SB(sb)->fs_div = HFS_SB(sb)->alloc_blksz >> sb->s_blocksize_bits; in hfs_mdb_get()
144 HFS_SB(sb)->clumpablks = be32_to_cpu(mdb->drClpSiz) / in hfs_mdb_get()
145 HFS_SB(sb)->alloc_blksz; in hfs_mdb_get()
146 if (!HFS_SB(sb)->clumpablks) in hfs_mdb_get()
147 HFS_SB(sb)->clumpablks = 1; in hfs_mdb_get()
148 HFS_SB(sb)->fs_start = (be16_to_cpu(mdb->drAlBlSt) + part_start) >> in hfs_mdb_get()
149 (sb->s_blocksize_bits - HFS_SECTOR_SIZE_BITS); in hfs_mdb_get()
152 HFS_SB(sb)->free_ablocks = be16_to_cpu(mdb->drFreeBks); in hfs_mdb_get()
153 HFS_SB(sb)->next_id = be32_to_cpu(mdb->drNxtCNID); in hfs_mdb_get()
154 HFS_SB(sb)->root_files = be16_to_cpu(mdb->drNmFls); in hfs_mdb_get()
155 HFS_SB(sb)->root_dirs = be16_to_cpu(mdb->drNmRtDirs); in hfs_mdb_get()
156 HFS_SB(sb)->file_count = be32_to_cpu(mdb->drFilCnt); in hfs_mdb_get()
157 HFS_SB(sb)->folder_count = be32_to_cpu(mdb->drDirCnt); in hfs_mdb_get()
161 bh = sb_bread512(sb, sect, mdb2); in hfs_mdb_get()
164 HFS_SB(sb)->alt_mdb_bh = bh; in hfs_mdb_get()
165 HFS_SB(sb)->alt_mdb = mdb2; in hfs_mdb_get()
170 if (!HFS_SB(sb)->alt_mdb) { in hfs_mdb_get()
175 HFS_SB(sb)->bitmap = kmalloc(8192, GFP_KERNEL); in hfs_mdb_get()
176 if (!HFS_SB(sb)->bitmap) in hfs_mdb_get()
182 size = (HFS_SB(sb)->fs_ablocks + 8) / 8; in hfs_mdb_get()
183 ptr = (u8 *)HFS_SB(sb)->bitmap; in hfs_mdb_get()
185 bh = sb_bread(sb, off >> sb->s_blocksize_bits); in hfs_mdb_get()
190 off2 = off & (sb->s_blocksize - 1); in hfs_mdb_get()
191 len = min((int)sb->s_blocksize - off2, size); in hfs_mdb_get()
199 HFS_SB(sb)->ext_tree = hfs_btree_open(sb, HFS_EXT_CNID, hfs_ext_keycmp); in hfs_mdb_get()
200 if (!HFS_SB(sb)->ext_tree) { in hfs_mdb_get()
204 HFS_SB(sb)->cat_tree = hfs_btree_open(sb, HFS_CAT_CNID, hfs_cat_keycmp); in hfs_mdb_get()
205 if (!HFS_SB(sb)->cat_tree) { in hfs_mdb_get()
213 sb->s_flags |= SB_RDONLY; in hfs_mdb_get()
217 sb->s_flags |= SB_RDONLY; in hfs_mdb_get()
219 if (!sb_rdonly(sb)) { in hfs_mdb_get()
227 mark_buffer_dirty(HFS_SB(sb)->mdb_bh); in hfs_mdb_get()
228 sync_dirty_buffer(HFS_SB(sb)->mdb_bh); in hfs_mdb_get()
236 hfs_mdb_put(sb); in hfs_mdb_get()
264 void hfs_mdb_commit(struct super_block *sb) in hfs_mdb_commit() argument
266 struct hfs_mdb *mdb = HFS_SB(sb)->mdb; in hfs_mdb_commit()
268 if (sb_rdonly(sb)) in hfs_mdb_commit()
271 lock_buffer(HFS_SB(sb)->mdb_bh); in hfs_mdb_commit()
272 if (test_and_clear_bit(HFS_FLG_MDB_DIRTY, &HFS_SB(sb)->flags)) { in hfs_mdb_commit()
275 mdb->drFreeBks = cpu_to_be16(HFS_SB(sb)->free_ablocks); in hfs_mdb_commit()
276 mdb->drNxtCNID = cpu_to_be32(HFS_SB(sb)->next_id); in hfs_mdb_commit()
277 mdb->drNmFls = cpu_to_be16(HFS_SB(sb)->root_files); in hfs_mdb_commit()
278 mdb->drNmRtDirs = cpu_to_be16(HFS_SB(sb)->root_dirs); in hfs_mdb_commit()
279 mdb->drFilCnt = cpu_to_be32(HFS_SB(sb)->file_count); in hfs_mdb_commit()
280 mdb->drDirCnt = cpu_to_be32(HFS_SB(sb)->folder_count); in hfs_mdb_commit()
283 mark_buffer_dirty(HFS_SB(sb)->mdb_bh); in hfs_mdb_commit()
289 if (test_and_clear_bit(HFS_FLG_ALT_MDB_DIRTY, &HFS_SB(sb)->flags) && in hfs_mdb_commit()
290 HFS_SB(sb)->alt_mdb) { in hfs_mdb_commit()
291 hfs_inode_write_fork(HFS_SB(sb)->ext_tree->inode, mdb->drXTExtRec, in hfs_mdb_commit()
293 hfs_inode_write_fork(HFS_SB(sb)->cat_tree->inode, mdb->drCTExtRec, in hfs_mdb_commit()
296 lock_buffer(HFS_SB(sb)->alt_mdb_bh); in hfs_mdb_commit()
297 memcpy(HFS_SB(sb)->alt_mdb, HFS_SB(sb)->mdb, HFS_SECTOR_SIZE); in hfs_mdb_commit()
298 HFS_SB(sb)->alt_mdb->drAtrb |= cpu_to_be16(HFS_SB_ATTRIB_UNMNT); in hfs_mdb_commit()
299 HFS_SB(sb)->alt_mdb->drAtrb &= cpu_to_be16(~HFS_SB_ATTRIB_INCNSTNT); in hfs_mdb_commit()
300 unlock_buffer(HFS_SB(sb)->alt_mdb_bh); in hfs_mdb_commit()
302 mark_buffer_dirty(HFS_SB(sb)->alt_mdb_bh); in hfs_mdb_commit()
303 sync_dirty_buffer(HFS_SB(sb)->alt_mdb_bh); in hfs_mdb_commit()
306 if (test_and_clear_bit(HFS_FLG_BITMAP_DIRTY, &HFS_SB(sb)->flags)) { in hfs_mdb_commit()
312 block = be16_to_cpu(HFS_SB(sb)->mdb->drVBMSt) + HFS_SB(sb)->part_start; in hfs_mdb_commit()
313 off = (block << HFS_SECTOR_SIZE_BITS) & (sb->s_blocksize - 1); in hfs_mdb_commit()
314 block >>= sb->s_blocksize_bits - HFS_SECTOR_SIZE_BITS; in hfs_mdb_commit()
315 size = (HFS_SB(sb)->fs_ablocks + 7) / 8; in hfs_mdb_commit()
316 ptr = (u8 *)HFS_SB(sb)->bitmap; in hfs_mdb_commit()
318 bh = sb_bread(sb, block); in hfs_mdb_commit()
323 len = min((int)sb->s_blocksize - off, size); in hfs_mdb_commit()
337 unlock_buffer(HFS_SB(sb)->mdb_bh); in hfs_mdb_commit()
340 void hfs_mdb_close(struct super_block *sb) in hfs_mdb_close() argument
343 if (sb_rdonly(sb)) in hfs_mdb_close()
345 HFS_SB(sb)->mdb->drAtrb |= cpu_to_be16(HFS_SB_ATTRIB_UNMNT); in hfs_mdb_close()
346 HFS_SB(sb)->mdb->drAtrb &= cpu_to_be16(~HFS_SB_ATTRIB_INCNSTNT); in hfs_mdb_close()
347 mark_buffer_dirty(HFS_SB(sb)->mdb_bh); in hfs_mdb_close()
354 void hfs_mdb_put(struct super_block *sb) in hfs_mdb_put() argument
356 if (!HFS_SB(sb)) in hfs_mdb_put()
359 hfs_btree_close(HFS_SB(sb)->ext_tree); in hfs_mdb_put()
360 hfs_btree_close(HFS_SB(sb)->cat_tree); in hfs_mdb_put()
363 brelse(HFS_SB(sb)->mdb_bh); in hfs_mdb_put()
364 brelse(HFS_SB(sb)->alt_mdb_bh); in hfs_mdb_put()
366 unload_nls(HFS_SB(sb)->nls_io); in hfs_mdb_put()
367 unload_nls(HFS_SB(sb)->nls_disk); in hfs_mdb_put()
369 kfree(HFS_SB(sb)->bitmap); in hfs_mdb_put()
370 kfree(HFS_SB(sb)); in hfs_mdb_put()
371 sb->s_fs_info = NULL; in hfs_mdb_put()