Changeset 3859 in MondoRescue for branches/3.3/mondo/src/common
- Timestamp:
- Mar 7, 2024, 1:33:54 AM (4 months ago)
- Location:
- branches/3.3/mondo/src/common
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3/mondo/src/common/libmondo-devices.c
r3857 r3859 356 356 assert(partno >= 0 && partno < 999); 357 357 358 malloc_string(searchstr);359 360 358 #ifdef __FreeBSD__ 361 359 // We assume here that this is running from mondorestore. (It is.) 362 mr_asprintf(program, "ls %s %s >/dev/null 2>&1", drive, build_partition_name(tmp, drive, partno)); 360 tmp = build_partition_name(drive, partno); 361 mr_asprintf(program, "ls %s %s >/dev/null 2>&1", drive, tmp); 362 mr_free(tmp); 363 363 res = system(program); 364 364 mr_free(program); … … 376 376 mr_free(program); 377 377 378 (void) build_partition_name(searchstr,drive, partno);379 strcat(searchstr, " ");378 searchstr = build_partition_name(drive, partno); 379 mr_strcat(searchstr, " "); 380 380 for (res = 0, mr_getline(incoming, fin); !res && !feof(fin) ; mr_getline(incoming, fin)) { 381 381 if (strstr(incoming, searchstr)) { … … 384 384 mr_free(incoming); 385 385 } 386 mr_free(searchstr); 386 387 mr_free(incoming); 387 388 … … 389 390 log_OS_error("Cannot pclose fin"); 390 391 } 391 paranoid_free(searchstr);392 392 return (res); 393 393 } -
branches/3.3/mondo/src/common/libmondo-string-EXT.h
r3858 r3859 3 3 */ 4 4 5 extern char *build_partition_name(char *partition, const char *drive, 6 int partno); 5 extern char *build_partition_name(const char *drive, int partno); 7 6 extern char *commarize(char *); 8 7 extern char *disklist_entry_to_string(struct list_of_disks *disklist, -
branches/3.3/mondo/src/common/libmondo-string.c
r3858 r3859 35 35 * @param drive The drive basename of the partition name (e.g. /dev/hda) 36 36 * @param partno The partition number (e.g. 1) 37 * @param partition Where to put the partition name (e.g. /dev/hda1) 38 * @return @p partition. 37 * @return @p the partition name (e.g. /dev/hda1) 39 38 * @note If @p drive ends in a digit, then 'p' (on Linux) or 's' (on *BSD) is added before @p partno. 40 39 */ 41 char *build_partition_name(c har *partition, const char *drive, int partno)40 char *build_partition_name(const char *drive, int partno) 42 41 { 43 42 char *p, *c; 44 43 45 assert(partition != NULL);46 44 assert_string_is_neither_NULL_nor_zerolength(drive); 47 45 assert(partno >= 0); 48 46 49 p = strcpy(partition, drive); 47 mr_free(partition); 48 mr_asprintf(partition, "%s", drive); 49 p = partition; 50 50 /* is this a devfs device path? */ 51 51 c = strrchr(partition, '/'); … … 54 54 /* This strcpy is safe */ 55 55 strcpy(c + 1, "part"); 56 p = c + 5;57 56 } else { 58 57 p += strlen(p); 59 58 if (isdigit(p[-1])) { 60 *p++ =59 mr_strcat(partition, "%c", 61 60 #ifdef BSD 62 61 's'; … … 64 63 'p'; 65 64 #endif 65 ); 66 66 } 67 67 } 68 sprintf(p, "%d", partno);68 mr_strcat(partition, "%d", partno); 69 69 return(partition); 70 70 } -
branches/3.3/mondo/src/common/libmondo-string.h
r3858 r3859 3 3 */ 4 4 5 char *build_partition_name(char *partition, const char *drive, int partno);6 5 char *commarize(char *); 7 6 char *disklist_entry_to_string(struct list_of_disks *disklist, int lino);
Note:
See TracChangeset
for help on using the changeset viewer.