.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* -*- mode: c; c-basic-offset: 8; -*- |
---|
2 | 3 | * vim: noexpandtab sw=8 ts=8 sts=0: |
---|
3 | 4 | * |
---|
.. | .. |
---|
6 | 7 | * debug functionality for o2net |
---|
7 | 8 | * |
---|
8 | 9 | * Copyright (C) 2005, 2008 Oracle. All rights reserved. |
---|
9 | | - * |
---|
10 | | - * This program is free software; you can redistribute it and/or |
---|
11 | | - * modify it under the terms of the GNU General Public |
---|
12 | | - * License as published by the Free Software Foundation; either |
---|
13 | | - * version 2 of the License, or (at your option) any later version. |
---|
14 | | - * |
---|
15 | | - * This program is distributed in the hope that it will be useful, |
---|
16 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
17 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
18 | | - * General Public License for more details. |
---|
19 | | - * |
---|
20 | | - * You should have received a copy of the GNU General Public |
---|
21 | | - * License along with this program; if not, write to the |
---|
22 | | - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
---|
23 | | - * Boston, MA 021110-1307, USA. |
---|
24 | | - * |
---|
25 | 10 | */ |
---|
26 | 11 | |
---|
27 | 12 | #ifdef CONFIG_DEBUG_FS |
---|
.. | .. |
---|
53 | 38 | #define SHOW_SOCK_STATS 1 |
---|
54 | 39 | |
---|
55 | 40 | static struct dentry *o2net_dentry; |
---|
56 | | -static struct dentry *sc_dentry; |
---|
57 | | -static struct dentry *nst_dentry; |
---|
58 | | -static struct dentry *stats_dentry; |
---|
59 | | -static struct dentry *nodes_dentry; |
---|
60 | 41 | |
---|
61 | 42 | static DEFINE_SPINLOCK(o2net_debug_lock); |
---|
62 | 43 | |
---|
.. | .. |
---|
462 | 443 | o2net_fill_node_map(map, sizeof(map)); |
---|
463 | 444 | |
---|
464 | 445 | while ((i = find_next_bit(map, O2NM_MAX_NODES, i + 1)) < O2NM_MAX_NODES) |
---|
465 | | - out += snprintf(buf + out, PAGE_SIZE - out, "%d ", i); |
---|
466 | | - out += snprintf(buf + out, PAGE_SIZE - out, "\n"); |
---|
| 446 | + out += scnprintf(buf + out, PAGE_SIZE - out, "%d ", i); |
---|
| 447 | + out += scnprintf(buf + out, PAGE_SIZE - out, "\n"); |
---|
467 | 448 | |
---|
468 | 449 | return out; |
---|
469 | 450 | } |
---|
.. | .. |
---|
505 | 486 | |
---|
506 | 487 | void o2net_debugfs_exit(void) |
---|
507 | 488 | { |
---|
508 | | - debugfs_remove(nodes_dentry); |
---|
509 | | - debugfs_remove(stats_dentry); |
---|
510 | | - debugfs_remove(sc_dentry); |
---|
511 | | - debugfs_remove(nst_dentry); |
---|
512 | | - debugfs_remove(o2net_dentry); |
---|
| 489 | + debugfs_remove_recursive(o2net_dentry); |
---|
513 | 490 | } |
---|
514 | 491 | |
---|
515 | | -int o2net_debugfs_init(void) |
---|
| 492 | +void o2net_debugfs_init(void) |
---|
516 | 493 | { |
---|
517 | 494 | umode_t mode = S_IFREG|S_IRUSR; |
---|
518 | 495 | |
---|
519 | 496 | o2net_dentry = debugfs_create_dir(O2NET_DEBUG_DIR, NULL); |
---|
520 | | - if (o2net_dentry) |
---|
521 | | - nst_dentry = debugfs_create_file(NST_DEBUG_NAME, mode, |
---|
522 | | - o2net_dentry, NULL, &nst_seq_fops); |
---|
523 | | - if (nst_dentry) |
---|
524 | | - sc_dentry = debugfs_create_file(SC_DEBUG_NAME, mode, |
---|
525 | | - o2net_dentry, NULL, &sc_seq_fops); |
---|
526 | | - if (sc_dentry) |
---|
527 | | - stats_dentry = debugfs_create_file(STATS_DEBUG_NAME, mode, |
---|
528 | | - o2net_dentry, NULL, &stats_seq_fops); |
---|
529 | | - if (stats_dentry) |
---|
530 | | - nodes_dentry = debugfs_create_file(NODES_DEBUG_NAME, mode, |
---|
531 | | - o2net_dentry, NULL, &nodes_fops); |
---|
532 | | - if (nodes_dentry) |
---|
533 | | - return 0; |
---|
534 | 497 | |
---|
535 | | - o2net_debugfs_exit(); |
---|
536 | | - mlog_errno(-ENOMEM); |
---|
537 | | - return -ENOMEM; |
---|
| 498 | + debugfs_create_file(NST_DEBUG_NAME, mode, o2net_dentry, NULL, |
---|
| 499 | + &nst_seq_fops); |
---|
| 500 | + debugfs_create_file(SC_DEBUG_NAME, mode, o2net_dentry, NULL, |
---|
| 501 | + &sc_seq_fops); |
---|
| 502 | + debugfs_create_file(STATS_DEBUG_NAME, mode, o2net_dentry, NULL, |
---|
| 503 | + &stats_seq_fops); |
---|
| 504 | + debugfs_create_file(NODES_DEBUG_NAME, mode, o2net_dentry, NULL, |
---|
| 505 | + &nodes_fops); |
---|
538 | 506 | } |
---|
539 | 507 | |
---|
540 | 508 | #endif /* CONFIG_DEBUG_FS */ |
---|