Kaynağa Gözat

[image] Modify imgfree command to accept an argument

This resolves potential difficulties occurring when more than one script
is used. Total cost: 88 bytes uncompressed.

Signed-off-by: Michael Brown <mcb30@etherboot.org>
tags/v0.9.8
Joshua Oreman 15 yıl önce
ebeveyn
işleme
f8448735b0
1 değiştirilmiş dosya ile 18 ekleme ve 5 silme
  1. 18
    5
      src/hci/commands/image_cmd.c

+ 18
- 5
src/hci/commands/image_cmd.c Dosyayı Görüntüle

@@ -499,9 +499,9 @@ static int imgstat_exec ( int argc, char **argv ) {
499 499
  */
500 500
 static void imgfree_syntax ( char **argv ) {
501 501
 	printf ( "Usage:\n"
502
-		 "  %s\n"
502
+		 "  %s [<image name>]\n"
503 503
 		 "\n"
504
-		 "Free all executable/loadable images\n",
504
+		 "Free one or all executable/loadable images\n",
505 505
 		 argv[0] );
506 506
 }
507 507
 
@@ -519,6 +519,7 @@ static int imgfree_exec ( int argc, char **argv ) {
519 519
 	};
520 520
 	struct image *image;
521 521
 	struct image *tmp;
522
+	const char *name = NULL;
522 523
 	int c;
523 524
 
524 525
 	/* Parse options */
@@ -533,15 +534,27 @@ static int imgfree_exec ( int argc, char **argv ) {
533 534
 		}
534 535
 	}
535 536
 
536
-	/* No arguments */
537
+	/* Need no more than one image name */
538
+	if ( optind != argc )
539
+		name = argv[optind++];
537 540
 	if ( optind != argc ) {
538 541
 		imgfree_syntax ( argv );
539 542
 		return 1;
540 543
 	}
541 544
 
542
-	/* Free all images */
543
-	list_for_each_entry_safe ( image, tmp, &images, list ) {
545
+	if ( name ) {
546
+		/* Free specified image (may leak) */
547
+		image = find_image ( name );
548
+		if ( ! image ) {
549
+			printf ( "No such image: %s\n", name );
550
+			return 1;
551
+		}
544 552
 		imgfree ( image );
553
+	} else {
554
+		/* Free all images */
555
+		list_for_each_entry_safe ( image, tmp, &images, list ) {
556
+			imgfree ( image );
557
+		}
545 558
 	}
546 559
 	return 0;
547 560
 }

Loading…
İptal
Kaydet