File indexing completed on 2025-05-11 08:24:19
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifdef HAVE_CONFIG_H
0016 #include "config.h"
0017 #endif
0018
0019 #include <stdio.h>
0020 #include <unistd.h>
0021 #include <string.h>
0022 #include <errno.h>
0023 #include <fcntl.h>
0024
0025 #include <rtems.h>
0026 #include <rtems/shell.h>
0027 #include <rtems/bdbuf.h>
0028 #include <rtems/blkdev.h>
0029 #include "internal.h"
0030
0031 static int rtems_shell_main_blksync(
0032 int argc,
0033 char *argv[]
0034 )
0035 {
0036 const char* driver = NULL;
0037 int arg;
0038 int fd;
0039
0040 for (arg = 1; arg < argc; arg++) {
0041 if (argv[arg][0] == '-') {
0042 fprintf( stderr, "%s: invalid option: %s\n", argv[0], argv[arg]);
0043 return 1;
0044 } else {
0045 if (!driver)
0046 driver = argv[arg];
0047 else {
0048 fprintf( stderr, "%s: only one driver name allowed: %s\n",
0049 argv[0], argv[arg]);
0050 return 1;
0051 }
0052 }
0053 }
0054
0055 fd = open (driver, O_WRONLY, 0);
0056 if (fd < 0) {
0057 fprintf( stderr, "%s: driver open failed: %s\n", argv[0], strerror (errno));
0058 return 1;
0059 }
0060
0061 if (rtems_disk_fd_sync (fd) < 0) {
0062 fprintf( stderr, "%s: driver sync failed: %s\n", argv[0], strerror (errno));
0063 close (fd);
0064 return 1;
0065 }
0066
0067 close (fd);
0068 return 0;
0069 }
0070
0071 rtems_shell_cmd_t rtems_shell_BLKSYNC_Command = {
0072 "blksync",
0073 "blksync driver # sync the block driver",
0074 "files",
0075 rtems_shell_main_blksync,
0076 NULL,
0077 NULL
0078 };