From ffb0cdcc91d86f6e7b62561aebe6dcb722c3d768 Mon Sep 17 00:00:00 2001 From: Rod Widdowson Date: Sun, 23 Jan 2011 12:04:59 +0000 Subject: [PATCH] Windows: remove faulty assumptions about device names in vol-salvage The implementation has an assumption that all disk volumes have an object name of \Device\HarddiskXXX (where XXX is a number). This is wrong since the name is purely a convention and since about WXP they have been called \Device\HarddiskVolumeXXX. Either way it is spurious to assume the format and then try to compare the XXX. This change just compares the strings. This is done in a case insenstive manner which is the safer option. It is quite feasible, but very unlikely that someone will uses 'case sensitively different' object names. Change-Id: Ifa91c88f2b17f747f30541b8833b722cf5993e48 Reviewed-on: http://gerrit.openafs.org/3745 Tested-by: BuildBot Reviewed-by: Jeffrey Altman --- src/vol/vol-salvage.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/vol/vol-salvage.c b/src/vol/vol-salvage.c index 7d9be8b238..b02d7b6bda 100644 --- a/src/vol/vol-salvage.c +++ b/src/vol/vol-salvage.c @@ -469,35 +469,31 @@ int SameDisk(struct DiskPartition64 *p1, struct DiskPartition64 *p2) { #define RES_LEN 256 - char res[RES_LEN]; - int d1, d2; + char res1[RES_LEN]; + char res2[RES_LEN]; + static int dowarn = 1; - if (!QueryDosDevice(p1->devName, res, RES_LEN - 1)) + if (!QueryDosDevice(p1->devName, res1, RES_LEN - 1)) return 1; - if (strncmp(res, HDSTR, HDLEN)) { + if (strncmp(res1, HDSTR, HDLEN)) { if (dowarn) { dowarn = 0; Log("WARNING: QueryDosDevice is returning %s, not %s for %s\n", - res, HDSTR, p1->devName); + res1, HDSTR, p1->devName); } - return 1; } - d1 = atoi(&res[HDLEN]); - - if (!QueryDosDevice(p2->devName, res, RES_LEN - 1)) + if (!QueryDosDevice(p2->devName, res2, RES_LEN - 1)) return 1; - if (strncmp(res, HDSTR, HDLEN)) { + if (strncmp(res2, HDSTR, HDLEN)) { if (dowarn) { dowarn = 0; Log("WARNING: QueryDosDevice is returning %s, not %s for %s\n", - res, HDSTR, p2->devName); + res2, HDSTR, p2->devName); } - return 1; } - d2 = atoi(&res[HDLEN]); - return d1 == d2; + return (0 == _strnicmp(res1, res2, RES_LEN - 1)); } #else #define SameDisk(P1, P2) ((P1)->device/PartsPerDisk == (P2)->device/PartsPerDisk)