[FIX] tasks file 09/21609/2
authorVitaliy Cherepanov <v.cherepanov@samsung.com>
Fri, 23 May 2014 11:18:01 +0000 (15:18 +0400)
committerDmitry Kovalenko <d.kovalenko@samsung.com>
Wed, 28 May 2014 11:03:58 +0000 (04:03 -0700)
add seek able
fix problem with symbol at end of string

Change-Id: I293b0151574dd29e229152e35835170da114c070
Signed-off-by: Vitaliy Cherepanov <v.cherepanov@samsung.com>
us_manager/debugfs_us_manager.c

index 4f682a0..84a0139 100644 (file)
@@ -34,13 +34,11 @@ static void on_each_proc_callback(struct sspt_proc *proc, void *data)
        if (rbuf->end - rbuf->ptr < len + 2)
                return;
 
-       if (rbuf->ptr != rbuf->begin) {
-               *rbuf->ptr = ' ';
-               ++rbuf->ptr;
-       }
-
        memcpy(rbuf->ptr, pid_str, len);
        rbuf->ptr += len;
+
+       *rbuf->ptr = ' ';
+       ++rbuf->ptr;
 }
 
 static ssize_t read_tasks(struct file *file, char __user *user_buf,
@@ -55,8 +53,9 @@ static ssize_t read_tasks(struct file *file, char __user *user_buf,
 
        on_each_proc_no_lock(on_each_proc_callback, (void *)&rbuf);
 
-       if (rbuf.ptr < rbuf.end)
-               ++rbuf.ptr;
+       if (rbuf.ptr != rbuf.begin)
+               rbuf.ptr--;
+
        *rbuf.ptr = '\n';
 
        return simple_read_from_buffer(user_buf, count, ppos, rbuf.begin,
@@ -65,7 +64,8 @@ static ssize_t read_tasks(struct file *file, char __user *user_buf,
 
 static const struct file_operations fops_tasks = {
        .owner = THIS_MODULE,
-       .read = read_tasks
+       .read = read_tasks,
+       .llseek = default_llseek
 };
 
 /* ============================================================================