Lines 370-375
static int FileExists(const char *name,
Link Here
|
370 |
|
370 |
|
371 |
|
371 |
|
372 |
/* |
372 |
/* |
|
|
373 |
* Linux mangles spaces in mount points by changing them to an octal string |
374 |
* of '\040'. So lets scan the mount point and fix it up by replacing all |
375 |
* occurrences off '\0##' with the ASCII value of 0##. Requires a writable |
376 |
* string as input as we mangle in place. Some of this was taken from the |
377 |
* util-linux package. |
378 |
*/ |
379 |
#define octalify(a) ((a) & 7) |
380 |
#define tooctal(s) (64*octalify(s[1]) + 8*octalify(s[2]) + octalify(s[3])) |
381 |
#define isoctal(a) (((a) & ~7) == '0') |
382 |
static char *DeMangleMount(char *s) |
383 |
{ |
384 |
char *tmp = s; |
385 |
while ((tmp = strchr(tmp, '\\')) != NULL) { |
386 |
if (isoctal(tmp[1]) && isoctal(tmp[2]) && isoctal(tmp[3])) { |
387 |
tmp[0] = tooctal(tmp); |
388 |
memmove(tmp+1, tmp+4, strlen(tmp)-3); |
389 |
} |
390 |
++tmp; |
391 |
} |
392 |
return s; |
393 |
} |
394 |
|
395 |
|
396 |
/* |
373 |
* Given name, such as foo, see if any of the following exist: |
397 |
* Given name, such as foo, see if any of the following exist: |
374 |
* |
398 |
* |
375 |
* foo (if foo starts with '.' or '/') |
399 |
* foo (if foo starts with '.' or '/') |
Lines 884-891
static int MountedDevice(const char *nam
Link Here
|
884 |
if (((strcmp(s1, name) == 0) || (strcmp(s2, name) == 0)) || |
908 |
if (((strcmp(s1, name) == 0) || (strcmp(s2, name) == 0)) || |
885 |
((maj != -1) && (maj == mtabmaj) && (min == mtabmin))) { |
909 |
((maj != -1) && (maj == mtabmaj) && (min == mtabmin))) { |
886 |
FCLOSE(fp); |
910 |
FCLOSE(fp); |
887 |
*deviceName = strdup(s1); |
911 |
*deviceName = DeMangleMount(strdup(s1)); |
888 |
*mountName = strdup(s2); |
912 |
*mountName = DeMangleMount(strdup(s2)); |
889 |
return 1; |
913 |
return 1; |
890 |
} |
914 |
} |
891 |
} |
915 |
} |
Lines 928-935
static int MountableDevice(const char *n
Link Here
|
928 |
rc = sscanf(line, "%1023s %1023s", s1, s2); |
952 |
rc = sscanf(line, "%1023s %1023s", s1, s2); |
929 |
if (rc >= 2 && s1[0] != '#' && strcmp(s2, name) == 0) { |
953 |
if (rc >= 2 && s1[0] != '#' && strcmp(s2, name) == 0) { |
930 |
FCLOSE(fp); |
954 |
FCLOSE(fp); |
931 |
*deviceName = strdup(s1); |
955 |
*deviceName = DeMangleMount(strdup(s1)); |
932 |
*mountName = strdup(s2); |
956 |
*mountName = DeMangleMount(strdup(s2)); |
933 |
return 1; |
957 |
return 1; |
934 |
} |
958 |
} |
935 |
} |
959 |
} |