Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 151257 | Differences between
and this patch

Collapse All | Expand All

(-)../eject/eject.c (-4 / +33 lines)
Lines 843-848 Link Here
843
	return 0;
843
	return 0;
844
}
844
}
845
845
846
/* next three functions copied from mntent.c from util-linux*/
847
#define isoctal(a) (((a) & ~7) == '0')
848
849
static int is_space_or_tab (char c) {
850
  return (c == ' ' || c == '\t');
851
}
852
853
char* skip_nonspaces(char *s) {
854
  while (*s && !is_space_or_tab(*s))
855
    s++;
856
  return s;
857
}
858
859
static char* unmangle(char *s) {
860
  char *ret, *ss, *sp;
861
862
  ss = skip_nonspaces(s);
863
  ret = sp = malloc(ss-s+1);
864
  /*FIXME: missing error checking*/
865
  while(s != ss) {
866
    if (*s == '\\' && isoctal(s[1]) && isoctal(s[2]) && isoctal(s[3])) {
867
      *sp++ = 64*(s[1] & 7) + 8*(s[2] & 7) + (s[3] & 7);
868
      s += 4;
869
    } else
870
      *sp++ = *s++;
871
  }
872
  *sp = 0;
873
  return ret;
874
}
846
875
847
/*
876
/*
848
 * See if device has been mounted by looking in mount table.  If so, set
877
 * See if device has been mounted by looking in mount table.  If so, set
Lines 876-883 Link Here
876
			if (((strcmp(s1, name) == 0) || (strcmp(s2, name) == 0)) ||
905
			if (((strcmp(s1, name) == 0) || (strcmp(s2, name) == 0)) ||
877
				((maj != -1) && (maj == mtabmaj) && (min == mtabmin))) {
906
				((maj != -1) && (maj == mtabmaj) && (min == mtabmin))) {
878
				FCLOSE(fp);
907
				FCLOSE(fp);
879
				*deviceName = strdup(s1);
908
				*deviceName = unmangle(strdup(s1));
880
				*mountName = strdup(s2);
909
				*mountName = unmangle(strdup(s2));
881
				return 1;
910
				return 1;
882
			}
911
			}
883
		}
912
		}
Lines 920-927 Link Here
920
		rc = sscanf(line, "%1023s %1023s", s1, s2);
949
		rc = sscanf(line, "%1023s %1023s", s1, s2);
921
		if (rc >= 2 && s1[0] != '#' && strcmp(s2, name) == 0) {
950
		if (rc >= 2 && s1[0] != '#' && strcmp(s2, name) == 0) {
922
			FCLOSE(fp);
951
			FCLOSE(fp);
923
			*deviceName = strdup(s1);
952
			*deviceName = unmangle(strdup(s1));
924
			*mountName = strdup(s2);
953
			*mountName = unmangle(strdup(s2));
925
			return 1;
954
			return 1;
926
		}
955
		}
927
	}
956
	}

Return to bug 151257