Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | /* * linux/fs/umsdos/check.c * * Sanity-checking code */ #include <linux/signal.h> #include <linux/sched.h> #include <linux/kernel.h> #include <linux/errno.h> #include <linux/string.h> #include <linux/types.h> #include <linux/ptrace.h> #include <linux/mman.h> #include <linux/mm.h> #include <linux/umsdos_fs.h> #include <asm/system.h> #ifdef CHECK_PAGE_TABLES static int check_one_table (struct pde *page_dir) { if (pgd_none (*page_dir)) return 0; if (pgd_bad (*page_dir)) return 1; return 0; } /* * This function checks all page tables of "current" */ void check_page_tables (void) { struct pgd *pg_dir; static int err = 0; int stack_level = (long) (&pg_dir) - current->kernel_stack_page; if (stack_level < 1500) printk ("** %d ** ", stack_level); pg_dir = PAGE_DIR_OFFSET (current, 0); if (err == 0) { int i; for (i = 0; i < PTRS_PER_PAGE; i++, page_dir++) { int notok = check_one_table (page_dir); if (notok) { err++; printk ("|%d:%08lx| ", i, page_dir->pgd); } } if (err) printk ("\nError MM %d\n", err); } } #endif #if UMS_DEBUG /* * check a superblock */ void check_sb (struct super_block *sb, const char c) { if (sb) { printk (" (has %c_sb=%d, %d)", c, MAJOR (sb->s_dev), MINOR (sb->s_dev)); } else { printk (" (%c_sb is NULL)", c); } } /* * check an inode */ extern struct inode_operations umsdos_rdir_inode_operations; void check_inode (struct inode *inode) { if (inode) { printk (KERN_DEBUG "* inode is %lu (i_count=%d)", inode->i_ino, inode->i_count); check_sb (inode->i_sb, 'i'); if (inode->i_dentry.next) { /* FIXME: does this work ? */ printk (" (has i_dentry)"); } else { printk (" (NO i_dentry)"); } printk (" (i_patched=%d)", inode->u.umsdos_i.i_patched); if (inode->i_op == NULL) { printk (" (i_op is NULL)\n"); } else if (inode->i_op == &umsdos_dir_inode_operations) { printk (" (i_op is umsdos_dir_inode_operations)\n"); } else if (inode->i_op == &umsdos_file_inode_operations) { printk (" (i_op is umsdos_file_inode_operations)\n"); } else if (inode->i_op == &umsdos_file_inode_operations_no_bmap) { printk (" (i_op is umsdos_file_inode_operations_no_bmap)\n"); } else if (inode->i_op == &umsdos_file_inode_operations_readpage) { printk (" (i_op is umsdos_file_inode_operations_readpage)\n"); } else if (inode->i_op == &umsdos_rdir_inode_operations) { printk (" (i_op is umsdos_rdir_inode_operations)\n"); } else if (inode->i_op == &umsdos_symlink_inode_operations) { printk (" (i_op is umsdos_symlink_inode_operations)\n"); } else { printk (" (i_op is UNKNOWN: %p)\n", inode->i_op); } } else { printk (KERN_DEBUG "* inode is NULL\n"); } } /* * checks all inode->i_dentry * */ void checkd_inode (struct inode *inode) { struct dentry *ret; struct list_head *cur; int count = 0; if (!inode) { printk (KERN_ERR "checkd_inode: inode is NULL!\n"); return; } printk (KERN_DEBUG "checkd_inode: inode %lu\n", inode->i_ino); cur = inode->i_dentry.next; while (count++ < 10) { PRINTK (("1...")); if (!cur) { printk (KERN_ERR "checkd_inode: *** NULL reached. exit.\n"); return; } PRINTK (("2...")); ret = list_entry (cur, struct dentry, d_alias); PRINTK (("3...")); if (cur == cur->next) { printk (KERN_DEBUG "checkd_inode: *** cur=cur->next: normal exit.\n"); return; } PRINTK (("4...")); if (!ret) { printk (KERN_ERR "checkd_inode: *** ret dentry is NULL. exit.\n"); return; } PRINTK (("5... (ret=%p)...", ret)); PRINTK (("5.1.. (ret->d_dname=%p)...", &(ret->d_name))); PRINTK (("5.1.1. (ret->d_dname.len=%d)...", (int) ret->d_name.len)); PRINTK (("5.1.2. (ret->d_dname.name=%c)...", ret->d_name.name)); printk (KERN_DEBUG "checkd_inode: i_dentry is %.*s\n", (int) ret->d_name.len, ret->d_name.name); PRINTK (("6...")); cur = cur->next; PRINTK (("7...")); #if 1 printk (KERN_DEBUG "checkd_inode: *** finished after count 1 (operator forced)\n"); return; #endif } printk (KERN_ERR "checkd_inode: *** OVER LIMIT (loop?) !\n"); return; } /* * internal part of check_dentry. does the real job. * */ void check_dent_int (struct dentry *dentry, int parent) { if (parent) { printk (KERN_DEBUG "* parent(%d) dentry: %.*s\n", parent, (int) dentry->d_name.len, dentry->d_name.name); } else { printk (KERN_DEBUG "* checking dentry: %.*s\n", (int) dentry->d_name.len, dentry->d_name.name); } check_inode (dentry->d_inode); printk (KERN_DEBUG "* d_count=%d", dentry->d_count); check_sb (dentry->d_sb, 'd'); if (dentry->d_op == NULL) { printk (" (d_op is NULL)\n"); } else { printk (" (d_op is UNKNOWN: %p)\n", dentry->d_op); } } /* * checks dentry with full traceback to root and prints info. Limited to 10 recursive depths to avoid infinite loops. * */ void check_dentry_path (struct dentry *dentry, const char *desc) { int count=0; printk (KERN_DEBUG "*** check_dentry_path: %.60s\n", desc); if (!dentry) { printk (KERN_DEBUG "*** checking dentry... it is NULL !\n"); return; } if (IS_ERR(dentry)) { printk (KERN_DEBUG "*** checking dentry... it is ERR(%ld) !\n", PTR_ERR(dentry)); return; } while (dentry && count < 10) { check_dent_int (dentry, count++); if (IS_ROOT(dentry)) { printk (KERN_DEBUG "*** end checking dentry (root reached ok)\n"); break; } dentry = dentry->d_parent; } if (count >= 10) { /* if infinite loop detected */ printk (KERN_ERR "*** WARNING ! INFINITE LOOP ! check_dentry_path aborted !\n"); } if (!dentry) { printk (KERN_ERR "*** WARNING ! NULL dentry ! check_dentry_path aborted !\n"); } } #else void check_sb (struct super_block *sb, const char c) {}; void check_inode (struct inode *inode) {}; void checkd_inode (struct inode *inode) {}; void check_dentry_path (struct dentry *dentry, const char *desc) {}; #endif /* UMS_DEBUG */ |