Changeset b00dbb9 in mainline for uspace/srv/bd/file_bd/file_bd.c
- Timestamp:
- 2010-12-04T18:42:09Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3f45993
- Parents:
- 9ca0013 (diff), 35537a7 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/bd/file_bd/file_bd.c
r9ca0013 rb00dbb9 56 56 #define NAME "file_bd" 57 57 58 static const size_t block_size = 512; 58 #define DEFAULT_BLOCK_SIZE 512 59 60 static size_t block_size; 59 61 static aoff64_t num_blocks; 60 62 static FILE *img; … … 63 65 static fibril_mutex_t dev_lock; 64 66 67 static void print_usage(void); 65 68 static int file_bd_init(const char *fname); 66 69 static void file_bd_connection(ipc_callid_t iid, ipc_call_t *icall); … … 71 74 { 72 75 int rc; 76 char *image_name; 77 char *device_name; 73 78 74 79 printf(NAME ": File-backed block device driver\n"); 75 80 76 if (argc != 3) { 77 printf("Expected two arguments (image name, device name).\n"); 81 block_size = DEFAULT_BLOCK_SIZE; 82 83 ++argv; --argc; 84 while (*argv != NULL && (*argv)[0] == '-') { 85 /* Option */ 86 if (str_cmp(*argv, "-b") == 0) { 87 if (argc < 2) { 88 printf("Argument missing.\n"); 89 print_usage(); 90 return -1; 91 } 92 93 rc = str_size_t(argv[1], NULL, 10, true, &block_size); 94 if (rc != EOK || block_size == 0) { 95 printf("Invalid block size '%s'.\n", argv[1]); 96 print_usage(); 97 return -1; 98 } 99 ++argv; --argc; 100 } else { 101 printf("Invalid option '%s'.\n", *argv); 102 print_usage(); 103 return -1; 104 } 105 ++argv; --argc; 106 } 107 108 if (argc < 2) { 109 printf("Missing arguments.\n"); 110 print_usage(); 78 111 return -1; 79 112 } 80 113 81 if (file_bd_init(argv[1]) != EOK) 114 image_name = argv[0]; 115 device_name = argv[1]; 116 117 if (file_bd_init(image_name) != EOK) 82 118 return -1; 83 119 84 rc = devmap_device_register( argv[2], &devmap_handle);120 rc = devmap_device_register(device_name, &devmap_handle); 85 121 if (rc != EOK) { 86 122 devmap_hangup_phone(DEVMAP_DRIVER); 87 printf(NAME ": Unable to register device %s.\n",88 argv[2]);123 printf(NAME ": Unable to register device '%s'.\n", 124 device_name); 89 125 return rc; 90 126 } … … 96 132 /* Not reached */ 97 133 return 0; 134 } 135 136 static void print_usage(void) 137 { 138 printf("Usage: " NAME " [-b <block_size>] <image_file> <device_name>\n"); 98 139 } 99 140
Note:
See TracChangeset
for help on using the changeset viewer.