Changeset b19e892 in mainline for uspace/app/redir/redir.c


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().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/redir/redir.c

    r80743a1 rb19e892  
    3737#include <sys/types.h>
    3838#include <stdlib.h>
    39 #include <fcntl.h>
    4039#include <unistd.h>
    4140#include <str.h>
     
    5453}
    5554
    56 static void reopen(FILE **stream, int fd, const char *path, int flags, const char *mode)
     55static void reopen(FILE **stream, int fd, const char *path, int flags, int mode,
     56    const char *fmode)
    5757{
    5858        if (fclose(*stream))
     
    6161        *stream = NULL;
    6262       
    63         int oldfd = open(path, flags);
     63        int oldfd = vfs_lookup_open(path, WALK_REGULAR | flags, mode);
    6464        if (oldfd < 0)
    6565                return;
     
    7373        }
    7474       
    75         *stream = fdopen(fd, mode);
     75        *stream = fdopen(fd, fmode);
    7676}
    7777
     
    122122                                return -2;
    123123                        }
    124                         reopen(&stdin, 0, argv[i], O_RDONLY, "r");
     124                        reopen(&stdin, 0, argv[i], 0, MODE_READ, "r");
    125125                } else if (str_cmp(argv[i], "-o") == 0) {
    126126                        i++;
     
    129129                                return -3;
    130130                        }
    131                         reopen(&stdout, 1, argv[i], O_WRONLY | O_CREAT, "w");
     131                        reopen(&stdout, 1, argv[i], WALK_MAY_CREATE, MODE_WRITE,
     132                            "w");
    132133                } else if (str_cmp(argv[i], "-e") == 0) {
    133134                        i++;
     
    136137                                return -4;
    137138                        }
    138                         reopen(&stderr, 2, argv[i], O_WRONLY | O_CREAT, "w");
     139                        reopen(&stderr, 2, argv[i], WALK_MAY_CREATE, MODE_WRITE,
     140                            "w");
    139141                } else if (str_cmp(argv[i], "--") == 0) {
    140142                        i++;
Note: See TracChangeset for help on using the changeset viewer.