From fed95a2dfb0615a49330659db6db9ce3ebd9d899 Mon Sep 17 00:00:00 2001 From: liuzerun Date: Mon, 5 Feb 2024 15:16:08 +0000 Subject: [PATCH 1/2] status Signed-off-by: liuzerun --- fs/hmdfs/comm/device_node.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/fs/hmdfs/comm/device_node.c b/fs/hmdfs/comm/device_node.c index 796e5cd09a72..3d38cf1c6c87 100644 --- a/fs/hmdfs/comm/device_node.c +++ b/fs/hmdfs/comm/device_node.c @@ -258,20 +258,21 @@ static ssize_t sbi_status_show(struct kobject *kobj, struct sbi_attribute *attr, struct tcp_handle *tcp = NULL; sbi = to_sbi(kobj); - size += sprintf(buf + size, "peers status\n"); + size += snprintf(buf + size, PAGE_SIZE - size, "peers status\n"); mutex_lock(&sbi->connections.node_lock); list_for_each_entry(peer, &sbi->connections.node_list, list) { - size += sprintf(buf + size, "%llu %d\n", peer->device_id, - peer->status); + size += snprintf(buf + size, PAGE_SIZE - size, "%llu %d\n", + peer->device_id, peer->status); // connection information - size += sprintf( + size += snprintf( buf + size, "\t socket_fd connection_status tcp_status ... refcnt\n"); mutex_lock(&peer->conn_impl_list_lock); list_for_each_entry(conn_impl, &peer->conn_impl_list, list) { tcp = conn_impl->connect_handle; - size += sprintf(buf + size, "\t %d \t%d \t%d \t%p \t%ld\n", + size += snprintf(buf + size, PAGE_SIZE - size, + "\t %d \t%d \t%d \t%p \t%ld\n", tcp->fd, conn_impl->status, tcp->sock->state, tcp->sock, file_count(tcp->sock->file)); } -- Gitee From 9bbd18ec910225bd8348b8529b50b39a8089168a Mon Sep 17 00:00:00 2001 From: liuzerun Date: Mon, 5 Feb 2024 15:18:34 +0000 Subject: [PATCH 2/2] stat Signed-off-by: liuzerun --- fs/hmdfs/comm/device_node.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/fs/hmdfs/comm/device_node.c b/fs/hmdfs/comm/device_node.c index 3d38cf1c6c87..a904c3acc87a 100644 --- a/fs/hmdfs/comm/device_node.c +++ b/fs/hmdfs/comm/device_node.c @@ -266,7 +266,7 @@ static ssize_t sbi_status_show(struct kobject *kobj, struct sbi_attribute *attr, peer->device_id, peer->status); // connection information size += snprintf( - buf + size, + buf + size, PAGE_SIZE - size, "\t socket_fd connection_status tcp_status ... refcnt\n"); mutex_lock(&peer->conn_impl_list_lock); list_for_each_entry(conn_impl, &peer->conn_impl_list, list) { @@ -308,12 +308,13 @@ static ssize_t sbi_stat_show(struct kobject *kobj, struct sbi_attribute *attr, mutex_lock(&peer->conn_impl_list_lock); list_for_each_entry(conn_impl, &peer->conn_impl_list, list) { tcp = conn_impl->connect_handle; - size += sprintf(buf + size, "socket_fd: %d\n", tcp->fd); - size += sprintf(buf + size, + size += snprintf(buf + size, PAGE_SIZE - size, + "socket_fd: %d\n", tcp->fd); + size += snprintf(buf + size, PAGE_SIZE - size, "\tsend_msg %d \tsend_bytes %llu\n", conn_impl->stat.send_message_count, conn_impl->stat.send_bytes); - size += sprintf(buf + size, + size += snprintf(buf + size, PAGE_SIZE - size, "\trecv_msg %d \trecv_bytes %llu\n", conn_impl->stat.recv_message_count, conn_impl->stat.recv_bytes); -- Gitee