Index: libzyutil-1.0/flash.c =================================================================== --- libzyutil-1.0.orig/flash.c 2016-08-17 15:24:30.277089115 +0800 +++ libzyutil-1.0/flash.c 2016-08-18 10:35:48.189894481 +0800 @@ -115,6 +115,27 @@ return ret; } +unsigned int zyUtilMtdDevGetSize(char *devName) +{ + int devFd = -1; + struct mtd_info_user mtd; + + /* Open MTD device */ + if((devFd = zyUtilOpen(devName, O_SYNC | O_RDWR)) == -1) { + printf("Cannot open MTD device!\n"); + return ZCFG_INTERNAL_ERROR; + } + + /* get some info about the flash device */ + if(ioctl(devFd, MEMGETINFO, &mtd) < 0) { + printf("This doesn't seem to be a valid MTD flash device!\n"); + close(devFd); + return ZCFG_INTERNAL_ERROR; + } + close(devFd); + return mtd.size; +} + zcfgRet_t zyUtilWriteBufToFlash(char *devName, void *buf, uint32_t buf_size) { int devFd = -1, i = 0; Index: libzyutil-1.0/zyutil.h =================================================================== --- libzyutil-1.0.orig/zyutil.h 2016-08-17 15:24:30.457089115 +0800 +++ libzyutil-1.0/zyutil.h 2016-08-17 20:26:22.348742224 +0800 @@ -24,6 +24,7 @@ /*Flash*/ zcfgRet_t zyUtilMtdDevGetByName(char *mtdname, char *mtddev); +unsigned int zyUtilMtdDevGetSize(char *devName); zcfgRet_t zyUtilWriteBufToFlash(char *devName, void *buf, uint32_t buf_size); int zyUtilReadBufFromFlash(char *devName, void *buf, uint32_t buf_size); #if 1 //#ifdef ZYXEL_WWAN