aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/stack_user.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ocfs2/stack_user.c')
-rw-r--r--fs/ocfs2/stack_user.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/fs/ocfs2/stack_user.c b/fs/ocfs2/stack_user.c
index c021280dd462..353fc35c6748 100644
--- a/fs/ocfs2/stack_user.c
+++ b/fs/ocfs2/stack_user.c
@@ -21,6 +21,7 @@
21#include <linux/fs.h> 21#include <linux/fs.h>
22#include <linux/miscdevice.h> 22#include <linux/miscdevice.h>
23#include <linux/mutex.h> 23#include <linux/mutex.h>
24#include <linux/smp_lock.h>
24#include <linux/reboot.h> 25#include <linux/reboot.h>
25#include <asm/uaccess.h> 26#include <asm/uaccess.h>
26 27
@@ -549,26 +550,17 @@ static ssize_t ocfs2_control_read(struct file *file,
549 size_t count, 550 size_t count,
550 loff_t *ppos) 551 loff_t *ppos)
551{ 552{
552 char *proto_string = OCFS2_CONTROL_PROTO; 553 ssize_t ret;
553 size_t to_write = 0;
554
555 if (*ppos >= OCFS2_CONTROL_PROTO_LEN)
556 return 0;
557
558 to_write = OCFS2_CONTROL_PROTO_LEN - *ppos;
559 if (to_write > count)
560 to_write = count;
561 if (copy_to_user(buf, proto_string + *ppos, to_write))
562 return -EFAULT;
563 554
564 *ppos += to_write; 555 ret = simple_read_from_buffer(buf, count, ppos,
556 OCFS2_CONTROL_PROTO, OCFS2_CONTROL_PROTO_LEN);
565 557
566 /* Have we read the whole protocol list? */ 558 /* Have we read the whole protocol list? */
567 if (*ppos >= OCFS2_CONTROL_PROTO_LEN) 559 if (ret > 0 && *ppos >= OCFS2_CONTROL_PROTO_LEN)
568 ocfs2_control_set_handshake_state(file, 560 ocfs2_control_set_handshake_state(file,
569 OCFS2_CONTROL_HANDSHAKE_READ); 561 OCFS2_CONTROL_HANDSHAKE_READ);
570 562
571 return to_write; 563 return ret;
572} 564}
573 565
574static int ocfs2_control_release(struct inode *inode, struct file *file) 566static int ocfs2_control_release(struct inode *inode, struct file *file)
@@ -619,10 +611,12 @@ static int ocfs2_control_open(struct inode *inode, struct file *file)
619 return -ENOMEM; 611 return -ENOMEM;
620 p->op_this_node = -1; 612 p->op_this_node = -1;
621 613
614 lock_kernel();
622 mutex_lock(&ocfs2_control_lock); 615 mutex_lock(&ocfs2_control_lock);
623 file->private_data = p; 616 file->private_data = p;
624 list_add(&p->op_list, &ocfs2_control_private_list); 617 list_add(&p->op_list, &ocfs2_control_private_list);
625 mutex_unlock(&ocfs2_control_lock); 618 mutex_unlock(&ocfs2_control_lock);
619 unlock_kernel();
626 620
627 return 0; 621 return 0;
628} 622}