Changeset 2230 in MondoRescue for branches/2.2.9/mondo/src/common/libmondo-string.c
- Timestamp:
- Jun 17, 2009, 10:53:23 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.9/mondo/src/common/libmondo-string.c
r2211 r2230 841 841 int i = strlen(partition) - 1; 842 842 char *c; 843 char *trunc = NULL; 844 845 mr_asprintf(&trunc, "%s", partition); 843 846 844 847 #ifdef __FreeBSD__ 845 848 846 if (islower( partition[i])) // BSD subpartition849 if (islower(trunc[i])) // BSD subpartition 847 850 i--; 848 if ( partition[i -1] == 's') {849 while (isdigit( partition[i]))851 if (trunc[i-1] == 's') { 852 while (isdigit(trunc[i])) 850 853 i--; 851 854 i--; 852 855 } 853 partition[i +1] = '\0';856 trunc[i+1] = '\0'; 854 857 855 858 #else … … 857 860 assert_string_is_neither_NULL_nor_zerolength(partition); 858 861 /* first see if it's a devfs style device */ 859 c = strrchr( partition, '/');862 c = strrchr(trunc, '/'); 860 863 if (c && strncmp(c, "/part", 5) == 0) { 861 864 /* yup it's devfs, return the "disc" path */ 862 865 strcpy(c + 1, "disc"); 863 return partition;866 return trunc; 864 867 } 865 868 /* then see if it's a dm style device */ 866 869 if (c && strncmp(c, "/dm-", 4) == 0) { 867 870 /* yup it's dm, return the full path */ 868 return partition;869 } 870 871 872 for (i = strlen( partition); isdigit(partition[i -1]); i--)871 return trunc; 872 } 873 874 875 for (i = strlen(trunc); isdigit(trunc[i-1]); i--) 873 876 continue; 874 if ( partition[i - 1] == 'p' && isdigit(partition[i -2])) {877 if (trunc[i-1] == 'p' && isdigit(trunc[i-2])) { 875 878 i--; 876 879 } else { 877 880 /* Some full devices like this /dev/mapper/mpath0 878 881 /dev/cciss/c0d0 may be used as partition names */ 879 if ((strstr( partition,"/dev/mapper/mpath") != NULL) ||880 (strstr( partition,"/dev/cciss/c") != NULL) ||881 (strstr( partition,"/dev/rd/") != NULL)) {882 return partition;882 if ((strstr(trunc,"/dev/mapper/mpath") != NULL) || 883 (strstr(trunc,"/dev/cciss/c") != NULL) || 884 (strstr(trunc,"/dev/rd/") != NULL)) { 885 return trunc; 883 886 } 884 887 } 885 partition[i] = '\0';888 trunc[i] = '\0'; 886 889 887 890 #endif 888 891 889 return partition;892 return trunc; 890 893 } 891 894
Note:
See TracChangeset
for help on using the changeset viewer.