Ticket #369: fileio_sample.diff
File fileio_sample.diff, 40.7 KB (added by thomas.doerfler, on 12/03/06 at 13:31:12) |
---|
-
c/src/tests/samples/ChangeLog
diff -x '*~' -x Makefile.in -x configure.in -x configure -x autom4te.cache -P -r -u rtems-4.6.0pre1/c/src/tests/samples/ChangeLog rtems-4.6.0pre1-ide/c/src/tests/samples/ChangeLog
old new 1 2003-02-27 Thomas Doerfler <Thomas.Doerfler@imd-systems.de> 2 3 * fileio/*: added fileio sample/benchmark application 4 1 5 2003-02-11 Ralf Corsepius <corsepiu@faw.uni-ulm.de> 2 6 3 7 * configure.ac: AM_INIT_AUTOMAKE([1.7.2]). -
c/src/tests/samples/Makefile.am
diff -x '*~' -x Makefile.in -x configure.in -x configure -x autom4te.cache -P -r -u rtems-4.6.0pre1/c/src/tests/samples/Makefile.am rtems-4.6.0pre1-ide/c/src/tests/samples/Makefile.am
old new 14 14 ## loopback tests a network loopback interface 15 15 NET_TESTS = loopback 16 16 17 SUBDIRS = hello ticker base_sp unlimited minimum $(MP_TESTS) \17 SUBDIRS = hello ticker base_sp unlimited minimum fileio $(MP_TESTS) \ 18 18 $(CPLUSPLUS_TESTS) $(FP_TESTS) $(NET_TESTS) 19 19 20 20 AUTOMAKE_FILES = sample.am -
c/src/tests/samples/configure.ac
diff -x '*~' -x Makefile.in -x configure.in -x configure -x autom4te.cache -P -r -u rtems-4.6.0pre1/c/src/tests/samples/configure.ac rtems-4.6.0pre1-ide/c/src/tests/samples/configure.ac
old new 44 44 hello/Makefile 45 45 loopback/Makefile 46 46 minimum/Makefile 47 fileio/Makefile 47 48 paranoia/Makefile 48 49 ticker/Makefile 49 50 unlimited/Makefile -
c/src/tests/samples/fileio/Makefile.am
diff -x '*~' -x Makefile.in -x configure.in -x configure -x autom4te.cache -P -r -u rtems-4.6.0pre1/c/src/tests/samples/fileio/Makefile.am rtems-4.6.0pre1-ide/c/src/tests/samples/fileio/Makefile.am
old new 1 ## 2 ## Makefile.am,v 1.9 2002/08/11 05:18:59 ralf Exp 3 ## 4 5 6 SAMPLE = fileio 7 PGM = ${ARCH}/$(SAMPLE).exe 8 9 MANAGERS = io message semaphore 10 11 C_FILES = init.c 12 C_O_FILES = $(C_FILES:%.c=${ARCH}/%.$(OBJEXT)) 13 14 H_FILES = system.h 15 noinst_HEADERS = $(H_FILES) 16 17 DOCTYPES = doc scn 18 DOCS = $(DOCTYPES:%=$(SAMPLE).%) 19 20 SRCS = $(DOCS) $(C_FILES) $(H_FILES) 21 OBJS = $(C_O_FILES) 22 23 PRINT_SRCS = $(DOCS) 24 25 include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg 26 include $(top_srcdir)/../../../../automake/compile.am 27 include $(top_srcdir)/../../../../automake/leaf.am 28 include $(top_srcdir)/sample.am 29 30 # 31 # (OPTIONAL) Add local stuff here using += 32 # 33 34 all-local: ${ARCH} $(TMPINSTALL_FILES) 35 36 ${PGM}: $(OBJS) $(LINK_FILES) 37 $(make-exe) 38 39 EXTRA_DIST = $(C_FILES) $(DOCS) 40 41 include $(top_srcdir)/../../../../automake/local.am -
c/src/tests/samples/fileio/fileio.doc
diff -x '*~' -x Makefile.in -x configure.in -x configure -x autom4te.cache -P -r -u rtems-4.6.0pre1/c/src/tests/samples/fileio/fileio.doc rtems-4.6.0pre1-ide/c/src/tests/samples/fileio/fileio.doc
old new 1 # 2 # fileio.doc,v 3 # 4 # COPYRIGHT (c) 1989-1999. 5 # On-Line Applications Research Corporation (OAR). 6 # 7 # The license and distribution terms for this file may be 8 # found in the file LICENSE in this distribution or at 9 # http://www.OARcorp.com/rtems/license.html. 10 # 11 12 This sample implements some basic tests for the file systems 13 available. It provides the following functionality: 14 15 - perform basic file read/write tests on arbitrary file paths with 16 selectable I/O buffer size 17 - perform functions to evaluate FAT disk partition tables 18 - perform functions to mount FAT disks to the file system tree 19 20 A sample session might look like this: 21 22 - start this system 23 24 - select "p" (part_table_initialize) to read in the partition table of 25 first harddisk, enter the device name "/dev/hda", when prompted 26 27 - select "f" (fsmount) to try to mount the partitions 28 /dev/hda1../dev/hdc4 to corresponding mount points. Non-existant 29 partitions will report an error, but will not abort the tests 30 31 - select "w" (write file) to create a new file on the mounted disk (or 32 in the IMFS). Enter the file name (e.g. "/mnt/hda1/test_1M.txt"), 33 the file size (e.g. 64K or 2M) and the buffer size to use for the 34 write calls (e.g. 32 or 4K). Then the sample will try to write the 35 corresponding file and print the time consumed and data rate achived. 36 37 - select "r" (read file) to read a file (without displaying the 38 contents). It has similar parameters as "write file", but does not 39 query the file size. 40 41 - select "s" to call the rtems shell with its various capabilities. 42 43 44 -
c/src/tests/samples/fileio/init.c
diff -x '*~' -x Makefile.in -x configure.in -x configure -x autom4te.cache -P -r -u rtems-4.6.0pre1/c/src/tests/samples/fileio/init.c rtems-4.6.0pre1-ide/c/src/tests/samples/fileio/init.c
old new 1 /* Init 2 * 3 * This routine is the initialization task for this test program. 4 * It is called from init_exec and has the responsibility for creating 5 * and starting the tasks that make up the test. If the time of day 6 * clock is required for the test, it should also be set to a known 7 * value by this function. 8 * 9 * Input parameters: NONE 10 * 11 * Output parameters: NONE 12 * 13 * COPYRIGHT (c) 1989-1999. 14 * On-Line Applications Research Corporation (OAR). 15 * 16 * The license and distribution terms for this file may be 17 * found in the file LICENSE in this distribution or at 18 * http://www.OARcorp.com/rtems/license.html. 19 * 20 * init.c,v 1.11 2000/06/12 15:00:12 joel Exp 21 */ 22 23 #define CONFIGURE_INIT 24 #include "system.h" 25 #include <stdio.h> 26 #include <string.h> 27 #include <unistd.h> 28 #include <stdlib.h> 29 #include <errno.h> 30 #include <rtems.h> 31 #include <fcntl.h> 32 #include <rtems/error.h> 33 #include <dosfs.h> 34 #include <ctype.h> 35 #include <rtems/ide_part_table.h> 36 #include <rtems/libcsupport.h> 37 #include <rtems/fsmount.h> 38 39 /* 40 * Table of FAT file systems that will be mounted 41 * with the "fsmount" function. 42 * See cpukit/libmisc/fsmount for definition of fields 43 */ 44 fstab_t fs_table[] = { 45 { 46 "/dev/hda1","/mnt/hda1", 47 &msdos_ops, RTEMS_FILESYSTEM_READ_WRITE, 48 FSMOUNT_MNT_OK | FSMOUNT_MNTPNT_CRTERR | FSMOUNT_MNT_FAILED, 49 0 50 }, 51 { 52 "/dev/hda2","/mnt/hda2", 53 &msdos_ops, RTEMS_FILESYSTEM_READ_WRITE, 54 FSMOUNT_MNT_OK | FSMOUNT_MNTPNT_CRTERR | FSMOUNT_MNT_FAILED, 55 0 56 }, 57 { 58 "/dev/hda3","/mnt/hda3", 59 &msdos_ops, RTEMS_FILESYSTEM_READ_WRITE, 60 FSMOUNT_MNT_OK | FSMOUNT_MNTPNT_CRTERR | FSMOUNT_MNT_FAILED, 61 0 62 }, 63 { 64 "/dev/hda4","/mnt/hda4", 65 &msdos_ops, RTEMS_FILESYSTEM_READ_WRITE, 66 FSMOUNT_MNT_OK | FSMOUNT_MNTPNT_CRTERR | FSMOUNT_MNT_FAILED, 67 0 68 }, 69 { 70 "/dev/hdc1","/mnt/hdc1", 71 &msdos_ops, RTEMS_FILESYSTEM_READ_WRITE, 72 FSMOUNT_MNT_OK | FSMOUNT_MNTPNT_CRTERR | FSMOUNT_MNT_FAILED, 73 0 74 }, 75 { 76 "/dev/hdc2","/mnt/hdc2", 77 &msdos_ops, RTEMS_FILESYSTEM_READ_WRITE, 78 FSMOUNT_MNT_OK | FSMOUNT_MNTPNT_CRTERR | FSMOUNT_MNT_FAILED, 79 0 80 }, 81 { 82 "/dev/hdc3","/mnt/hdc3", 83 &msdos_ops, RTEMS_FILESYSTEM_READ_WRITE, 84 FSMOUNT_MNT_OK | FSMOUNT_MNTPNT_CRTERR | FSMOUNT_MNT_FAILED, 85 0 86 }, 87 { 88 "/dev/hdc4","/mnt/hdc4", 89 &msdos_ops, RTEMS_FILESYSTEM_READ_WRITE, 90 FSMOUNT_MNT_OK | FSMOUNT_MNTPNT_CRTERR | FSMOUNT_MNT_FAILED, 91 0 92 } 93 }; 94 95 #ifndef MIN 96 #define MIN(a,b) (((a) > (b)) ? (b) : (a)) 97 #endif 98 99 #define USE_SHELL 100 101 #ifdef USE_SHELL 102 #include <rtems/shell.h> 103 104 void fileio_start_shell(void) 105 { 106 printf(" =========================\n"); 107 printf(" starting shell\n"); 108 printf(" =========================\n"); 109 shell_init("SHLL",0,100,"/dev/console", 110 B9600 | CS8, 111 0); 112 rtems_task_suspend(RTEMS_SELF); 113 } 114 115 #endif /* USE_SHELL */ 116 117 void fileio_print_free_heap(void) 118 { 119 printf("--- unused dynamic memory: %lu bytes ---\n", 120 (unsigned long) malloc_free_space()); 121 } 122 123 124 void fileio_part_table_initialize(void) 125 { 126 char devname[64]; 127 rtems_status_code rc; 128 129 printf(" =========================\n"); 130 printf(" Initialize partition table\n"); 131 printf(" =========================\n"); 132 fileio_print_free_heap(); 133 printf(" Enter device to initialize ==>"); 134 fgets(devname,sizeof(devname)-1,stdin); 135 while (devname[strlen(devname)-1] == '\n') { 136 devname[strlen(devname)-1] = '\0'; 137 } 138 /* 139 * call function 140 */ 141 rc = rtems_ide_part_table_initialize(devname); 142 printf("result = %d\n",rc); 143 fileio_print_free_heap(); 144 } 145 146 void fileio_fsmount(void) 147 { 148 rtems_status_code rc; 149 150 printf(" =========================\n"); 151 printf(" Process fsmount table\n"); 152 printf(" =========================\n"); 153 fileio_print_free_heap(); 154 /* 155 * call function 156 */ 157 rc = rtems_fsmount( fs_table, 158 sizeof(fs_table)/sizeof(fs_table[0]), 159 NULL); 160 printf("result = %d\n",rc); 161 fileio_print_free_heap(); 162 } 163 164 void fileio_list_file(void) 165 { 166 char fname[1024]; 167 char *buf_ptr = NULL; 168 unsigned32 flen = 0; 169 int fd = -1; 170 ssize_t n; 171 size_t buf_size = 100; 172 173 rtems_interval start_tick,curr_tick,ticks_per_sec; 174 175 printf(" =========================\n"); 176 printf(" LIST FILE ... \n"); 177 printf(" =========================\n"); 178 fileio_print_free_heap(); 179 printf(" Enter filename to list ==>"); 180 fgets(fname,sizeof(fname)-1,stdin); 181 while (fname[strlen(fname)-1] == '\n') { 182 fname[strlen(fname)-1] = '\0'; 183 } 184 /* 185 * allocate buffer of given size 186 */ 187 if (buf_size > 0) { 188 buf_ptr = malloc(buf_size); 189 } 190 191 if (buf_ptr != NULL) { 192 printf("\n Trying to open file \"%s\" for read\n",fname); 193 fd = open(fname,O_RDONLY); 194 if (fd < 0) { 195 printf("*** file open failed, errno = %d(%s)\n",errno,strerror(errno)); 196 } 197 } 198 199 if (fd >= 0) { 200 rtems_clock_get (RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &start_tick); 201 do { 202 n = read(fd,buf_ptr,buf_size); 203 if (n > 0) { 204 write(1,buf_ptr,n); 205 flen += n; 206 } 207 } while (n > 0); 208 209 rtems_clock_get (RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &curr_tick); 210 211 printf("\n ******** End of file reached, flen = %d\n",flen); 212 close(fd); 213 214 rtems_clock_get(RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticks_per_sec); 215 printf("time elapsed for read: %g seconds\n", 216 ((double)curr_tick-start_tick)/ticks_per_sec); 217 } 218 /* 219 * free buffer 220 */ 221 if (buf_ptr != NULL) { 222 free(buf_ptr); 223 } 224 fileio_print_free_heap(); 225 } 226 227 /* 228 * convert a size string (like 34K or 12M) to actual byte count 229 */ 230 boolean fileio_str2size(const char *str,unsigned32 *res_ptr) 231 { 232 boolean failed = FALSE; 233 unsigned long size; 234 char suffix = ' '; 235 236 if (1 > sscanf(str,"%lu%c",&size,&suffix)) { 237 failed = TRUE; 238 } 239 else if (toupper(suffix) == 'K') { 240 size *= 1024; 241 } 242 else if (toupper(suffix) == 'M') { 243 size *= 1024UL*1024UL; 244 } 245 else if (isalpha(suffix)) { 246 failed = TRUE; 247 } 248 249 if (!failed) { 250 *res_ptr = size; 251 } 252 return failed; 253 } 254 255 void fileio_write_file(void) 256 { 257 char fname[1024]; 258 char tmp_str[32]; 259 unsigned32 file_size = 0; 260 unsigned32 buf_size = 0; 261 size_t curr_pos,bytes_to_copy; 262 int fd = -1; 263 ssize_t n; 264 rtems_interval start_tick,curr_tick,ticks_per_sec; 265 char *bufptr = NULL; 266 boolean failed = FALSE; 267 static const char write_test_string[] = 268 "The quick brown fox jumps over the lazy dog\n"; 269 static const char write_block_string[] = 270 "\n----- end of write buffer ------\n"; 271 272 printf(" =========================\n"); 273 printf(" WRITE FILE ... \n"); 274 printf(" =========================\n"); 275 fileio_print_free_heap(); 276 /* 277 * get number of ticks per second 278 */ 279 rtems_clock_get(RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticks_per_sec); 280 281 /* 282 * get path to file to write 283 */ 284 if (!failed) { 285 printf("Enter path/filename ==>"); 286 fgets(fname,sizeof(fname)-1,stdin); 287 while (fname[strlen(fname)-1] == '\n') { 288 fname[strlen(fname)-1] = '\0'; 289 } 290 if (0 == strlen(fname)) { 291 printf("*** no filename entered, aborted\n"); 292 failed = TRUE; 293 } 294 } 295 /* 296 * get total file size to write 297 */ 298 if (!failed) { 299 printf("use suffix K for Kbytes, M for Mbytes or no suffix for bytes:\n" 300 "Enter filesize to write ==>"); 301 fgets(tmp_str,sizeof(tmp_str)-1,stdin); 302 failed = fileio_str2size(tmp_str,&file_size); 303 if (failed) { 304 printf("*** illegal file size, aborted\n"); 305 } 306 } 307 /* 308 * get block size to write 309 */ 310 if (!failed) { 311 printf("use suffix K for Kbytes, M for Mbytes or no suffix for bytes:\n" 312 "Enter block size to use for write calls ==>"); 313 fgets(tmp_str,sizeof(tmp_str)-1,stdin); 314 failed = fileio_str2size(tmp_str,&buf_size); 315 if (failed) { 316 printf("*** illegal block size, aborted\n"); 317 } 318 } 319 320 /* 321 * allocate buffer 322 */ 323 if (!failed) { 324 printf("... allocating %lu bytes of buffer for write data\n", 325 (unsigned long)buf_size); 326 bufptr = malloc(buf_size+1); /* extra space for terminating NUL char */ 327 if (bufptr == NULL) { 328 printf("*** malloc failed, aborted\n"); 329 failed = TRUE; 330 } 331 } 332 /* 333 * fill buffer with test pattern 334 */ 335 if (!failed) { 336 printf("... filling buffer with write data\n"); 337 curr_pos = 0; 338 /* 339 * fill buffer with test string 340 */ 341 while (curr_pos < buf_size) { 342 bytes_to_copy = MIN(buf_size-curr_pos, 343 sizeof(write_test_string)-1); 344 memcpy(bufptr+curr_pos,write_test_string,bytes_to_copy); 345 curr_pos += bytes_to_copy; 346 } 347 /* 348 * put "end" mark at end of buffer 349 */ 350 bytes_to_copy = sizeof(write_block_string)-1; 351 if (buf_size >= bytes_to_copy) { 352 memcpy(bufptr+buf_size-bytes_to_copy, 353 write_block_string, 354 bytes_to_copy); 355 } 356 } 357 /* 358 * create file 359 */ 360 if (!failed) { 361 printf("... creating file \"%s\"\n",fname); 362 fd = open(fname,O_WRONLY | O_CREAT | O_TRUNC,S_IREAD|S_IWRITE); 363 if (fd < 0) { 364 printf("*** file create failed, errno = %d(%s)\n",errno,strerror(errno)); 365 failed = TRUE; 366 } 367 } 368 /* 369 * write file 370 */ 371 if (!failed) { 372 printf("... writing to file\n"); 373 rtems_clock_get (RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &start_tick); 374 curr_pos = 0; 375 do { 376 bytes_to_copy = buf_size; 377 do { 378 n = write(fd, 379 bufptr + (buf_size-bytes_to_copy), 380 MIN(bytes_to_copy,file_size-curr_pos)); 381 if (n > 0) { 382 bytes_to_copy -= n; 383 curr_pos += n; 384 } 385 } while ((bytes_to_copy > 0) && (n > 0)); 386 } while ((file_size > curr_pos) && (n > 0)); 387 rtems_clock_get (RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &curr_tick); 388 if (n < 0) { 389 failed = TRUE; 390 printf("*** file write failed, " 391 "%lu bytes written, " 392 "errno = %d(%s)\n", 393 (unsigned long)curr_pos,errno,strerror(errno)); 394 } 395 else { 396 printf("time elapsed for write: %g seconds\n", 397 ((double)curr_tick-start_tick)/ticks_per_sec); 398 printf("write data rate: %g KBytes/second\n", 399 (((double)file_size) / 1024.0 / 400 (((double)curr_tick-start_tick)/ticks_per_sec))); 401 } 402 } 403 if (fd >= 0) { 404 printf("... closing file\n"); 405 close(fd); 406 } 407 if (bufptr != NULL) { 408 printf("... deallocating buffer\n"); 409 free(bufptr); 410 bufptr = NULL; 411 } 412 printf("\n ******** End of file write\n"); 413 fileio_print_free_heap(); 414 } 415 416 void fileio_read_file(void) 417 { 418 char fname[1024]; 419 char tmp_str[32]; 420 unsigned32 buf_size = 0; 421 size_t curr_pos; 422 int fd = -1; 423 ssize_t n; 424 rtems_interval start_tick,curr_tick,ticks_per_sec; 425 char *bufptr = NULL; 426 boolean failed = FALSE; 427 428 printf(" =========================\n"); 429 printf(" READ FILE ... \n"); 430 printf(" =========================\n"); 431 fileio_print_free_heap(); 432 /* 433 * get number of ticks per second 434 */ 435 rtems_clock_get(RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticks_per_sec); 436 437 /* 438 * get path to file to read 439 */ 440 if (!failed) { 441 printf("Enter path/filename ==>"); 442 fgets(fname,sizeof(fname)-1,stdin); 443 while (fname[strlen(fname)-1] == '\n') { 444 fname[strlen(fname)-1] = '\0'; 445 } 446 if (0 == strlen(fname)) { 447 printf("*** no filename entered, aborted\n"); 448 failed = TRUE; 449 } 450 } 451 /* 452 * get block size to read 453 */ 454 if (!failed) { 455 printf("use suffix K for Kbytes, M for Mbytes or no suffix for bytes:\n" 456 "Enter block size to use for read calls ==>"); 457 fgets(tmp_str,sizeof(tmp_str)-1,stdin); 458 failed = fileio_str2size(tmp_str,&buf_size); 459 if (failed) { 460 printf("*** illegal block size, aborted\n"); 461 } 462 } 463 464 /* 465 * allocate buffer 466 */ 467 if (!failed) { 468 printf("... allocating %lu bytes of buffer for write data\n", 469 (unsigned long)buf_size); 470 bufptr = malloc(buf_size+1); /* extra space for terminating NUL char */ 471 if (bufptr == NULL) { 472 printf("*** malloc failed, aborted\n"); 473 failed = TRUE; 474 } 475 } 476 /* 477 * open file 478 */ 479 if (!failed) { 480 printf("... opening file \"%s\"\n",fname); 481 fd = open(fname,O_RDONLY); 482 if (fd < 0) { 483 printf("*** file open failed, errno = %d(%s)\n",errno,strerror(errno)); 484 failed = TRUE; 485 } 486 } 487 /* 488 * read file 489 */ 490 if (!failed) { 491 printf("... reading from file\n"); 492 rtems_clock_get (RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &start_tick); 493 curr_pos = 0; 494 do { 495 n = read(fd, 496 bufptr, 497 buf_size); 498 if (n > 0) { 499 curr_pos += n; 500 } 501 } while (n > 0); 502 rtems_clock_get (RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &curr_tick); 503 if (n < 0) { 504 failed = TRUE; 505 printf("*** file read failed, " 506 "%lu bytes read, " 507 "errno = %d(%s)\n", 508 (unsigned long)curr_pos,errno,strerror(errno)); 509 } 510 else { 511 printf("%lu bytes read\n", 512 (unsigned long)curr_pos); 513 printf("time elapsed for read: %g seconds\n", 514 ((double)curr_tick-start_tick)/ticks_per_sec); 515 printf("read data rate: %g KBytes/second\n", 516 (((double)curr_pos) / 1024.0 / 517 (((double)curr_tick-start_tick)/ticks_per_sec))); 518 } 519 } 520 if (fd >= 0) { 521 printf("... closing file\n"); 522 close(fd); 523 } 524 if (bufptr != NULL) { 525 printf("... deallocating buffer\n"); 526 free(bufptr); 527 bufptr = NULL; 528 } 529 printf("\n ******** End of file read\n"); 530 fileio_print_free_heap(); 531 532 } 533 534 void fileio_menu (void) 535 { 536 char inbuf[10]; 537 538 /* 539 * Wait for characters from console terminal 540 */ 541 for (;;) { 542 printf(" =========================\n"); 543 printf(" RTEMS FILE I/O Test Menu \n"); 544 printf(" =========================\n"); 545 printf(" p -> part_table_initialize\n"); 546 printf(" f -> mount all disks in fs_table\n"); 547 printf(" l -> list file\n"); 548 printf(" r -> read file\n"); 549 printf(" w -> write file\n"); 550 #ifdef USE_SHELL 551 printf(" s -> start shell\n"); 552 #endif 553 printf(" Enter your selection ==>"); 554 555 inbuf[0] = '\0'; 556 fgets(inbuf,sizeof(inbuf),stdin); 557 switch (inbuf[0]) { 558 case 'l': 559 fileio_list_file (); 560 break; 561 case 'r': 562 fileio_read_file (); 563 break; 564 case 'w': 565 fileio_write_file (); 566 break; 567 case 'p': 568 fileio_part_table_initialize (); 569 break; 570 case 'f': 571 fileio_fsmount (); 572 break; 573 #ifdef USE_SHELL 574 case 's': 575 fileio_start_shell (); 576 break; 577 #endif 578 default: 579 printf("Selection `%c` not implemented\n",inbuf[0]); 580 break; 581 } 582 583 } 584 exit (0); 585 } 586 587 int menu_tid; 588 589 /* 590 * RTEMS Startup Task 591 */ 592 rtems_task 593 Init (rtems_task_argument ignored) 594 { 595 puts( "\n\n*** FILE I/O SAMPLE AND TEST ***" ); 596 597 fileio_menu(); 598 } 599 -
c/src/tests/samples/fileio/system.h
diff -x '*~' -x Makefile.in -x configure.in -x configure -x autom4te.cache -P -r -u rtems-4.6.0pre1/c/src/tests/samples/fileio/system.h rtems-4.6.0pre1-ide/c/src/tests/samples/fileio/system.h
old new 1 /* system.h 2 * 3 * This include file contains information that is included in every 4 * function in the test set. 5 * 6 * COPYRIGHT (c) 1989-1999. 7 * On-Line Applications Research Corporation (OAR). 8 * 9 * The license and distribution terms for this file may be 10 * found in the file LICENSE in this distribution or at 11 * http://www.OARcorp.com/rtems/license.html. 12 * 13 * system.h,v 1.13 2000/06/12 15:00:12 joel Exp 14 */ 15 16 #include <rtems.h> 17 18 /* functions */ 19 20 rtems_task Init( 21 rtems_task_argument argument 22 ); 23 24 /* global variables */ 25 26 27 /* configuration information */ 28 29 #include <bsp.h> /* for device driver prototypes */ 30 #include <rtems/ata.h> /* for ata driver prototype */ 31 #include <libchip/ide_ctrl.h> /* for general ide driver prototype */ 32 33 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER 34 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER 35 #define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM 36 37 #define CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE 38 39 #ifdef CONFIGURE_INIT 40 rtems_driver_address_table Device_drivers[] = 41 { 42 CONSOLE_DRIVER_TABLE_ENTRY 43 ,CLOCK_DRIVER_TABLE_ENTRY 44 #ifdef RTEMS_BSP_HAS_IDE_DRIVER 45 ,IDE_CONTROLLER_DRIVER_TABLE_ENTRY 46 /* important: ATA driver must be after ide drivers */ 47 ,ATA_DRIVER_TABLE_ENTRY 48 #endif 49 }; 50 51 #include <rtems/bdbuf.h> 52 rtems_bdbuf_config rtems_bdbuf_configuration[] = { 53 {512,128,NULL} 54 }; 55 int rtems_bdbuf_configuration_size =( sizeof(rtems_bdbuf_configuration) 56 /sizeof(rtems_bdbuf_configuration[0])); 57 #endif 58 59 60 /* 61 * XXX: these values are higher than needed... 62 */ 63 #define CONFIGURE_MAXIMUM_TASKS 20 64 #define CONFIGURE_MAXIMUM_SEMAPHORES 20 65 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 20 66 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 20 67 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE 68 69 #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE) 70 71 #include <confdefs.h> 72 73 /* 74 * Handy macros and static inline functions 75 */ 76 77 /* 78 * Macro to hide the ugliness of printing the time. 79 */ 80 81 #define print_time(_s1, _tb, _s2) \ 82 do { \ 83 printf( "%s%02d:%02d:%02d %02d/%02d/%04d%s", \ 84 _s1, (_tb)->hour, (_tb)->minute, (_tb)->second, \ 85 (_tb)->month, (_tb)->day, (_tb)->year, _s2 ); \ 86 fflush(stdout); \ 87 } while ( 0 ) 88 89 /* 90 * Macro to print an task name that is composed of ASCII characters. 91 * 92 */ 93 94 #define put_name( _name, _crlf ) \ 95 do { \ 96 rtems_unsigned32 c0, c1, c2, c3; \ 97 \ 98 c0 = ((_name) >> 24) & 0xff; \ 99 c1 = ((_name) >> 16) & 0xff; \ 100 c2 = ((_name) >> 8) & 0xff; \ 101 c3 = (_name) & 0xff; \ 102 putchar( (char)c0 ); \ 103 if ( c1 ) putchar( (char)c1 ); \ 104 if ( c2 ) putchar( (char)c2 ); \ 105 if ( c3 ) putchar( (char)c3 ); \ 106 if ( (_crlf) ) \ 107 putchar( '\n' ); \ 108 } while (0) 109 110 /* 111 * static inline routine to make obtaining ticks per second easier. 112 */ 113 114 static inline rtems_unsigned32 get_ticks_per_second( void ) 115 { 116 rtems_interval ticks_per_second; 117 (void) rtems_clock_get( RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticks_per_second ); return ticks_per_second; 118 } 119 120 121 /* 122 * This allows us to view the "Test_task" instantiations as a set 123 * of numbered tasks by eliminating the number of application 124 * tasks created. 125 * 126 * In reality, this is too complex for the purposes of this 127 * example. It would have been easier to pass a task argument. :) 128 * But it shows how rtems_id's can sometimes be used. 129 */ 130 131 #define task_number( tid ) \ 132 ( rtems_get_index( tid ) - \ 133 rtems_configuration_get_rtems_api_configuration()->number_of_initialization_tasks ) 134 135 /* end of include file */ -
cpukit/libmisc/ChangeLog
diff -x '*~' -x Makefile.in -x configure.in -x configure -x autom4te.cache -P -r -u rtems-4.6.0pre1/cpukit/libmisc/ChangeLog rtems-4.6.0pre1-ide/cpukit/libmisc/ChangeLog
old new 1 2003-02-27 Thomas Doerfler <Thomas.Doerfler@imd-systems.de> 2 3 * fsmount/*: added fsmount module 4 * shell/cmds.c: DIR command should show "st_mtime" to work with DOSFS 5 1 6 2003-01-27 Dan Smisko <dan@balanced.com> 2 7 3 8 * stackchk/check.c: Fix problem where _Objects_Get_information() -
cpukit/libmisc/Makefile.am
diff -x '*~' -x Makefile.in -x configure.in -x configure -x autom4te.cache -P -r -u rtems-4.6.0pre1/cpukit/libmisc/Makefile.am rtems-4.6.0pre1-ide/cpukit/libmisc/Makefile.am
old new 5 5 ACLOCAL_AMFLAGS = -I ../aclocal 6 6 7 7 SUBDIRS = capture cpuuse devnull dummy dumpbuf monitor mw-fb shell \ 8 rtmonuse serdbg stackchk untar wrapup8 rtmonuse serdbg stackchk untar fsmount wrapup 9 9 10 10 EXTRA_DIST = README 11 11 -
cpukit/libmisc/configure.ac
diff -x '*~' -x Makefile.in -x configure.in -x configure -x autom4te.cache -P -r -u rtems-4.6.0pre1/cpukit/libmisc/configure.ac rtems-4.6.0pre1-ide/cpukit/libmisc/configure.ac
old new 71 71 stackchk/Makefile 72 72 capture/Makefile 73 73 untar/Makefile 74 fsmount/Makefile 74 75 mw-fb/Makefile 75 76 wrapup/Makefile 76 77 ]) -
cpukit/libmisc/fsmount/.cvsignore
diff -x '*~' -x Makefile.in -x configure.in -x configure -x autom4te.cache -P -r -u rtems-4.6.0pre1/cpukit/libmisc/fsmount/.cvsignore rtems-4.6.0pre1-ide/cpukit/libmisc/fsmount/.cvsignore
old new 1 Makefile 2 Makefile.in -
cpukit/libmisc/fsmount/Makefile.am
diff -x '*~' -x Makefile.in -x configure.in -x configure -x autom4te.cache -P -r -u rtems-4.6.0pre1/cpukit/libmisc/fsmount/Makefile.am rtems-4.6.0pre1-ide/cpukit/libmisc/fsmount/Makefile.am
old new 1 ## 2 ## Makefile.am,v 1.9 2002/08/11 05:51:17 ralf Exp 3 ## 4 5 6 include_rtemsdir = $(includedir)/rtems 7 8 LIBNAME = libfsmount 9 LIB = $(ARCH)/$(LIBNAME).a 10 11 C_FILES = fsmount.c 12 C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.$(OBJEXT)) 13 14 include_rtems_HEADERS = fsmount.h 15 16 OBJS = $(C_O_FILES) 17 18 include $(top_srcdir)/../automake/compile.am 19 include $(top_srcdir)/../automake/lib.am 20 21 $(PROJECT_INCLUDE)/rtems: 22 @$(mkinstalldirs) $@ 23 $(PROJECT_INCLUDE)/rtems/%.h: %.h 24 $(INSTALL_DATA) $< $@ 25 26 # 27 # (OPTIONAL) Add local stuff here using += 28 # 29 30 $(LIB): $(OBJS) 31 $(make-library) 32 33 PREINSTALL_FILES = $(PROJECT_INCLUDE)/rtems \ 34 $(include_rtems_HEADERS:%=$(PROJECT_INCLUDE)/rtems/%) 35 36 all-local: $(ARCH) $(PREINSTALL_FILES) $(OBJS) $(LIB) 37 38 .PRECIOUS: $(LIB) 39 40 EXTRA_DIST = README fsmount.c 41 42 include $(top_srcdir)/../automake/local.am -
cpukit/libmisc/fsmount/README
diff -x '*~' -x Makefile.in -x configure.in -x configure -x autom4te.cache -P -r -u rtems-4.6.0pre1/cpukit/libmisc/fsmount/README rtems-4.6.0pre1-ide/cpukit/libmisc/fsmount/README
old new 1 # 2 # 3 # fsmount information 4 # 5 # Author: Thomas Doerfler 02/07/2003 6 # 7 # README,v 1.1 1999/07/09 17:23:15 joel Exp 8 # 9 10 fsmount.c contains the function fsmount. It processes the 11 fs table given as an parameter to create the listed mount points 12 and mount the corresponding file systems to their mount points. 13 See "c/src/tests/samples/fileio" for a sample on how to use this 14 function. 15 16 The field "report_reasons" specifies, what results of the mount point 17 creation/mount operations should print to the console. 18 19 The field "abort_reasons" specifies, what results of the mount point 20 creation/mount operations should abort the function. Do not set the 21 "abort_reasons" bit, unless you want to stop the processing of the 22 fsmount table after the first successful mount. 23 -
cpukit/libmisc/fsmount/fsmount.c
diff -x '*~' -x Makefile.in -x configure.in -x configure -x autom4te.cache -P -r -u rtems-4.6.0pre1/cpukit/libmisc/fsmount/fsmount.c rtems-4.6.0pre1-ide/cpukit/libmisc/fsmount/fsmount.c
old new 1 /*===============================================================*\ 2 | Project: RTEMS fsmount | 3 +-----------------------------------------------------------------+ 4 | File: fsmount.c | 5 +-----------------------------------------------------------------+ 6 | Copyright (c) 2003 IMD | 7 | Ingenieurbuero fuer Microcomputertechnik Th. Doerfler | 8 | <Thomas.Doerfler@imd-systems.de> | 9 | all rights reserved | 10 +-----------------------------------------------------------------+ 11 | this file contains the fsmount functions. These functions | 12 | are used to mount a list of filesystems (and create their mount | 13 | points before) | 14 | | 15 | The license and distribution terms for this file may be | 16 | found in the file LICENSE in this distribution or at | 17 | http://www.OARcorp.com/rtems/license.html. | 18 | | 19 +-----------------------------------------------------------------+ 20 | date history ID | 21 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 22 | 02.07.03 creation doe | 23 \*===============================================================*/ 24 #include <rtems.h> 25 #include <rtems/fsmount.h> 26 #include <stdio.h> 27 #include <stdlib.h> 28 #include <string.h> 29 #include <errno.h> 30 #include <imfs.h> 31 #include <sys/stat.h> 32 33 /*=========================================================================*\ 34 | Function: | 35 \*-------------------------------------------------------------------------*/ 36 int rtems_fsmount_create_mountpoint 37 ( 38 /*-------------------------------------------------------------------------*\ 39 | Purpose: | 40 | This function will create the mount point given | 41 +---------------------------------------------------------------------------+ 42 | Input Parameters: | 43 \*-------------------------------------------------------------------------*/ 44 const char *mount_point 45 ) 46 /*-------------------------------------------------------------------------*\ 47 | Return Value: | 48 | 0, if success, -1 and errno if failed | 49 \*=========================================================================*/ 50 { 51 int rc = 0; 52 char *tok_buffer = NULL; 53 char *token = NULL; 54 int token_len; 55 size_t total_len; 56 IMFS_token_types token_type; 57 struct stat file_info; 58 /* 59 * allocate temp memory to rebuild path name 60 */ 61 tok_buffer = calloc(strlen(mount_point)+1,sizeof(char)); 62 token = tok_buffer; 63 total_len = 0; 64 do { 65 /* 66 * scan through given string, one segment at a time 67 */ 68 token_type = IMFS_get_token(mount_point+total_len,token,&token_len); 69 total_len += token_len; 70 strncpy(tok_buffer,mount_point,total_len); 71 tok_buffer[total_len] = '\0'; 72 73 if ((token_type != IMFS_NO_MORE_PATH) && 74 (token_type != IMFS_CURRENT_DIR) && 75 (token_type != IMFS_INVALID_TOKEN)) { 76 /* 77 * check, whether segment exists 78 */ 79 if (0 != stat(tok_buffer,&file_info)) { 80 /* 81 * if not, create directory 82 */ 83 rc = mknod(tok_buffer,S_IRWXU | S_IRWXG | S_IRWXO | S_IFDIR,0); 84 } 85 } 86 } while ((rc == 0) && 87 (token_type != IMFS_NO_MORE_PATH) && 88 (token_type != IMFS_INVALID_TOKEN)); 89 90 /* 91 * return token buffer to heap 92 */ 93 if (tok_buffer != NULL) { 94 free(tok_buffer); 95 } 96 return rc; 97 } 98 99 /*=========================================================================*\ 100 | Function: | 101 \*-------------------------------------------------------------------------*/ 102 int rtems_fsmount 103 ( 104 /*-------------------------------------------------------------------------*\ 105 | Purpose: | 106 | This function will create the mount points listed and mount the file | 107 | systems listed in the calling parameters | 108 +---------------------------------------------------------------------------+ 109 | Input Parameters: | 110 \*-------------------------------------------------------------------------*/ 111 const fstab_t *fstab_ptr, 112 int fstab_count, 113 int *fail_idx 114 ) 115 /*-------------------------------------------------------------------------*\ 116 | Return Value: | 117 | 0, if success, -1 and errno if failed | 118 \*=========================================================================*/ 119 { 120 int rc = 0; 121 int tmp_rc; 122 int fstab_idx = 0; 123 rtems_filesystem_mount_table_entry_t *tmp_mt_entry; 124 boolean terminate = FALSE; 125 126 /* 127 * scan through all fstab entries; 128 */ 129 while (!terminate && 130 (fstab_idx < fstab_count)) { 131 tmp_rc = 0; 132 /* 133 * create mount point 134 */ 135 if (tmp_rc == 0) { 136 tmp_rc = rtems_fsmount_create_mountpoint(fstab_ptr->mount_point); 137 if (tmp_rc != 0) { 138 if (0 != (fstab_ptr->report_reasons & FSMOUNT_MNTPNT_CRTERR)) { 139 printf("fsmount: creation of mount point \"%s\" failed: %s\n", 140 fstab_ptr->mount_point, 141 strerror(errno)); 142 } 143 if (0 != (fstab_ptr->abort_reasons & FSMOUNT_MNTPNT_CRTERR)) { 144 terminate = TRUE; 145 rc = tmp_rc; 146 } 147 } 148 } 149 /* 150 * mount device to given mount point 151 */ 152 if (tmp_rc == RTEMS_SUCCESSFUL) { 153 tmp_rc = mount(&tmp_mt_entry, 154 fstab_ptr->fs_ops, 155 fstab_ptr->mount_options, 156 fstab_ptr->dev, 157 fstab_ptr->mount_point); 158 if (tmp_rc != RTEMS_SUCCESSFUL) { 159 if (0 != (fstab_ptr->report_reasons & FSMOUNT_MNT_FAILED)) { 160 printf("fsmount: mounting of \"%s\" to" 161 " \"%s\" failed: %s\n", 162 fstab_ptr->dev, 163 fstab_ptr->mount_point, 164 strerror(errno)); 165 } 166 if (0 != (fstab_ptr->abort_reasons & FSMOUNT_MNT_FAILED)) { 167 terminate = TRUE; 168 rc = tmp_rc; 169 } 170 } 171 else { 172 if (0 != (fstab_ptr->report_reasons & FSMOUNT_MNT_OK)) { 173 printf("fsmount: mounting of \"%s\" to" 174 " \"%s\" succeeded\n", 175 fstab_ptr->dev, 176 fstab_ptr->mount_point); 177 } 178 if (0 != (fstab_ptr->abort_reasons & FSMOUNT_MNT_OK)) { 179 terminate = TRUE; 180 } 181 } 182 } 183 /* 184 * proceed to next entry 185 */ 186 if (!terminate) { 187 fstab_ptr++; 188 fstab_idx++; 189 } 190 } 191 if (fail_idx != NULL) { 192 *fail_idx = fstab_idx; 193 } 194 return rc; 195 } -
cpukit/libmisc/fsmount/fsmount.h
diff -x '*~' -x Makefile.in -x configure.in -x configure -x autom4te.cache -P -r -u rtems-4.6.0pre1/cpukit/libmisc/fsmount/fsmount.h rtems-4.6.0pre1-ide/cpukit/libmisc/fsmount/fsmount.h
old new 1 /*===============================================================*\ 2 | Project: RTEMS fsmount | 3 +-----------------------------------------------------------------+ 4 | File: fsmount.h | 5 +-----------------------------------------------------------------+ 6 | Copyright (c) 2003 IMD | 7 | Ingenieurbuero fuer Microcomputertechnik Th. Doerfler | 8 | <Thomas.Doerfler@imd-systems.de> | 9 | all rights reserved | 10 +-----------------------------------------------------------------+ 11 | this file contains the fsmount functions. These functions | 12 | are used to mount a list of filesystems (and create their mount | 13 | points before) | 14 | | 15 | The license and distribution terms for this file may be | 16 | found in the file LICENSE in this distribution or at | 17 | http://www.OARcorp.com/rtems/license.html. | 18 | | 19 +-----------------------------------------------------------------+ 20 | date history ID | 21 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 22 | 02.07.03 creation doe | 23 \*===============================================================*/ 24 #ifndef _FSMOUNT_H 25 #define _FSMOUNT_H 26 #include <rtems.h> 27 #include <rtems/libio.h> 28 #include <rtems/libcsupport.h> 29 30 /* 31 * bits to define, what errors will cause reporting (via printf) and 32 * abort of mount processing 33 * Use a combination of these bits 34 * for the fields "report_reasons" and "abort_reasons" 35 */ 36 #define FSMOUNT_MNT_OK 0x0001 /* mounted ok */ 37 #define FSMOUNT_MNTPNT_CRTERR 0x0002 /* cannot create mount point */ 38 #define FSMOUNT_MNT_FAILED 0x0004 /* mounting failed */ 39 40 typedef struct { 41 char *dev; 42 char *mount_point; 43 rtems_filesystem_operations_table *fs_ops; 44 rtems_filesystem_options_t mount_options; 45 unsigned16 report_reasons; 46 unsigned16 abort_reasons; 47 } fstab_t; 48 49 50 /*=========================================================================*\ 51 | Function: | 52 \*-------------------------------------------------------------------------*/ 53 int rtems_fsmount 54 ( 55 /*-------------------------------------------------------------------------*\ 56 | Purpose: | 57 | This function will create the mount points listed and mount the file | 58 | systems listed in the calling parameters | 59 +---------------------------------------------------------------------------+ 60 | Input Parameters: | 61 \*-------------------------------------------------------------------------*/ 62 const fstab_t *fstab_ptr, /* Ptr to filesystem mount table */ 63 int fstab_count, /* number of entries in mount table*/ 64 int *fail_idx /* return: index of failed entry */ 65 ); 66 /*-------------------------------------------------------------------------*\ 67 | Return Value: | 68 | 0, if success, -1 and errno if failed | 69 \*=========================================================================*/ 70 71 #endif /* _FSMOUNT_H */ -
cpukit/libmisc/shell/cmds.c
diff -x '*~' -x Makefile.in -x configure.in -x configure -x autom4te.cache -P -r -u rtems-4.6.0pre1/cpukit/libmisc/shell/cmds.c rtems-4.6.0pre1-ide/cpukit/libmisc/shell/cmds.c
old new 282 282 strcat(nbuf,dp->d_name); /* always the fullpathname. Avoid ftpd problem.*/ 283 283 if (stat(nbuf, &stat_buf) == 0) 284 284 { /* AWFUL buts works...*/ 285 strftime(sbuf,sizeof(sbuf)-1,"%b %d %H:%M",gmtime(&stat_buf.st_ atime));285 strftime(sbuf,sizeof(sbuf)-1,"%b %d %H:%M",gmtime(&stat_buf.st_mtime)); 286 286 pwd=getpwuid(stat_buf.st_uid); 287 287 user=pwd?pwd->pw_name:"nouser"; 288 288 grp=getgrgid(stat_buf.st_gid); -
cpukit/libmisc/wrapup/Makefile.am
diff -x '*~' -x Makefile.in -x configure.in -x configure -x autom4te.cache -P -r -u rtems-4.6.0pre1/cpukit/libmisc/wrapup/Makefile.am rtems-4.6.0pre1-ide/cpukit/libmisc/wrapup/Makefile.am
old new 28 28 TMP_LIBS += ../dummy/$(ARCH)/libdummy.a 29 29 TMP_LIBS += ../mw-fb/$(ARCH)/libmw-fb.a 30 30 TMP_LIBS += ../capture/$(ARCH)/libcapture.a 31 TMP_LIBS += ../fsmount/$(ARCH)/libfsmount.a 31 32 32 33 # 33 34 # (OPTIONAL) Add local stuff here using +=