net/ioctl: Add default print for sockets without FIOC_FILEPATH support

Example of /proc/PID/group/fd in this case:

FD  OFLAGS  TYPE POS       PATH
17  67      9    0         socket:[domain 16, type 2, proto 0]

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
This commit is contained in:
Zhe Weng 2023-08-07 16:02:57 +08:00 committed by Xiang Xiao
parent 58f9cf7c04
commit 8e8d86a7bb
1 changed files with 15 additions and 3 deletions

View File

@ -27,10 +27,11 @@
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <string.h>
#include <assert.h> #include <assert.h>
#include <errno.h>
#include <debug.h> #include <debug.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <nuttx/net/net.h> #include <nuttx/net/net.h>
#include <nuttx/net/ip.h> #include <nuttx/net/ip.h>
@ -1536,7 +1537,18 @@ static int netdev_ioctl(FAR struct socket *psock, int cmd,
break; break;
default: case FIOC_FILEPATH:
if (ret == -ENOTTY)
{
snprintf((FAR char *)(uintptr_t)arg, PATH_MAX, "socket:["
"domain %" PRIu8 ", type %" PRIu8 ", proto %" PRIu8 "]",
psock->s_domain, psock->s_type, psock->s_proto);
ret = OK;
}
break;
default:
break; break;
} }