Changeset 368ee04 in mainline for uspace/lib/bithenge/src/file.c


Ignore:
Timestamp:
2017-04-05T18:10:39Z (7 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/lib/bithenge/src/file.c

    r39f892a9 r368ee04  
    3838#include <assert.h>
    3939#include <errno.h>
    40 #include <fcntl.h>
    4140#include <stdio.h>
    4241#include <stdlib.h>
    43 #include <sys/stat.h>
     42#include <vfs/vfs.h>
    4443#include <sys/types.h>
    4544#include <unistd.h>
     
    7877        if (offset > blob->size)
    7978                return ELIMIT;
    80         if (lseek(blob->fd, offset, SEEK_SET) < 0)
    81                 return errno == EINVAL ? EIO : errno;
    8279
    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);
     80        ssize_t amount_read = vfs_read(blob->fd, &offset, buffer, *size);
     81        if (amount_read < 0)
     82                return errno;
     83        *size += amount_read;
    9484        return EOK;
    9585}
     
    9888{
    9989        file_blob_t *blob = blob_as_file(base);
    100         close(blob->fd);
     90        vfs_put(blob->fd);
    10191        free(blob);
    10292}
     
    113103
    114104        struct stat stat;
    115         int rc = fstat(fd, &stat);
    116         if (rc != 0) {
     105        int rc = vfs_stat(fd, &stat);
     106        if (rc != EOK) {
    117107                if (needs_close)
    118                         close(fd);
     108                        vfs_put(fd);
    119109                return rc;
    120110        }
     
    124114        if (!blob) {
    125115                if (needs_close)
    126                         close(fd);
     116                        vfs_put(fd);
    127117                return ENOMEM;
    128118        }
     
    131121                free(blob);
    132122                if (needs_close)
    133                         close(fd);
     123                        vfs_put(fd);
    134124                return rc;
    135125        }
     
    155145        assert(filename);
    156146
    157         int fd = open(filename, O_RDONLY);
     147        int fd = vfs_lookup_open(filename, WALK_REGULAR, MODE_READ);
    158148        if (fd < 0)
    159149                return errno;
Note: See TracChangeset for help on using the changeset viewer.