Changeset 2211 in MondoRescue for branches/2.2.9/mondo/src/common/libmondo-devices.c
- Timestamp:
- Jun 3, 2009, 7:10:19 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.9/mondo/src/common/libmondo-devices.c
r2205 r2211 9 9 10 10 #include "my-stuff.h" 11 #include "mr_mem.h" 11 12 #include "mondostructures.h" 12 13 #include "libmondo-files-EXT.h" … … 327 328 char *program; 328 329 char *incoming; 329 char *searchstr ;330 char *searchstr = NULL; 330 331 char *tmp; 331 332 … … 1040 1041 bool is_this_a_valid_disk_format(char *format) 1041 1042 { 1042 char *good_formats ;1043 char *good_formats = NULL; 1043 1044 char *command; 1044 1045 char *format_sz; … … 1288 1289 { 1289 1290 /*@ buffer ****************************************************** */ 1290 char *command; 1291 char *dev; 1292 char *options; 1291 char *command = NULL; 1293 1292 int retval; 1294 1293 1295 malloc_string(command);1296 malloc_string(dev);1297 malloc_string(options);1298 1294 assert_string_is_neither_NULL_nor_zerolength(device); 1299 1295 assert_string_is_neither_NULL_nor_zerolength(mountpoint); 1300 1296 1301 1297 make_hole_for_dir(mountpoint); 1302 strcpy(options, "ro"); 1298 1299 #ifndef __FreeBSD__ 1300 char *dev = NULL; 1301 char *options = NULL; 1302 mr_asprintf(&options, "ro"); 1303 #endif 1304 1303 1305 if (isdigit(device[0])) { 1304 1306 find_cdrom_device(device, FALSE); 1305 } else {1306 strcpy(dev, device);1307 1307 } 1308 1308 if (g_ISO_restore_mode) { 1309 1309 1310 1310 #ifdef __FreeBSD__ 1311 strcpy(dev, make_vn(device));1311 mr_asprintf(&dev, make_vn(device)); 1312 1312 if (!dev) { 1313 sprintf(command, "Unable to mount ISO (make_vn(%s) failed)", 1314 device); 1313 mr_asprintf(&command, "Unable to mount ISO (make_vn(%s) failed)", device); 1315 1314 fatal_error(command); 1316 1315 } 1317 1316 strcpy(device, dev); 1317 paranoid_free(dev); 1318 1318 #else 1319 strcat(options, ",loop");1319 mr_strcat(options, ",loop"); 1320 1320 #endif 1321 1321 … … 1326 1326 1327 1327 #ifdef __FreeBSD__ 1328 sprintf(command, "mount_cd9660 -r %s %s 2>> %s",1328 mr_asprintf(&command, "mount_cd9660 -r %s %s 2>> %s", 1329 1329 device, mountpoint, MONDO_LOGFILE); 1330 1330 1331 1331 #else 1332 sprintf(command, "mount %s -o %s -t iso9660 %s 2>> %s",1332 mr_asprintf(&command, "mount %s -o %s -t iso9660 %s 2>> %s", 1333 1333 device, options, mountpoint, MONDO_LOGFILE); 1334 paranoid_free(options); 1334 1335 #endif 1335 1336 … … 1340 1341 retval = system(command); 1341 1342 log_msg(1, "system(%s) returned %d", command, retval); 1342 1343 1343 paranoid_free(command); 1344 paranoid_free(dev); 1345 paranoid_free(options); 1344 1346 1345 return (retval); 1347 1346 } … … 2183 2182 void sensibly_set_tmpdir_and_scratchdir() 2184 2183 { 2185 char *tmp , *command, *sz;2186 2187 malloc_string(tmp); 2184 char *tmp = NULL; 2185 char *command, *sz; 2186 2188 2187 malloc_string(command); 2189 2188 malloc_string(sz); … … 2191 2190 2192 2191 #ifdef __FreeBSD__ 2193 strcpy(tmp,2192 mr_asprintf(&tmp, 2194 2193 call_program_and_get_last_line_of_output 2195 2194 ("LANGUAGE=C df -m -P -t nonfs,msdosfs,ntfs,ntfs-3g,smbfs,smb,cifs,afs,gfs,ocfs,ocfs2,mvfs,nsspool,nssvol | tr -s '\t' ' ' | grep -vE \"none|Filesystem\" | awk '{printf \"%s %s\\n\", $4, $6;}' | sort -n | tail -n1 | awk '{print $NF;}'")); 2196 2195 #else 2197 strcpy(tmp,2196 mr_asprintf(&tmp, 2198 2197 call_program_and_get_last_line_of_output 2199 2198 ("LANGUAGE=C df -m -P -x nfs -x nfs4 -x vfat -x ntfs -x ntfs-3g -x smbfs -x smb -x cifs -x afs -x gfs -x ocfs -x ocfs2 -x mvfs -x nsspool -x nssvol -x iso9660| sed 's/ /devdev/' | tr -s '\t' ' ' | grep -vE \"none|Filesystem|/dev/shm\" | awk '{printf \"%s %s\\n\", $4, $6;}' | sort -n | tail -n1 | awk '{print $NF;}'")); … … 2202 2201 if (tmp[0] != '/') { 2203 2202 strcpy(sz, tmp); 2204 strcpy(tmp, "/");2205 strcat(tmp, sz);2203 paranoid_free(tmp); 2204 mr_asprintf(&tmp, "/%s", sz); 2206 2205 } 2207 2206 if (!tmp[0]) { … … 2216 2215 2217 2216 sprintf(command, "rm -Rf %s/tmp.mondo.* %s/mondo.scratch.*", tmp, tmp); 2217 paranoid_free(tmp); 2218 2218 2219 paranoid_system(command); 2219 paranoid_free(tmp);2220 2220 paranoid_free(command); 2221 2221 paranoid_free(sz); … … 2282 2282 { 2283 2283 int cd_number = -1; 2284 char *mountdev; 2285 char *tmp; 2286 2287 malloc_string(mountdev); 2288 malloc_string(tmp); 2284 char *mountdev = NULL; 2285 char *tmp = NULL; 2286 2289 2287 assert(bkpinfo != NULL); 2290 2288 // log_it("Asking what_number_cd_is_this"); 2291 2289 if (g_ISO_restore_mode) { 2292 sprintf(tmp, "mount | grep iso9660 | awk '{print $3;}'"); 2293 // log_it("tmp = %s", tmp); 2294 2295 strcpy(mountdev, call_program_and_get_last_line_of_output(tmp)); 2296 strcat(mountdev, "/archives/THIS-CD-NUMBER"); 2297 // log_it("mountdev = %s", mountdev); 2290 mr_asprintf(&tmp, "mount | grep iso9660 | awk '{print $3;}'"); 2291 2292 mr_asprintf(&mountdev, "%s%s", call_program_and_get_last_line_of_output(tmp), "/archives/THIS-CD-NUMBER"); 2298 2293 cd_number = atoi(last_line_of_file(mountdev)); 2299 // log_it("cd_number = %d", cd_number);2300 2294 paranoid_free(mountdev); 2301 2295 paranoid_free(tmp); 2296 2302 2297 return (cd_number); 2303 2298 } 2304 2299 2305 strcpy(mountdev, bkpinfo->media_device);2300 mr_asprintf(&mountdev, bkpinfo->media_device); 2306 2301 if (!mountdev[0]) { 2307 2302 log_it … … 2316 2311 } 2317 2312 } 2318 cd_number =2319 atoi(last_line_of_file(MNT_CDROM "/archives/THIS-CD-NUMBER"));2320 // log_it("cd_number..later.. = %d", cd_number);2321 2313 paranoid_free(mountdev); 2322 paranoid_free(tmp); 2314 2315 cd_number = atoi(last_line_of_file(MNT_CDROM "/archives/THIS-CD-NUMBER")); 2323 2316 return (cd_number); 2324 2317 }
Note:
See TracChangeset
for help on using the changeset viewer.