Changeset 2a24c7cd in freewrt for package/mtd
- Timestamp:
- Apr 22, 2007, 3:25:18 PM (19 years ago)
- Branches:
- freewrt_1_0, freewrt_2_0
- Children:
- bc551bda
- Parents:
- 69447cd
- Location:
- package/mtd
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
package/mtd/Makefile
r69447cd r2a24c7cd 9 9 PKG_NAME:= mtd 10 10 PKG_VERSION:= 1.0 11 PKG_RELEASE:= 6 12 11 PKG_RELEASE:= 7 13 12 WRKSRC= ${WRKDIR}/$(PKG_NAME) 14 13 DISTFILES:= -
package/mtd/mtd.c
r69447cd r2a24c7cd 40 40 #include <errno.h> 41 41 #include <error.h> 42 #include <err.h> 42 43 #include <time.h> 43 44 #include <string.h> … … 73 74 void usage(void) __attribute__((noreturn)); 74 75 75 char buf[BUFSIZE]; 76 typedef char char_aligned_32bit __attribute__((aligned (4), may_alias)); 77 78 char_aligned_32bit buf[BUFSIZE]; 76 79 int buflen; 77 80 … … 99 102 break; 100 103 case 0x464c457f: /* ELF Netgear WGT634u */ 101 fprintf(stderr, "found elf header\n"); 102 lseek(imagefd,128*1024,SEEK_SET); 104 fprintf(stderr, "found ELF header\n"); 105 if (lseek(imagefd, 128*1024, SEEK_SET) == -1) { 106 if (errno != ESPIPE) 107 err(1, "lseek"); 108 /* 109 * the lseek failed because stdin is a pipe, 110 * so fake it; we know we've already read 111 * 32 bytes in the above call, so just read 112 * in (128 * 1024 - 32) bytes now, modulo 113 * sizeof (buf). why is this 128 KiB btw, 114 * wouldn't it be better to parse the ELF 115 * header? 116 */ 117 buflen = 128 * 1024 - 32; 118 while (buflen) { 119 ssize_t n; 120 121 n = read(imagefd, buf, 122 MIN((size_t)buflen, sizeof (buf))); 123 if (n < 0) 124 err(1, "read"); 125 buflen -= n; 126 } 127 } 103 128 buflen = read(imagefd, buf, sizeof(struct trx_header)); 104 129 break; … … 144 169 systype = SYSTYPE_UNKNOWN; 145 170 f = fopen("/proc/cpuinfo", "r"); 146 while (!feof(f) && (fgets(buf, BUFSIZE - 1, f) != NULL)) { 147 if ((strncmp(buf, "system type", 11) == 0) && (c = strchr(buf, ':'))) { 171 while (!feof(f) && (fgets((char *)buf, BUFSIZE - 1, f) != NULL)) { 172 if ((memcmp(buf, "system type", 11) == 0) && 173 (c = strchr((char *)buf, ':'))) { 148 174 c += 2; 149 175 if (strncmp(c, "Broadcom BCM947XX", 17) == 0) … … 366 392 { 367 393 int ch, i, boot, imagefd = -1, force, quiet, unlocked; 368 char *erase[MAX_ARGS], *device, *imagefile = NULL; 394 char *erase[MAX_ARGS], *device; 395 const char *imagefile = NULL; 369 396 enum { 370 397 CMD_ERASE,
Note:
See TracChangeset
for help on using the changeset viewer.
