Changeset 641 for trunk/user/ksh/ksh.c
- Timestamp:
- Oct 10, 2019, 1:42:04 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/user/ksh/ksh.c
r640 r641 123 123 124 124 #if DEBUG_CMD_CAT 125 snprintf( string , 128 , "[ksh] enter %s" , __FUNCTION__);125 snprintf( string , 128 , "[ksh] %s enters" , __FUNCTION__); 126 126 display_string( string ); 127 127 #endif … … 138 138 139 139 #if DEBUG_CMD_CAT 140 snprintf( string , 128 , "[ksh] in%s : after strcpy" , __FUNCTION__ );140 snprintf( string , 128 , "[ksh] %s : after strcpy" , __FUNCTION__ ); 141 141 display_string( string ); 142 142 #endif … … 180 180 181 181 #if DEBUG_CMD_CAT 182 snprintf( string , 128 , "[ksh] %s : size = %d", __FUNCTION__, size ); 182 snprintf( string , 128 , "[ksh] %s : size = %d", 183 __FUNCTION__, size ); 183 184 display_string( string ); 184 185 #endif … … 206 207 207 208 #if DEBUG_CMD_CAT 208 snprintf( string , 128 , "[ksh] %s : maped file %d to buffer %x", __FUNCTION__, fd , buf ); 209 snprintf( string , 128 , "[ksh] %s : mapped file %d to buffer %x", 210 __FUNCTION__, fd , buf ); 209 211 display_string( string ); 210 212 #endif … … 213 215 write( 1 , buf , size ); 214 216 215 // unmap t e file217 // unmap the file 216 218 if( munmap( buf , size ) ) 217 219 { … … 220 222 221 223 #if DEBUG_CMD_CAT 222 snprintf( string , 128 , "[ksh] %s : unmaped file %d from buffer %x", __FUNCTION__, fd , buf ); 224 snprintf( string , 128 , "[ksh] %s : unmapped file %d from buffer %x", 225 __FUNCTION__, fd , buf ); 223 226 display_string( string ); 224 227 #endif … … 852 855 853 856 #if DEBUG_CMD_LS 854 snprintf( string , 128 , "[ksh] %s : directory <%s> open / DIR %x \n",857 snprintf( string , 128 , "[ksh] %s : directory <%s> open / DIR %x", 855 858 __FUNCTION__, pathname , dir ); 856 859 display_string( string ); … … 875 878 876 879 #if DEBUG_CMD_LS 877 snprintf( string , 128 , "[ksh] %s : directory <%s> closed \n",880 snprintf( string , 128 , "[ksh] %s : directory <%s> closed", 878 881 __FUNCTION__, pathname ); 879 882 display_string( string ); … … 1020 1023 sem_post( &semaphore ); 1021 1024 1022 } // end_cmd_rm() 1025 } // end cmd_rm() 1026 1027 /////////////////////////////////////////////// 1028 static void cmd_stat( int argc , char **argv ) 1029 { 1030 struct stat st; 1031 unsigned int size; 1032 1033 if (argc != 2) 1034 { 1035 printf(" usage: %s pathname\n", argv[0]); 1036 } 1037 else 1038 { 1039 strcpy( pathname , argv[1] ); 1040 1041 if ( stat( pathname , &st ) ) 1042 { 1043 printf(" error: cannot stat <%s>\n", argv[2] ); 1044 } 1045 else 1046 { 1047 // get file size 1048 size = st.st_size; 1049 1050 // print file stat info 1051 printf(" <%s> : %d bytes\n", pathname, size ); 1052 } 1053 } 1054 1055 // release semaphore to get next command 1056 sem_post( &semaphore ); 1057 1058 } // end cmd_stat() 1023 1059 1024 1060 /////////////////////////////////////////////// … … 1103 1139 { "rm", "remove a file from file system", cmd_rm }, 1104 1140 { "rmdir", "remove a directory from file system", cmd_rmdir }, 1141 { "stat", "print infos on a given file", cmd_stat }, 1105 1142 { "trace", "activate trace for a given core", cmd_trace }, 1106 1143 { "untrace", "desactivate trace for a given core", cmd_untrace }, … … 1149 1186 1150 1187 #if DEBUG_EXECUTE 1151 snprintf( string , 128 , "\n[ksh] in %s : argc = %d / arg0 = %s / arg1 = %s \n",1188 snprintf( string , 128 , "\n[ksh] in %s : argc = %d / arg0 = %s / arg1 = %s", 1152 1189 __FUNCTION__ , argc , argv[0], argv[1] ); 1153 1190 #endif … … 1187 1224 char cmd[CMD_MAX_SIZE]; // buffer for one command 1188 1225 1189 /* 1. first direct command 1226 1227 1228 // 1. first direct command 1190 1229 if( sem_wait( &semaphore ) ) 1191 1230 { … … 1195 1234 else 1196 1235 { 1197 printf("\n[ksh] load bin/user/sort.elf\n"); 1236 strcpy( cmd , "load bin/user/fft.elf" ); 1237 printf("[ksh] %s\n", cmd ); 1238 execute( cmd ); 1198 1239 } 1199 1200 strcpy( cmd , "load bin/user/sort.elf" ); 1201 execute( cmd ); 1202 */ 1203 1204 1205 1206 // 2. second direct command 1240 // 1241 1242 1243 1244 /* 2. second direct command 1207 1245 if( sem_wait( &semaphore ) ) 1208 1246 { … … 1212 1250 else 1213 1251 { 1214 printf("\n[ksh] load bin/user/fft.elf\n"); 1252 strcpy( cmd , "cat home/p_fft_dqt_16384_1_2" ); 1253 printf("[ksh] %s\n", cmd ); 1254 execute( cmd ); 1215 1255 } 1216 1217 strcpy( cmd , "load bin/user/fft.elf" ); 1218 execute( cmd ); 1219 // 1220 1256 */ 1221 1257 1222 1258 … … 1253 1289 { 1254 1290 // initialize command buffer 1255 // memset( cmd , 0x20 , sizeof(cmd) ); // TODO useful ?1256 1291 count = 0; 1257 1292 state = NORMAL; … … 1459 1494 1460 1495 #if DEBUG_MAIN 1461 snprintf( string , 128 , "\n[ksh] main thread started on core[%x,%d] \n", cxy , lid );1496 snprintf( string , 128 , "\n[ksh] main thread started on core[%x,%d]", cxy , lid ); 1462 1497 display_string( string ); 1463 1498 #endif … … 1471 1506 1472 1507 #if DEBUG_MAIN 1473 snprintf( string , 128 , "\n[ksh] main initialized semaphore \n" );1508 snprintf( string , 128 , "\n[ksh] main initialized semaphore" ); 1474 1509 display_string( string ); 1475 1510 #endif … … 1485 1520 NULL ); 1486 1521 #if DEBUG_MAIN 1487 snprintf( string , 128 , "\n[ksh] main thread launched interactive thread %x \n", trdid );1522 snprintf( string , 128 , "\n[ksh] main thread launched interactive thread %x", trdid ); 1488 1523 display_string( string ); 1489 1524 #endif
Note: See TracChangeset
for help on using the changeset viewer.