* @brief Dump all file descriptors information in the global file descriptor table * * @param[in] argc Number of command line arguments (unused) * @param[in] argv Array of command line arguments (unused) * * @return int 0 on success, * -RT_ENOSYS if failed to acquire file system lock */
| 1158 | * -RT_ENOSYS if failed to acquire file system lock |
| 1159 | */ |
| 1160 | int dfs_fd_dump(int argc, char** argv) |
| 1161 | { |
| 1162 | int index; |
| 1163 | |
| 1164 | if (dfs_file_lock() != RT_EOK) |
| 1165 | { |
| 1166 | return -RT_ENOSYS; |
| 1167 | } |
| 1168 | |
| 1169 | for (index = 0; index < _fdtab.maxfd; index++) |
| 1170 | { |
| 1171 | struct dfs_file *file = _fdtab.fds[index]; |
| 1172 | if (file) |
| 1173 | { |
| 1174 | char* fullpath = dfs_dentry_full_path(file->dentry); |
| 1175 | if (fullpath) |
| 1176 | { |
| 1177 | printf("[%d] - %s, ref_count %zd\n", index, |
| 1178 | fullpath, (size_t)rt_atomic_load(&(file->ref_count))); |
| 1179 | rt_free(fullpath); |
| 1180 | } |
| 1181 | else |
| 1182 | { |
| 1183 | printf("[%d] - %s, ref_count %zd\n", index, |
| 1184 | file->dentry->pathname, (size_t)rt_atomic_load(&(file->ref_count))); |
| 1185 | } |
| 1186 | } |
| 1187 | } |
| 1188 | dfs_file_unlock(); |
| 1189 | |
| 1190 | return 0; |
| 1191 | } |
| 1192 | MSH_CMD_EXPORT_ALIAS(dfs_fd_dump, fd_dump, fd dump); |
| 1193 | |
| 1194 | #ifdef PKG_USING_DLOG |
nothing calls this directly
no test coverage detected