]> err.no Git - linux-2.6/blobdiff - fs/jffs2/readinode.c
Merge branch 'server-cluster-locking-api' of git://linux-nfs.org/~bfields/linux
[linux-2.6] / fs / jffs2 / readinode.c
index 49d4b0a67c55b4ca8c86faf558ef75a5e6abfad9..6aff38930b50619475e4e2974341427f185298b8 100644 (file)
@@ -1,14 +1,12 @@
 /*
  * JFFS2 -- Journalling Flash File System, Version 2.
  *
- * Copyright (C) 2001-2003 Red Hat, Inc.
+ * Copyright © 2001-2007 Red Hat, Inc.
  *
  * Created by David Woodhouse <dwmw2@infradead.org>
  *
  * For licensing information, see the file 'LICENCE' in this directory.
  *
- * $Id: readinode.c,v 1.143 2005/11/07 11:14:41 gleixner Exp $
- *
  */
 
 #include <linux/kernel.h>
@@ -1054,10 +1052,10 @@ static int jffs2_get_inode_nodes(struct jffs2_sb_info *c, struct jffs2_inode_inf
                        jffs2_mark_node_obsolete(c, ref);
                        goto cont;
                }
-               /* Due to poor choice of crc32 seed, an all-zero node will have a correct CRC */
-               if (!je32_to_cpu(node->u.hdr_crc) && !je16_to_cpu(node->u.nodetype) &&
-                   !je16_to_cpu(node->u.magic) && !je32_to_cpu(node->u.totlen)) {
-                       JFFS2_NOTICE("All zero node header at %#08x.\n", ref_offset(ref));
+               if (je16_to_cpu(node->u.magic) != JFFS2_MAGIC_BITMASK) {
+                       /* Not a JFFS2 node, whinge and move on */
+                       JFFS2_NOTICE("Wrong magic bitmask 0x%04x in node header at %#08x.\n",
+                                    je16_to_cpu(node->u.magic), ref_offset(ref));
                        jffs2_mark_node_obsolete(c, ref);
                        goto cont;
                }
@@ -1134,7 +1132,7 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c,
                                        struct jffs2_raw_inode *latest_node)
 {
        struct jffs2_readinode_info rii;
-       uint32_t crc;
+       uint32_t crc, new_size;
        size_t retlen;
        int ret;
 
@@ -1235,7 +1233,12 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c,
 
        case S_IFREG:
                /* If it was a regular file, truncate it to the latest node's isize */
-               jffs2_truncate_fragtree(c, &f->fragtree, je32_to_cpu(latest_node->isize));
+               new_size = jffs2_truncate_fragtree(c, &f->fragtree, je32_to_cpu(latest_node->isize));
+               if (new_size != je32_to_cpu(latest_node->isize)) {
+                       JFFS2_WARNING("Truncating ino #%u to %d bytes failed because it only had %d bytes to start with!\n",
+                                     f->inocache->ino, je32_to_cpu(latest_node->isize), new_size);
+                       latest_node->isize = cpu_to_je32(new_size);
+               }
                break;
 
        case S_IFLNK: