From 9110aac6930a84bc9c61c988743e3b1a447d54df 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. Reviewed-on: http://gerrit.openafs.org/3745 Tested-by: BuildBot Reviewed-by: Jeffrey Altman (cherry picked from commit ffb0cdcc91d86f6e7b62561aebe6dcb722c3d768) Change-Id: I3f69c2a8f76d073afcfe626eec45be9942bf4042 Reviewed-on: http://gerrit.openafs.org/3859 Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- 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 656ec52b6..580fd5872 100644 --- a/src/vol/vol-salvage.c +++ b/src/vol/vol-salvage.c @@ -457,35 +457,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) -- 2.39.5