Annotation of /trunk/eject/patches/eject-2.1.5-handle-spaces.patch
Parent Directory | Revision Log
Revision 903 -
(hide annotations)
(download)
Fri Oct 16 16:19:38 2009 UTC (14 years, 11 months ago) by niro
File size: 1729 byte(s)
Fri Oct 16 16:19:38 2009 UTC (14 years, 11 months ago) by niro
File size: 1729 byte(s)
-added several fixed
1 | niro | 903 | http://bugs.gentoo.org/151257 |
2 | |||
3 | --- eject.c | ||
4 | +++ eject.c | ||
5 | @@ -370,6 +370,30 @@ static int FileExists(const char *name, | ||
6 | |||
7 | |||
8 | /* | ||
9 | + * Linux mangles spaces in mount points by changing them to an octal string | ||
10 | + * of '\040'. So lets scan the mount point and fix it up by replacing all | ||
11 | + * occurrences off '\0##' with the ASCII value of 0##. Requires a writable | ||
12 | + * string as input as we mangle in place. Some of this was taken from the | ||
13 | + * util-linux package. | ||
14 | + */ | ||
15 | +#define octalify(a) ((a) & 7) | ||
16 | +#define tooctal(s) (64*octalify(s[1]) + 8*octalify(s[2]) + octalify(s[3])) | ||
17 | +#define isoctal(a) (((a) & ~7) == '0') | ||
18 | +static char *DeMangleMount(char *s) | ||
19 | +{ | ||
20 | + char *tmp = s; | ||
21 | + while ((tmp = strchr(tmp, '\\')) != NULL) { | ||
22 | + if (isoctal(tmp[1]) && isoctal(tmp[2]) && isoctal(tmp[3])) { | ||
23 | + tmp[0] = tooctal(tmp); | ||
24 | + memmove(tmp+1, tmp+4, strlen(tmp)-3); | ||
25 | + } | ||
26 | + ++tmp; | ||
27 | + } | ||
28 | + return s; | ||
29 | +} | ||
30 | + | ||
31 | + | ||
32 | +/* | ||
33 | * Given name, such as foo, see if any of the following exist: | ||
34 | * | ||
35 | * foo (if foo starts with '.' or '/') | ||
36 | @@ -884,8 +908,8 @@ static int MountedDevice(const char *nam | ||
37 | if (((strcmp(s1, name) == 0) || (strcmp(s2, name) == 0)) || | ||
38 | ((maj != -1) && (maj == mtabmaj) && (min == mtabmin))) { | ||
39 | FCLOSE(fp); | ||
40 | - *deviceName = strdup(s1); | ||
41 | - *mountName = strdup(s2); | ||
42 | + *deviceName = DeMangleMount(strdup(s1)); | ||
43 | + *mountName = DeMangleMount(strdup(s2)); | ||
44 | return 1; | ||
45 | } | ||
46 | } | ||
47 | @@ -928,8 +952,8 @@ static int MountableDevice(const char *n | ||
48 | rc = sscanf(line, "%1023s %1023s", s1, s2); | ||
49 | if (rc >= 2 && s1[0] != '#' && strcmp(s2, name) == 0) { | ||
50 | FCLOSE(fp); | ||
51 | - *deviceName = strdup(s1); | ||
52 | - *mountName = strdup(s2); | ||
53 | + *deviceName = DeMangleMount(strdup(s1)); | ||
54 | + *mountName = DeMangleMount(strdup(s2)); | ||
55 | return 1; | ||
56 | } | ||
57 | } |