+ return 1;
+}
+
+int
+image_check(int imagefd, const char *mtd)
+{
+ int fd, systype;
+ size_t count;
+ char *c;
+ FILE *f;
+
+ systype = SYSTYPE_UNKNOWN;
+ f = fopen("/proc/cpuinfo", "r");
+ while (!feof(f) && (fgets(buf, BUFSIZE - 1, f) != NULL)) {
+ if ((strncmp(buf, "system type", 11) == 0) && (c = strchr(buf, ':'))) {
+ c += 2;
+ if (strncmp(c, "Broadcom BCM947XX", 17) == 0)
+ systype = SYSTYPE_BROADCOM;
+ }
+ }
+ fclose(f);
+
+ switch(systype) {
+ case SYSTYPE_BROADCOM:
+ return image_check_bcom(imagefd, mtd);
+ default:
+ return 1;
+ }
+}
+
+int mtd_check(char *mtd)
+{
+ struct mtd_info_user mtdInfo;
+ int fd;
+
+ fd = mtd_open(mtd, O_RDWR | O_SYNC);
+ if(fd < 0) {
+ fprintf(stderr, "Could not open mtd device: %s\n", mtd);
+ return 0;
+ }
+
+ if(ioctl(fd, MEMGETINFO, &mtdInfo)) {
+ fprintf(stderr, "Could not get MTD device info from %s\n", mtd);
+ close(fd);
+ return 0;
+ }