Changeset 9b0a6b4 in mainline for uspace/app


Ignore:
Timestamp:
2012-04-13T06:36:25Z (14 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
90f067d9
Parents:
e61aa80 (diff), d11a181 (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
Files:
10 edited

Legend:

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

    re61aa80 r9b0a6b4  
    5252#define CAT_VERSION "0.0.1"
    5353#define CAT_DEFAULT_BUFLEN 1024
    54 
    55 static const char *cat_oops = "That option is not yet supported\n";
     54#define CAT_FULL_FILE 0
     55
    5656static const char *hexchars = "0123456789abcdef";
    5757
     
    163163}
    164164
    165 static unsigned int cat_file(const char *fname, size_t blen, bool hex)
     165static unsigned int cat_file(const char *fname, size_t blen, bool hex,
     166    off64_t head, off64_t tail, bool tail_first)
    166167{
    167168        int fd, bytes = 0, count = 0, reads = 0;
    168169        char *buff = NULL;
    169170        int i;
    170         size_t offset = 0;
     171        size_t offset = 0, copied_bytes = 0;
     172        off64_t file_size = 0, length = 0;
    171173
    172174        fd = open(fname, O_RDONLY);
     
    183185        }
    184186
     187        if (tail != CAT_FULL_FILE) {
     188                file_size = lseek(fd, 0, SEEK_END);
     189                if (head == CAT_FULL_FILE) {
     190                        head = file_size;
     191                        length = tail;
     192                } else if (tail_first) {
     193                        length = head;
     194                } else {
     195                        if (tail > head)
     196                                tail = head;
     197                        length = tail;
     198                }
     199
     200                if (tail_first) {
     201                        lseek(fd, (tail >= file_size) ? 0 : (file_size - tail), SEEK_SET);
     202                } else {
     203                        lseek(fd, ((head - tail) >= file_size) ? 0 : (head - tail), SEEK_SET);
     204                }
     205        } else
     206                length = head;
     207
    185208        do {
    186                 bytes = read(fd, buff, blen);
     209                bytes = read(fd, buff + copied_bytes, (
     210                        (length != CAT_FULL_FILE && length - (off64_t)count <= (off64_t)(blen - copied_bytes)) ?
     211                        (size_t)(length - count) :
     212                        (blen - copied_bytes) ) );
     213                bytes += copied_bytes;
     214                copied_bytes = 0;
     215
    187216                if (bytes > 0) {
    188                         count += bytes;
    189217                        buff[bytes] = '\0';
    190218                        offset = 0;
     
    193221                                        paged_char(hexchars[((uint8_t)buff[i])/16]);
    194222                                        paged_char(hexchars[((uint8_t)buff[i])%16]);
     223                                        paged_char(((count+i+1) & 0xf) == 0 ? '\n' : ' ');
    195224                                }
    196225                                else {
     
    199228                                                /* Reached end of string */
    200229                                                break;
     230                                        } else if (c == U_SPECIAL && offset + 2 >= (size_t)bytes) {
     231                                                /* If an extended character is cut off due to the size of the buffer,
     232                                                   we will copy it over to the next buffer so it can be read correctly. */
     233                                                copied_bytes = bytes - offset + 1;
     234                                                memcpy(buff, buff + offset - 1, copied_bytes);
     235                                                break;
    201236                                        }
    202237                                        paged_char(c);
     
    204239                               
    205240                        }
     241                        count += bytes;
    206242                        reads++;
    207243                }
    208         } while (bytes > 0 && !should_quit);
     244        } while (bytes > 0 && !should_quit && (count < length || length == CAT_FULL_FILE));
    209245
    210246        close(fd);
     
    223259int cmd_cat(char **argv)
    224260{
    225         unsigned int argc, i, ret = 0, buffer = 0;
     261        unsigned int argc, i, ret = 0;
     262        size_t buffer = 0;
    226263        int c, opt_ind;
     264        aoff64_t head = CAT_FULL_FILE, tail = CAT_FULL_FILE;
    227265        bool hex = false;
    228266        bool more = false;
     267        bool tailFirst = false;
    229268        sysarg_t rows, cols;
    230269        int rc;
     
    254293                        return CMD_SUCCESS;
    255294                case 'H':
    256                         printf("%s", cat_oops);
    257                         return CMD_FAILURE;
     295                        if (!optarg || str_uint64_t(optarg, NULL, 10, false, &head) != EOK ) {
     296                                puts("Invalid head size\n");
     297                                return CMD_FAILURE;
     298                        }
     299                        break;
    258300                case 't':
    259                         printf("%s", cat_oops);
    260                         return CMD_FAILURE;
     301                        if (!optarg || str_uint64_t(optarg, NULL, 10, false, &tail) != EOK ) {
     302                                puts("Invalid tail size\n");
     303                                return CMD_FAILURE;
     304                        }
     305                        if (head == CAT_FULL_FILE)
     306                                tailFirst = true;
     307                        break;
    261308                case 'b':
    262                         printf("%s", cat_oops);
     309                        if (!optarg || str_size_t(optarg, NULL, 10, false, &buffer) != EOK ) {
     310                                puts("Invalid buffer size\n");
     311                                return CMD_FAILURE;
     312                        }
    263313                        break;
    264314                case 'm':
     
    279329        }
    280330
    281         if (buffer <= 0)
     331        if (buffer < 4)
    282332                buffer = CAT_DEFAULT_BUFLEN;
    283333       
     
    295345
    296346        for (i = optind; argv[i] != NULL && !should_quit; i++)
    297                 ret += cat_file(argv[i], buffer, hex);
     347                ret += cat_file(argv[i], buffer, hex, head, tail, tailFirst);
    298348
    299349        if (ret)
  • uspace/app/bdsh/cmds/modules/cat/cat.h

    re61aa80 r9b0a6b4  
    44/* Prototypes for the cat command, excluding entry points */
    55
    6 static unsigned int cat_file(const char *, size_t, bool);
     6static unsigned int cat_file(const char *, size_t, bool, off64_t, off64_t, bool);
    77
    88#endif /* CAT_H */
  • uspace/app/binutils/Makefile

    re61aa80 r9b0a6b4  
    112112endif
    113113ifeq ($(PLATFORM),arm32)
    114 TARGET = arm-linux-gnu
     114TARGET = arm-linux-gnueabi
    115115endif
    116116ifeq ($(PLATFORM),ia32)
  • uspace/app/getterm/Makefile

    re61aa80 r9b0a6b4  
    2929
    3030USPACE_PREFIX = ../..
    31 DEFS = -DRELEASE=$(RELEASE) "-DNAME=$(NAME)"
     31DEFS = -DRELEASE=$(RELEASE) "-DCOPYRIGHT=$(COPYRIGHT)" "-DNAME=$(NAME)"
    3232BINARY = getterm
    3333
  • uspace/app/getterm/version.c

    re61aa80 r9b0a6b4  
    4040#include "version.h"
    4141
     42static const char *copyright = STRING(COPYRIGHT);
    4243static const char *release = STRING(RELEASE);
    4344static const char *name = STRING(NAME);
     
    6162        printf("HelenOS release %s (%s)%s%s\n", release, name, revision, timestamp);
    6263        printf("Running on %s (%s)\n", arch, term);
    63         printf("Copyright (c) 2001-2011 HelenOS project\n\n");
     64        printf("%s\n\n", copyright);
    6465}
    6566
  • uspace/app/sbi/src/run_texpr.c

    re61aa80 r9b0a6b4  
    9898{
    9999        stree_symbol_t *sym;
    100         tdata_item_t *targ_i;
    101         tdata_item_t *titem;
     100        tdata_item_t *targ_i = NULL;
     101        tdata_item_t *titem = NULL;;
    102102        tdata_object_t *tobject;
    103103        tdata_deleg_t *tdeleg;
     
    139139                return;
    140140        }
    141 
    142         /* Make compiler happy. */
    143         titem = NULL;
    144141
    145142        switch (sym->sc) {
     
    222219    stree_tindex_t *tindex, tdata_item_t **res)
    223220{
    224         tdata_item_t *base_ti;
     221        tdata_item_t *base_ti = NULL;
    225222        tdata_item_t *titem;
    226223        tdata_array_t *tarray;
  • uspace/app/sportdmp/sportdmp.c

    re61aa80 r9b0a6b4  
    2727 */
    2828
     29#include <device/char_dev.h>
    2930#include <errno.h>
     31#include <ipc/serial_ctl.h>
     32#include <loc.h>
    3033#include <stdio.h>
    31 #include <devman.h>
    32 #include <ipc/devman.h>
    33 #include <device/char_dev.h>
    34 #include <ipc/serial_ctl.h>
    3534
    3635#define BUF_SIZE 1
    3736
    38 static void syntax_print() {
    39         fprintf(stderr, "Usage: sportdmp <baud> <device_path>\n");
     37static void syntax_print(void)
     38{
     39        fprintf(stderr, "Usage: sportdmp <baud> <device_service>\n");
    4040}
    4141
    4242int main(int argc, char **argv)
    4343{
    44         const char* devpath = "/hw/pci0/00:01.0/com1/a";
     44        const char* svc_path = "devices/\\hw\\pci0\\00:01.0\\com1\\a";
    4545        sysarg_t baud = 9600;
    4646       
     
    5656       
    5757        if (argc > 2) {
    58                 devpath = argv[2];
     58                svc_path = argv[2];
    5959        }
    6060       
     
    6464        }
    6565       
    66         devman_handle_t device;
    67         int rc = devman_fun_get_handle(devpath, &device, IPC_FLAG_BLOCKING);
     66        service_id_t svc_id;
     67        int rc = loc_service_get_id(svc_path, &svc_id, IPC_FLAG_BLOCKING);
    6868        if (rc != EOK) {
    69                 fprintf(stderr, "Cannot open device %s\n", devpath);
     69                fprintf(stderr, "Cannot find device service %s\n", svc_path);
    7070                return 1;
    7171        }
    7272       
    73         async_sess_t *sess = devman_device_connect(EXCHANGE_SERIALIZE, device,
     73        async_sess_t *sess = loc_service_connect(EXCHANGE_SERIALIZE, svc_id,
    7474            IPC_FLAG_BLOCKING);
    7575        if (!sess) {
    76                 fprintf(stderr, "Cannot connect device\n");
     76                fprintf(stderr, "Failed connecting to service %s\n", svc_path);
    7777        }
    7878       
     
    8383       
    8484        if (rc != EOK) {
    85                 fprintf(stderr, "Cannot set serial properties\n");
     85                fprintf(stderr, "Failed setting serial properties\n");
    8686                return 2;
    8787        }
     
    8989        uint8_t *buf = (uint8_t *) malloc(BUF_SIZE);
    9090        if (buf == NULL) {
    91                 fprintf(stderr, "Cannot allocate buffer\n");
     91                fprintf(stderr, "Failed allocating buffer\n");
    9292                return 3;
    9393        }
  • uspace/app/tester/fault/fault2.c

    re61aa80 r9b0a6b4  
    3535const char *test_fault2(void)
    3636{
    37         volatile long long var;
    38         volatile int var1;
    39        
    40         var1 = *((aliasing_int *) (((char *) (&var)) + 1));
     37        volatile long long var = 0;
     38        volatile int var1 = *((aliasing_int *) (((char *) (&var)) + 1));
    4139        printf("Read %d\n", var1);
    4240       
  • uspace/app/tester/hw/serial/serial1.c

    re61aa80 r9b0a6b4  
    4242#include <async.h>
    4343#include <ipc/services.h>
    44 #include <ipc/devman.h>
    45 #include <devman.h>
     44#include <loc.h>
    4645#include <device/char_dev.h>
    4746#include <str.h>
     
    7170                }
    7271       
    73         devman_handle_t handle;
    74         int res = devman_fun_get_handle("/hw/pci0/00:01.0/com1/a", &handle,
    75             IPC_FLAG_BLOCKING);
     72        service_id_t svc_id;
     73        int res = loc_service_get_id("devices/\\hw\\pci0\\00:01.0\\com1\\a",
     74            &svc_id, IPC_FLAG_BLOCKING);
    7675        if (res != EOK)
    77                 return "Could not get serial device handle";
    78        
    79         async_sess_t *sess = devman_device_connect(EXCHANGE_SERIALIZE, handle,
     76                return "Failed getting serial port service ID";
     77       
     78        async_sess_t *sess = loc_service_connect(EXCHANGE_SERIALIZE, svc_id,
    8079            IPC_FLAG_BLOCKING);
    8180        if (!sess)
    82                 return "Unable to connect to serial device";
     81                return "Failed connecting to serial device";
    8382       
    8483        char *buf = (char *) malloc(cnt + 1);
    8584        if (buf == NULL) {
    8685                async_hangup(sess);
    87                 return "Failed to allocate input buffer";
     86                return "Failed allocating input buffer";
    8887        }
    8988       
     
    112111                free(buf);
    113112                async_hangup(sess);
    114                 return "Failed to set serial communication parameters";
    115         }
    116        
    117         TPRINTF("Trying to read %zu characters from serial device "
    118             "(handle=%" PRIun ")\n", cnt, handle);
     113                return "Failed setting serial communication parameters";
     114        }
     115       
     116        TPRINTF("Trying reading %zu characters from serial device "
     117            "(svc_id=%" PRIun ")\n", cnt, svc_id);
    119118       
    120119        size_t total = 0;
     
    130129                        free(buf);
    131130                        async_hangup(sess);
    132                         return "Failed read from serial device";
     131                        return "Failed reading from serial device";
    133132                }
    134133               
     
    165164                                free(buf);
    166165                                async_hangup(sess);
    167                                 return "Failed write to serial device";
     166                                return "Failed writing to serial device";
    168167                        }
    169168                       
  • uspace/app/websrv/websrv.c

    re61aa80 r9b0a6b4  
    201201{
    202202        if (str_cmp(uri, "/") == 0)
    203                 uri = "/index.htm";
     203                uri = "/index.html";
    204204       
    205205        char *fname;
Note: See TracChangeset for help on using the changeset viewer.