diff options
-rw-r--r-- | apps/tagcache.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/apps/tagcache.c b/apps/tagcache.c index 2c46860c95..01dc09fdc8 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c | |||
@@ -215,6 +215,7 @@ static int open_tag_fd(struct tagcache_header *hdr, int tag, bool write) | |||
215 | { | 215 | { |
216 | int fd; | 216 | int fd; |
217 | char buf[MAX_PATH]; | 217 | char buf[MAX_PATH]; |
218 | int rc; | ||
218 | 219 | ||
219 | if (tagcache_is_numeric_tag(tag) || tag < 0 || tag >= TAG_COUNT) | 220 | if (tagcache_is_numeric_tag(tag) || tag < 0 || tag >= TAG_COUNT) |
220 | return -1; | 221 | return -1; |
@@ -230,8 +231,8 @@ static int open_tag_fd(struct tagcache_header *hdr, int tag, bool write) | |||
230 | } | 231 | } |
231 | 232 | ||
232 | /* Check the header. */ | 233 | /* Check the header. */ |
233 | read(fd, hdr, sizeof(struct tagcache_header)); | 234 | rc = read(fd, hdr, sizeof(struct tagcache_header)); |
234 | if (hdr->magic != TAGCACHE_MAGIC) | 235 | if (hdr->magic != TAGCACHE_MAGIC || rc != sizeof(struct tagcache_header)) |
235 | { | 236 | { |
236 | logf("header error"); | 237 | logf("header error"); |
237 | stat.ready = false; | 238 | stat.ready = false; |
@@ -700,6 +701,7 @@ static void remove_files(void) | |||
700 | char buf[MAX_PATH]; | 701 | char buf[MAX_PATH]; |
701 | 702 | ||
702 | stat.ready = false; | 703 | stat.ready = false; |
704 | stat.ramcache = false; | ||
703 | remove(TAGCACHE_FILE_MASTER); | 705 | remove(TAGCACHE_FILE_MASTER); |
704 | for (i = 0; i < TAG_COUNT; i++) | 706 | for (i = 0; i < TAG_COUNT; i++) |
705 | { | 707 | { |
@@ -715,6 +717,7 @@ static void remove_files(void) | |||
715 | static int open_master_fd(struct master_header *hdr, bool write) | 717 | static int open_master_fd(struct master_header *hdr, bool write) |
716 | { | 718 | { |
717 | int fd; | 719 | int fd; |
720 | int rc; | ||
718 | 721 | ||
719 | fd = open(TAGCACHE_FILE_MASTER, write ? O_RDWR : O_RDONLY); | 722 | fd = open(TAGCACHE_FILE_MASTER, write ? O_RDWR : O_RDONLY); |
720 | if (fd < 0) | 723 | if (fd < 0) |
@@ -725,8 +728,8 @@ static int open_master_fd(struct master_header *hdr, bool write) | |||
725 | } | 728 | } |
726 | 729 | ||
727 | /* Check the header. */ | 730 | /* Check the header. */ |
728 | read(fd, hdr, sizeof(struct master_header)); | 731 | rc = read(fd, hdr, sizeof(struct master_header)); |
729 | if (hdr->tch.magic != TAGCACHE_MAGIC) | 732 | if (hdr->tch.magic != TAGCACHE_MAGIC || rc != sizeof(struct master_header)) |
730 | { | 733 | { |
731 | logf("header error"); | 734 | logf("header error"); |
732 | stat.ready = false; | 735 | stat.ready = false; |
@@ -1659,6 +1662,7 @@ static int build_index(int index_type, struct tagcache_header *h, int tmpfd) | |||
1659 | * Creating new index file to store the tags. No need to preload | 1662 | * Creating new index file to store the tags. No need to preload |
1660 | * anything whether the index type is sorted or not. | 1663 | * anything whether the index type is sorted or not. |
1661 | */ | 1664 | */ |
1665 | snprintf(buf, sizeof buf, TAGCACHE_FILE_INDEX, index_type); | ||
1662 | fd = open(buf, O_WRONLY | O_CREAT | O_TRUNC); | 1666 | fd = open(buf, O_WRONLY | O_CREAT | O_TRUNC); |
1663 | if (fd < 0) | 1667 | if (fd < 0) |
1664 | { | 1668 | { |