]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Support 4K-sector NTFS.
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Fri, 20 Jan 2012 14:01:35 +0000 (15:01 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Fri, 20 Jan 2012 14:01:35 +0000 (15:01 +0100)
* include/grub/ntfs.h (GRUB_NTFS_MAX_MFT): Increase to 8.
(grub_ntfs_data): Remove blocksize.
* grub-core/fs/ntfs.c (fixup): Fix size comparison.
Remove data argument. All users updated.

ChangeLog
grub-core/fs/ntfs.c
include/grub/ntfs.h

index 0693a826a5f4d808f143828314dd043c000685ac..436e3b29cc5062a54edc025454add542cceea93f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2012-01-20  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       Support 4K-sector NTFS.
+
+       * include/grub/ntfs.h (GRUB_NTFS_MAX_MFT): Increase to 8.
+       (grub_ntfs_data): Remove blocksize.
+       * grub-core/fs/ntfs.c (fixup): Fix size comparison.
+       Remove data argument. All users updated.
+
 2012-01-20  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * grub-core/kern/mips/arc/init.c (grub_total_modules_size): Mark as
index 7dbe0e5e531a9bb50862dc458ef7455748006964..6023d74dfc8ad47c43c04cdcd6219aa9eacbafb7 100644 (file)
@@ -55,26 +55,26 @@ u64at (void *ptr, grub_size_t ofs)
 grub_ntfscomp_func_t grub_ntfscomp_func;
 
 static grub_err_t
-fixup (struct grub_ntfs_data *data, char *buf, int len, const char *magic)
+fixup (char *buf, int len, const char *magic)
 {
   int ss;
   char *pu;
   grub_uint16_t us;
 
+  COMPILE_TIME_ASSERT ((1 << GRUB_NTFS_BLK_SHR) == GRUB_DISK_SECTOR_SIZE);
+
   if (grub_memcmp (buf, magic, 4))
     return grub_error (GRUB_ERR_BAD_FS, "%s label not found", magic);
 
   ss = u16at (buf, 6) - 1;
-  if (ss * (int) data->blocksize != len * GRUB_DISK_SECTOR_SIZE)
-    return grub_error (GRUB_ERR_BAD_FS, "size not match",
-                      ss * (int) data->blocksize,
-                      len * GRUB_DISK_SECTOR_SIZE);
+  if (ss != len)
+    return grub_error (GRUB_ERR_BAD_FS, "size not match");
   pu = buf + u16at (buf, 4);
   us = u16at (pu, 0);
   buf -= 2;
   while (ss > 0)
     {
-      buf += data->blocksize;
+      buf += GRUB_DISK_SECTOR_SIZE;
       pu += 2;
       if (u16at (buf, 0) != us)
        return grub_error (GRUB_ERR_BAD_FS, "fixup signature not match");
@@ -148,9 +148,7 @@ find_attr (struct grub_ntfs_attr *at, unsigned char attr)
                        512, at->emft_buf + 512)))
                    return NULL;
 
-                 if (fixup
-                     (at->mft->data, at->emft_buf, at->mft->data->mft_size,
-                      "FILE"))
+                 if (fixup (at->emft_buf, at->mft->data->mft_size, "FILE"))
                    return NULL;
                }
              else
@@ -542,7 +540,7 @@ read_mft (struct grub_ntfs_data *data, char *buf, grub_uint32_t mftno)
       (&data->mmft.attr, buf, mftno * ((grub_disk_addr_t) data->mft_size << GRUB_NTFS_BLK_SHR),
        data->mft_size << GRUB_NTFS_BLK_SHR, 0, 0))
     return grub_error (GRUB_ERR_BAD_FS, "read MFT 0x%X fails", mftno);
-  return fixup (data, buf, data->mft_size, "FILE");
+  return fixup (buf, data->mft_size, "FILE");
 }
 
 static grub_err_t
@@ -901,7 +899,7 @@ grub_ntfs_iterate_dir (grub_fshelp_node_t dir,
              if ((read_attr
                   (at, indx, i * (mft->data->idx_size << GRUB_NTFS_BLK_SHR),
                    (mft->data->idx_size << GRUB_NTFS_BLK_SHR), 0, 0))
-                 || (fixup (mft->data, indx, mft->data->idx_size, "INDX")))
+                 || (fixup (indx, mft->data->idx_size, "INDX")))
                goto done;
              ret = list_file (mft, &indx[0x18 + u16at (indx, 0x18)], hook);
              if (ret)
@@ -946,8 +944,9 @@ grub_ntfs_mount (grub_disk_t disk)
   if (grub_memcmp ((char *) &bpb.oem_name, "NTFS", 4))
     goto fail;
 
-  data->blocksize = grub_le_to_cpu16 (bpb.bytes_per_sector);
-  data->spc = bpb.sectors_per_cluster * (data->blocksize >> GRUB_NTFS_BLK_SHR);
+  data->spc = (bpb.sectors_per_cluster
+              * (grub_le_to_cpu16 (bpb.bytes_per_sector)
+                 >> GRUB_NTFS_BLK_SHR));
 
   if (bpb.clusters_per_mft > 0)
     data->mft_size = data->spc * bpb.clusters_per_mft;
@@ -977,7 +976,7 @@ grub_ntfs_mount (grub_disk_t disk)
 
   data->uuid = grub_le_to_cpu64 (bpb.num_serial);
 
-  if (fixup (data, data->mmft.buf, data->mft_size, "FILE"))
+  if (fixup (data->mmft.buf, data->mft_size, "FILE"))
     goto fail;
 
   if (!locate_attr (&data->mmft.attr, &data->mmft, GRUB_NTFS_AT_DATA))
index cf90ce110020c5044fb2fe02354394121560d488..5cdd5f73f4a7694c61ed1ee53de3308452d8ae81 100644 (file)
@@ -81,7 +81,7 @@ enum
 
 #define GRUB_NTFS_BLK_SHR              GRUB_DISK_SECTOR_BITS
 
-#define GRUB_NTFS_MAX_MFT              (1024 >> GRUB_NTFS_BLK_SHR)
+#define GRUB_NTFS_MAX_MFT              (4096 >> GRUB_NTFS_BLK_SHR)
 #define GRUB_NTFS_MAX_IDX              (16384 >> GRUB_NTFS_BLK_SHR)
 
 #define GRUB_NTFS_COM_LEN              4096
@@ -157,7 +157,6 @@ struct grub_ntfs_data
   grub_uint32_t mft_size;
   grub_uint32_t idx_size;
   grub_uint32_t spc;
-  grub_uint32_t blocksize;
   grub_uint32_t mft_start;
   grub_uint64_t uuid;
 };