From 177a5edc3c9ef1d60d5b4aa47f3577cdec68384f Mon Sep 17 00:00:00 2001 From: liuzerun Date: Tue, 23 Jan 2024 02:40:09 +0000 Subject: [PATCH 1/2] stat Signed-off-by: liuzerun --- fs/hmdfs/comm/device_node.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/hmdfs/comm/device_node.c b/fs/hmdfs/comm/device_node.c index bf65199261ec..b91d68336e28 100644 --- a/fs/hmdfs/comm/device_node.c +++ b/fs/hmdfs/comm/device_node.c @@ -250,12 +250,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 += sprintf_s(buf + size, PAGE_SIZE - size, + "socket_fd: %d\n", tcp->fd); + size += sprintf_s(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 += sprintf_s(buf + size, PAGE_SIZE - size, "\trecv_msg %d \trecv_bytes %llu\n", conn_impl->stat.recv_message_count, conn_impl->stat.recv_bytes); -- Gitee From 8c36ff0c7092cbb803b16377ba7276e43566cace Mon Sep 17 00:00:00 2001 From: liuzerun Date: Tue, 30 Jan 2024 02:39:54 +0000 Subject: [PATCH 2/2] snprintf Signed-off-by: liuzerun --- fs/hmdfs/comm/device_node.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/hmdfs/comm/device_node.c b/fs/hmdfs/comm/device_node.c index b91d68336e28..c8febc2947ca 100644 --- a/fs/hmdfs/comm/device_node.c +++ b/fs/hmdfs/comm/device_node.c @@ -250,13 +250,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_s(buf + size, PAGE_SIZE - size, + size += snprintf(buf + size, PAGE_SIZE - size, "socket_fd: %d\n", tcp->fd); - size += sprintf_s(buf + size, PAGE_SIZE - size, + 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_s(buf + size, PAGE_SIZE - 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