MCPcopy Create free account
hub / github.com/HelenOS/helenos / log_append

Function log_append

kernel/generic/src/log/log.c:119–144  ·  view source on GitHub ↗

Append data to the currently open log entry. * * This function requires that the log_lock is acquired by the caller. */

Source from the content-addressed store, hash-verified

117 * This function requires that the log_lock is acquired by the caller.
118 */
119static void log_append(const uint8_t *data, size_t len)
120{
121 /* Cap the length so that the entry entirely fits into the buffer */
122 if (len > LOG_LENGTH - log_current_len) {
123 len = LOG_LENGTH - log_current_len;
124 }
125
126 if (len == 0)
127 return;
128
129 size_t log_free = LOG_LENGTH - log_used - log_current_len;
130
131 /* Discard older entries to make space, if necessary */
132 while (len > log_free) {
133 size_t entry_len;
134 log_copy_from((uint8_t *) &entry_len, log_start, sizeof(size_t));
135 log_start = (log_start + entry_len) % LOG_LENGTH;
136 log_used -= entry_len;
137 log_free += entry_len;
138 next_for_uspace -= entry_len;
139 }
140
141 size_t pos = (log_current_start + log_current_len) % LOG_LENGTH;
142 log_copy_to(data, pos, len);
143 log_current_len += len;
144}
145
146/** Begin writing an entry to the log.
147 *

Callers 3

log_beginFunction · 0.85
log_printf_str_writeFunction · 0.85
log_printf_wstr_writeFunction · 0.85

Calls 2

log_copy_fromFunction · 0.85
log_copy_toFunction · 0.85

Tested by

no test coverage detected