fs/proc: Fix groupfd to get fd by group instead of current tcb
/proc/<pid>/group/fd should read the fds of <pid>, not current tcb. Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
This commit is contained in:
parent
c17fcb5ddd
commit
bffe858e47
|
@ -71,16 +71,6 @@ static FAR struct file *files_fget_by_index(FAR struct filelist *list,
|
||||||
return filep;
|
return filep;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: files_fget
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
static FAR struct file *files_fget(FAR struct filelist *list, int fd)
|
|
||||||
{
|
|
||||||
return files_fget_by_index(list, fd / CONFIG_NFILE_DESCRIPTORS_PER_BLOCK,
|
|
||||||
fd % CONFIG_NFILE_DESCRIPTORS_PER_BLOCK);
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: files_extend
|
* Name: files_extend
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
@ -347,6 +337,27 @@ int files_countlist(FAR struct filelist *list)
|
||||||
return list->fl_rows * CONFIG_NFILE_DESCRIPTORS_PER_BLOCK;
|
return list->fl_rows * CONFIG_NFILE_DESCRIPTORS_PER_BLOCK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: files_fget
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Get the instance of struct file from file list by file descriptor.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* list - The list of files for a task.
|
||||||
|
* fd - A valid descriptor between 0 and files_countlist(list).
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Pointer to file structure of list[fd].
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
FAR struct file *files_fget(FAR struct filelist *list, int fd)
|
||||||
|
{
|
||||||
|
return files_fget_by_index(list, fd / CONFIG_NFILE_DESCRIPTORS_PER_BLOCK,
|
||||||
|
fd % CONFIG_NFILE_DESCRIPTORS_PER_BLOCK);
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: file_allocate_from_tcb
|
* Name: file_allocate_from_tcb
|
||||||
*
|
*
|
||||||
|
|
|
@ -1193,7 +1193,6 @@ static ssize_t proc_groupfd(FAR struct proc_file_s *procfile,
|
||||||
size_t copysize;
|
size_t copysize;
|
||||||
size_t totalsize;
|
size_t totalsize;
|
||||||
int count;
|
int count;
|
||||||
int ret;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
DEBUGASSERT(group != NULL);
|
DEBUGASSERT(group != NULL);
|
||||||
|
@ -1226,8 +1225,11 @@ static ssize_t proc_groupfd(FAR struct proc_file_s *procfile,
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
ret = fs_getfilep(i, &filep);
|
filep = files_fget(&group->tg_filelist, i);
|
||||||
if (ret != OK || filep == NULL)
|
|
||||||
|
/* Is there an inode associated with the file descriptor? */
|
||||||
|
|
||||||
|
if (filep->f_inode == NULL)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -882,6 +882,23 @@ int files_duplist(FAR struct filelist *plist, FAR struct filelist *clist,
|
||||||
FAR const posix_spawn_file_actions_t *actions,
|
FAR const posix_spawn_file_actions_t *actions,
|
||||||
bool cloexec);
|
bool cloexec);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: files_fget
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Get the instance of struct file from file list by file descriptor.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* list - The list of files for a task.
|
||||||
|
* fd - A valid descriptor between 0 and files_countlist(list).
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Pointer to file structure of list[fd].
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
FAR struct file *files_fget(FAR struct filelist *list, int fd);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: file_allocate_from_tcb
|
* Name: file_allocate_from_tcb
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue