rem: if (write(sLogFile, line, length) != length) { dprintf("log: must drop log entries!\n");
add: ssize_t written = write(sLogFile, line, length); if (written != length) { dprintf("log: must drop log entries: %ld, %s!\n", written, strerror(written));
context: log_writer_daemon(void *arg, int /*iteration*/){	mutex_lock(&sLock);	if (sCurrentEntry > kLogWriteThreshold || arg != NULL) {		for (uint32 i = 0; i < sCurrentEntry; i++) {			cache_log *log = &sLogEntries[i];			char line[1536];			ssize_t length = 0;			switch (log->action) {				case 'l':	// launch					length = snprintf(line, sizeof(line), "%ld: %Ld \"%s\" l ",								log->team, log->timestamp, log->team_name);					for (int32 j = 0; j < log->args.count; j++) {						strlcat(line, log->args.array[j], sizeof(line));						length = strlcat(line, " ", sizeof(line));					}					if (length >= (ssize_t)sizeof(line))						length = sizeof(line) - 1;					line[length - 1] = '\n';					break;				case 'c':	// close					length = snprintf(line, sizeof(line), "%ld: %Ld \"%s\" c%d %ld:%Ld %ld\n",						log->team, log->timestamp, log->team_name, log->type,						log->device, log->node, log->access_type);					break;				default:	// open, ?					length = snprintf(line, sizeof(line), "%ld: %Ld \"%s\" %c%d %ld:%Ld:%Ld:\"%s\"\n",						log->team, log->timestamp, log->team_name, log->action, log->type, log->device,						log->parent, log->node, log->file_name);					break;			}			if (write(sLogFile, line, length) != length) {				dprintf("log: must drop log entries!\n");				break;			}		}		// need to free any launch log items (also if writing fails)		for (uint32 i = 0; i < sCurrentEntry; i++) {			cache_log *log = &sLogEntries[i];			if (log->action != 'l')				continue;			for (int32 j = 0; j < log->args.count; j++)				free(log->args.array[j]);			free(log->args.array);		}		release_sem_etc(sLogEntrySem, sCurrentEntry, B_DO_NOT_RESCHEDULE);		sCurrentEntry = 0;	}	mutex_unlock(&sLock);}