Changeset b19e892 in mainline for uspace/app/bdsh/cmds


Ignore:
Timestamp:
2017-04-02T10:39:13Z (7 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9c4cf0d
Parents:
80743a1
Message:

Merge open() with posix_open() and provide vfs_lookup_open() instead

vfs_lookup_open() is really just a convenience wrapper around
vfs_lookup() and vfs_open().

Location:
uspace/app/bdsh/cmds/modules
Files:
8 edited

Legend:

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

    r80743a1 rb19e892  
    3333#include <getopt.h>
    3434#include <str.h>
    35 #include <fcntl.h>
    3635#include <io/console.h>
    3736#include <io/color.h>
     
    196195                blen = STR_BOUNDS(1);
    197196        } else
    198                 fd = open(fname, O_RDONLY);
     197                fd = vfs_lookup_open(fname, WALK_REGULAR, MODE_READ);
    199198       
    200199        if (fd < 0) {
  • uspace/app/bdsh/cmds/modules/cmp/cmp.c

    r80743a1 rb19e892  
    2828
    2929#include <errno.h>
    30 #include <fcntl.h>
    3130#include <getopt.h>
    3231#include <mem.h>
     
    8281
    8382        for (int i = 0; i < 2; i++) {
    84                 fd[i] = open(fn[i], O_RDONLY);
     83                fd[i] = vfs_lookup_open(fn[i], WALK_REGULAR, MODE_READ);
    8584                if (fd[i] < 0) {
    86                         rc = errno;
     85                        rc = fd[i];
    8786                        printf("Unable to open %s\n", fn[i]);
    8887                        goto end;
  • uspace/app/bdsh/cmds/modules/cp/cp.c

    r80743a1 rb19e892  
    3535#include <getopt.h>
    3636#include <str.h>
    37 #include <fcntl.h>
    3837#include <vfs/vfs.h>
    3938#include <dirent.h>
     
    383382                printf("Copying %s to %s\n", src, dest);
    384383
    385         if (-1 == (fd1 = open(src, O_RDONLY))) {
     384        fd1 = vfs_lookup_open(src, WALK_REGULAR, MODE_READ);
     385        if (fd1 < 0) {
    386386                printf("Unable to open source file %s\n", src);
    387387                return -1;
    388388        }
    389389
    390         if (-1 == (fd2 = open(dest, O_WRONLY | O_CREAT))) {
     390        fd2 = vfs_lookup_open(dest, WALK_REGULAR | WALK_MAY_CREATE, MODE_WRITE);
     391        if (fd2 < 0) {
    391392                printf("Unable to open destination file %s\n", dest);
    392393                close(fd1);
  • uspace/app/bdsh/cmds/modules/ls/ls.c

    r80743a1 rb19e892  
    3636#include <unistd.h>
    3737#include <dirent.h>
    38 #include <fcntl.h>
    3938#include <getopt.h>
    4039#include <sys/types.h>
  • uspace/app/bdsh/cmds/modules/mkdir/mkdir.c

    r80743a1 rb19e892  
    3030#include <stdlib.h>
    3131#include <dirent.h>
    32 #include <fcntl.h>
    3332#include <sys/types.h>
    3433#include <getopt.h>
  • uspace/app/bdsh/cmds/modules/mkfile/mkfile.c

    r80743a1 rb19e892  
    3131#include <stdlib.h>
    3232#include <dirent.h>
    33 #include <fcntl.h>
    3433#include <sys/types.h>
    3534#include <macros.h>
     
    3837#include <str.h>
    3938#include <ctype.h>
     39#include <vfs/vfs.h>
    4040
    4141#include "config.h"
     
    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);
  • uspace/app/bdsh/cmds/modules/rm/rm.c

    r80743a1 rb19e892  
    3131#include <stdlib.h>
    3232#include <unistd.h>
    33 #include <fcntl.h>
    3433#include <dirent.h>
    3534#include <getopt.h>
     
    151150        }
    152151
    153         fd = open(path, O_RDONLY);
     152        fd = vfs_lookup(path, WALK_REGULAR);
    154153        if (fd >= 0) {
    155154                close(fd);
  • uspace/app/bdsh/cmds/modules/touch/touch.c

    r80743a1 rb19e892  
    3535#include <stdlib.h>
    3636#include <unistd.h>
    37 #include <fcntl.h>
    3837#include <dirent.h>
    3938#include <sys/types.h>
     
    125124                if ((!no_create) ||
    126125                    ((no_create) && (vfs_stat_path(buff, &file_stat) == EOK))) {
    127                         fd = open(buff, O_RDWR | O_CREAT);
     126                        fd = vfs_lookup(buff, WALK_REGULAR | WALK_MAY_CREATE);
    128127                }
    129128               
Note: See TracChangeset for help on using the changeset viewer.