inode.c (f01387d2693813eb5271a3448e6a082322c7d75d) | inode.c (f175ff8100eef0eb4b946c08e78a27bd17ca5896) |
---|---|
1/* 2 * Compressed rom filesystem for Linux. 3 * 4 * Copyright (C) 1999 Linus Torvalds. 5 * 6 * This file is released under the GPL. 7 */ 8 --- 263 unchanged lines hidden (view full) --- 272 memcpy(&super, cramfs_read(sb, 0, sizeof(super)), sizeof(super)); 273 mutex_unlock(&read_mutex); 274 275 /* Do sanity checks on the superblock */ 276 if (super.magic != CRAMFS_MAGIC) { 277 /* check for wrong endianness */ 278 if (super.magic == CRAMFS_MAGIC_WEND) { 279 if (!silent) | 1/* 2 * Compressed rom filesystem for Linux. 3 * 4 * Copyright (C) 1999 Linus Torvalds. 5 * 6 * This file is released under the GPL. 7 */ 8 --- 263 unchanged lines hidden (view full) --- 272 memcpy(&super, cramfs_read(sb, 0, sizeof(super)), sizeof(super)); 273 mutex_unlock(&read_mutex); 274 275 /* Do sanity checks on the superblock */ 276 if (super.magic != CRAMFS_MAGIC) { 277 /* check for wrong endianness */ 278 if (super.magic == CRAMFS_MAGIC_WEND) { 279 if (!silent) |
280 printk(KERN_ERR "cramfs: wrong endianness\n"); | 280 pr_err("cramfs: wrong endianness\n"); |
281 return -EINVAL; 282 } 283 284 /* check at 512 byte offset */ 285 mutex_lock(&read_mutex); 286 memcpy(&super, cramfs_read(sb, 512, sizeof(super)), sizeof(super)); 287 mutex_unlock(&read_mutex); 288 if (super.magic != CRAMFS_MAGIC) { 289 if (super.magic == CRAMFS_MAGIC_WEND && !silent) | 281 return -EINVAL; 282 } 283 284 /* check at 512 byte offset */ 285 mutex_lock(&read_mutex); 286 memcpy(&super, cramfs_read(sb, 512, sizeof(super)), sizeof(super)); 287 mutex_unlock(&read_mutex); 288 if (super.magic != CRAMFS_MAGIC) { 289 if (super.magic == CRAMFS_MAGIC_WEND && !silent) |
290 printk(KERN_ERR "cramfs: wrong endianness\n"); | 290 pr_err("cramfs: wrong endianness\n"); |
291 else if (!silent) | 291 else if (!silent) |
292 printk(KERN_ERR "cramfs: wrong magic\n"); | 292 pr_err("cramfs: wrong magic\n"); |
293 return -EINVAL; 294 } 295 } 296 297 /* get feature flags first */ 298 if (super.flags & ~CRAMFS_SUPPORTED_FLAGS) { | 293 return -EINVAL; 294 } 295 } 296 297 /* get feature flags first */ 298 if (super.flags & ~CRAMFS_SUPPORTED_FLAGS) { |
299 printk(KERN_ERR "cramfs: unsupported filesystem features\n"); | 299 pr_err("cramfs: unsupported filesystem features\n"); |
300 return -EINVAL; 301 } 302 303 /* Check that the root inode is in a sane state */ 304 if (!S_ISDIR(super.root.mode)) { | 300 return -EINVAL; 301 } 302 303 /* Check that the root inode is in a sane state */ 304 if (!S_ISDIR(super.root.mode)) { |
305 printk(KERN_ERR "cramfs: root is not a directory\n"); | 305 pr_err("cramfs: root is not a directory\n"); |
306 return -EINVAL; 307 } 308 /* correct strange, hard-coded permissions of mkcramfs */ 309 super.root.mode |= (S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); 310 311 root_offset = super.root.offset << 2; 312 if (super.flags & CRAMFS_FLAG_FSID_VERSION_2) { 313 sbi->size=super.size; 314 sbi->blocks=super.fsid.blocks; 315 sbi->files=super.fsid.files; 316 } else { 317 sbi->size=1<<28; 318 sbi->blocks=0; 319 sbi->files=0; 320 } 321 sbi->magic=super.magic; 322 sbi->flags=super.flags; 323 if (root_offset == 0) | 306 return -EINVAL; 307 } 308 /* correct strange, hard-coded permissions of mkcramfs */ 309 super.root.mode |= (S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); 310 311 root_offset = super.root.offset << 2; 312 if (super.flags & CRAMFS_FLAG_FSID_VERSION_2) { 313 sbi->size=super.size; 314 sbi->blocks=super.fsid.blocks; 315 sbi->files=super.fsid.files; 316 } else { 317 sbi->size=1<<28; 318 sbi->blocks=0; 319 sbi->files=0; 320 } 321 sbi->magic=super.magic; 322 sbi->flags=super.flags; 323 if (root_offset == 0) |
324 printk(KERN_INFO "cramfs: empty filesystem"); | 324 pr_info("cramfs: empty filesystem"); |
325 else if (!(super.flags & CRAMFS_FLAG_SHIFTED_ROOT_OFFSET) && 326 ((root_offset != sizeof(struct cramfs_super)) && 327 (root_offset != 512 + sizeof(struct cramfs_super)))) 328 { | 325 else if (!(super.flags & CRAMFS_FLAG_SHIFTED_ROOT_OFFSET) && 326 ((root_offset != sizeof(struct cramfs_super)) && 327 (root_offset != 512 + sizeof(struct cramfs_super)))) 328 { |
329 printk(KERN_ERR "cramfs: bad root offset %lu\n", root_offset); | 329 pr_err("cramfs: bad root offset %lu\n", root_offset); |
330 return -EINVAL; 331 } 332 333 /* Set it all up.. */ 334 sb->s_op = &cramfs_ops; 335 root = get_cramfs_inode(sb, &super.root, 0); 336 if (IS_ERR(root)) 337 return PTR_ERR(root); --- 269 unchanged lines hidden --- | 330 return -EINVAL; 331 } 332 333 /* Set it all up.. */ 334 sb->s_op = &cramfs_ops; 335 root = get_cramfs_inode(sb, &super.root, 0); 336 if (IS_ERR(root)) 337 return PTR_ERR(root); --- 269 unchanged lines hidden --- |