fs_procfsproc:Fix the wrong position of information display, integrate the fd information of socket and file
By left-aligned display, the effect is as follows (0, 1, 2 is fd information, 3 is sd information) FD OFLAGS TYPE POS PATH 0 3 1 0 /dev/console 1 3 1 0 /dev/console 2 3 1 0 /dev/console 3 65 2 Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
This commit is contained in:
parent
9381e929dd
commit
eb0a43f4cf
|
@ -1203,8 +1203,8 @@ static ssize_t proc_groupfd(FAR struct proc_file_s *procfile,
|
||||||
totalsize = 0;
|
totalsize = 0;
|
||||||
|
|
||||||
linesize = procfs_snprintf(procfile->line, STATUS_LINELEN,
|
linesize = procfs_snprintf(procfile->line, STATUS_LINELEN,
|
||||||
"\n%-3s %-9s %-7s %-4s %s \n",
|
"\n%-3s %-7s %-4s %-9s %s\n",
|
||||||
"FD", "POS", "OFLAGS", "TYPE", "PATH");
|
"FD", "OFLAGS", "TYPE", "POS", "PATH");
|
||||||
copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining,
|
copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining,
|
||||||
&offset);
|
&offset);
|
||||||
|
|
||||||
|
@ -1227,30 +1227,24 @@ static ssize_t proc_groupfd(FAR struct proc_file_s *procfile,
|
||||||
{
|
{
|
||||||
/* Is there an inode associated with the file descriptor? */
|
/* Is there an inode associated with the file descriptor? */
|
||||||
|
|
||||||
if (file->f_inode && !INODE_IS_SOCKET(file->f_inode))
|
if (file->f_inode == NULL)
|
||||||
{
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (file_ioctl(file, FIOC_FILEPATH, path) < 0)
|
if (file_ioctl(file, FIOC_FILEPATH, path) < 0)
|
||||||
{
|
{
|
||||||
path[0] = '\0';
|
path[0] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
linesize = procfs_snprintf(procfile->line, STATUS_LINELEN,
|
linesize = procfs_snprintf(procfile->line, STATUS_LINELEN,
|
||||||
"%-3d %-9ld %-7d %4x",
|
"%-3d %-7d %-4x %-9ld %s\n",
|
||||||
i * CONFIG_NFILE_DESCRIPTORS_PER_BLOCK +
|
i * CONFIG_NFILE_DESCRIPTORS_PER_BLOCK
|
||||||
j, (long)file->f_pos,
|
+ j, file->f_oflags,
|
||||||
INODE_GET_TYPE(file->f_inode),
|
INODE_GET_TYPE(file->f_inode),
|
||||||
file->f_oflags);
|
(long)file->f_pos, path);
|
||||||
copysize = procfs_memcpy(procfile->line, linesize, buffer,
|
copysize = procfs_memcpy(procfile->line, linesize,
|
||||||
remaining, &offset);
|
buffer, remaining, &offset);
|
||||||
|
|
||||||
totalsize += copysize;
|
|
||||||
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;
|
totalsize += copysize;
|
||||||
buffer += copysize;
|
buffer += copysize;
|
||||||
|
@ -1262,57 +1256,6 @@ static ssize_t proc_groupfd(FAR struct proc_file_s *procfile,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef CONFIG_NET
|
|
||||||
linesize = procfs_snprintf(procfile->line, STATUS_LINELEN,
|
|
||||||
"\n%-3s %-5s %s %s\n",
|
|
||||||
"SD", "RF", "TYP", "FLAGS");
|
|
||||||
copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining,
|
|
||||||
&offset);
|
|
||||||
|
|
||||||
totalsize += copysize;
|
|
||||||
buffer += copysize;
|
|
||||||
remaining -= copysize;
|
|
||||||
|
|
||||||
if (totalsize >= buflen)
|
|
||||||
{
|
|
||||||
return totalsize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Examine each open socket descriptor */
|
|
||||||
|
|
||||||
for (i = 0; i < group->tg_filelist.fl_rows; i++)
|
|
||||||
{
|
|
||||||
for (j = 0, file = group->tg_filelist.fl_files[i];
|
|
||||||
j < CONFIG_NFILE_DESCRIPTORS_PER_BLOCK;
|
|
||||||
j++, file++)
|
|
||||||
{
|
|
||||||
/* Is there an connection associated with the socket descriptor? */
|
|
||||||
|
|
||||||
if (file->f_inode && INODE_IS_SOCKET(file->f_inode))
|
|
||||||
{
|
|
||||||
FAR struct socket *socket = file->f_priv;
|
|
||||||
FAR struct socket_conn_s *conn = socket->s_conn;
|
|
||||||
linesize = procfs_snprintf(procfile->line, STATUS_LINELEN,
|
|
||||||
"%-3d %-5d %02x\n",
|
|
||||||
i * CONFIG_NFILE_DESCRIPTORS_PER_BLOCK +
|
|
||||||
j, socket->s_type, conn->s_flags);
|
|
||||||
copysize = procfs_memcpy(procfile->line, linesize, buffer,
|
|
||||||
remaining, &offset);
|
|
||||||
|
|
||||||
totalsize += copysize;
|
|
||||||
buffer += copysize;
|
|
||||||
remaining -= copysize;
|
|
||||||
|
|
||||||
if (totalsize >= buflen)
|
|
||||||
{
|
|
||||||
return totalsize;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return totalsize;
|
return totalsize;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue