From e9a5c646563c984f362db1777f8c6bc7da63a4ab Mon Sep 17 00:00:00 2001 From: root Date: Sun, 21 Aug 2011 23:14:35 +0000 Subject: Sun Aug 21 23:14:34 UTC 2011 --- extra/eject/eject-2.1.5-spaces.patch | 62 ++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 extra/eject/eject-2.1.5-spaces.patch (limited to 'extra/eject/eject-2.1.5-spaces.patch') diff --git a/extra/eject/eject-2.1.5-spaces.patch b/extra/eject/eject-2.1.5-spaces.patch new file mode 100644 index 000000000..40834d902 --- /dev/null +++ b/extra/eject/eject-2.1.5-spaces.patch @@ -0,0 +1,62 @@ +diff --git a/eject.c b/eject.c +index d67089c..f7b2a2e 100644 +--- a/eject.c ++++ b/eject.c +@@ -370,6 +370,30 @@ static int FileExists(const char *name, const int try, int *found) + + + /* ++ * Linux mangles spaces in mount points by changing them to an octal string ++ * of '\040'. So lets scan the mount point and fix it up by replacing all ++ * occurrences off '\0##' with the ASCII value of 0##. Requires a writable ++ * string as input as we mangle in place. Some of this was taken from the ++ * util-linux package. ++ */ ++#define octalify(a) ((a) & 7) ++#define tooctal(s) (64*octalify(s[1]) + 8*octalify(s[2]) + octalify(s[3])) ++#define isoctal(a) (((a) & ~7) == '0') ++static char *DeMangleMount(char *s) ++{ ++ char *tmp = s; ++ while ((tmp = strchr(tmp, '\\')) != NULL) { ++ if (isoctal(tmp[1]) && isoctal(tmp[2]) && isoctal(tmp[3])) { ++ tmp[0] = tooctal(tmp); ++ memmove(tmp+1, tmp+4, strlen(tmp)-3); ++ } ++ ++tmp; ++ } ++ return s; ++} ++ ++ ++/* + * Given name, such as foo, see if any of the following exist: + * + * foo (if foo starts with '.' or '/') +@@ -882,6 +906,8 @@ static int MountedDevice(const char *name, char **mountName, char **deviceName) + rc = sscanf(line, "%1023s %1023s", s1, s2); + if (rc >= 2) { + int mtabmaj, mtabmin; ++ DeMangleMount(s1); ++ DeMangleMount(s2); + GetMajorMinor(s1, &mtabmaj, &mtabmin); + if (((strcmp(s1, name) == 0) || (strcmp(s2, name) == 0)) || + ((maj != -1) && (maj == mtabmaj) && (min == mtabmin))) { +@@ -928,6 +954,8 @@ static int MountableDevice(const char *name, char **mountName, char **deviceName + + while (fgets(line, sizeof(line), fp) != 0) { + rc = sscanf(line, "%1023s %1023s", s1, s2); ++ DeMangleMount(s1); ++ DeMangleMount(s2); + if (rc >= 2 && s1[0] != '#' && strcmp(s2, name) == 0) { + FCLOSE(fp); + *deviceName = strdup(s1); +@@ -968,6 +996,8 @@ static void UnmountDevices(const char *pattern) + while (fgets(line, sizeof(line), fp) != 0) { + status = sscanf(line, "%1023s %1023s", s1, s2); + if (status >= 2) { ++ DeMangleMount(s1); ++ DeMangleMount(s2); + status = regexec(&preg, s1, 0, 0, 0); + if (status == 0) { + if (v_option) -- cgit v1.2.3-54-g00ecf