Changeset 2316 in MondoRescue for branches/2.2.10/mondo/src/common/libmondo-string.c
- Timestamp:
- Aug 18, 2009, 2:34:29 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/common/libmondo-string.c
r2315 r2316 34 34 * @param drive The drive basename of the partition name (e.g. /dev/hda) 35 35 * @param partno The partition number (e.g. 1) 36 * @param partition Where to put the partition name (e.g. /dev/hda1)37 36 * @return @p partition. 38 37 * @note If @p drive ends in a digit, then 'p' (on Linux) or 's' (on *BSD) is added before @p partno. 39 38 */ 40 char *build_partition_name(c har *partition, const char *drive, int partno)41 { 42 char * p, *c;43 44 assert(partition != NULL); 39 char *build_partition_name(const char *drive, int partno) 40 { 41 char *c = NULL; 42 char *partition = NULL; 43 45 44 assert_string_is_neither_NULL_nor_zerolength(drive); 46 45 assert(partno >= 0); 47 46 48 p = strcpy(partition, drive);47 mr_asprintf(&partition, drive); 49 48 /* is this a devfs device path? */ 50 49 c = strrchr(partition, '/'); 51 50 if (c && strncmp(c, "/disc", 5) == 0) { 52 51 /* yup it's devfs, return the "part" path */ 52 /* This strcpy is safe */ 53 53 strcpy(c + 1, "part"); 54 p = c + 5;55 54 } else { 56 p += strlen(p); 57 if (isdigit(p[-1])) { 58 *p++ = 55 if (isdigit(partition[-1])) { 56 mr_strcat(partition, 59 57 #ifdef BSD 60 's' ;58 's'); 61 59 #else 62 'p' ;60 'p'); 63 61 #endif 64 62 } 65 63 } 66 sprintf(p, "%d", partno); 67 return (partition); 68 } 69 70 71 72 73 74 75 76 77 78 79 64 mr_strcat(partition, "%d", partno); 65 return(partition); 66 } 80 67 81 68
Note:
See TracChangeset
for help on using the changeset viewer.