add: TRACE(("tty_write_to_tty(source = %p, target = %p, length = %lu, %s%s)\n", source, target, length, sourceIsMaster ? "master" : "slave", echo ? ", echo mode" : ""));
context: tty_write_to_tty(struct tty *source, struct tty *target, const void *buffer, size_t *_length,	uint32 mode, bool sourceIsMaster){	const char *data = (const char *)buffer;	size_t length = *_length;	size_t bytesWritten = 0;	bool dontBlock = (mode & O_NONBLOCK) != 0;	bool echo = (target->termios.c_lflag & ECHO) != 0;		// Confusingly enough, we need to echo when the target's ECHO flag is		// set. That's because our target is supposed to echo back at us, not		// to itself.	// ToDo: "buffer" is not yet copied or accessed in a safe way!	if (length == 0)		return B_OK;	WriterLocker locker(source, target, echo, sourceIsMaster);	while (bytesWritten < length) {		status_t status = locker.AcquireWriter(dontBlock);		if (status != B_OK) {			*_length = bytesWritten;			return status;		}		size_t writable = line_buffer_writable(target->input_buffer);		if (echo) {			// we can only write as much as is available on both ends			size_t locallyWritable = line_buffer_writable(source->input_buffer);			if (locallyWritable < writable)				writable = locallyWritable;		}		if (writable == 0) {			locker.ReportWritten(0);			continue;		}		while (writable > bytesWritten && bytesWritten < length) {			char c = data[0];			if (c == '\n' && (source->termios.c_oflag & (OPOST | ONLCR)) == OPOST | ONLCR) {				// post-process output and transfrom '\n' to '\r\n'				tty_input_putc_locked(target, '\r');			 	if (echo)					tty_input_putc_locked(source, '\r');				if (--writable == 0)					continue;			}			tty_input_putc_locked(target, c);			if (echo)				tty_input_putc_locked(source, c);			data++;			bytesWritten++;		}		locker.ReportWritten(bytesWritten);	}	return B_OK;}