vfs: provide function to get internal file information by fd
This commit is contained in:
parent
e1d27cb7d5
commit
ef844d8863
@ -882,6 +882,21 @@ int vfs_normalize_path(char *buf, const char *path, size_t buflen);
|
|||||||
*/
|
*/
|
||||||
const vfs_mount_t *vfs_iterate_mounts(const vfs_mount_t *cur);
|
const vfs_mount_t *vfs_iterate_mounts(const vfs_mount_t *cur);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get information about the file for internal purposes
|
||||||
|
*
|
||||||
|
* @attention Not thread safe! Do not modify any of the fields in the returned
|
||||||
|
* struct.
|
||||||
|
* @note For file descriptor internal usage only.
|
||||||
|
*
|
||||||
|
* @internal
|
||||||
|
* @param[in] fd A file descriptor
|
||||||
|
*
|
||||||
|
* @return Pointer to the file information struct if a file with @p fd exists.
|
||||||
|
* @return NULL, when no file with file descriptor @p fd exists.
|
||||||
|
*/
|
||||||
|
const vfs_file_t *vfs_file_get(int fd);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -864,6 +864,16 @@ const vfs_mount_t *vfs_iterate_mounts(const vfs_mount_t *cur)
|
|||||||
return container_of(node, vfs_mount_t, list_entry);
|
return container_of(node, vfs_mount_t, list_entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const vfs_file_t *vfs_file_get(int fd)
|
||||||
|
{
|
||||||
|
if (_fd_is_valid(fd) == 0) {
|
||||||
|
return &_vfs_open_files[fd];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static inline int _allocate_fd(int fd)
|
static inline int _allocate_fd(int fd)
|
||||||
{
|
{
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user