Ignore:
Timestamp:
2017-04-05T18:10:39Z (8 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
93ad8166
Parents:
39f892a9 (diff), 2166728 (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 from lp:~jakub/helenos/vfs-2.5-cherrypick

This merge cherry-picks some of the changesets from Jiri Zarevucky's:

lp:~zarevucky-jiri/helenos/vfs-2.5

and then continues independently, yet sometime in a similar vein.

Roughly speaking, Jiri's branch is merged entirely up to its revision
1926 and then cherry-picked on and off until its revision 1965. Among
these changes are:

  • relativization of the API,
  • client-side roots,
  • server-side mounts,
  • inbox for passing arbitrary files from parent to child,
  • some streamlining and cleanup.

Additional changes include:

  • addressing issues introduced by the above changes,
  • client-side I/O cursors (file positions),
  • all HelenOS file system APIs begin with the vfs_ prefix and can be used after including vfs/vfs.h,
  • removal of some POSIX-ish headers and definitions,
  • additional cleanup.
File:
1 edited

Legend:

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

    r39f892a9 r368ee04  
    3333#include <getopt.h>
    3434#include <str.h>
    35 #include <fcntl.h>
    3635#include <io/console.h>
    3736#include <io/color.h>
     
    187186        size_t offset = 0, copied_bytes = 0;
    188187        off64_t file_size = 0, length = 0;
     188        aoff64_t pos = 0;
    189189
    190190        bool reading_stdin = dash_represents_stdin && (str_cmp(fname, "-") == 0);
     
    195195                blen = STR_BOUNDS(1);
    196196        } else
    197                 fd = open(fname, O_RDONLY);
     197                fd = vfs_lookup_open(fname, WALK_REGULAR, MODE_READ);
    198198       
    199199        if (fd < 0) {
     
    203203
    204204        if (NULL == (buff = (char *) malloc(blen + 1))) {
    205                 close(fd);
     205                vfs_put(fd);
    206206                printf("Unable to allocate enough memory to read %s\n",
    207                         fname);
     207                    fname);
    208208                return 1;
    209209        }
    210210
    211211        if (tail != CAT_FULL_FILE) {
    212                 file_size = lseek(fd, 0, SEEK_END);
     212                struct stat st;
     213
     214                if (vfs_stat(fd, &st) != EOK) {
     215                        vfs_put(fd);
     216                        free(buff);
     217                        printf("Unable to vfs_stat %d\n", fd);
     218                        return 1;
     219                }
     220                file_size = st.size;
    213221                if (head == CAT_FULL_FILE) {
    214222                        head = file_size;
     
    223231
    224232                if (tail_first) {
    225                         lseek(fd, (tail >= file_size) ? 0 : (file_size - tail), SEEK_SET);
     233                        pos = (tail >= file_size) ? 0 : (file_size - tail);
    226234                } else {
    227                         lseek(fd, ((head - tail) >= file_size) ? 0 : (head - tail), SEEK_SET);
     235                        pos = ((head - tail) >= file_size) ? 0 : (head - tail);
    228236                }
    229237        } else
     
    243251                }
    244252               
    245                 bytes = read(fd, buff + copied_bytes, bytes_to_read);
     253                bytes = vfs_read(fd, &pos, buff + copied_bytes, bytes_to_read);
    246254                copied_bytes = 0;
    247255
     
    279287        } while (bytes > 0 && !should_quit && (count < length || length == CAT_FULL_FILE));
    280288
    281         close(fd);
     289        vfs_put(fd);
    282290        if (bytes == -1) {
    283291                printf("Error reading %s\n", fname);
Note: See TracChangeset for help on using the changeset viewer.