Changeset 2a24c7cd in freewrt for package/mtd


Ignore:
Timestamp:
Apr 22, 2007, 3:25:18 PM (19 years ago)
Author:
Waldemar Brodkorb <wbx@…>
Branches:
freewrt_1_0, freewrt_2_0
Children:
bc551bda
Parents:
69447cd
Message:

sync with trunk

git-svn-id: svn://www.freewrt.org/branches/freewrt_1_0@2411 afb5a338-a214-0410-bd46-81f09a774fd1

Location:
package/mtd
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • package/mtd/Makefile

    r69447cd r2a24c7cd  
    99PKG_NAME:=              mtd
    1010PKG_VERSION:=           1.0
    11 PKG_RELEASE:=           6
    12 
     11PKG_RELEASE:=           7
    1312WRKSRC=                 ${WRKDIR}/$(PKG_NAME)
    1413DISTFILES:=
  • package/mtd/mtd.c

    r69447cd r2a24c7cd  
    4040#include <errno.h>
    4141#include <error.h>
     42#include <err.h>
    4243#include <time.h>
    4344#include <string.h>
     
    7374void usage(void) __attribute__((noreturn));
    7475
    75 char buf[BUFSIZE];
     76typedef char char_aligned_32bit __attribute__((aligned (4), may_alias));
     77
     78char_aligned_32bit buf[BUFSIZE];
    7679int buflen;
    7780
     
    99102                        break;
    100103                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                        }
    103128                        buflen = read(imagefd, buf, sizeof(struct trx_header));
    104129                        break;
     
    144169        systype = SYSTYPE_UNKNOWN;
    145170        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, ':'))) {
    148174                        c += 2;
    149175                        if (strncmp(c, "Broadcom BCM947XX", 17) == 0)
     
    366392{
    367393        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;
    369396        enum {
    370397                CMD_ERASE,
Note: See TracChangeset for help on using the changeset viewer.