Changes by: flatcap
Update of /cvsroot/linux-ntfs/dynamic-disk/linux/fs/partitions
In directory usw-pr-cvs1:/tmp/cvs-serv5436/linux/fs/partitions
Modified Files:
ldm.c ldm.h
Log Message:
tidy ups, build fixes
Index: ldm.c
===================================================================
RCS file: /cvsroot/linux-ntfs/dynamic-disk/linux/fs/partitions/ldm.c,v
retrieving revision 1.80
retrieving revision 1.81
diff -U2 -r1.80 -r1.81
--- ldm.c 23 Jun 2002 17:07:11 -0000 1.80
+++ ldm.c 5 Aug 2002 15:46:50 -0000 1.81
@@ -24,10 +24,5 @@
*/
-#include <linux/blkdev.h>
#include <linux/slab.h>
-#include <linux/pagemap.h>
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,11)
-#include <linux/buffer_head.h>
-#endif
#include <linux/stringify.h>
#include "ldm.h"
@@ -44,6 +39,6 @@
#ifdef CONFIG_LDM_MD
-extern void ldm_md_addpart (const u8 *dg_guid, u32 objid, u8 comptype,
- u8 n, u8 parts, u8 chunk_s, kdev_t dev);
+void ldm_md_addpart(const u8 *dg_guid, u32 objid, u8 comptype,
+ u8 n, u8 parts, u8 chunk_s, kdev_t dev);
#endif
@@ -56,5 +51,5 @@
* ldm_debug/info/error/crit - Output an error message
* @f: A printf format string containing the message
- * @...: The variables to substitute into @f
+ * @...: Variables to substitute into @f
*
* ldm_debug() writes a DEBUG level message to the syslog but only if the
@@ -219,5 +214,5 @@
}
strncpy (toc->bitmap1_name, data + 0x24, sizeof (toc->bitmap1_name));
- toc->bitmap1_name[sizeof (toc->bitmap1_name) - 1] = (u8)'\0';
+ toc->bitmap1_name[sizeof (toc->bitmap1_name) - 1] = 0;
toc->bitmap1_start = BE64 (data + 0x2E);
toc->bitmap1_size = BE64 (data + 0x36);
@@ -230,5 +225,5 @@
}
strncpy (toc->bitmap2_name, data + 0x46, sizeof (toc->bitmap2_name));
- toc->bitmap2_name[sizeof (toc->bitmap2_name) - 1] = (u8)'\0';
+ toc->bitmap2_name[sizeof (toc->bitmap2_name) - 1] = 0;
toc->bitmap2_start = BE64 (data + 0x50);
toc->bitmap2_size = BE64 (data + 0x58);
@@ -283,6 +278,6 @@
/**
* ldm_compare_privheads - Compare two privhead objects
- * @ph1: first privhead
- * @ph2: second privhead
+ * @ph1: First privhead
+ * @ph2: Second privhead
*
* This compares the two privhead structures @ph1 and @ph2.
@@ -307,6 +302,6 @@
/**
* ldm_compare_tocblocks - Compare two tocblock objects
- * @toc1: first toc
- * @toc2: second toc
+ * @toc1: First toc
+ * @toc2: Second toc
*
* This compares the two tocblock structures @toc1 and @toc2.
@@ -332,9 +327,6 @@
/**
* ldm_validate_privheads - Compare the primary privhead with its backups
- * @bdev: Partition device holding the LDM Database
- * @first_sector: First sector within the device
- * @ph1: Memory struct to fill with ph contents
- * @hd: The array of all disks
- * @first_minor: The first available device minor
+ * @bdev: Device holding the LDM Database
+ * @ph1: Memory struct to fill with ph contents
*
* Read and compare all three privheads from disk.
@@ -348,6 +340,5 @@
*/
static BOOL ldm_validate_privheads (struct block_device *bdev,
- unsigned long first_sector, struct privhead *ph1, struct gendisk *hd,
- unsigned long first_minor)
+ struct privhead *ph1)
{
static const int off[3] = { OFF_PRIV1, OFF_PRIV2, OFF_PRIV3 };
@@ -374,5 +365,5 @@
for (i = 0; i < 3; i++) {
data = read_dev_sector (bdev,
- first_sector + ph[0]->config_start + off[i], §);
+ ph[0]->config_start + off[i], §);
if (!data) {
ldm_crit ("Disk read failed.");
@@ -390,6 +381,5 @@
}
- num_sects = hd->part[(first_minor >> hd->minor_shift)
- << hd->minor_shift].nr_sects;
+ num_sects = bdev->bd_inode->i_size >> 9;
if ((ph[0]->config_start > num_sects) ||
@@ -414,6 +404,5 @@
ldm_crit ("Primary and backup PRIVHEADs don't match.");
goto out;
- }
- */
+ }*/
ldm_debug ("Validated PRIVHEADs successfully.");
result = TRUE;
@@ -426,7 +415,7 @@
/**
* ldm_validate_tocblocks - Validate the table of contents and its backups
- * @bdev: Partition device holding the LDM Database
- * @base: The offset into the device
- * @toc1: In-memory table of contents in which to return information
+ * @bdev: Device holding the LDM Database
+ * @base: Offset, into @bdev, of the database
+ * @ldb: Cache of the database structures
*
* Find and compare the four tables of contents of the LDM Database stored on
@@ -500,12 +489,12 @@
* ldm_validate_vmdb - Read the VMDB and validate it
* @bdev: Device holding the LDM Database
- * @base: The offset into the device
- * @vm: In-memory vmdb in which to return information
+ * @base: Offset, into @bdev, of the database
+ * @ldb: Cache of the database structures
*
* Find the vmdb of the LDM Database stored on @bdev and return the parsed
- * information in @vm.
+ * information in @ldb.
*
- * Return: TRUE @vm contains validated VBDB info
- * FALSE @vm contents are undefined
+ * Return: TRUE @ldb contains validated VBDB info
+ * FALSE @ldb contents are undefined
*/
static BOOL ldm_validate_vmdb (struct block_device *bdev, unsigned long base,
@@ -542,5 +531,5 @@
/* FIXME: How should we handle this situation? */
- if ((vm->vblk_size * vm->last_vblk_seq) != (toc->bitmap1_size * 512))
+ if ((vm->vblk_size * vm->last_vblk_seq) != (toc->bitmap1_size << 9))
ldm_info ("VMDB and TOCBLOCK don't agree on the database size.");
@@ -554,5 +543,5 @@
/**
* ldm_validate_partition_table - Determine whether bdev might be a dynamic disk
- * @bdev: Device to test
+ * @bdev: Device holding the LDM Database
*
* This function provides a weak test to decide whether the device is a dynamic
@@ -633,5 +622,5 @@
/**
* ldm_get_disk_objid - Search a linked list of vblk's for a given Disk Id
- * @ldb: ldmdb struct
+ * @ldb: Cache of the database structures
*
* The LDM Database contains a list of all partitions on all dynamic disks. The
@@ -658,41 +647,7 @@
/**
- * ldm_create_partition - Create a kernel partition device
- * @hd: gendisk structure in which to create partition
- * @minor: Create a this minor number on the device
- * @start: Offset (in sectors) into the device of the partition
- * @size: Size (in sectors) of the partition
- *
- * This validates the range, then puts an entry into the kernel's partition
- * table.
- *
- * Return: TRUE Created the partition
- * FALSE Error
- */
-static BOOL ldm_create_partition (struct gendisk *hd, int minor, int start,
- int size)
-{
- int disk_minor;
-
- BUG_ON (!hd || !hd->part);
-
- /* Get the minor number of the parent device
- * so we can check we don't go beyond the end of the device. */
- 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.");
- return FALSE;
- }
- add_gd_partition (hd, minor, start, size);
- ldm_debug ("Created partition successfully.");
- return TRUE;
-}
-
-/**
* ldm_create_data_partitions - Create data partitions for this device
- * @hd: gendisk structure in which to create the data partitions
- * @first_sector: First sector of data on the device
- * @first_minor: Device minor to be used
- * @ldb: ldmdb structure
+ * @pp: List of the partitions parsed so far
+ * @ldb: Cache of the database structures
*
* The database contains ALL the partitions for ALL disk groups, so we need to
@@ -700,6 +655,5 @@
* the partitions in the database that belong to this disk.
*
- * For each found partition, we create a corresponding partition device starting
- * with minor number @first_minor.
+ * Add each partition in our database, to the parsed_partitions structure.
*
* N.B. This function creates the partitions in the order it finds partition
@@ -709,14 +663,20 @@
* FALSE Error, probably a range checking problem
*/
-static BOOL ldm_create_data_partitions (struct gendisk *hd,
- unsigned long first_sector, int first_minor, const struct ldmdb *ldb)
+#ifdef CONFIG_BLK_DEV_MD
+static BOOL ldm_create_data_partitions (struct parsed_partitions *pp,
+ const struct ldmdb *ldb,
+ struct block_device *bdev)
+#else
+static BOOL ldm_create_data_partitions (struct parsed_partitions *pp,
+ const struct ldmdb *ldb)
+#endif
{
struct list_head *item;
- struct vblk_part *part;
+ struct vblk *vb;
struct vblk *disk;
- int disk_minor;
- int minor;
+ struct vblk_part *part;
+ int part_num = 1;
- BUG_ON (!hd || !ldb);
+ BUG_ON (!pp || !ldb);
disk = ldm_get_disk_objid (ldb);
@@ -726,16 +686,11 @@
}
- /* We use the range-check the partitions against the parent device. */
- disk_minor = (first_minor >> hd->minor_shift) << hd->minor_shift;
- minor = first_minor;
-
printk (" [LDM]");
/* Create the data partitions */
list_for_each (item, &ldb->v_part) {
- struct vblk *vb;
#ifdef CONFIG_BLK_DEV_MD /* CONFIG_LDM_MD implies CONFIG_BLK_DEV_MD */
struct vblk *v, *c;
- const kdev_t dev = mk_kdev (hd->major, minor);
+ const kdev_t dev = bdev->bd_inode->i_dev;
#endif
vb = list_entry (item, struct vblk, list);
@@ -745,8 +700,6 @@
continue;
- if (!ldm_create_partition (hd, minor,
- part->start + ldb->ph.logical_disk_start, part->size))
- continue; /* Already logged */
- minor++;
+ put_partition (pp, part_num, ldb->ph.logical_disk_start +
+ part->start, part->size);
#ifdef CONFIG_BLK_DEV_MD
/* Try to get parent component */
@@ -769,6 +722,6 @@
continue;
}
- /* Register to LDM_MD */
#ifdef CONFIG_LDM_MD
+ /* Register to LDM_MD */
ldm_md_addpart (v->vblk.volu.guid, c->obj_id,
c->vblk.comp.type, part->partnum, c->vblk.comp.children,
@@ -776,8 +729,8 @@
#endif
#endif
+ part_num++;
}
printk ("\n");
-
return TRUE;
}
@@ -786,8 +739,8 @@
/**
* ldm_relative - Calculate the next relative offset
- * @buffer: The block of data being worked on
- * @buflen: The size of the block of data
- * @base: The size of the previous fixed width fields
- * @offset: The cumulative size of the previous variable-width fields
+ * @buffer: Block of data being worked on
+ * @buflen: Size of the block of data
+ * @base: Size of the previous fixed width fields
+ * @offset: Cumulative size of the previous variable-width fields
*
* Because many of the VBLK fields are variable-width, it's necessary
@@ -796,5 +749,5 @@
*
* Return: -1 Error, the calculated offset exceeded the size of the buffer
- * : n OK, a range-checked offset into buffer
+ * n OK, a range-checked offset into buffer
*/
static int ldm_relative (const u8 *buffer, int buflen, int base, int offset)
@@ -868,10 +821,9 @@
length = block[0];
if (length >= buflen) {
- ldm_error ("String too long for buffer (%d/%d). Truncating.",
- length, buflen);
+ ldm_error ("Truncating string %d -> %d.", length, buflen);
length = buflen - 1;
}
memcpy (buffer, block + 1, length);
- buffer[length] = (u8)'\0';
+ buffer[length] = 0;
return length;
}
@@ -880,6 +832,6 @@
/**
* ldm_parse_cmp3 - Read a raw VBLK Component object into a vblk structure
- * @buffer: The block of data being worked on
- * @buflen: The size of the block of data
+ * @buffer: Block of data being worked on
+ * @buflen: Size of the block of data
* @vb: In-memory vblk in which to return information
*
@@ -931,6 +883,6 @@
/**
* ldm_parse_dgr3 - Read a raw VBLK Disk Group object into a vblk structure
- * @buffer: The block of data being worked on
- * @buflen: The size of the block of data
+ * @buffer: Block of data being worked on
+ * @buflen: Size of the block of data
* @vb: In-memory vblk in which to return information
*
@@ -975,6 +927,6 @@
/**
* ldm_parse_dgr4 - Read a raw VBLK Disk Group object into a vblk structure
- * @buffer: The block of data being worked on
- * @buflen: The size of the block of data
+ * @buffer: Block of data being worked on
+ * @buflen: Size of the block of data
* @vb: In-memory vblk in which to return information
*
@@ -1019,6 +971,6 @@
/**
* ldm_parse_dsk3 - Read a raw VBLK Disk object into a vblk structure
- * @buffer: The block of data being worked on
- * @buflen: The size of the block of data
+ * @buffer: Block of data being worked on
+ * @buflen: Size of the block of data
* @vb: In-memory vblk in which to return information
*
@@ -1058,6 +1010,6 @@
/**
* ldm_parse_dsk4 - Read a raw VBLK Disk object into a vblk structure
- * @buffer: The block of data being worked on
- * @buflen: The size of the block of data
+ * @buffer: Block of data being worked on
+ * @buflen: Size of the block of data
* @vb: In-memory vblk in which to return information
*
@@ -1091,6 +1043,6 @@
/**
* ldm_parse_prt3 - Read a raw VBLK Partition object into a vblk structure
- * @buffer: The block of data being worked on
- * @buflen: The size of the block of data
+ * @buffer: Block of data being worked on
+ * @buflen: Size of the block of data
* @vb: In-memory vblk in which to return information
*
@@ -1143,6 +1095,6 @@
/**
* ldm_parse_vol5 - Read a raw VBLK Volume object into a vblk structure
- * @buffer: The block of data being worked on
- * @buflen: The size of the block of data
+ * @buffer: Block of data being worked on
+ * @buflen: Size of the block of data
* @vb: In-memory vblk in which to return information
*
@@ -1212,6 +1164,6 @@
/**
* ldm_parse_vblk - Read a raw VBLK object into a vblk structure
- * @buf: The block of data being worked on
- * @len: The size of the block of data
+ * @buf: Block of data being worked on
+ * @len: Size of the block of data
* @vb: In-memory vblk in which to return information
*
@@ -1264,7 +1216,7 @@
/**
* ldm_ldmdb_add - Adds a raw VBLK entry to the ldmdb database
- * @data: The raw VBLK to add to the database
- * @len: The size of the raw VBLK
- * @ldb: ldmdb database containing VBLK lists
+ * @data: Raw VBLK to add to the database
+ * @len: Size of the raw VBLK
+ * @ldb: Cache of the database structures
*
* The VBLKs are sorted into categories. Partitions are also sorted by offset.
@@ -1288,7 +1240,6 @@
}
- if (!ldm_parse_vblk (data, len, vb)) {
+ if (!ldm_parse_vblk (data, len, vb))
return FALSE; /* Already logged */
- }
/* Put vblk into the correct list. */
@@ -1326,7 +1277,7 @@
/**
* ldm_frag_add - Add a VBLK fragment to a list
- * @data: The raw fragment to be added
- * @size: The size of the raw fragment
- * @frags: The list of fragments
+ * @data: Raw fragment to be added to the list
+ * @size: Size of the raw fragment
+ * @frags: Linked list of VBLK fragments
*
* Fragmented VBLKs may not be consecutive in the database, so they are placed
@@ -1377,5 +1328,5 @@
}
- f->map |= 1 << rec;
+ f->map |= (1 << rec);
if (num > 0) {
@@ -1390,5 +1341,5 @@
/**
* ldm_frag_free - Free a linked list of VBLK fragments
- * @list: A linked list of fragments
+ * @list: Linked list of fragments
*
* Free a linked list of VBLK fragments
@@ -1408,6 +1359,6 @@
/**
* ldm_frag_commit - Validate fragmented VBLKs and add them to the database
- * @frags: The list of VBLK fragment
- * @ldb: The ldmdb database
+ * @frags: Linked list of VBLK fragments
+ * @ldb: Cache of the database structures
*
* Now that all the fragmented VBLKs have been collected, they must be added to
@@ -1421,5 +1372,4 @@
struct frag *f;
struct list_head *item;
- BOOL result = FALSE;
BUG_ON (!frags || !ldb);
@@ -1431,20 +1381,18 @@
ldm_error ("VBLK group %d is incomplete (0x%02x).",
f->group, f->map);
- goto out;
+ return FALSE;
}
if (!ldm_ldmdb_add (f->data, f->num*ldb->vm.vblk_size, ldb))
- goto out;
+ return FALSE; /* Already logged */
}
- result = TRUE;
-out:
- return result;
+ return TRUE;
}
/**
* ldm_get_vblks - Read the on-disk database of VBLKs into memory
- * @bdev: The block device to read from
- * @base: The offset, into @bdev, of the database
- * @ldb: The database to store the parsed VBLKs
+ * @bdev: Device holding the LDM Database
+ * @base: Offset, into @bdev, of the database
+ * @ldb: Cache of the database structures
*
* To use the information from the VBLKs, they need to be read from the disk,
@@ -1467,6 +1415,6 @@
size = ldb->vm.vblk_size;
perbuf = 512 / size;
- skip = ldb->vm.vblk_offset / 512;
- finish = (size * ldb->vm.last_vblk_seq) / 512;
+ skip = ldb->vm.vblk_offset >> 9; /* Bytes to sectors */
+ finish = (size * ldb->vm.last_vblk_seq) >> 9;
for (s = skip; s < finish; s++) { /* For each sector */
@@ -1527,8 +1475,6 @@
/**
* ldm_partition - Find out whether a device is a dynamic disk and handle it
- * @hd: gendisk structure in which to return the handled disk
- * @bdev: Device we need to look at
- * @first_sector: First sector within the device
- * @first_minor: First minor number of partitions for the device
+ * @pp: List of the partitions parsed so far
+ * @bdev: Device holding the LDM Database
*
* This determines whether the device @bdev is a dynamic disk and if so creates
@@ -1545,12 +1491,17 @@
* Or @bdev is a dynamic disk, but it may be corrupted
*/
-int ldm_partition (struct gendisk *hd, struct block_device *bdev,
- unsigned long first_sector, int first_minor)
+#ifdef CONFIG_LDM_EXPORT_SYMBOLS
+int ldm_partition (struct parsed_partitions *pp, struct block_device *bdev, struct ldmdb *ldb)
+#else
+int ldm_partition (struct parsed_partitions *pp, struct block_device *bdev)
+#endif
{
+#ifndef CONFIG_LDM_EXPORT_SYMBOLS
struct ldmdb *ldb;
+#endif
unsigned long base;
- int err = -1;
+ int result = -1;
- BUG_ON (!hd || !bdev);
+ BUG_ON (!pp || !bdev);
/* Look for signs of a Dynamic Disk */
@@ -1558,4 +1509,5 @@
return 0;
+#ifndef CONFIG_LDM_EXPORT_SYMBOLS
ldb = kmalloc (sizeof (*ldb), GFP_KERNEL);
if (!ldb) {
@@ -1563,18 +1515,20 @@
goto out;
}
+#endif
/* Parse and check privheads. */
- if (!ldm_validate_privheads (bdev, first_sector, &ldb->ph, hd, first_minor))
- goto out;
+ if (!ldm_validate_privheads (bdev, &ldb->ph))
+ goto out; /* Already logged */
/* All further references are relative to base (database start). */
- base = first_sector + ldb->ph.config_start;
+ base = ldb->ph.config_start;
/* Parse and check tocs and vmdb. */
if (!ldm_validate_tocblocks (bdev, base, ldb) ||
!ldm_validate_vmdb (bdev, base, ldb))
- goto out;
+ goto out; /* Already logged */
/* Initialize vblk lists in ldmdb struct */
+#ifndef CONFIG_LDM_EXPORT_SYMBOLS
INIT_LIST_HEAD (&ldb->v_dgrp);
INIT_LIST_HEAD (&ldb->v_disk);
@@ -1582,4 +1536,5 @@
INIT_LIST_HEAD (&ldb->v_comp);
INIT_LIST_HEAD (&ldb->v_part);
+#endif
if (!ldm_get_vblks (bdev, base, ldb)) {
@@ -1589,11 +1544,16 @@
/* Finally, create the data partition devices. */
- if (ldm_create_data_partitions (hd, first_sector, first_minor, ldb)) {
+#ifdef CONFIG_BLK_DEV_MD
+ if (ldm_create_data_partitions (pp, ldb, bdev)) {
+#else
+ if (ldm_create_data_partitions (pp, ldb)) {
+#endif
ldm_debug ("Parsed LDM database successfully.");
- err = 1;
+ result = 1;
}
/* else Already logged */
cleanup:
+#ifndef CONFIG_LDM_EXPORT_SYMBOLS
ldm_free_vblks (&ldb->v_dgrp);
ldm_free_vblks (&ldb->v_disk);
@@ -1601,6 +1561,10 @@
ldm_free_vblks (&ldb->v_comp);
ldm_free_vblks (&ldb->v_part);
+#endif
out:
+#ifndef CONFIG_LDM_EXPORT_SYMBOLS
kfree (ldb);
- return err;
+#endif
+ return result;
}
+
Index: ldm.h
===================================================================
RCS file: /cvsroot/linux-ntfs/dynamic-disk/linux/fs/partitions/ldm.h,v
retrieving revision 1.49
retrieving revision 1.50
diff -U2 -r1.49 -r1.50
--- ldm.h 21 Jun 2002 14:31:44 -0000 1.49
+++ ldm.h 5 Aug 2002 15:46:50 -0000 1.50
@@ -1,5 +1,2 @@
-#ifndef _FS_PT_LDM_H_
-#define _FS_PT_LDM_H_
-
/**
* ldm - Part of the Linux-NTFS project.
@@ -27,4 +24,7 @@
*/
+#ifndef _FS_PT_LDM_H_
+#define _FS_PT_LDM_H_
+
#include <linux/types.h>
#include <linux/list.h>
@@ -34,4 +34,6 @@
#include <asm/byteorder.h>
+struct parsed_partitions;
+
/* Magic numbers in CPU format. */
#define MAGIC_VMDB 0x564D4442 /* VMDB */
@@ -213,6 +215,9 @@
};
-int ldm_partition (struct gendisk *hd, struct block_device *bdev,
- unsigned long first_sector, int first_minor);
+#ifdef CONFIG_LDM_EXPORT_SYMBOLS
+int ldm_partition (struct parsed_partitions *pp, struct block_device *bdev, struct ldmdb *ldb);
+#else
+int ldm_partition (struct parsed_partitions *pp, struct block_device *bdev);
+#endif
#endif /* _FS_PT_LDM_H_ */
|