Changeset 368ee04 in mainline for uspace/app/viewer/viewer.c


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/viewer/viewer.c

    r39f892a9 r368ee04  
    3434
    3535#include <stdio.h>
    36 #include <unistd.h>
    37 #include <fcntl.h>
    38 #include <sys/stat.h>
     36#include <stdlib.h>
     37#include <vfs/vfs.h>
    3938#include <errno.h>
    4039#include <malloc.h>
     
    110109static bool img_load(const char *fname, surface_t **p_local_surface)
    111110{
    112         int fd = open(fname, O_RDONLY);
     111        int fd = vfs_lookup_open(fname, WALK_REGULAR, MODE_READ);
    113112        if (fd < 0)
    114113                return false;
    115114       
    116115        struct stat stat;
    117         int rc = fstat(fd, &stat);
    118         if (rc != 0) {
    119                 close(fd);
     116        int rc = vfs_stat(fd, &stat);
     117        if (rc != EOK) {
     118                vfs_put(fd);
    120119                return false;
    121120        }
     
    123122        void *tga = malloc(stat.size);
    124123        if (tga == NULL) {
    125                 close(fd);
    126                 return false;
    127         }
    128        
    129         ssize_t rd = read(fd, tga, stat.size);
     124                vfs_put(fd);
     125                return false;
     126        }
     127
     128        ssize_t rd = vfs_read(fd, (aoff64_t []) {0}, tga, stat.size);
    130129        if ((rd < 0) || (rd != (ssize_t) stat.size)) {
    131130                free(tga);
    132                 close(fd);
    133                 return false;
    134         }
    135        
    136         close(fd);
     131                vfs_put(fd);
     132                return false;
     133        }
     134       
     135        vfs_put(fd);
    137136       
    138137        *p_local_surface = decode_tga(tga, stat.size, 0);
Note: See TracChangeset for help on using the changeset viewer.