projects
/
archipelago
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
make mt-sosd use the newly added dispatch reason
[archipelago]
/
xseg
/
sys
/
kernel
/
segdev.c
diff --git
a/xseg/sys/kernel/segdev.c
b/xseg/sys/kernel/segdev.c
index
6eec912
..
bb1a6ab
100644
(file)
--- a/
xseg/sys/kernel/segdev.c
+++ b/
xseg/sys/kernel/segdev.c
@@
-21,7
+21,7
@@
#include <linux/vmalloc.h>
#include <linux/spinlock.h>
#include <linux/wait.h>
#include <linux/vmalloc.h>
#include <linux/spinlock.h>
#include <linux/wait.h>
-
+#include <sys/util.h>
#include "segdev.h"
static struct segdev segdev;
#include "segdev.h"
static struct segdev segdev;
@@
-39,6
+39,7
@@
int segdev_create_segment(struct segdev *dev, u64 segsize, char reserved)
/* vmalloc can handle large sizes */
ret = -ENOMEM;
/* vmalloc can handle large sizes */
ret = -ENOMEM;
+ XSEGLOG("creating segment of size %llu\n", segsize);
segment = vmalloc(segsize);
if (!segment)
goto out_unlock;
segment = vmalloc(segsize);
if (!segment)
goto out_unlock;
@@
-82,7
+83,7
@@
int segdev_destroy_segment(struct segdev *dev)
goto out_unlock;
clear_bit(SEGDEV_READY, &dev->flags);
goto out_unlock;
clear_bit(SEGDEV_READY, &dev->flags);
- ret = wait_event_interruptible(dev->wq, atomic_read(&dev->usercount) < 1);
+ ret = wait_event_interruptible(dev->wq, atomic_read(&dev->usercount) <= 1);
if (ret)
goto out_unlock;
if (ret)
goto out_unlock;
@@
-213,22
+214,24
@@
static ssize_t segdev_write(struct file *file, const char __user *buf,
{
struct segdev_file *vf = file->private_data;
struct segdev *dev = segdev_get(vf->minor);
{
struct segdev_file *vf = file->private_data;
struct segdev *dev = segdev_get(vf->minor);
+ uint32_t portno;
int ret = -ENODEV;
if (!dev)
goto out;
int ret = -ENODEV;
if (!dev)
goto out;
- if (count > SEGDEV_BUFSIZE)
- count = SEGDEV_BUFSIZE;
+ if (count != sizeof(uint32_t))
+ goto out;
- ret = copy_from_user(dev->buffer, buf, count);
+ ret = copy_from_user(&portno, buf, sizeof(uint32_t));
if (ret < 0)
goto out;
if (ret < 0)
goto out;
- dev->buffer_index = count - ret;
+ if((count - ret) != sizeof(uint32_t))
+ goto out;
ret = 0;
if (dev->callback)
ret = 0;
if (dev->callback)
- dev->callback(dev);
+ dev->callback(dev, portno);
else
ret = -ENOSYS;
else
ret = -ENOSYS;