File indexing completed on 2025-05-11 08:24:19
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifdef HAVE_CONFIG_H
0010 #include "config.h"
0011 #endif
0012
0013 #include <stdio.h>
0014 #include <inttypes.h>
0015
0016 #include <rtems/libio_.h>
0017 #include <rtems/shell.h>
0018 #include <rtems/shellconfig.h>
0019
0020 static void print_location( const rtems_filesystem_location_info_t *loc )
0021 {
0022 fprintf(
0023 stdout,
0024 "\tloc = 0x%08" PRIxPTR "\n\t\tnode_access = 0x%08" PRIxPTR
0025 ", node_access_2 = 0x%08" PRIxPTR ", handler = 0x%08" PRIxPTR "\n",
0026 (uintptr_t) loc,
0027 (uintptr_t) loc->node_access,
0028 (uintptr_t) loc->node_access_2,
0029 (uintptr_t) loc->handlers
0030 );
0031 }
0032
0033 static void print_mt_entry_locations(
0034 const rtems_filesystem_mount_table_entry_t *mt_entry
0035 )
0036 {
0037 const rtems_chain_control *mt_entry_chain = &mt_entry->location_chain;
0038 const rtems_chain_node *mt_entry_node;
0039
0040 for (
0041 mt_entry_node = rtems_chain_immutable_first( mt_entry_chain );
0042 !rtems_chain_is_tail( mt_entry_chain, mt_entry_node );
0043 mt_entry_node = rtems_chain_immutable_next( mt_entry_node )
0044 ) {
0045 const rtems_filesystem_location_info_t *loc =
0046 (const rtems_filesystem_location_info_t *) mt_entry_node;
0047
0048 print_location( loc );
0049 }
0050 }
0051
0052 static void lsof(void)
0053 {
0054 const rtems_chain_control *mt_chain = &rtems_filesystem_mount_table;
0055 const rtems_chain_node *mt_node;
0056
0057 fprintf(
0058 stdout,
0059 "type = null, root loc = 0x%08" PRIxPTR "\n",
0060 (uintptr_t) rtems_filesystem_null_mt_entry.mt_fs_root
0061 );
0062
0063 print_mt_entry_locations( &rtems_filesystem_null_mt_entry );
0064
0065 for (
0066 mt_node = rtems_chain_immutable_first( mt_chain );
0067 !rtems_chain_is_tail( mt_chain, mt_node );
0068 mt_node = rtems_chain_immutable_next( mt_node )
0069 ) {
0070 rtems_filesystem_mount_table_entry_t *mt_entry =
0071 (rtems_filesystem_mount_table_entry_t *) mt_node;
0072
0073 fprintf(
0074 stdout,
0075 "type = %s, %s, %s, target = %s, dev = %s, root loc = 0x%08" PRIxPTR "\n",
0076 mt_entry->type,
0077 mt_entry->mounted ? "mounted" : "unmounted",
0078 mt_entry->writeable ? "read-write" : "read-only",
0079 mt_entry->target,
0080 mt_entry->dev == NULL ? "NULL" : mt_entry->dev,
0081 (uintptr_t) mt_entry->mt_fs_root
0082 );
0083
0084 print_mt_entry_locations( mt_entry );
0085 }
0086 }
0087
0088 static int rtems_shell_main_lsof(int argc, char **argv)
0089 {
0090 lsof();
0091
0092 return 0;
0093 }
0094
0095 rtems_shell_cmd_t rtems_shell_LSOF_Command = {
0096 .name = "lsof",
0097 .usage = "lsof",
0098 .topic = "files",
0099 .command = rtems_shell_main_lsof
0100 };