Changes by: flatcap
Update of /cvsroot/linux-ntfs/dynamic-disk/linux/fs/partitions
In directory usw-pr-cvs1:/tmp/cvs-serv9020/linux/fs/partitions
Modified Files:
ldm.c ldm.h
Log Message:
reinstate Jakob's parse guid, because I wasn't listening
more renames
Index: ldm.c
===================================================================
RCS file: /cvsroot/linux-ntfs/dynamic-disk/linux/fs/partitions/ldm.c,v
retrieving revision 1.68
retrieving revision 1.69
diff -U2 -r1.68 -r1.69
--- ldm.c 10 Apr 2002 15:41:59 -0000 1.68
+++ ldm.c 11 Apr 2002 14:27:39 -0000 1.69
@@ -100,4 +100,29 @@
}
+/**
+ * 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;
+}
/**
@@ -106,5 +131,5 @@
* @dest: memory block to hold binary GUID (16 bytes)
*
- * NB not NULL terminated!
+ * N.B. The GUID need not be NULL terminated.
*
* Return: TRUE @dest contains binary GUID
@@ -113,15 +138,19 @@
static BOOL ldm_parse_guid (const u8 *src, u8 *dest)
{
- u16 *tmp = (u16*)dest;
-
- DEBUG_ON (!src || !dest);
+ static const int size[] = { 4, 2, 2, 2, 6 };
+ int i, j, v;
- if ((src[8] != '-') || (src[13] != '-') || /* Check alignment */
- (src[18] != '-') || (src[23] != '-'))
+ if (src[8] != '-' || src[13] != '-' ||
+ 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));
+ 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 ??
/**
@@ -841,15 +870,15 @@
/**
- * ldm_parse_comp - Read a raw VBLK Component object into a vblk structure
+ * 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
* @vb: In-memory vblk in which to return information
*
- * Read a raw VBLK Component object into a more usable vblk structure.
+ * Read a raw VBLK Component object (version 3) into a vblk structure.
*
* Return: TRUE @vb contains a Component VBLK
* FALSE @vb contents are not defined
*/
-static BOOL ldm_parse_comp (const u8 *buffer, int buflen, struct vblk *vb)
+static BOOL ldm_parse_cmp3 (const u8 *buffer, int buflen, struct vblk *vb)
{
int r_objid, r_name, r_vstate, r_child, r_parent, r_stripe, r_cols, len;
@@ -876,5 +905,5 @@
return FALSE;
- len += VBLK_SIZE_COMP;
+ len += VBLK_SIZE_CMP3;
if (len != BE32 (buffer + 0x14))
return FALSE;
@@ -895,15 +924,15 @@
/**
- * ldm_parse_dgrp - Read a raw VBLK Disk Group object into a vblk structure
+ * 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
* @vb: In-memory vblk in which to return information
*
- * Read a raw VBLK Disk Group object into a more usable vblk structure.
+ * Read a raw VBLK Disk Group object (version 3) into a vblk structure.
*
* Return: TRUE @vb contains a Disk Group VBLK
* FALSE @vb contents are not defined
*/
-static int ldm_parse_dgrp (const u8 *buffer, int buflen, struct vblk *vb)
+static int ldm_parse_dgr3 (const u8 *buffer, int buflen, struct vblk *vb)
{
int r_objid, r_name, r_diskid, r_id1, r_id2, len;
@@ -916,5 +945,5 @@
r_diskid = ldm_relative (buffer, buflen, 0x18, r_name);
- if (buffer[0x12] & VBLK_FLAG_DGR1_IDS) {
+ if (buffer[0x12] & VBLK_FLAG_DGR3_IDS) {
r_id1 = ldm_relative (buffer, buflen, 0x24, r_diskid);
r_id2 = ldm_relative (buffer, buflen, 0x24, r_id1);
@@ -928,5 +957,5 @@
return FALSE;
- len += VBLK_SIZE_DGR1;
+ len += VBLK_SIZE_DGR3;
if (len != BE32 (buffer + 0x14))
return FALSE;
@@ -939,15 +968,15 @@
/**
- * ldm_parse_dgrp2 - Read a raw VBLK Disk Group object into a vblk structure
+ * 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
* @vb: In-memory vblk in which to return information
*
- * Read a raw VBLK Disk Group object into a more usable vblk structure.
+ * Read a raw VBLK Disk Group object (version 4) into a vblk structure.
*
* Return: TRUE @vb contains a Disk Group VBLK
* FALSE @vb contents are not defined
*/
-static BOOL ldm_parse_dgrp2 (const u8 *buffer, int buflen, struct vblk *vb)
+static BOOL ldm_parse_dgr4 (const u8 *buffer, int buflen, struct vblk *vb)
{
char buf[64];
@@ -960,5 +989,5 @@
r_name = ldm_relative (buffer, buflen, 0x18, r_objid);
- if (buffer[0x12] & VBLK_FLAG_DGR2_IDS) {
+ if (buffer[0x12] & VBLK_FLAG_DGR4_IDS) {
r_id1 = ldm_relative (buffer, buflen, 0x44, r_name);
r_id2 = ldm_relative (buffer, buflen, 0x44, r_id1);
@@ -972,5 +1001,5 @@
return FALSE;
- len += VBLK_SIZE_DGR2;
+ len += VBLK_SIZE_DGR4;
if (len != BE32 (buffer + 0x14))
return FALSE;
@@ -983,15 +1012,15 @@
/**
- * ldm_parse_disk - Read a raw VBLK Disk object into a vblk structure
+ * 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
* @vb: In-memory vblk in which to return information
*
- * Read a raw VBLK Disk object into a more usable vblk structure.
+ * Read a raw VBLK Disk object (version 3) into a vblk structure.
*
* Return: TRUE @vb contains a Disk VBLK
* FALSE @vb contents are not defined
*/
-static BOOL ldm_parse_disk (const u8 *buffer, int buflen, struct vblk *vb)
+static BOOL ldm_parse_dsk3 (const u8 *buffer, int buflen, struct vblk *vb)
{
int r_objid, r_name, r_diskid, r_altname, len;
@@ -1008,5 +1037,5 @@
return FALSE;
- len += VBLK_SIZE_DSK1;
+ len += VBLK_SIZE_DSK3;
if (len != BE32 (buffer + 0x14))
return FALSE;
@@ -1024,15 +1053,15 @@
/**
- * ldm_parse_disk2 - Read a raw VBLK Disk object into a vblk structure
+ * 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
* @vb: In-memory vblk in which to return information
*
- * Read a raw VBLK Disk object into a more usable vblk structure.
+ * Read a raw VBLK Disk object (versino 4) into a vblk structure.
*
* Return: TRUE @vb contains a Disk VBLK
* FALSE @vb contents are not defined
*/
-static BOOL ldm_parse_disk2 (const u8 *buffer, int buflen, struct vblk *vb)
+static BOOL ldm_parse_dsk4 (const u8 *buffer, int buflen, struct vblk *vb)
{
int r_objid, r_name, len;
@@ -1047,5 +1076,5 @@
return FALSE;
- len += VBLK_SIZE_DSK2;
+ len += VBLK_SIZE_DSK4;
if (len != BE32 (buffer + 0x14))
return FALSE;
@@ -1057,15 +1086,15 @@
/**
- * ldm_parse_part - Read a raw VBLK Partition object into a vblk structure
+ * 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
* @vb: In-memory vblk in which to return information
*
- * Read a raw VBLK Partition object into a more usable vblk structure.
+ * Read a raw VBLK Partition object (version 3) into a vblk structure.
*
* Return: TRUE @vb contains a Partition VBLK
* FALSE @vb contents are not defined
*/
-static BOOL ldm_parse_part (const u8 *buffer, int buflen, struct vblk *vb)
+static BOOL ldm_parse_prt3 (const u8 *buffer, int buflen, struct vblk *vb)
{
int r_objid, r_name, r_size, r_parent, r_diskid, r_index, len;
@@ -1090,5 +1119,5 @@
return FALSE;
- len += VBLK_SIZE_PART;
+ len += VBLK_SIZE_PRT3;
if (len != BE32 (buffer + 0x14))
return FALSE;
@@ -1109,15 +1138,15 @@
/**
- * ldm_parse_volu - Read a raw VBLK Volume object into a vblk structure
+ * 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
* @vb: In-memory vblk in which to return information
*
- * Read a raw VBLK Volume object into a more usable vblk structure.
+ * Read a raw VBLK Volume object (version 5) into a vblk structure.
*
* Return: TRUE @vb contains a Volume VBLK
* FALSE @vb contents are not defined
*/
-static BOOL ldm_parse_volu (const u8 *buffer, int buflen, struct vblk *vb)
+static BOOL ldm_parse_vol5 (const u8 *buffer, int buflen, struct vblk *vb)
{
int r_objid, r_name, r_vtype, r_child, r_size, r_id1, r_id2, r_size2, r_drive, len;
@@ -1156,5 +1185,5 @@
return FALSE;
- len += VBLK_SIZE_VOLU;
+ len += VBLK_SIZE_VOL5;
if (len != BE32 (buffer + 0x14))
return FALSE;
@@ -1207,7 +1236,7 @@
* @vb: In-memory vblk in which to return information
*
- * Read a raw VBLK Component object into a more usable vblk structure.
- * This function just reads the information common to all VBLK types, then
- * delegates the rest of the work to help functions: parse_*.
+ * Read a raw VBLK object into a vblk structure. This function just reads the
+ * information common to all VBLK types, then delegates the rest of the work to
+ * help functions: ldm_parse_*.
*
* Return: TRUE @vb contains a VBLK
@@ -1235,18 +1264,11 @@
switch (vb->type) {
- case VBLK_COMP:
- result = ldm_parse_comp (buffer, buflen, vb); break;
- case VBLK_DSK1:
- result = ldm_parse_disk (buffer, buflen, vb); break;
- case VBLK_DSK2:
- result = ldm_parse_disk2(buffer, buflen, vb); break;
- case VBLK_DGR1:
- result = ldm_parse_dgrp (buffer, buflen, vb); break;
- case VBLK_DGR2:
- result = ldm_parse_dgrp2(buffer, buflen, vb); break;
- case VBLK_PART:
- result = ldm_parse_part (buffer, buflen, vb); break;
- case VBLK_VOLU:
- result = ldm_parse_volu (buffer, buflen, vb); break;
+ case VBLK_CMP3: result = ldm_parse_cmp3 (buffer, buflen, vb); break;
+ case VBLK_DSK3: result = ldm_parse_dsk3 (buffer, buflen, vb); break;
+ case VBLK_DSK4: result = ldm_parse_dsk4 (buffer, buflen, vb); break;
+ case VBLK_DGR3: result = ldm_parse_dgr3 (buffer, buflen, vb); break;
+ case VBLK_DGR4: result = ldm_parse_dgr4 (buffer, buflen, vb); break;
+ case VBLK_PRT3: result = ldm_parse_prt3 (buffer, buflen, vb); break;
+ case VBLK_VOL5: result = ldm_parse_vol5 (buffer, buflen, vb); break;
}
@@ -1280,19 +1302,19 @@
/* Put vblk into the correct list. @vb is already sanity-checked. */
switch (vb->type) {
- case VBLK_DGR1:
- case VBLK_DGR2:
+ case VBLK_DGR3:
+ case VBLK_DGR4:
list_add(&vb->list, &ldb->v_dgrp);
return;
- case VBLK_DSK1:
- case VBLK_DSK2:
+ case VBLK_DSK3:
+ case VBLK_DSK4:
list_add(&vb->list, &ldb->v_disk);
return;
- case VBLK_VOLU:
+ case VBLK_VOL5:
list_add(&vb->list, &ldb->v_volu);
return;
- case VBLK_COMP:
+ case VBLK_CMP3:
list_add(&vb->list, &ldb->v_comp);
return;
- case VBLK_PART:
+ case VBLK_PRT3:
/* Sort by partition's start sector */
list_for_each(item, &ldb->v_part) {
Index: ldm.h
===================================================================
RCS file: /cvsroot/linux-ntfs/dynamic-disk/linux/fs/partitions/ldm.h,v
retrieving revision 1.40
retrieving revision 1.41
diff -U2 -r1.40 -r1.41
--- ldm.h 10 Apr 2002 15:42:00 -0000 1.40
+++ ldm.h 11 Apr 2002 14:27:39 -0000 1.41
@@ -48,11 +48,11 @@
/* The defined vblk types. */
-#define VBLK_COMP 0x32 /* Component */
-#define VBLK_PART 0x33 /* Partition */
-#define VBLK_DSK1 0x34 /* Disk */
-#define VBLK_DSK2 0x44 /* Disk */
-#define VBLK_DGR1 0x35 /* Disk Group */
-#define VBLK_DGR2 0x45 /* Disk Group */
-#define VBLK_VOLU 0x51 /* Volume */
+#define VBLK_VOL5 0x51 /* Volume, version 5 */
+#define VBLK_CMP3 0x32 /* Component, version 3 */
+#define VBLK_PRT3 0x33 /* Partition, version 3 */
+#define VBLK_DSK3 0x34 /* Disk, version 3 */
+#define VBLK_DSK4 0x44 /* Disk, version 4 */
+#define VBLK_DGR3 0x35 /* Disk Group, version 3 */
+#define VBLK_DGR4 0x45 /* Disk Group, version 4 */
/* vblk flags. */
@@ -63,6 +63,6 @@
#define VBLK_FLAG_COMP_STRIPE 0x10
#define VBLK_FLAG_PART_INDEX 0x08
-#define VBLK_FLAG_DGR1_IDS 0x08
-#define VBLK_FLAG_DGR2_IDS 0x08
+#define VBLK_FLAG_DGR3_IDS 0x08
+#define VBLK_FLAG_DGR4_IDS 0x08
#define VBLK_FLAG_VOLU_ID1 0x08
#define VBLK_FLAG_VOLU_ID2 0x20
@@ -73,11 +73,11 @@
#define VBLK_SIZE_HEAD 16
-#define VBLK_SIZE_COMP 22
-#define VBLK_SIZE_PART 28
-#define VBLK_SIZE_DSK1 12
-#define VBLK_SIZE_DSK2 45
-#define VBLK_SIZE_DGR1 12
-#define VBLK_SIZE_DGR2 44
-#define VBLK_SIZE_VOLU 59
+#define VBLK_SIZE_CMP3 22 /* Name and version */
+#define VBLK_SIZE_DGR3 12
+#define VBLK_SIZE_DGR4 44
+#define VBLK_SIZE_DSK3 12
+#define VBLK_SIZE_DSK4 45
+#define VBLK_SIZE_PRT3 28
+#define VBLK_SIZE_VOL5 59
/* component types */
@@ -124,4 +124,6 @@
#define FRAG_GETBAD(f) (f->map & (1 << (FRAG_MAPBITS-1)))
#define FRAG_SETBAD(f) (f->map |= (1 << (FRAG_MAPBITS-1)))
+
+typedef struct list_head list_t;
struct frags {
|