| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | 2 * Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 #include <errno.h> | 6 #include <errno.h> |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 #include <inttypes.h> | 8 #include <inttypes.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <stdio.h> | 10 #include <stdio.h> |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 char* s; | 50 char* s; |
| 51 for (s=buf;* s; s++) | 51 for (s=buf;* s; s++) |
| 52 if (*s == ' ') | 52 if (*s == ' ') |
| 53 *s = '_'; | 53 *s = '_'; |
| 54 FILE* fp = fopen(buf,"wb"); | 54 FILE* fp = fopen(buf,"wb"); |
| 55 if (!fp) { | 55 if (!fp) { |
| 56 fprintf(stderr, "%s: can't open %s: %s\n", | 56 fprintf(stderr, "%s: can't open %s: %s\n", |
| 57 progname, buf, strerror(errno)); | 57 progname, buf, strerror(errno)); |
| 58 retval = 1; | 58 retval = 1; |
| 59 } else { | 59 } else { |
| 60 if (1 != fwrite(base_of_rom + ah->area_offset, ah->area_size, 1, fp)) { | 60 if (ah->area_size && |
| 61 1 != fwrite(base_of_rom + ah->area_offset, ah->area_size, 1, fp)) { |
| 61 fprintf(stderr, "%s: can't write %s: %s\n", | 62 fprintf(stderr, "%s: can't write %s: %s\n", |
| 62 progname, buf, strerror(errno)); | 63 progname, buf, strerror(errno)); |
| 63 retval = 1; | 64 retval = 1; |
| 64 } else { | 65 } else { |
| 65 printf("saved as \"%s\"\n", buf); | 66 printf("saved as \"%s\"\n", buf); |
| 66 } | 67 } |
| 67 fclose(fp); | 68 fclose(fp); |
| 68 } | 69 } |
| 69 } | 70 } |
| 70 | 71 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 if (0 != munmap(base_of_rom, sb.st_size)) { | 160 if (0 != munmap(base_of_rom, sb.st_size)) { |
| 160 fprintf(stderr, "%s: can't munmap %s: %s\n", | 161 fprintf(stderr, "%s: can't munmap %s: %s\n", |
| 161 progname, | 162 progname, |
| 162 argv[optind], | 163 argv[optind], |
| 163 strerror(errno)); | 164 strerror(errno)); |
| 164 return 1; | 165 return 1; |
| 165 } | 166 } |
| 166 | 167 |
| 167 return retval; | 168 return retval; |
| 168 } | 169 } |
| OLD | NEW |