about summary refs log tree commit diff homepage
path: root/runtime/POSIX/fd_64.c
blob: 7691538f78b0653c97f222638503ca7d7256332d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
//===-- fd_64.c -----------------------------------------------------------===//
//
//                     The KLEE Symbolic Virtual Machine
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#if __GNUC__
#if __x86_64__ || __ppc64__
#define ENV64
#else
#define ENV32
#endif
#endif

#define _LARGEFILE64_SOURCE
#define _FILE_OFFSET_BITS 64
#include "fd.h"

#include "klee/Config/Version.h"
#include "klee/klee.h"

#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/types.h>
#ifndef __FreeBSD__
#include <sys/vfs.h>
#endif
#include <dirent.h>
#include <sys/ioctl.h>
#include <sys/mtio.h>
#include <sys/select.h>
#include <termios.h>
#include <unistd.h>

/*** Forward to actual implementations ***/

int open(const char *pathname, int flags, ...) {
  mode_t mode = 0;

  if (flags & O_CREAT) {
    /* get mode */
    va_list ap;
    va_start(ap, flags);
    mode = va_arg(ap, int);
    va_end(ap);
  }

  return __fd_open(pathname, flags, mode);
}

int openat(int fd, const char *pathname, int flags, ...) {
  mode_t mode = 0;

  if (flags & O_CREAT) {
    /* get mode */
    va_list ap;
    va_start(ap, flags);
    mode = va_arg(ap, int);
    va_end(ap);
  }

  return __fd_openat(fd, pathname, flags, mode);
}

off64_t lseek(int fd, off64_t offset, int whence) {
  return __fd_lseek(fd, offset, whence);
}

int __xstat(int vers, const char *path, struct stat *buf) {
  return __fd_stat(path, (struct stat64*) buf);
}

int stat(const char *path, struct stat *buf) {
  return __fd_stat(path, (struct stat64*) buf);
}

int __lxstat(int vers, const char *path, struct stat *buf) {
  return __fd_lstat(path, (struct stat64*) buf);
}

int lstat(const char *path, struct stat *buf) {
  return __fd_lstat(path, (struct stat64*) buf);
}

int __fxstat(int vers, int fd, struct stat *buf) {
  return __fd_fstat(fd, (struct stat64*) buf);
}

int fstat(int fd, struct stat *buf) {
  return __fd_fstat(fd, (struct stat64*) buf);
}

int ftruncate64(int fd, off64_t length) {
  return __fd_ftruncate(fd, length);
}

int statfs(const char *path, struct statfs *buf) __attribute__((weak));
int statfs(const char *path, struct statfs *buf) {
  return __fd_statfs(path, buf);
}

ssize_t getdents64(int fd, void *dirp, size_t count) {
  return __fd_getdents(fd, (struct dirent64*) dirp, count);
}
ssize_t __getdents64(int fd, void *dirp, size_t count)
     __attribute__((alias("getdents64")));