--- ../eject/eject.c 2006-02-11 12:24:38.000000000 +1030 +++ ./eject.c 2006-10-14 13:41:36.000000000 +0930 @@ -843,6 +843,35 @@ return 0; } +/* next three functions copied from mntent.c from util-linux*/ +#define isoctal(a) (((a) & ~7) == '0') + +static int is_space_or_tab (char c) { + return (c == ' ' || c == '\t'); +} + +char* skip_nonspaces(char *s) { + while (*s && !is_space_or_tab(*s)) + s++; + return s; +} + +static char* unmangle(char *s) { + char *ret, *ss, *sp; + + ss = skip_nonspaces(s); + ret = sp = malloc(ss-s+1); + /*FIXME: missing error checking*/ + while(s != ss) { + if (*s == '\\' && isoctal(s[1]) && isoctal(s[2]) && isoctal(s[3])) { + *sp++ = 64*(s[1] & 7) + 8*(s[2] & 7) + (s[3] & 7); + s += 4; + } else + *sp++ = *s++; + } + *sp = 0; + return ret; +} /* * See if device has been mounted by looking in mount table. If so, set @@ -876,8 +905,8 @@ if (((strcmp(s1, name) == 0) || (strcmp(s2, name) == 0)) || ((maj != -1) && (maj == mtabmaj) && (min == mtabmin))) { FCLOSE(fp); - *deviceName = strdup(s1); - *mountName = strdup(s2); + *deviceName = unmangle(strdup(s1)); + *mountName = unmangle(strdup(s2)); return 1; } } @@ -920,8 +949,8 @@ rc = sscanf(line, "%1023s %1023s", s1, s2); if (rc >= 2 && s1[0] != '#' && strcmp(s2, name) == 0) { FCLOSE(fp); - *deviceName = strdup(s1); - *mountName = strdup(s2); + *deviceName = unmangle(strdup(s1)); + *mountName = unmangle(strdup(s2)); return 1; } }