Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/bithenge/src/file.c

    rce04ea44 r6afc9d7  
    3838#include <assert.h>
    3939#include <errno.h>
     40#include <fcntl.h>
    4041#include <stdio.h>
    4142#include <stdlib.h>
    42 #include <vfs/vfs.h>
     43#include <sys/stat.h>
    4344#include <sys/types.h>
    4445#include <unistd.h>
     
    7778        if (offset > blob->size)
    7879                return ELIMIT;
     80        if (lseek(blob->fd, offset, SEEK_SET) < 0)
     81                return errno == EINVAL ? EIO : errno;
    7982
    80         ssize_t amount_read = vfs_read(blob->fd, &offset, buffer, *size);
    81         if (amount_read < 0)
    82                 return errno;
    83         *size += amount_read;
     83        ssize_t amount_read;
     84        aoff64_t remaining_size = *size;
     85        *size = 0;
     86        do {
     87                amount_read = read(blob->fd, buffer, remaining_size);
     88                if (amount_read < 0)
     89                        return errno;
     90                buffer += amount_read;
     91                *size += amount_read;
     92                remaining_size -= amount_read;
     93        } while (remaining_size && amount_read);
    8494        return EOK;
    8595}
     
    8898{
    8999        file_blob_t *blob = blob_as_file(base);
    90         vfs_put(blob->fd);
     100        close(blob->fd);
    91101        free(blob);
    92102}
     
    103113
    104114        struct stat stat;
    105         int rc = vfs_stat(fd, &stat);
    106         if (rc != EOK) {
     115        int rc = fstat(fd, &stat);
     116        if (rc != 0) {
    107117                if (needs_close)
    108                         vfs_put(fd);
     118                        close(fd);
    109119                return rc;
    110120        }
     
    114124        if (!blob) {
    115125                if (needs_close)
    116                         vfs_put(fd);
     126                        close(fd);
    117127                return ENOMEM;
    118128        }
     
    121131                free(blob);
    122132                if (needs_close)
    123                         vfs_put(fd);
     133                        close(fd);
    124134                return rc;
    125135        }
     
    145155        assert(filename);
    146156
    147         int fd = vfs_lookup_open(filename, WALK_REGULAR, MODE_READ);
     157        int fd = open(filename, O_RDONLY);
    148158        if (fd < 0)
    149159                return errno;
Note: See TracChangeset for help on using the changeset viewer.