/* relay_file_read_end_pos - return the new read position @read_pos: file read position @buf: relay channel buffer @count: number of bytes to be read  */
static size_t relay_file_read_end_pos(struct rchan_buf *buf, size_t read_pos, size_t count)
/* relay_file_read_end_pos - return the new read position @read_pos: file read position @buf: relay channel buffer @count: number of bytes to be read  */
static size_t relay_file_read_end_pos(struct rchan_buf *buf, size_t read_pos, size_t count)
{
	size_t read_subbuf, padding, end_pos;
	size_t subbuf_size = buf->chan->subbuf_size;
	size_t n_subbufs = buf->chan->n_subbufs;
	read_subbuf = read_pos / subbuf_size;
	padding = buf->padding[read_subbuf];
	if (read_pos % subbuf_size + count + padding == subbuf_size)
		end_pos = (read_subbuf + 1) * subbuf_size;
	else
		end_pos = read_pos + count;
	if (end_pos >= subbuf_size * n_subbufs)
		end_pos = 0;
	return end_pos;
}