Changeset 1db44ea7 in mainline for uspace/app/bdsh/cmds/modules
- Timestamp:
- 2011-09-25T18:46:45Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 36cb22f
- Parents:
- dcc44ca1 (diff), f9d8c3a (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. - Location:
- uspace/app/bdsh/cmds/modules
- Files:
-
- 2 edited
-
mkfile/mkfile.c (modified) (6 diffs)
-
mount/mount.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/modules/mkfile/mkfile.c
rdcc44ca1 r1db44ea7 54 54 static struct option const long_options[] = { 55 55 {"size", required_argument, 0, 's'}, 56 {"sparse", no_argument, 0, 'p'}, 56 57 {"help", no_argument, 0, 'h'}, 57 58 {0, 0, 0, 0} … … 69 70 " -h, --help A short option summary\n" 70 71 " -s, --size sz Size of the file\n" 72 " -p, --sparse Create a sparse file\n" 71 73 "\n" 72 74 "Size is a number followed by 'k', 'm' or 'g' for kB, MB, GB.\n" … … 115 117 ssize_t file_size; 116 118 ssize_t total_written; 117 ssize_t to_write, rc ;119 ssize_t to_write, rc, rc2 = 0; 118 120 char *file_name; 119 121 void *buffer; 122 bool create_sparse = false; 120 123 121 124 file_size = 0; … … 124 127 125 128 for (c = 0, optind = 0, opt_ind = 0; c != -1;) { 126 c = getopt_long(argc, argv, " s:h", long_options, &opt_ind);129 c = getopt_long(argc, argv, "ps:h", long_options, &opt_ind); 127 130 switch (c) { 128 131 case 'h': 129 132 help_cmd_mkfile(HELP_LONG); 130 133 return CMD_SUCCESS; 134 case 'p': 135 create_sparse = true; 136 break; 131 137 case 's': 132 138 file_size = read_size(optarg); … … 154 160 printf("%s: failed to create file %s.\n", cmdname, file_name); 155 161 return CMD_FAILURE; 162 } 163 164 if (create_sparse && file_size > 0) { 165 const char byte = 0x00; 166 167 if ((rc2 = lseek(fd, file_size - 1, SEEK_SET)) < 0) 168 goto exit; 169 170 rc2 = write(fd, &byte, sizeof(char)); 171 goto exit; 156 172 } 157 173 … … 174 190 } 175 191 192 free(buffer); 193 exit: 176 194 rc = close(fd); 177 if (rc != 0) { 195 196 if (rc != 0 || rc2 < 0) { 178 197 printf("%s: Error writing file (%zd).\n", cmdname, rc); 179 198 return CMD_FAILURE; 180 199 } 181 182 free(buffer);183 200 184 201 return CMD_SUCCESS; -
uspace/app/bdsh/cmds/modules/mount/mount.c
rdcc44ca1 r1db44ea7 43 43 static struct option const long_options[] = { 44 44 { "help", no_argument, 0, 'h' }, 45 { "instance", required_argument, 0, 'i' }, 45 46 { 0, 0, 0, 0 } 46 47 }; … … 68 69 const char *dev = ""; 69 70 int rc, c, opt_ind; 71 unsigned int instance = 0; 72 bool instance_set = false; 73 char **t_argv; 70 74 71 75 argc = cli_count_args(argv); 72 76 73 77 for (c = 0, optind = 0, opt_ind = 0; c != -1;) { 74 c = getopt_long(argc, argv, " h", long_options, &opt_ind);78 c = getopt_long(argc, argv, "i:h", long_options, &opt_ind); 75 79 switch (c) { 76 80 case 'h': 77 81 help_cmd_mount(HELP_LONG); 78 82 return CMD_SUCCESS; 83 case 'i': 84 instance = (unsigned int) strtol(optarg, NULL, 10); 85 instance_set = true; 86 break; 79 87 } 80 88 } 89 90 if (instance_set) { 91 argc -= 2; 92 t_argv = &argv[2]; 93 } else 94 t_argv = &argv[0]; 81 95 82 96 if ((argc < 3) || (argc > 5)) { … … 86 100 } 87 101 if (argc > 3) 88 dev = argv[3];102 dev = t_argv[3]; 89 103 if (argc == 5) 90 mopts = argv[4];104 mopts = t_argv[4]; 91 105 92 rc = mount( argv[1], argv[2], dev, mopts, 0);106 rc = mount(t_argv[1], t_argv[2], dev, mopts, 0, instance); 93 107 if (rc != EOK) { 94 108 printf("Unable to mount %s filesystem to %s on %s (rc=%d)\n", 95 argv[1], argv[2],argv[3], rc);109 t_argv[1], t_argv[2], t_argv[3], rc); 96 110 return CMD_FAILURE; 97 111 }
Note:
See TracChangeset
for help on using the changeset viewer.
