Changeset bd5f3b7 in mainline for uspace/app/bdsh/cmds
- Timestamp:
- 2011-08-21T13:07:35Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 00aece0, f1a9e87
- Parents:
- 86a34d3e (diff), a6480d5 (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:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/modules/bdd/bdd.c
r86a34d3e rbd5f3b7 39 39 40 40 #include <libblock.h> 41 #include < devmap.h>41 #include <loc.h> 42 42 #include <errno.h> 43 43 #include <assert.h> … … 69 69 unsigned int argc; 70 70 unsigned int i, j; 71 devmap_handle_t handle;71 service_id_t service_id; 72 72 aoff64_t offset; 73 73 uint8_t *blk; … … 96 96 size = 256; 97 97 98 rc = devmap_device_get_handle(argv[1], &handle, 0);98 rc = loc_service_get_id(argv[1], &service_id, 0); 99 99 if (rc != EOK) { 100 100 printf("%s: Error resolving device `%s'.\n", cmdname, argv[1]); … … 102 102 } 103 103 104 rc = block_init(EXCHANGE_SERIALIZE, handle, 2048);104 rc = block_init(EXCHANGE_SERIALIZE, service_id, 2048); 105 105 if (rc != EOK) { 106 106 printf("%s: Error initializing libblock.\n", cmdname); … … 108 108 } 109 109 110 rc = block_get_bsize( handle, &block_size);110 rc = block_get_bsize(service_id, &block_size); 111 111 if (rc != EOK) { 112 112 printf("%s: Error determining device block size.\n", cmdname); … … 117 117 if (blk == NULL) { 118 118 printf("%s: Error allocating memory.\n", cmdname); 119 block_fini( handle);119 block_fini(service_id); 120 120 return CMD_FAILURE; 121 121 } … … 124 124 125 125 while (size > 0) { 126 rc = block_read_direct( handle, ba, 1, blk);126 rc = block_read_direct(service_id, ba, 1, blk); 127 127 if (rc != EOK) { 128 128 printf("%s: Error reading block %" PRIuOFF64 "\n", cmdname, ba); 129 129 free(blk); 130 block_fini( handle);130 block_fini(service_id); 131 131 return CMD_FAILURE; 132 132 } … … 170 170 171 171 free(blk); 172 block_fini( handle);172 block_fini(service_id); 173 173 174 174 return CMD_SUCCESS; -
uspace/app/bdsh/cmds/modules/cp/cp.c
r86a34d3e rbd5f3b7 71 71 size_t blen, int vb) 72 72 { 73 int fd1, fd2, bytes = 0;74 off64_t total = 0;73 int fd1, fd2, bytes; 74 off64_t total; 75 75 int64_t copied = 0; 76 76 char *buff = NULL; … … 104 104 } 105 105 106 for (;;) { 107 ssize_t res; 108 size_t written = 0; 109 110 bytes = read(fd1, buff, blen); 111 if (bytes <= 0) 106 while ((bytes = read_all(fd1, buff, blen)) > 0) { 107 if ((bytes = write_all(fd2, buff, bytes)) < 0) 112 108 break; 113 109 copied += bytes; 114 res = bytes;115 do {116 /*117 * Theoretically, it may not be enough to call write()118 * only once. Also the previous read() may have119 * returned less data than requested.120 */121 bytes = write(fd2, buff + written, res);122 if (bytes < 0)123 goto err;124 written += bytes;125 res -= bytes;126 } while (res > 0);127 128 /* TODO: re-insert assert() once this is stand alone,129 * removed as abort() exits the entire shell130 */131 if (res != 0) {132 printf("\n%zd more bytes than actually exist were copied\n", res);133 goto err;134 }135 110 } 136 111 137 112 if (bytes < 0) { 138 err:139 113 printf("\nError copying %s, (%d)\n", src, bytes); 140 114 copied = bytes; -
uspace/app/bdsh/cmds/modules/help/help.c
r86a34d3e rbd5f3b7 1 1 /* 2 2 * Copyright (c) 2008 Tim Post 3 * Copyright (c) 2011 Martin Sucha 3 4 * All rights reserved. 4 5 * … … 30 31 #include <stdlib.h> 31 32 #include <str.h> 33 #include <fmtutil.h> 32 34 33 35 #include "config.h" … … 128 130 static void help_survival(void) 129 131 { 130 printf("Don't panic!\n\n"); 131 132 printf("This is Bdsh, the Brain dead shell, currently " 132 print_wrapped_console( 133 "Don't panic!\n\n" 134 135 "This is Bdsh, the Brain dead shell, currently " 133 136 "the primary user interface to HelenOS. Bdsh allows you to enter " 134 137 "commands and supports history (Up, Down arrow keys), " 135 138 "line editing (Left Arrow, Right Arrow, Home, End, Backspace), " 136 139 "selection (Shift + movement keys), copy and paste (Ctrl-C, " 137 "Ctrl-V), similar to common desktop environments.\n\n" );138 139 printf("The most basic filesystem commands are Bdsh builtins. Type "140 "Ctrl-V), similar to common desktop environments.\n\n" 141 142 "The most basic filesystem commands are Bdsh builtins. Type " 140 143 "'help commands' [Enter] to see the list of Bdsh builtin commands. " 141 144 "Other commands are external executables located in the /app and " 142 145 "/srv directories. Type 'ls /app' [Enter] and 'ls /srv' [Enter] " 143 146 "to see their list. You can execute an external command simply " 144 "by entering its name (e.g. type 'tetris' [Enter]).\n\n" );145 146 printf("HelenOS has virtual consoles (VCs). You can switch between "147 "these using the F1-F11 keys.\n\n" );148 149 printf("This is but a small glimpse of what you can do with HelenOS. "147 "by entering its name (e.g. type 'tetris' [Enter]).\n\n" 148 149 "HelenOS has virtual consoles (VCs). You can switch between " 150 "these using the F1-F11 keys.\n\n" 151 152 "This is but a small glimpse of what you can do with HelenOS. " 150 153 "To learn more please point your browser to the HelenOS User's " 151 "Guide: http://trac.helenos.org/trac.fcgi/wiki/UsersGuide\n\n"); 154 "Guide: http://trac.helenos.org/trac.fcgi/wiki/UsersGuide\n\n", 155 ALIGN_LEFT); 152 156 } 153 157 -
uspace/app/bdsh/cmds/modules/ls/ls.c
r86a34d3e rbd5f3b7 169 169 170 170 /* fill the name field */ 171 tosort[nbdirs].name = (char *) malloc(str_ length(dp->d_name) + 1);171 tosort[nbdirs].name = (char *) malloc(str_size(dp->d_name) + 1); 172 172 if (!tosort[nbdirs].name) { 173 173 cli_error(CL_ENOMEM, "ls: failed to scan %s", d); 174 174 goto out; 175 175 } 176 177 str_cpy(tosort[nbdirs].name, str_ length(dp->d_name) + 1, dp->d_name);176 177 str_cpy(tosort[nbdirs].name, str_size(dp->d_name) + 1, dp->d_name); 178 178 len = snprintf(buff, PATH_MAX - 1, "%s/%s", d, tosort[nbdirs].name); 179 179 buff[len] = '\0';
Note:
See TracChangeset
for help on using the changeset viewer.
