1/*
2 * Copyright (c) 2007-2012, ETH Zurich.
3 * All rights reserved.
4 *
5 * This file is distributed under the terms in the attached LICENSE file.
6 * If you do not find this file, copies can be found by writing to:
7 * ETH Zurich D-INFK, CAB F.78, Universitaetstrasse 6, CH-8092 Zurich,
8 * Attn: Systems Group.
9 */
10
11#include <fcntl.h>
12#include <string.h>
13#include <vfs/vfs_fd.h>
14
15#include "posixcompat.h"
16#include "pty.h"
17
18//XXX: flags are ignored...
19__weak_reference(open, _open);
20int open(const char *pathname, int flags, ...)
21{
22    /*
23     * If the slave side of a pseudo-terminal is opened, call wrapper function.
24     *
25     * FIXME: Find a more flexible way to call specific open function for
26     *        special files.
27     */
28    if (strncmp(pathname, PTY_PTS_PATH_PREFIX, strlen(PTY_PTS_PATH_PREFIX)) == 0) {
29        return pts_open(pathname, flags);
30    } else {
31        return vfsfd_open(pathname, flags);
32    }
33}
34