-
-/*
- * VM specific Controls
- * (c) Lei Xia, 2010
+/*
+ * Stream Implementation
+ * (c) Lei Xia 2010
*/
+
+
#include <linux/errno.h>
#include <linux/percpu.h>
#include <linux/sched.h>
struct list_head open_streams;
};
-static int stream_enqueue(struct stream_buffer * stream, char * buf, int len) {
- int bytes = 0;
-
- bytes = ringbuf_write(stream->buf, buf, len);
-
- return bytes;
-}
-
-
-static int stream_dequeue(struct stream_buffer * stream, char * buf, int len) {
- int bytes = 0;
-
- bytes = ringbuf_read(stream->buf, buf, len);
-
- return bytes;
-}
-
-static int stream_datalen(struct stream_buffer * stream){
- return ringbuf_data_len(stream->buf);
-}
-
-
-
-
static struct stream_buffer * find_stream_by_name(struct v3_guest * guest, const char * name) {
struct stream_buffer * stream = NULL;
struct list_head * stream_list = NULL;
struct vm_stream_state * vm_state = NULL;
-
if (guest == NULL) {
stream_list = &global_streams;
} else {
wait_event_interruptible(stream->intr_queue, (ringbuf_data_len(stream->buf) != 0));
-
- return 0;
+ return ringbuf_read(stream->buf, buf, size);
}
struct stream_buffer * stream = (struct stream_buffer *)stream_ptr;
int ret = 0;
- ret = stream_enqueue(stream, buf, len);
+ ret = ringbuf_write(stream->buf, buf, len);
if (ret > 0) {
wake_up_interruptible(&(stream->intr_queue));