Changes by: flatcap
Update of /cvsroot/linux-ntfs/dynamic-disk/linux/fs/partitions
In directory usw-pr-cvs1:/tmp/cvs-serv6178/linux/fs/partitions
Modified Files:
ldm.c ldm.h
Log Message:
lots of minor formatting changes
guid code swapped again. if it doesn't work, I want to see examples
all the offsets are ranged checked against known safe values
added a check to see if the database was in an inconsistant state
shortened a few names for convenience
Index: ldm.c
===================================================================
RCS file: /cvsroot/linux-ntfs/dynamic-disk/linux/fs/partitions/ldm.c,v
retrieving revision 1.67
retrieving revision 1.68
diff -U2 -r1.67 -r1.68
--- ldm.c 22 Mar 2002 16:02:07 -0000 1.67
+++ ldm.c 10 Apr 2002 15:41:59 -0000 1.68
@@ -8,18 +8,18 @@
* Documentation is available at http://linux-ntfs.sf.net/ldm
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program (in the main directory of the Linux-NTFS source
- * in the file COPYING); if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program (in the main directory of the source in the file COPYING); if
+ * not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307 USA
*/
@@ -96,38 +96,13 @@
level = LDM_LVL_NONE;
- printk("%s(%s) (%s, %d) %s(): %s", prefix[level], label[level],
+ printk("%s(%s) (%s, %d) %s(): %s\n", prefix[level], label[level],
file, line, function, buf);
}
-/**
- * ldm_parse_hexbyte - Convert a ASCII hex number to a byte
- * @src: Pointer to at least 2 characters to convert.
- *
- * Return: integer in the range [0,255] on success
- * -1 on error.
- */
-static int ldm_parse_hexbyte (const u8 *src)
-{
- unsigned int x; /* For correct wrapping */
- int h;
-
- /* high part */
- if ((x = src[0] - '0') <= '9'-'0') h = x;
- else if ((x = src[0] - 'a') <= 'f'-'a') h = x+10;
- else if ((x = src[0] - 'A') <= 'F'-'A') h = x+10;
- else return -1;
- h <<= 4;
-
- /* low part */
- if ((x = src[1] - '0') <= '9'-'0') return h | x;
- if ((x = src[1] - 'a') <= 'f'-'a') return h | (x+10);
- if ((x = src[1] - 'A') <= 'F'-'A') return h | (x+10);
- return -1;
-}
/**
* ldm_parse_guid - Convert GUID from ASCII to binary
- * @src: 36 char string on the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba
- * @dest: memory block to hold binary GUID (16 bytes)
+ * @src: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba
+ * @dest: memory block to hold binary GUID (16 bytes)
*
* NB not NULL terminated!
@@ -138,37 +113,15 @@
static BOOL ldm_parse_guid (const u8 *src, u8 *dest)
{
- static const int size[] = { 4, 2, 2, 2, 6 };
- int i, j, v;
-
- if (src[8] != '-' || src[13] != '-' ||
- src[18] != '-' || src[23] != '-')
- return FALSE;
-
- for (j = 0; j < 5; j++, src++)
- for (i = 0; i < size[j]; i++, src+=2, *dest++ = v)
- if ((v = ldm_parse_hexbyte(src)) < 0)
- return FALSE;
-
- return TRUE;
-}
-// FIXME: Why doesn't this work ??
-/**
- *
-static BOOL ldm_parse_guid (const u8 *src, u8 *dest)
-{
u16 *tmp = (u16*)dest;
DEBUG_ON (!src || !dest);
- if ((src[8] != '-') || (src[13] != '-') ||
+ if ((src[8] != '-') || (src[13] != '-') || /* Check alignment */
(src[18] != '-') || (src[23] != '-'))
return FALSE;
- return (
- 8 == sscanf (src, "%04hx%04hx-%04hx-%04hx-%04hx-%04hx%04hx%04hx",
- tmp, tmp+1, tmp+2, tmp+3, tmp+4, tmp+5, tmp+6, tmp+7)
- );
+ return (8 == sscanf (src, "%04hx%04hx-%04hx-%04hx-%04hx-%04hx%04hx%04hx",
+ tmp, tmp+1, tmp+2, tmp+3, tmp+4, tmp+5, tmp+6, tmp+7));
}
-*/
/**
@@ -189,5 +142,5 @@
if (MAGIC_PRIVHEAD != BE64 (data)) {
ldm_error ("Cannot find PRIVHEAD structure. LDM database is"
- " corrupt. Aborting.\n");
+ " corrupt. Aborting.");
return FALSE;
}
@@ -195,7 +148,8 @@
ph->ver_major = BE16 (data + 0x000C);
ph->ver_minor = BE16 (data + 0x000E);
+ // FIXME move checks to validate_*, maybe later coalesce?
if ((ph->ver_major != 2) || (ph->ver_minor != 11)) {
ldm_error ("Expected PRIVHEAD version %d.%d, got %d.%d."
- " Aborting.\n", 2, 11, ph->ver_major, ph->ver_minor);
+ " Aborting.", 2, 11, ph->ver_major, ph->ver_minor);
return FALSE;
}
@@ -205,5 +159,5 @@
/* Warn the user and continue, carefully */
ldm_info ("Database is normally %u bytes, it claims to "
- "be %llu bytes.\n", LDM_DB_SIZE,
+ "be %llu bytes.", LDM_DB_SIZE,
(unsigned long long)ph->config_size );
}
@@ -212,14 +166,14 @@
if ((ph->logical_disk_size == 0) ||
(ph->logical_disk_start + ph->logical_disk_size > ph->config_start)) {
- ldm_error ("PRIVHEAD disk size doesn't match real disk size\n");
+ ldm_error ("PRIVHEAD disk size doesn't match real disk size");
return FALSE;
}
if (!ldm_parse_guid (data + 0x0030, ph->disk_id)) {
- ldm_error ("PRIVHEAD contains an invalid GUID.\n");
+ ldm_error ("PRIVHEAD contains an invalid GUID.");
return FALSE;
}
- ldm_debug ("Parsed PRIVHEAD successfully.\n");
+ ldm_debug ("Parsed PRIVHEAD successfully.");
return TRUE;
}
@@ -246,5 +200,5 @@
if (MAGIC_TOCBLOCK != BE64 (data)) {
- ldm_crit ("Cannot find TOCBLOCK, database may be corrupt.\n");
+ ldm_crit ("Cannot find TOCBLOCK, database may be corrupt.");
return FALSE;
}
@@ -256,5 +210,5 @@
if (strncmp (toc->bitmap1_name, TOC_BITMAP1,
sizeof (toc->bitmap1_name)) != 0) {
- ldm_crit ("TOCBLOCK's first bitmap is '%s', should be '%s'.\n",
+ ldm_crit ("TOCBLOCK's first bitmap is '%s', should be '%s'.",
TOC_BITMAP1, toc->bitmap1_name);
return FALSE;
@@ -266,9 +220,9 @@
if (strncmp (toc->bitmap2_name, TOC_BITMAP2,
sizeof (toc->bitmap2_name)) != 0) {
- ldm_crit ("TOCBLOCK's second bitmap is '%s', should be '%s'.\n",
+ ldm_crit ("TOCBLOCK's second bitmap is '%s', should be '%s'.",
TOC_BITMAP2, toc->bitmap2_name);
return FALSE;
}
- ldm_debug ("Parsed TOCBLOCK successfully.\n");
+ ldm_debug ("Parsed TOCBLOCK successfully.");
return TRUE;
}
@@ -282,6 +236,5 @@
* the in-memory vmdb structure @vm with the obtained information.
*
- * N.B. The *_start, *_size and *_seq values returned in @vm have not been
- * checked for validity, so make sure to check them when using them.
+ * N.B. The *_start, *_size and *_seq values will be range-checked later.
*
* Return: TRUE @vm contains VMDB info
@@ -293,12 +246,13 @@
if (MAGIC_VMDB != BE32 (data)) {
- ldm_crit ("Cannot find the VMDB, database may be corrupt.\n");
+ ldm_crit ("Cannot find the VMDB, database may be corrupt.");
return FALSE;
}
+
vm->ver_major = BE16 (data + 0x12);
vm->ver_minor = BE16 (data + 0x14);
if ((vm->ver_major != 4) || (vm->ver_minor != 10)) {
ldm_error ("Expected VMDB version %d.%d, got %d.%d. "
- "Aborting.\n", 4, 10, vm->ver_major, vm->ver_minor);
+ "Aborting.", 4, 10, vm->ver_major, vm->ver_minor);
return FALSE;
}
@@ -308,5 +262,5 @@
vm->last_vblk_seq = BE32 (data + 0x04);
- ldm_debug ("Parsed VMDB successfully.\n");
+ ldm_debug ("Parsed VMDB successfully.");
return TRUE;
}
@@ -324,5 +278,5 @@
*/
static BOOL ldm_compare_privheads (const struct privhead *ph1,
- const struct privhead *ph2)
+ const struct privhead *ph2)
{
DEBUG_ON (!ph1 || !ph2);
@@ -348,5 +302,5 @@
*/
static BOOL ldm_compare_tocblocks (const struct tocblock *toc1,
- const struct tocblock *toc2)
+ const struct tocblock *toc2)
{
DEBUG_ON (!toc1 || !toc2);
@@ -391,10 +345,10 @@
data = read_dev_sector (bdev, 0, §);
if (!data) {
- ldm_crit ("Disk read failed.\n");
+ ldm_crit ("Disk read failed.");
return FALSE;
}
if (*(u16*) (data + 0x01FE) != cpu_to_le16 (MSDOS_LABEL_MAGIC)) {
- ldm_debug ("No MS-DOS partition table found.\n");
+ ldm_debug ("No MS-DOS partition table found.");
goto out;
}
@@ -408,7 +362,7 @@
if (result)
- ldm_debug ("Parsed partition table successfully.\n");
+ ldm_debug ("Parsed partition table successfully.");
else
- ldm_debug ("Found an MS-DOS partition table, not a dynamic disk.\n");
+ ldm_debug ("Found an MS-DOS partition table, not a dynamic disk.");
out:
put_dev_sector(sect);
@@ -428,20 +382,20 @@
*/
static BOOL ldm_validate_privheads (struct block_device *bdev,
- unsigned long first_sector, struct privhead *ph1)
+ unsigned long first_sector, struct privhead *ph1, struct gendisk *hd, unsigned long minor)
{
- struct privhead *ph[3] = { ph1, NULL, NULL };
- static const int off[3] = { OFF_PRIVHEAD1, OFF_PRIVHEAD2, OFF_PRIVHEAD3 };
+ static const int off[3] = { OFF_PRIV1, OFF_PRIV2, OFF_PRIV3 };
+ struct privhead *ph[3] = { ph1 };
Sector sect;
u8 *data;
BOOL result = FALSE;
+ long num_sects;
int i;
DEBUG_ON (!bdev || !ph1);
- // FIXME coalesce
- ph[1] = kmalloc (sizeof (*ph[1]), GFP_KERNEL);
+ ph[1] = kmalloc (sizeof (*ph[1]), GFP_KERNEL); // FIXME coalesce?
ph[2] = kmalloc (sizeof (*ph[2]), GFP_KERNEL);
if (!ph[1] || !ph[2]) {
- ldm_crit ("Out of memory.\n");
+ ldm_crit ("Out of memory.");
goto out;
}
@@ -456,11 +410,29 @@
first_sector + ph[0]->config_start + off[i], §);
if (!data) {
- ldm_crit ("Disk read failed.\n");
+ ldm_crit ("Disk read failed.");
goto out;
}
result = ldm_parse_privhead(data, ph[i]);
put_dev_sector (sect);
- if (!result)
- goto out; /* Already logged */
+ if (!result) {
+ //if (i < 2)
+ goto out; /* Already logged */
+ //else
+ //ldm_info ("Ignoring error");
+ }
+ }
+
+ num_sects = hd->part[(minor >> hd->minor_shift) << hd->minor_shift].nr_sects;
+
+ if ((ph[0]->config_start > num_sects) ||
+ ((ph[0]->config_start + ph[0]->config_size) > num_sects)) {
+ ldm_crit ("Database is out of range. Aborting."); //FIXME
+ goto out;
+ }
+
+ if ((ph[0]->logical_disk_start > ph[0]->config_start) ||
+ ((ph[0]->logical_disk_start + ph[0]->logical_disk_size) > ph[0]->config_start)) {
+ ldm_crit ("Disk is out of range. Aborting."); //FIXME
+ goto out;
}
@@ -468,9 +440,10 @@
if (!ldm_compare_privheads (ph[0], ph[1]) ||
!ldm_compare_privheads (ph[0], ph[2])) {
- ldm_crit ("Primary and backup PRIVHEADs don't match.\n");
+ ldm_crit ("Primary and backup PRIVHEADs don't match.");
goto out;
+ // FIXME ignore this too?
}
- ldm_debug ("Validated PRIVHEADs successfully.\n");
+ ldm_debug ("Validated PRIVHEADs successfully.");
result = TRUE;
out:
@@ -489,35 +462,37 @@
* @bdev and return the parsed information into @toc1.
*
+ * The offsets and sizes of the configs are range-checked against a privhead.
+ *
* Return: TRUE @toc1 contains validated TOCBLOCK info
* FALSE @toc1 contents are undefined
*/
static BOOL ldm_validate_tocblocks (struct block_device *bdev,
- unsigned long base, struct tocblock *toc1)
+ unsigned long base, struct ldmdb *ldb)
{
+ static const int off[4] = { OFF_TOCB1, OFF_TOCB2, OFF_TOCB3, OFF_TOCB4};
+ struct tocblock *tb[4];
+ struct privhead *ph;
Sector sect;
u8 *data;
- struct tocblock *tb[4] = { toc1, NULL, NULL, NULL };
- static const int off[4] = {
- OFF_TOCBLOCK1, OFF_TOCBLOCK2, OFF_TOCBLOCK3, OFF_TOCBLOCK4 };
BOOL result = FALSE;
int i;
- DEBUG_ON (!bdev || !toc1);
+ DEBUG_ON (!bdev || !ldb);
- // FIXME coalesce
- tb[1] = kmalloc (sizeof (*tb[1]), GFP_KERNEL);
+ ph = &ldb->ph;
+ tb[0] = &ldb->toc;
+ tb[1] = kmalloc (sizeof (*tb[1]), GFP_KERNEL); // FIXME coalesce?
tb[2] = kmalloc (sizeof (*tb[2]), GFP_KERNEL);
tb[3] = kmalloc (sizeof (*tb[3]), GFP_KERNEL);
if (!tb[1] || !tb[2] || !tb[3]) {
- ldm_crit ("Out of memory.\n");
+ ldm_crit ("Out of memory.");
goto out;
}
- /* Read and parse all four toc's. */
- for (i = 0; i < 4; i++)
+ for (i = 0; i < 4; i++) /* Read and parse all four toc's. */
{
data = read_dev_sector (bdev, base + off[i], §);
if (!data) {
- ldm_crit ("Disk read failed.\n");
+ ldm_crit ("Disk read failed.");
goto out;
}
@@ -525,16 +500,22 @@
put_dev_sector (sect);
if (!result)
- goto out;
+ goto out; // FIXME already logged?
}
- /* Compare all tocs. */
- if (!ldm_compare_tocblocks (tb[0], tb[1]) ||
+ /* Range check the toc against a privhead. */
+ if (((tb[0]->bitmap1_start + tb[0]->bitmap1_size) > ph->config_size) ||
+ ((tb[0]->bitmap2_start + tb[0]->bitmap2_size) > ph->config_size)) {
+ ldm_crit ("The bitmaps are out of range. Giving up.");
+ goto out;
+ }
+
+ if (!ldm_compare_tocblocks (tb[0], tb[1]) || /* Compare all tocs. */
!ldm_compare_tocblocks (tb[0], tb[2]) ||
!ldm_compare_tocblocks (tb[0], tb[3])) {
- ldm_crit ("The TOCBLOCKs don't match.\n");
+ ldm_crit ("The TOCBLOCKs don't match.");
goto out;
}
- ldm_debug ("Validated TOCBLOCKs successfully.\n");
+ ldm_debug ("Validated TOCBLOCKs successfully.");
result = TRUE;
out:
@@ -558,18 +539,43 @@
*/
static BOOL ldm_validate_vmdb (struct block_device *bdev, unsigned long base,
- struct vmdb *vm)
+ struct ldmdb *ldb)
{
Sector sect;
u8 *data;
- BOOL result;
+ BOOL result = FALSE;
+ struct vmdb *vm;
+ struct tocblock *toc;
+
+ DEBUG_ON (!bdev || !ldb);
- DEBUG_ON (!bdev || !vm);
+ vm = &ldb->vm;
+ toc = &ldb->toc;
data = read_dev_sector (bdev, base + OFF_VMDB, §);
if (!data) {
- ldm_crit ("Disk read failed.\n");
+ ldm_crit ("Disk read failed.");
return FALSE;
}
- result = ldm_parse_vmdb(data, vm);
+
+ if (!ldm_parse_vmdb(data, vm))
+ goto out; /* Already logged */
+
+ /* Are there uncommitted transactions? */
+ if (BE16(data + 0x10) != 0x01) {
+ ldm_crit ("Database is not in a consistant state. Aborting.");
+ goto out;
+ }
+
+ if (vm->vblk_offset != 512)
+ ldm_info ("VBLKs start at offset 0x%04x.", vm->vblk_offset);
+
+ if ((vm->vblk_size * vm->last_vblk_seq) != (toc->bitmap1_size * 512)) {
+ ldm_error ("VMDM and TOCBLOCK don't agree on config size."
+ "Aborting.");
+ goto out;
+ }
+
+ result = TRUE;
+out:
put_dev_sector (sect);
return result;
@@ -597,5 +603,5 @@
}
- ldm_debug("Search for vblk #%llu failed!\n", (unsigned long long) id);
+ ldm_debug("Search for vblk #%llu failed!", (unsigned long long) id);
return NULL;
}
@@ -626,9 +632,9 @@
disk_minor = (minor >> hd->minor_shift) << hd->minor_shift;
if ((start < 1) || ((start + size) > hd->part[disk_minor].nr_sects)) {
- ldm_crit ("Partition exceeds physical disk. Aborting.\n");
+ ldm_crit ("Partition exceeds physical disk. Aborting.");
return FALSE;
}
add_gd_partition (hd, minor, start, size);
- ldm_debug ("Created partition successfully.\n");
+ ldm_debug ("Created partition successfully.");
return TRUE;
}
@@ -714,9 +720,10 @@
}
- printk("\n");
+ printk ("\n");
return TRUE;
}
+
/**
* ldm_out_of_range - Check that an offset will not overflow the buffer
@@ -793,5 +800,5 @@
tmp = (tmp << 8) | *block++;
else
- ldm_error ("Illegal length %d.\n", length);
+ ldm_error ("Illegal length %d.", length);
return tmp;
@@ -823,5 +830,5 @@
length = block[0];
if (length >= buflen) {
- ldm_error ("String too long for buffer (%d/%d). Truncating.\n",
+ ldm_error ("String too long for buffer (%d/%d). Truncating.",
length, buflen);
length = buflen - 1;
@@ -1009,5 +1016,5 @@
sizeof (disk->alt_name));
if (!ldm_parse_guid (buffer + 0x19 + r_name, disk->disk_id)) {
- ldm_error ("VBLK DISK contains an invalid GUID.\n");
+ ldm_error ("VBLK DISK contains an invalid GUID.");
return FALSE;
}
@@ -1245,8 +1252,8 @@
if (result)
- ldm_debug ("Parsed VBLK 0x%llx (type: 0x%02x) ok.\n",
+ ldm_debug ("Parsed VBLK 0x%llx (type: 0x%02x) ok.",
(unsigned long long) vb->obj_id, vb->type);
else
- ldm_error ("Failed to parse VBLK 0x%llx (type: 0x%02x).\n",
+ ldm_error ("Failed to parse VBLK 0x%llx (type: 0x%02x).",
vb->obj_id, vb->type);
@@ -1254,4 +1261,5 @@
}
+
/**
* ldm_ldmdb_add - Adds a VBLK entry to the ldmdb structure
@@ -1301,8 +1309,8 @@
}
-// FIXME: better descriptions.
/**
- * ldm_frag_[find,listfree] - Obvious fraglist helper functions.
+ * ldm_frag_find - Obvious fraglist helper functions.
* @list: List of fragments.
+ * FIXME: better descriptions.
*/
static struct frags *ldm_frag_find(list_t *list, u32 group)
@@ -1335,5 +1343,4 @@
}
-// FIXME: desc.
/**
* ldm_frag_add - Adds a VBLK fragment to fragment list.
@@ -1344,4 +1351,5 @@
*
* Process fragment data and copy to fragment list.
+ * FIXME: desc.
*
* Returns: TRUE fragment added.
@@ -1359,5 +1367,5 @@
/* Sanity check vblk header. */
if (vbh->nrec > FRAG_MAX || vbh->rec >= vbh->nrec) {
- ldm_error ("Invalid VBLK header.\n");
+ ldm_error ("Invalid VBLK header.");
bad = TRUE; // FIXME shouldn't we return?
}
@@ -1370,5 +1378,5 @@
// FIXME has this been logged already?
} else if (vbh->nrec != f->nrec || FRAG_GETMAP(f, vbh->rec)) {
- ldm_error ("Inconsistent VBLK fragments!\n");
+ ldm_error ("Inconsistent VBLK fragments!");
bad = TRUE;
}
@@ -1379,5 +1387,5 @@
f = kmalloc(sizeof (*f) + nrec * size, GFP_KERNEL);
if (!f) {
- ldm_crit ("Out of memory.\n");
+ ldm_crit ("Out of memory.");
return -1;
}
@@ -1404,5 +1412,4 @@
}
-// FIXME: desc.
/**
* ldm_frag_commit - Parse complete multipart VBLK records and add to ldmdb.
@@ -1411,4 +1418,5 @@
* @ldb: ldmdb.
*
+ * FIXME: desc.
*
* Returns: TRUE
@@ -1433,5 +1441,5 @@
for (i = 0; i < f->nrec; i++)
if (!FRAG_GETMAP(f, i)) {
- ldm_error ("VBLK group %lu is incomplete.\n",
+ ldm_error ("VBLK group %lu is incomplete.",
(unsigned long)f->group);
goto entry_done;
@@ -1442,5 +1450,5 @@
vb = kmalloc (sizeof(*vb), GFP_KERNEL);
if (!vb) {
- ldm_crit ("Out of memory.\n");
+ ldm_crit ("Out of memory.");
result = FALSE;
goto out;
@@ -1464,5 +1472,4 @@
}
-// FIXME: This function is ugly, it should be rewritten.
/**
* ldm_get_vblks - Read and cache the VMDB in the ldmdb
@@ -1480,4 +1487,5 @@
struct ldmdb *ldb)
{
+ // FIXME: This function is ugly, it should be rewritten.
const int perbuf = 512 / ldb->vm.vblk_size;
const int skip = ldb->vm.vblk_offset / 512;
@@ -1501,5 +1509,5 @@
data = read_dev_sector (bdev, base + OFF_VMDB + s, §);
if (!data) {
- ldm_crit ("Disk read failed in get buffers.\n");
+ ldm_crit ("Disk read failed in get buffers.");
goto out;
}
@@ -1512,5 +1520,5 @@
if (!ldm_parse_vblk_head (block, &vbh)) {
- ldm_error ("not a VBLK\n");
+ ldm_error ("not a VBLK");
goto out;
}
@@ -1530,5 +1538,5 @@
vb = kmalloc (sizeof(*vb), GFP_KERNEL);
if (!vb) {
- ldm_crit ("Out of memory.\n");
+ ldm_crit ("Out of memory.");
goto out;
}
@@ -1624,5 +1632,4 @@
unsigned long first_sector, int first_minor)
{
- struct tocblock *toc;
struct ldmdb *ldb;
struct vblk *disk;
@@ -1636,13 +1643,12 @@
return 0;
- toc = kmalloc (sizeof (*toc), GFP_KERNEL);
ldb = kmalloc (sizeof (*ldb), GFP_KERNEL);
- if (!toc || !ldb) {
- ldm_crit ("Out of memory.\n");
+ if (!ldb) {
+ ldm_crit ("Out of memory.");
goto out;
}
/* Parse and check privheads. */
- if (!ldm_validate_privheads (bdev, first_sector, &ldb->ph))
+ if (!ldm_validate_privheads (bdev, first_sector, &ldb->ph, hd, first_minor))
goto out;
@@ -1651,6 +1657,6 @@
/* Parse and check tocs and vmdb. */
- if (!ldm_validate_tocblocks (bdev, base, toc) ||
- !ldm_validate_vmdb (bdev, base, &ldb->vm))
+ if (!ldm_validate_tocblocks (bdev, base, ldb) ||
+ !ldm_validate_vmdb (bdev, base, ldb))
goto out;
@@ -1667,5 +1673,5 @@
if (!ldm_get_vblks (bdev, base, ldb)) {
- ldm_crit ("get buffers failed\n");
+ ldm_crit ("get buffers failed");
goto cleanup;
}
@@ -1673,5 +1679,5 @@
disk = ldm_get_disk_objid (ldb);
if (!disk) {
- ldm_crit ("can't find this disk\n");
+ ldm_crit ("can't find this disk");
goto cleanup;
}
@@ -1680,5 +1686,5 @@
if (ldm_create_data_partitions (hd, first_sector, first_minor,
ldb, disk)) {
- ldm_debug ("Parsed LDM database successfully.\n");
+ ldm_debug ("Parsed LDM database successfully.");
err = 1;
}
@@ -1692,7 +1698,5 @@
ldm_free_vblks(&ldb->v_part);
out:
- kfree (toc);
kfree (ldb);
-
return err;
}
Index: ldm.h
===================================================================
RCS file: /cvsroot/linux-ntfs/dynamic-disk/linux/fs/partitions/ldm.h,v
retrieving revision 1.39
retrieving revision 1.40
diff -U2 -r1.39 -r1.40
--- ldm.h 12 Mar 2002 14:07:07 -0000 1.39
+++ ldm.h 10 Apr 2002 15:42:00 -0000 1.40
@@ -89,16 +89,16 @@
#define LDM_DB_SIZE 2048 /* Size in sectors (= 1MiB). */
-#define OFF_PRIVHEAD1 6 /* Offset of the first privhead
+#define OFF_PRIV1 6 /* Offset of the first privhead
relative to the start of the
device in sectors */
/* Offsets to structures within the LDM Database in sectors. */
-#define OFF_PRIVHEAD2 1856 /* Backup private headers. */
-#define OFF_PRIVHEAD3 2047
+#define OFF_PRIV2 1856 /* Backup private headers. */
+#define OFF_PRIV3 2047
-#define OFF_TOCBLOCK1 1 /* Tables of contents. */
-#define OFF_TOCBLOCK2 2
-#define OFF_TOCBLOCK3 2045
-#define OFF_TOCBLOCK4 2046
+#define OFF_TOCB1 1 /* Tables of contents. */
+#define OFF_TOCB2 2
+#define OFF_TOCB3 2045
+#define OFF_TOCB4 2046
#define OFF_VMDB 17 /* List of partitions. */
@@ -223,4 +223,5 @@
struct ldmdb {
struct privhead ph;
+ struct tocblock toc;
struct vmdb vm;
list_t v_dgrp;
|