mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-09-02 23:29:01 +00:00
corrected EOF hint calculation.
This commit is contained in:
parent
e42d572f81
commit
a06ad707ee
@ -882,13 +882,13 @@ cfs_close(int fd)
|
|||||||
|
|
||||||
if(FD_VALID(fd)) {
|
if(FD_VALID(fd)) {
|
||||||
read_header(&hdr, coffee_fd_set[fd].file_page);
|
read_header(&hdr, coffee_fd_set[fd].file_page);
|
||||||
current_page = coffee_fd_set[fd].end / COFFEE_PAGE_SIZE;
|
current_page = (coffee_fd_set[fd].end + sizeof(hdr)) / COFFEE_PAGE_SIZE;
|
||||||
part_size = hdr.max_pages / (sizeof(hdr.eof_hint) * CHAR_BIT);
|
part_size = hdr.max_pages / (sizeof(hdr.eof_hint) * CHAR_BIT);
|
||||||
if(part_size == 0) {
|
if(part_size == 0) {
|
||||||
part_size = 1;
|
part_size = 1;
|
||||||
}
|
}
|
||||||
for(i = eof_hint = 0; i < sizeof(eof_hint) * CHAR_BIT; i++) {
|
for(i = eof_hint = 0; i < sizeof(eof_hint) * CHAR_BIT; i++) {
|
||||||
eof_hint |= (current_page > (i + 1) * part_size) << i;
|
eof_hint |= (current_page >= (i + 1) * part_size) << i;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(eof_hint > hdr.eof_hint) {
|
if(eof_hint > hdr.eof_hint) {
|
||||||
@ -999,7 +999,7 @@ cfs_write(int fd, const void *buf, unsigned size)
|
|||||||
int i;
|
int i;
|
||||||
struct log_param lp;
|
struct log_param lp;
|
||||||
coffee_offset_t remains;
|
coffee_offset_t remains;
|
||||||
|
printf("write %d bytes to fd %d\n", size, fd);
|
||||||
if(!(FD_VALID(fd) && FD_WRITABLE(fd))) {
|
if(!(FD_VALID(fd) && FD_WRITABLE(fd))) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user