r = 0;
}
- reader->file.size += r;
if (r < dlogutil_entry->len) {
reader->partial_log_size = dlogutil_entry->len - r;
memcpy(reader->partial_log, ((char *)dlogutil_entry) + r, reader->partial_log_size);
logfile_close_if_needed(l_file);
}
-static int logfile_update_fsize(struct log_file *l_file)
+static int logfile_get_fsize(struct log_file *l_file)
{
assert(l_file);
assert(l_file->fd >= 0);
if (fstat(l_file->fd, &st) < 0)
return -errno;
- l_file->size = st.st_size;
- return 0;
+ return st.st_size;
}
static int logfile_open_internal(struct log_file *l_file)
return -errno;
logfile_set_fd(l_file, fd, 1);
- logfile_update_fsize(l_file);
return 0;
}
if (l_file->path == NULL || l_file->rotate_size_kbytes <= 0 || l_file->max_rotated <= 0)
return 0;
- logfile_update_fsize(l_file);
+ int size = logfile_get_fsize(l_file);
+ if (size < 0)
+ return size;
- size_t size = l_file->size;
if (l_file->buffer.data)
size += l_file->buffer.position;
written_bytes += log_print_log_line(file->format, file->fd, e, &file->buffer);
if (written_bytes <= 0)
return 1;
- file->size += written_bytes;
logfile_add_timestamp(file, ts);
fake_open = true;
open_errno = 456;
assert(-456 == logfile_open(&lf));
-
open_errno = 0;
- fail_fstat = true;
- lf.size = 9999;
- open_calls = 0;
- assert(!logfile_open(&lf));
- assert(lf.fd == 0xFD);
- assert(lf.size == 9999);
- assert(open_calls == 1);
- fail_fstat = false;
open_calls = 0;
lf.rotate_size_kbytes = 0;
assert(!logfile_open(&lf));
assert(lf.fd == 0xFD);
- assert(lf.size == 7654321);
assert(open_calls == 1);
lf.rotate_size_kbytes = 10;