procfs/group/fd: add path for every file descriptor
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
This commit is contained in:
parent
120fa93d7f
commit
4f79a1e22c
|
@ -50,6 +50,7 @@
|
|||
#include <nuttx/environ.h>
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/fs/procfs.h>
|
||||
#include <nuttx/fs/ioctl.h>
|
||||
#include <nuttx/fs/dirent.h>
|
||||
#include <nuttx/mm/mm.h>
|
||||
|
||||
|
@ -68,7 +69,7 @@
|
|||
* to handle the longest line generated by this logic.
|
||||
*/
|
||||
|
||||
#define STATUS_LINELEN 32
|
||||
#define STATUS_LINELEN PATH_MAX
|
||||
|
||||
/****************************************************************************
|
||||
* Private Type Definitions
|
||||
|
@ -1164,6 +1165,7 @@ static ssize_t proc_groupfd(FAR struct proc_file_s *procfile,
|
|||
{
|
||||
FAR struct task_group_s *group = tcb->group;
|
||||
FAR struct file *file;
|
||||
char path[PATH_MAX];
|
||||
size_t remaining;
|
||||
size_t linesize;
|
||||
size_t copysize;
|
||||
|
@ -1177,8 +1179,8 @@ static ssize_t proc_groupfd(FAR struct proc_file_s *procfile,
|
|||
totalsize = 0;
|
||||
|
||||
linesize = procfs_snprintf(procfile->line, STATUS_LINELEN,
|
||||
"\n%-3s %-8s %s\n",
|
||||
"FD", "POS", "OFLAGS");
|
||||
"\n%-3s %-8s %-8s %s\n",
|
||||
"FD", "POS", "OFLAGS", "PATH");
|
||||
copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining,
|
||||
&offset);
|
||||
|
||||
|
@ -1203,8 +1205,13 @@ static ssize_t proc_groupfd(FAR struct proc_file_s *procfile,
|
|||
|
||||
if (file->f_inode && !INODE_IS_SOCKET(file->f_inode))
|
||||
{
|
||||
if (file_ioctl(file, FIOC_FILEPATH, path) < 0)
|
||||
{
|
||||
path[0] = '\0';
|
||||
}
|
||||
|
||||
linesize = procfs_snprintf(procfile->line, STATUS_LINELEN,
|
||||
"%3d %8ld %04x\n",
|
||||
"%3d %8ld %8x",
|
||||
i * CONFIG_NFILE_DESCRIPTORS_PER_BLOCK +
|
||||
j, (long)file->f_pos,
|
||||
file->f_oflags);
|
||||
|
@ -1215,6 +1222,15 @@ static ssize_t proc_groupfd(FAR struct proc_file_s *procfile,
|
|||
buffer += copysize;
|
||||
remaining -= copysize;
|
||||
|
||||
linesize = procfs_snprintf(procfile->line, STATUS_LINELEN,
|
||||
" %s\n", path);
|
||||
copysize = procfs_memcpy(procfile->line, linesize, buffer,
|
||||
remaining, &offset);
|
||||
|
||||
totalsize += copysize;
|
||||
buffer += copysize;
|
||||
remaining -= copysize;
|
||||
|
||||
if (totalsize >= buflen)
|
||||
{
|
||||
return totalsize;
|
||||
|
|
Loading…
Reference in New Issue