Changeset 15430
- Timestamp:
- 2009-04-27T03:38:15+02:00 (9 years ago)
- Location:
- trunk/package/unvram
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/package/unvram/Makefile
r15429 r15430 9 9 10 10 PKG_NAME:=unvram 11 PKG_RELEASE:= 211 PKG_RELEASE:=3 12 12 13 13 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) -
trunk/package/unvram/src/nvram.c
r15429 r15430 339 339 { 340 340 int fd; 341 char *mtd = NULL; 341 342 nvram_handle_t *h; 342 343 nvram_header_t *header; … … 346 347 { 347 348 /* Finding the mtd will set the appropriate erase size */ 348 if( file == NULL ) 349 file = nvram_find_mtd(); 350 else 351 (void) nvram_find_mtd(); 352 353 if( nvram_erase_size == 0 ) 349 if( (mtd = nvram_find_mtd()) == NULL || nvram_erase_size == 0 ) 350 { 351 free(mtd); 354 352 return NULL; 355 } 356 357 if( (fd = open(file, O_RDWR)) > -1 ) 353 } 354 } 355 356 if( (fd = open(file ? file : mtd, O_RDWR)) > -1 ) 358 357 { 359 358 char *mmap_area = (char *) mmap( … … 378 377 { 379 378 _nvram_rehash(h); 379 free(mtd); 380 380 return h; 381 381 } … … 389 389 } 390 390 391 free(mtd); 391 392 return NULL; 392 393 } … … 404 405 405 406 /* Determine NVRAM device node. */ 406 c onst char * nvram_find_mtd(void)407 char * nvram_find_mtd(void) 407 408 { 408 409 FILE *fp; … … 412 413 struct stat s; 413 414 414 // "/dev/mtdblock/" + ( 0 < x < 99 ) + \0 = 19 415 if( (path = (char *) malloc(19)) == NULL ) 416 return NULL; 417 418 if ((fp = fopen("/proc/mtd", "r"))) { 419 while (fgets(dev, sizeof(dev), fp)) { 420 if (strstr(dev, "nvram") && sscanf(dev, "mtd%d: %08x", &i, &esz)) 415 if( (fp = fopen("/proc/mtd", "r")) ) 416 { 417 while( fgets(dev, sizeof(dev), fp) ) 418 { 419 if( strstr(dev, "nvram") && sscanf(dev, "mtd%d: %08x", &i, &esz) ) 421 420 { 422 421 nvram_erase_size = esz; … … 452 451 453 452 /* Check NVRAM staging file. */ 454 c onst char * nvram_find_staging(void)453 char * nvram_find_staging(void) 455 454 { 456 455 struct stat s; … … 468 467 { 469 468 int fdmtd, fdstg, stat; 470 c onst char *mtd = nvram_find_mtd();469 char *mtd = nvram_find_mtd(); 471 470 char buf[nvram_erase_size]; 472 471 … … 493 492 } 494 493 494 free(mtd); 495 495 return stat; 496 496 } … … 500 500 { 501 501 int fdmtd, fdstg, stat; 502 c onst char *mtd = nvram_find_mtd();502 char *mtd = nvram_find_mtd(); 503 503 char buf[nvram_erase_size]; 504 504 … … 527 527 } 528 528 529 free(mtd); 529 530 return stat; 530 531 } -
trunk/package/unvram/src/nvram.h
r15429 r15430 91 91 92 92 /* Determine NVRAM device node. */ 93 c onst char * nvram_find_mtd(void);93 char * nvram_find_mtd(void); 94 94 95 95 /* Copy NVRAM contents to staging file. */ … … 100 100 101 101 /* Check NVRAM staging file. */ 102 c onst char * nvram_find_staging(void);102 char * nvram_find_staging(void); 103 103 104 104
Note: See TracChangeset
for help on using the changeset viewer.