Ignore:
Timestamp:
2017-04-05T18:10:39Z (9 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/fix-logger-deadlock, 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/mkfile/mkfile.c

    r39f892a9 r368ee04  
    3131#include <stdlib.h>
    3232#include <dirent.h>
    33 #include <fcntl.h>
    3433#include <sys/types.h>
    35 #include <sys/stat.h>
    3634#include <macros.h>
    3735#include <getopt.h>
     
    3937#include <str.h>
    4038#include <ctype.h>
     39#include <vfs/vfs.h>
    4140
    4241#include "config.h"
     
    121120        void *buffer;
    122121        bool create_sparse = false;
     122        aoff64_t pos = 0;
    123123
    124124        file_size = 0;
     
    156156        file_name = argv[optind];
    157157
    158         fd = open(file_name, O_CREAT | O_EXCL | O_WRONLY, 0666);
     158        fd = vfs_lookup_open(file_name, WALK_REGULAR | WALK_MUST_CREATE, MODE_WRITE);
    159159        if (fd < 0) {
    160160                printf("%s: failed to create file %s.\n", cmdname, file_name);
     
    164164        if (create_sparse && file_size > 0) {
    165165                const char byte = 0x00;
    166 
    167                 if ((rc2 = lseek(fd, file_size - 1, SEEK_SET)) < 0) {
    168                         close(fd);
    169                         goto error;
    170                 }
    171 
    172                 rc2 = write(fd, &byte, sizeof(char));
     166               
     167                pos = file_size - 1;
     168                rc2 = vfs_write(fd, &pos, &byte, sizeof(char));
    173169                if (rc2 < 0) {
    174                         close(fd);
     170                        vfs_put(fd);
    175171                        goto error;
    176172                }
     
    187183        while (total_written < file_size) {
    188184                to_write = min(file_size - total_written, BUFFER_SIZE);
    189                 rc = write(fd, buffer, to_write);
     185                rc = vfs_write(fd, &pos, buffer, to_write);
    190186                if (rc <= 0) {
    191187                        printf("%s: Error writing file (%d).\n", cmdname, errno);
    192                         close(fd);
     188                        vfs_put(fd);
    193189                        free(buffer);
    194190                        return CMD_FAILURE;
     
    199195        free(buffer);
    200196
    201         if (close(fd) < 0)
     197        if (vfs_put(fd) < 0)
    202198                goto error;
    203199
Note: See TracChangeset for help on using the changeset viewer.