Changeset bd5f3b7 in mainline for uspace/app/bdsh/cmds


Ignore:
Timestamp:
2011-08-21T13:07:35Z (15 years ago)
Author:
Jakub Jermar <jakub@…>
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.
Message:

Merge mainline changes.

Location:
uspace/app/bdsh/cmds/modules
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/cmds/modules/bdd/bdd.c

    r86a34d3e rbd5f3b7  
    3939
    4040#include <libblock.h>
    41 #include <devmap.h>
     41#include <loc.h>
    4242#include <errno.h>
    4343#include <assert.h>
     
    6969        unsigned int argc;
    7070        unsigned int i, j;
    71         devmap_handle_t handle;
     71        service_id_t service_id;
    7272        aoff64_t offset;
    7373        uint8_t *blk;
     
    9696                size = 256;
    9797
    98         rc = devmap_device_get_handle(argv[1], &handle, 0);
     98        rc = loc_service_get_id(argv[1], &service_id, 0);
    9999        if (rc != EOK) {
    100100                printf("%s: Error resolving device `%s'.\n", cmdname, argv[1]);
     
    102102        }
    103103
    104         rc = block_init(EXCHANGE_SERIALIZE, handle, 2048);
     104        rc = block_init(EXCHANGE_SERIALIZE, service_id, 2048);
    105105        if (rc != EOK)  {
    106106                printf("%s: Error initializing libblock.\n", cmdname);
     
    108108        }
    109109
    110         rc = block_get_bsize(handle, &block_size);
     110        rc = block_get_bsize(service_id, &block_size);
    111111        if (rc != EOK) {
    112112                printf("%s: Error determining device block size.\n", cmdname);
     
    117117        if (blk == NULL) {
    118118                printf("%s: Error allocating memory.\n", cmdname);
    119                 block_fini(handle);
     119                block_fini(service_id);
    120120                return CMD_FAILURE;
    121121        }
     
    124124
    125125        while (size > 0) {
    126                 rc = block_read_direct(handle, ba, 1, blk);
     126                rc = block_read_direct(service_id, ba, 1, blk);
    127127                if (rc != EOK) {
    128128                        printf("%s: Error reading block %" PRIuOFF64 "\n", cmdname, ba);
    129129                        free(blk);
    130                         block_fini(handle);
     130                        block_fini(service_id);
    131131                        return CMD_FAILURE;
    132132                }
     
    170170
    171171        free(blk);
    172         block_fini(handle);
     172        block_fini(service_id);
    173173
    174174        return CMD_SUCCESS;
  • uspace/app/bdsh/cmds/modules/cp/cp.c

    r86a34d3e rbd5f3b7  
    7171        size_t blen, int vb)
    7272{
    73         int fd1, fd2, bytes = 0;
    74         off64_t total = 0;
     73        int fd1, fd2, bytes;
     74        off64_t total;
    7575        int64_t copied = 0;
    7676        char *buff = NULL;
     
    104104        }
    105105
    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)
    112108                        break;
    113109                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 have
    119                          * 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 shell
    130                  */
    131                 if (res != 0) {
    132                         printf("\n%zd more bytes than actually exist were copied\n", res);
    133                         goto err;
    134                 }
    135110        }
    136111
    137112        if (bytes < 0) {
    138 err:
    139113                printf("\nError copying %s, (%d)\n", src, bytes);
    140114                copied = bytes;
  • uspace/app/bdsh/cmds/modules/help/help.c

    r86a34d3e rbd5f3b7  
    11/*
    22 * Copyright (c) 2008 Tim Post
     3 * Copyright (c) 2011 Martin Sucha
    34 * All rights reserved.
    45 *
     
    3031#include <stdlib.h>
    3132#include <str.h>
     33#include <fmtutil.h>
    3234
    3335#include "config.h"
     
    128130static void help_survival(void)
    129131{
    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 "
    133136            "the primary user interface to HelenOS. Bdsh allows you to enter "
    134137            "commands and supports history (Up, Down arrow keys), "
    135138            "line editing (Left Arrow, Right Arrow, Home, End, Backspace), "
    136139            "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 "
    140143            "'help commands' [Enter] to see the list of Bdsh builtin commands. "
    141144            "Other commands are external executables located in the /app and "
    142145            "/srv directories. Type 'ls /app' [Enter] and 'ls /srv' [Enter] "
    143146            "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. "
    150153            "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);
    152156}
    153157
  • uspace/app/bdsh/cmds/modules/ls/ls.c

    r86a34d3e rbd5f3b7  
    169169               
    170170                /* 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);
    172172                if (!tosort[nbdirs].name) {
    173173                        cli_error(CL_ENOMEM, "ls: failed to scan %s", d);
    174174                        goto out;
    175175                }
    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);
    178178                len = snprintf(buff, PATH_MAX - 1, "%s/%s", d, tosort[nbdirs].name);
    179179                buff[len] = '\0';
Note: See TracChangeset for help on using the changeset viewer.