diff options
Diffstat (limited to 'fs/ocfs2/stack_user.c')
-rw-r--r-- | fs/ocfs2/stack_user.c | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/fs/ocfs2/stack_user.c b/fs/ocfs2/stack_user.c index bd7e0f3acfc7..353fc35c6748 100644 --- a/fs/ocfs2/stack_user.c +++ b/fs/ocfs2/stack_user.c | |||
@@ -550,26 +550,17 @@ static ssize_t ocfs2_control_read(struct file *file, | |||
550 | size_t count, | 550 | size_t count, |
551 | loff_t *ppos) | 551 | loff_t *ppos) |
552 | { | 552 | { |
553 | char *proto_string = OCFS2_CONTROL_PROTO; | 553 | ssize_t ret; |
554 | size_t to_write = 0; | ||
555 | |||
556 | if (*ppos >= OCFS2_CONTROL_PROTO_LEN) | ||
557 | return 0; | ||
558 | |||
559 | to_write = OCFS2_CONTROL_PROTO_LEN - *ppos; | ||
560 | if (to_write > count) | ||
561 | to_write = count; | ||
562 | if (copy_to_user(buf, proto_string + *ppos, to_write)) | ||
563 | return -EFAULT; | ||
564 | 554 | ||
565 | *ppos += to_write; | 555 | ret = simple_read_from_buffer(buf, count, ppos, |
556 | OCFS2_CONTROL_PROTO, OCFS2_CONTROL_PROTO_LEN); | ||
566 | 557 | ||
567 | /* Have we read the whole protocol list? */ | 558 | /* Have we read the whole protocol list? */ |
568 | if (*ppos >= OCFS2_CONTROL_PROTO_LEN) | 559 | if (ret > 0 && *ppos >= OCFS2_CONTROL_PROTO_LEN) |
569 | ocfs2_control_set_handshake_state(file, | 560 | ocfs2_control_set_handshake_state(file, |
570 | OCFS2_CONTROL_HANDSHAKE_READ); | 561 | OCFS2_CONTROL_HANDSHAKE_READ); |
571 | 562 | ||
572 | return to_write; | 563 | return ret; |
573 | } | 564 | } |
574 | 565 | ||
575 | static int ocfs2_control_release(struct inode *inode, struct file *file) | 566 | static int ocfs2_control_release(struct inode *inode, struct file *file) |