reduced rom size by ~40 bytes

This commit is contained in:
nvt-se 2008-11-04 16:58:52 +00:00
parent a6a17bc52c
commit becfecfe1b

View file

@ -714,10 +714,10 @@ write_log_page(struct file_desc *fdp, struct log_param *lp)
READ_HEADER(&hdr, fdp->file_page); READ_HEADER(&hdr, fdp->file_page);
log_entry_size = hdr.log_entry_size == 0 ?
COFFEE_PAGE_SIZE : hdr.log_entry_size;
log_entries = hdr.log_entries == 0 ? log_entries = hdr.log_entries == 0 ?
COFFEE_LOG_SIZE / COFFEE_PAGE_SIZE : hdr.log_entries; COFFEE_LOG_SIZE / COFFEE_PAGE_SIZE : hdr.log_entries;
log_entry_size = hdr.log_entry_size == 0 ?
COFFEE_PAGE_SIZE : hdr.log_entry_size;
page = lp->offset / log_entry_size; page = lp->offset / log_entry_size;
lp->offset %= log_entry_size; lp->offset %= log_entry_size;
@ -823,12 +823,14 @@ cfs_open(const char *name, int flags)
int fd; int fd;
int page; int page;
struct file_header hdr; struct file_header hdr;
struct file_desc *fdp;
fd = get_available_fd(); fd = get_available_fd();
if(fd < 0) { if(fd < 0) {
PRINTF("Coffee: Failed to allocate a new file descriptor!\n"); PRINTF("Coffee: Failed to allocate a new file descriptor!\n");
return -1; return -1;
} }
fdp = &coffee_fd_set[fd];
page = find_file(name); page = find_file(name);
if(page < 0) { if(page < 0) {
@ -838,21 +840,21 @@ cfs_open(const char *name, int flags)
if((page = reserve(name, COFFEE_DYN_SIZE, 1)) < 0) { if((page = reserve(name, COFFEE_DYN_SIZE, 1)) < 0) {
return -1; return -1;
} }
coffee_fd_set[fd].max_pages = (COFFEE_DYN_SIZE + sizeof(hdr) + fdp->max_pages = (COFFEE_DYN_SIZE + sizeof(hdr) +
COFFEE_PAGE_SIZE - 1) / COFFEE_PAGE_SIZE; COFFEE_PAGE_SIZE - 1) / COFFEE_PAGE_SIZE;
} else { } else {
READ_HEADER(&hdr, page); READ_HEADER(&hdr, page);
if(COFFEE_PAGE_MODIFIED(hdr)) { if(COFFEE_PAGE_MODIFIED(hdr)) {
coffee_fd_set[fd].flags = COFFEE_FD_MODIFIED; fdp->flags = COFFEE_FD_MODIFIED;
} else } else
coffee_fd_set[fd].max_pages = hdr.max_pages; fdp->max_pages = hdr.max_pages;
} }
coffee_fd_set[fd].file_page = page; fdp->file_page = page;
coffee_fd_set[fd].flags |= flags; fdp->flags |= flags;
coffee_fd_set[fd].end = find_offset_in_file(page); fdp->end = find_offset_in_file(page);
coffee_fd_set[fd].offset = flags & CFS_APPEND ? coffee_fd_set[fd].end : 0; fdp->offset = flags & CFS_APPEND ? fdp->end : 0;
coffee_fd_set[fd].next_log_entry = 0; fdp->next_log_entry = 0;
return fd; return fd;
} }