Module Name: src Committed By: ahoka Date: Sun Mar 20 06:10:27 UTC 2011
Modified Files: src/usr.sbin/flashctl: flashctl.c Log Message: Fix markbad command To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/flashctl/flashctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.sbin/flashctl/flashctl.c diff -u src/usr.sbin/flashctl/flashctl.c:1.1 src/usr.sbin/flashctl/flashctl.c:1.2 --- src/usr.sbin/flashctl/flashctl.c:1.1 Sat Feb 26 18:07:32 2011 +++ src/usr.sbin/flashctl/flashctl.c Sun Mar 20 06:10:27 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: flashctl.c,v 1.1 2011/02/26 18:07:32 ahoka Exp $ */ +/* $NetBSD: flashctl.c,v 1.2 2011/03/20 06:10:27 ahoka Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -57,8 +57,10 @@ setprogname(argv[0]); - if (argc < 3) + if (argc < 3) { usage(); + exit(1); + } device = argv[1]; command = argv[2]; @@ -66,8 +68,9 @@ argv += 3; fd = open(device, O_RDWR, 0); - if (fd == -1) + if (fd == -1) { err(EXIT_FAILURE, "can't open flash device"); + } if (!strcmp("erase", command)) { struct flash_info_params ip; @@ -176,14 +179,24 @@ addr += ip.ip_erase_size; } - if (hasbad) + if (hasbad) { printf("Done.\n"); - else + } else { printf("No bad blocks found.\n"); + } } else if (!strcmp("markbad", command)) { flash_addr_t address; + + /* TODO: maybe we should let the user specify + * multiple blocks? + */ + if (argc != 1) { + warnx("invalid number of arguments"); + error = 1; + goto out; + } - error = to_intmax(&n, argv[1]); + error = to_intmax(&n, argv[0]); if (error) { warnx(strerror(error)); goto out; @@ -244,6 +257,4 @@ getprogname()); fprintf(stderr, " %s device markbad <address>\n", getprogname()); - - exit(1); }