13 #include <linux/module.h>
15 #include <linux/slab.h>
32 static void qnx6_destroy_inode(
struct inode *
inode);
35 static int qnx6_show_options(
struct seq_file *seq,
struct dentry *root);
38 .alloc_inode = qnx6_alloc_inode,
39 .destroy_inode = qnx6_destroy_inode,
40 .put_super = qnx6_put_super,
41 .statfs = qnx6_statfs,
42 .remount_fs = qnx6_remount,
43 .show_options = qnx6_show_options,
46 static int qnx6_show_options(
struct seq_file *seq,
struct dentry *root)
65 return fs32_to_cpu(sbi, block) + sbi->
s_blks_off;
68 static unsigned qnx6_block_map(
struct inode *
inode,
unsigned iblock);
71 struct buffer_head *bh,
int create)
76 inode->
i_ino, (
unsigned long)iblock));
78 phys = qnx6_block_map(inode, iblock);
81 map_bh(bh, inode->
i_sb, phys);
86 static int qnx6_check_blockptr(
__fs32 ptr)
110 static unsigned qnx6_block_map(
struct inode *inode,
unsigned no)
116 struct buffer_head *bh;
125 bitdelta = ptrbits *
depth;
126 levelptr = no >> bitdelta;
134 block = qnx6_get_devblock(s, ei->
di_block_ptr[levelptr]);
136 for (i = 0; i <
depth; i++) {
137 bh = sb_bread(s, block);
144 levelptr = (no >> bitdelta) & mask;
145 ptr = ((
__fs32 *)bh->b_data)[levelptr];
147 if (!qnx6_check_blockptr(ptr))
150 block = qnx6_get_devblock(s, ptr);
160 u64 id = huge_encode_dev(sb->
s_bdev->bd_dev);
164 buf->
f_blocks = fs32_to_cpu(sbi, sbi->
sb->sb_num_blocks);
165 buf->
f_bfree = fs32_to_cpu(sbi, sbi->
sb->sb_free_blocks);
166 buf->
f_files = fs32_to_cpu(sbi, sbi->
sb->sb_num_inodes);
167 buf->
f_ffree = fs32_to_cpu(sbi, sbi->
sb->sb_free_inodes);
181 static const char *qnx6_checkroot(
struct super_block *s)
183 static char match_root[2][3] = {
".\0\0",
"..\0"};
186 struct inode *root = s->
s_root->d_inode;
188 struct page *
page = read_mapping_page(mapping, 0,
NULL);
190 return "error reading root directory";
193 for (i = 0; i < 2; i++) {
195 if (
strncmp(dir_entry[i].de_fname, match_root[i], 3))
200 return "error reading root directory.";
204 #ifdef CONFIG_QNX6FS_DEBUG
268 static struct buffer_head *qnx6_check_first_superblock(
struct super_block *s,
272 struct buffer_head *bh;
277 bh = sb_bread(s, offset);
295 " in superblock #1.\n");
298 " at position (0x%lx) - will try"
299 " alternative position (0x0000).\n",
309 static struct inode *qnx6_private_inode(
struct super_block *s,
312 static int qnx6_fill_super(
struct super_block *s,
void *
data,
int silent)
314 struct buffer_head *bh1 =
NULL, *bh2 =
NULL;
336 if (!qnx6_parse_options((
char *) data, s)) {
351 bh1 = qnx6_check_first_superblock(s,
355 bh1 = qnx6_check_first_superblock(s, 0, silent);
361 bootblock_offset = 0;
365 #ifdef CONFIG_QNX6FS_DEBUG
366 qnx6_superblock_debug(sb1, s);
371 crc32_be(0, (
char *)(bh1->b_data + 8), 504)) {
398 bh2 = sb_bread(s, offset);
407 " in superblock #2.\n");
412 if (fs32_to_cpu(sbi, sb2->sb_checksum) !=
413 crc32_be(0, (
char *)(bh2->b_data + 8), 504)) {
419 fs64_to_cpu(sbi, sb2->sb_serial)) {
441 " (max %i, sb %i)\n",
445 s->
s_op = &qnx6_sops;
473 errmsg = qnx6_checkroot(s);
474 if (errmsg !=
NULL) {
515 .readpage = qnx6_readpage,
516 .readpages = qnx6_readpages,
520 static struct inode *qnx6_private_inode(
struct super_block *s,
561 return ERR_PTR(-
EIO);
565 mapping = sbi->
inodes->i_mapping;
566 page = read_mapping_page(mapping, n,
NULL);
569 "dev %s\n", sb->
s_id);
571 return ERR_CAST(page);
577 i_uid_write(inode, (
uid_t)fs32_to_cpu(sbi, raw_inode->
di_uid));
578 i_gid_write(inode, (
gid_t)fs32_to_cpu(sbi, raw_inode->
di_gid));
613 static struct inode *qnx6_alloc_inode(
struct super_block *sb)
628 static void qnx6_destroy_inode(
struct inode *inode)
633 static void init_once(
void *
foo)
640 static int init_inodecache(
void)
647 if (!qnx6_inode_cachep)
652 static void destroy_inodecache(
void)
663 int flags,
const char *dev_name,
void *data)
665 return mount_bdev(fs_type, flags, dev_name, data, qnx6_fill_super);
676 static int __init init_qnx6_fs(
void)
680 err = init_inodecache();
686 destroy_inodecache();
694 static void __exit exit_qnx6_fs(
void)
697 destroy_inodecache();