2 * linux/fs/umsdos/check.c
7 #include <linux/signal.h>
8 #include <linux/sched.h>
9 #include <linux/kernel.h>
10 #include <linux/errno.h>
11 #include <linux/string.h>
12 #include <linux/types.h>
13 #include <linux/ptrace.h>
14 #include <linux/mman.h>
16 #include <linux/umsdos_fs.h>
18 #include <asm/system.h>
20 #ifdef CHECK_PAGE_TABLES
21 static int check_one_table (struct pde
*page_dir
)
23 if (pgd_none (*page_dir
))
25 if (pgd_bad (*page_dir
))
31 * This function checks all page tables of "current"
33 void check_page_tables (void)
38 int stack_level
= (long) (&pg_dir
) - current
->kernel_stack_page
;
40 if (stack_level
< 1500)
41 printk ("** %d ** ", stack_level
);
42 pg_dir
= PAGE_DIR_OFFSET (current
, 0);
46 for (i
= 0; i
< PTRS_PER_PAGE
; i
++, page_dir
++) {
47 int notok
= check_one_table (page_dir
);
51 printk ("|%d:%08lx| ", i
, page_dir
->pgd
);
55 printk ("\nError MM %d\n", err
);
66 void check_sb (struct super_block
*sb
, const char c
)
69 printk (" (has %c_sb=%d, %d)",
70 c
, MAJOR (sb
->s_dev
), MINOR (sb
->s_dev
));
72 printk (" (%c_sb is NULL)", c
);
79 extern struct inode_operations umsdos_rdir_inode_operations
;
81 void check_inode (struct inode
*inode
)
84 printk (KERN_DEBUG
"* inode is %lu (i_count=%d)",
85 inode
->i_ino
, inode
->i_count
);
86 check_sb (inode
->i_sb
, 'i');
88 if (inode
->i_dentry
.next
) { /* FIXME: does this work ? */
89 printk (" (has i_dentry)");
91 printk (" (NO i_dentry)");
94 printk (" (i_patched=%d)", inode
->u
.umsdos_i
.i_patched
);
96 if (inode
->i_op
== NULL
) {
97 printk (" (i_op is NULL)\n");
98 } else if (inode
->i_op
== &umsdos_dir_inode_operations
) {
99 printk (" (i_op is umsdos_dir_inode_operations)\n");
100 } else if (inode
->i_op
== &umsdos_file_inode_operations
) {
101 printk (" (i_op is umsdos_file_inode_operations)\n");
102 } else if (inode
->i_op
== &umsdos_file_inode_operations_no_bmap
) {
103 printk (" (i_op is umsdos_file_inode_operations_no_bmap)\n");
104 } else if (inode
->i_op
== &umsdos_file_inode_operations_readpage
) {
105 printk (" (i_op is umsdos_file_inode_operations_readpage)\n");
106 } else if (inode
->i_op
== &umsdos_rdir_inode_operations
) {
107 printk (" (i_op is umsdos_rdir_inode_operations)\n");
108 } else if (inode
->i_op
== &umsdos_symlink_inode_operations
) {
109 printk (" (i_op is umsdos_symlink_inode_operations)\n");
111 printk (" (i_op is UNKNOWN: %p)\n", inode
->i_op
);
114 printk (KERN_DEBUG
"* inode is NULL\n");
119 * checks all inode->i_dentry
122 void checkd_inode (struct inode
*inode
)
125 struct list_head
*cur
;
128 printk (KERN_ERR
"checkd_inode: inode is NULL!\n");
132 printk (KERN_DEBUG
"checkd_inode: inode %lu\n", inode
->i_ino
);
133 cur
= inode
->i_dentry
.next
;
134 while (count
++ < 10) {
137 printk (KERN_ERR
"checkd_inode: *** NULL reached. exit.\n");
141 ret
= list_entry (cur
, struct dentry
, d_alias
);
143 if (cur
== cur
->next
) {
144 printk (KERN_DEBUG
"checkd_inode: *** cur=cur->next: normal exit.\n");
149 printk (KERN_ERR
"checkd_inode: *** ret dentry is NULL. exit.\n");
152 PRINTK (("5... (ret=%p)...", ret
));
153 PRINTK (("5.1.. (ret->d_dname=%p)...", &(ret
->d_name
)));
154 PRINTK (("5.1.1. (ret->d_dname.len=%d)...", (int) ret
->d_name
.len
));
155 PRINTK (("5.1.2. (ret->d_dname.name=%c)...", ret
->d_name
.name
));
156 printk (KERN_DEBUG
"checkd_inode: i_dentry is %.*s\n", (int) ret
->d_name
.len
, ret
->d_name
.name
);
161 printk (KERN_DEBUG
"checkd_inode: *** finished after count 1 (operator forced)\n");
165 printk (KERN_ERR
"checkd_inode: *** OVER LIMIT (loop?) !\n");
170 * internal part of check_dentry. does the real job.
174 void check_dent_int (struct dentry
*dentry
, int parent
)
177 printk (KERN_DEBUG
"* parent(%d) dentry: %.*s\n",
178 parent
, (int) dentry
->d_name
.len
, dentry
->d_name
.name
);
180 printk (KERN_DEBUG
"* checking dentry: %.*s\n",
181 (int) dentry
->d_name
.len
, dentry
->d_name
.name
);
183 check_inode (dentry
->d_inode
);
184 printk (KERN_DEBUG
"* d_count=%d", dentry
->d_count
);
185 check_sb (dentry
->d_sb
, 'd');
186 if (dentry
->d_op
== NULL
) {
187 printk (" (d_op is NULL)\n");
189 printk (" (d_op is UNKNOWN: %p)\n", dentry
->d_op
);
194 * checks dentry with full traceback to root and prints info. Limited to 10 recursive depths to avoid infinite loops.
198 void check_dentry_path (struct dentry
*dentry
, const char *desc
)
201 printk (KERN_DEBUG
"*** check_dentry_path: %.60s\n", desc
);
204 printk (KERN_DEBUG
"*** checking dentry... it is NULL !\n");
207 if (IS_ERR(dentry
)) {
208 printk (KERN_DEBUG
"*** checking dentry... it is ERR(%ld) !\n",
213 while (dentry
&& count
< 10) {
214 check_dent_int (dentry
, count
++);
215 if (dentry
== dentry
->d_parent
) {
216 printk (KERN_DEBUG
"*** end checking dentry (root reached ok)\n");
219 dentry
= dentry
->d_parent
;
222 if (count
>= 10) { /* if infinite loop detected */
224 "*** WARNING ! INFINITE LOOP ! check_dentry_path aborted !\n");
229 "*** WARNING ! NULL dentry ! check_dentry_path aborted !\n");
233 void check_sb (struct super_block
*sb
, const char c
) {};
234 void check_inode (struct inode
*inode
) {};
235 void checkd_inode (struct inode
*inode
) {};
236 void check_dentry_path (struct dentry
*dentry
, const char *desc
) {};
237 #endif /* UMS_DEBUG */