Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 166825
Collapse All | Expand All

(-)eject.c (+28 lines)
Lines 379-384 static int FileExists(const char *name, Link Here
379
379
380
380
381
/*
381
/*
382
 * Linux mangles spaces in mount points by changing them to an octal string
383
 * of '\040'.  So lets scan the mount point and fix it up by replacing all
384
 * occurrences off '\0##' with the ASCII value of 0##.  Requires a writable
385
 * string as input as we mangle in place.  Some of this was taken from the
386
 * util-linux package.
387
 */
388
#define octalify(a) ((a) & 7)
389
#define tooctal(s) (64*octalify(s[1]) + 8*octalify(s[2]) + octalify(s[3]))
390
#define isoctal(a) (((a) & ~7) == '0')
391
static char *DeMangleMount(char *s)
392
{
393
	char *tmp = s;
394
	while ((tmp = strchr(tmp, '\\')) != NULL) {
395
		if (tmp[1] == '0' && isoctal(tmp[2]) && isoctal(tmp[3])) {
396
			tmp[0] = tooctal(tmp);
397
			memmove(tmp+1, tmp+4, strlen(tmp)-3);
398
		}
399
		++tmp;
400
	}
401
	return s;
402
}
403
404
405
/*
382
 * Given name, such as foo, see if any of the following exist:
406
 * Given name, such as foo, see if any of the following exist:
383
 *
407
 *
384
 * foo (if foo starts with '.' or '/')
408
 * foo (if foo starts with '.' or '/')
Lines 890-895 static int MountedDevice(const char *nam Link Here
890
		if (rc >= 2) {
914
		if (rc >= 2) {
891
			int mtabmaj, mtabmin;
915
			int mtabmaj, mtabmin;
892
			GetMajorMinor(s1, &mtabmaj, &mtabmin);
916
			GetMajorMinor(s1, &mtabmaj, &mtabmin);
917
			DeMangleMount(s1);
918
			DeMangleMount(s2);
893
			if (((strcmp(s1, name) == 0) || (strcmp(s2, name) == 0)) ||
919
			if (((strcmp(s1, name) == 0) || (strcmp(s2, name) == 0)) ||
894
				((maj != -1) && (maj == mtabmaj) && (min == mtabmin))) {
920
				((maj != -1) && (maj == mtabmaj) && (min == mtabmin))) {
895
				FCLOSE(fp);
921
				FCLOSE(fp);
Lines 935-940 static int MountableDevice(const char *n Link Here
935
961
936
	while (fgets(line, sizeof(line), fp) != 0) {
962
	while (fgets(line, sizeof(line), fp) != 0) {
937
		rc = sscanf(line, "%1023s %1023s", s1, s2);
963
		rc = sscanf(line, "%1023s %1023s", s1, s2);
964
		DeMangleMount(s1);
965
		DeMangleMount(s2);
938
		if (rc >= 2 && s1[0] != '#' && strcmp(s2, name) == 0) {
966
		if (rc >= 2 && s1[0] != '#' && strcmp(s2, name) == 0) {
939
			FCLOSE(fp);
967
			FCLOSE(fp);
940
			*deviceName = strdup(s1);
968
			*deviceName = strdup(s1);

Return to bug 166825