Changeset 70d689a in rtems for cpukit/libmisc/shell/cmds.c
- Timestamp:
- Aug 9, 2001, 10:08:46 PM (20 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- b6a2d2fa
- Parents:
- bd520203
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpukit/libmisc/shell/cmds.c
rbd520203 r70d689a 335 335 int main_mkdir (int argc, char *argv[]) { 336 336 char *dir; 337 dir=NULL; 338 if (argc>1) dir=argv[1]; 339 if (mkdir(dir,S_IRWXU|S_IRWXG|S_IRWXO)) { 340 printf("mkdir '%s' failed:%s\n",dir,strerror(errno)); 337 int n; 338 n=1; 339 while (n<argc) { 340 dir=argv[n++]; 341 if (mkdir(dir,S_IRWXU|S_IRWXG|S_IRWXO)) { 342 printf("mkdir '%s' failed:%s\n",dir,strerror(errno)); 343 }; 341 344 }; 342 345 return errno; … … 346 349 { 347 350 char *dir; 348 dir=NULL; 349 if (argc>1) dir=argv[1]; 350 if (rmdir(dir)) printf("rmdir '%s' failed:%s\n",dir,strerror(errno)); 351 int n; 352 n=1; 353 while (n<argc) { 354 dir=argv[n++]; 355 if (rmdir(dir)) printf("rmdir '%s' failed:%s\n",dir,strerror(errno)); 356 }; 351 357 return errno; 352 358 } … … 384 390 } 385 391 /*-----------------------------------------------------------*/ 386 /* date - print or set time and date */ 387 388 static int set_time(char *t) 389 { 390 rtems_time_of_day tod; 391 FILE * rtc; 392 int len; 393 394 if ( rtems_clock_get(RTEMS_CLOCK_GET_TOD,&tod) != RTEMS_SUCCESSFUL ) 395 memset( &tod, 0, sizeof(tod) ); 396 397 /* JRS 398 * 399 * This code that was used to parse the command line was taken 400 * from an inappropriate source. It has been removed and needs 401 * to be replaced. 402 */ 403 404 if (!_TOD_Validate(&tod)) { 405 fprintf(stderr, "Invalid date value\n"); 406 } else { 407 rtems_clock_set(&tod); 408 rtems_clock_get(RTEMS_CLOCK_GET_TOD,&tod); 409 rtc=fopen("/dev/rtc","r+"); 410 if (rtc) { 411 fwrite(&tod,sizeof(tod),1,rtc); 412 fclose(rtc); 413 }; 414 }; 415 return 1; 416 } 392 /* date - print time and date */ 417 393 418 394 int main_date(int argc,char *argv[]) 419 395 { 420 396 time_t t; 421 if (argc == 2)422 set_time(argv[1]);423 397 time(&t); 424 398 printf("%s", ctime(&t)); … … 529 503 shell_add_cmd ("logoff","misc","logoff from the system" ,main_logoff); 530 504 shell_alias_cmd("logoff","exit"); 531 shell_add_cmd ("date" ,"misc","date [[MMDDYY]hhmm[ss]]",main_date);505 shell_add_cmd ("date" ,"misc","date" ,main_date); 532 506 shell_add_cmd ("reset","misc","reset the BSP" ,main_reset); 533 507 shell_add_cmd ("alias","misc","alias old new" ,main_alias);
Note: See TracChangeset
for help on using the changeset viewer.