version 1.1.2.5, 2014/01/28 22:37:07
|
version 1.1.2.6, 2014/01/28 22:50:37
|
Line 8 env_t *env;
|
Line 8 env_t *env;
|
static int |
static int |
ub_flash_io(const char *csSec, int mode) |
ub_flash_io(const char *csSec, int mode) |
{ |
{ |
int f, ret = 0; | int f, rlen, ret = 0; |
const char *str; |
const char *str; |
|
size_t siz; |
|
|
FTRACE(4); |
FTRACE(4); |
|
|
|
str = cfg_getAttribute(&cfg, csSec, "size"); |
|
siz = strtol(str, NULL, 0); |
|
if (!siz) |
|
return -1; |
str = cfg_getAttribute(&cfg, csSec, "drive"); |
str = cfg_getAttribute(&cfg, csSec, "drive"); |
if (!str) { |
if (!str) { |
printf("Error:: drive not found!\n"); |
printf("Error:: drive not found!\n"); |
Line 26 ub_flash_io(const char *csSec, int mode)
|
Line 31 ub_flash_io(const char *csSec, int mode)
|
} |
} |
|
|
if (mode & O_RDWR) { |
if (mode & O_RDWR) { |
} else { | rlen = write(f, env, siz); |
| if (rlen != siz) |
| printf("Error:: written %d bytes != %d\n", rlen, siz); |
| else |
| VERB(3) printf("Written %d bytes\n", rlen); |
| lseek(f, 0, SEEK_SET); |
} |
} |
|
|
|
rlen = read(f, env, siz); |
|
if (rlen != siz) |
|
printf("Error:: readed %d bytes != %d\n", rlen, siz); |
|
else |
|
VERB(3) printf("Readed %d bytes\n", rlen); |
|
|
close(f); |
close(f); |
return ret; |
return ret; |