El lun, 30-06-2008 a las 07:14 -0400, Isaac Dupree escribió:
> > +#define EXT3_FEATURE_INCOMPAT_RECOVER              0x0004 /* Needs 
> > recovery */
> 
> > +#define EXT2_DRIVER_SUPPORTED_INCOMPAT ( EXT2_FEATURE_INCOMPAT_FILETYPE )
> 
> I suspect this will mean that journalled ext3 when the system crashed 
> (so the filesystem "needs recovery" from the journal) won't load.  (Of 
> course, properly speaking that would load grub's code to replay the 
> journal...)  But I think that (without other changes) that would make 
> the system unbootable every time there was a power outage?  (Of course 
> it was not guaranteed to load correctly when ignoring the journal when 
> it needed recovery, but it was likely to work, IIUC.)
> 
> -Isaac

As I said, I didn't add it because I didn't know whether recovery was
supported or not. _Theoretically_ we should focus on correctness and
refuse to read such a filesystem, but here goes a workaround for
incompatible features that we do not support but still willingly want to
ignore for the sake of "compatibility". This new version of the patch
adds another macro, EXT2_DRIVER_IGNORED_INCOMPAT where we can put
features that we don't fully support, but still want a filesystem with
them to be mounted, like the needs_recover flag.

Of course, this is risky: INCOMPAT_* features are so for a reason, but
it will allow dirty ext3 filesystems to be mounted until we have a
working journal implementation. I had thought of adding some kind of
warning, but since GRUB mounts and umounts filesystems constantly, it
just cluttered the screen and I removed it.
Index: fs/ext2.c
===================================================================
RCS file: /sources/grub/grub2/fs/ext2.c,v
retrieving revision 1.26
diff -u -r1.26 ext2.c
--- fs/ext2.c	16 Jun 2008 19:02:07 -0000	1.26
+++ fs/ext2.c	30 Jun 2008 12:07:56 -0000
@@ -71,7 +71,37 @@
          ? EXT2_GOOD_OLD_INODE_SIZE \
          : grub_le_to_cpu16 (data->sblock.inode_size))
 
-#define EXT3_FEATURE_COMPAT_HAS_JOURNAL	0x0004
+/* Superblock filesystem feature flags (RW compatible) */
+#define EXT2_FEATURE_COMPAT_DIR_PREALLOC	0x0001
+#define EXT2_FEATURE_COMPAT_IMAGIC_INODES	0x0002
+#define EXT3_FEATURE_COMPAT_HAS_JOURNAL		0x0004
+#define EXT2_FEATURE_COMPAT_EXT_ATTR		0x0008
+#define EXT2_FEATURE_COMPAT_RESIZE_INODE	0x0010
+#define EXT2_FEATURE_COMPAT_DIR_INDEX		0x0020
+/* Superblock filesystem feature flags (RO compatible) */
+#define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER	0x0001
+#define EXT2_FEATURE_RO_COMPAT_LARGE_FILE	0x0002
+#define EXT2_FEATURE_RO_COMPAT_BTREE_DIR	0x0004
+#define EXT4_FEATURE_RO_COMPAT_GDT_CSUM		0x0010
+#define EXT4_FEATURE_RO_COMPAT_DIR_NLINK	0x0020
+#define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE	0x0040
+/* Superblock filesystem feature flags (back-incompatible) */
+#define EXT2_FEATURE_INCOMPAT_COMPRESSION	0x0001
+#define EXT2_FEATURE_INCOMPAT_FILETYPE		0x0002
+#define EXT3_FEATURE_INCOMPAT_RECOVER		0x0004 /* Needs recovery */
+#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV	0x0008 /* Journal device */
+#define EXT2_FEATURE_INCOMPAT_META_BG		0x0010
+#define EXT4_FEATURE_INCOMPAT_EXTENTS		0x0040 /* extents support */
+#define EXT4_FEATURE_INCOMPAT_64BIT		0x0080
+#define EXT4_FEATURE_INCOMPAT_FLEX_BG		0x0200
+
+/* The set of back-incompatible features this driver DOES support. Add (OR)
+ * flags here as the related features are implemented into the driver */
+#define EXT2_DRIVER_SUPPORTED_INCOMPAT ( EXT2_FEATURE_INCOMPAT_FILETYPE )
+/* The set of back-incompatible features this driver DOES NOT support but are
+ * ignored for some hackish reason. Flags here should be here _temporarily_!
+ * Remember that INCOMPAT_* features are so for a reason! */
+#define EXT2_DRIVER_IGNORED_INCOMPAT ( EXT3_FEATURE_INCOMPAT_RECOVER )
 
 #define EXT3_JOURNAL_MAGIC_NUMBER	0xc03b3998U
 
@@ -394,6 +424,11 @@
   if (grub_le_to_cpu16 (data->sblock.magic) != EXT2_MAGIC)
     goto fail;
   
+  /* Check the FS doesn't have feature bits enabled that we don't support */
+  if (grub_le_to_cpu32 (data->sblock.feature_incompat)
+      & ~(EXT2_DRIVER_SUPPORTED_INCOMPAT | EXT2_DRIVER_IGNORED_INCOMPAT))
+    goto fail;
+  
   data->disk = disk;
 
   data->diropen.data = data;
@@ -409,7 +444,8 @@
   return data;
 
  fail:
-  grub_error (GRUB_ERR_BAD_FS, "not an ext2 filesystem");
+  grub_error (GRUB_ERR_BAD_FS, "not an ext2 filesystem, or incompatible"
+                               "features enabled (extents, etc.)");
   grub_free (data);
   return 0;
 }

Attachment: signature.asc
Description: Esta parte del mensaje está firmada digitalmente

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to