diff options
author | David Teigland <teigland@redhat.com> | 2006-08-08 12:31:30 -0400 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2006-08-09 09:46:04 -0400 |
commit | 06442440bc442ef79cb060c6e786eaeeabd9044b (patch) | |
tree | d4744898d6121ecbb709b99c77ee84d08c941061 /fs | |
parent | f6db1b8e724b071d144055b48da3827ce26dba1c (diff) |
[DLM] break from snprintf loop
When the debug buffer has filled up, break from the loop and return the
correct number of bytes that have been written.
Signed-off-by: David Teigland <teigland@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/dlm/debug_fs.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/fs/dlm/debug_fs.c b/fs/dlm/debug_fs.c index 8f471d9a9e3a..9c3aeddc8667 100644 --- a/fs/dlm/debug_fs.c +++ b/fs/dlm/debug_fs.c | |||
@@ -310,16 +310,19 @@ static ssize_t waiters_read(struct file *file, char __user *userbuf, | |||
310 | { | 310 | { |
311 | struct dlm_ls *ls = file->private_data; | 311 | struct dlm_ls *ls = file->private_data; |
312 | struct dlm_lkb *lkb; | 312 | struct dlm_lkb *lkb; |
313 | size_t len = DLM_DEBUG_BUF_LEN, pos = 0, rv; | 313 | size_t len = DLM_DEBUG_BUF_LEN, pos = 0, ret, rv; |
314 | 314 | ||
315 | mutex_lock(&debug_buf_lock); | 315 | mutex_lock(&debug_buf_lock); |
316 | mutex_lock(&ls->ls_waiters_mutex); | 316 | mutex_lock(&ls->ls_waiters_mutex); |
317 | memset(debug_buf, 0, sizeof(debug_buf)); | 317 | memset(debug_buf, 0, sizeof(debug_buf)); |
318 | 318 | ||
319 | list_for_each_entry(lkb, &ls->ls_waiters, lkb_wait_reply) { | 319 | list_for_each_entry(lkb, &ls->ls_waiters, lkb_wait_reply) { |
320 | pos += snprintf(debug_buf + pos, len - pos, "%x %d %d %s\n", | 320 | ret = snprintf(debug_buf + pos, len - pos, "%x %d %d %s\n", |
321 | lkb->lkb_id, lkb->lkb_wait_type, | 321 | lkb->lkb_id, lkb->lkb_wait_type, |
322 | lkb->lkb_nodeid, lkb->lkb_resource->res_name); | 322 | lkb->lkb_nodeid, lkb->lkb_resource->res_name); |
323 | if (ret >= len - pos) | ||
324 | break; | ||
325 | pos += ret; | ||
323 | } | 326 | } |
324 | mutex_unlock(&ls->ls_waiters_mutex); | 327 | mutex_unlock(&ls->ls_waiters_mutex); |
325 | 328 | ||