|
1 |
| -/* FUNCTION: fcntl */ |
| 1 | +/* FUNCTION: __CPROVER_fcntl */ |
2 | 2 |
|
3 | 3 | #ifndef __CPROVER_FCNTL_H_INCLUDED
|
4 | 4 | #include <fcntl.h>
|
5 | 5 | #define __CPROVER_FCNTL_H_INCLUDED
|
6 | 6 | #endif
|
7 | 7 |
|
| 8 | +#ifndef __CPROVER_ERRNO_H_INCLUDED |
| 9 | +# include <errno.h> |
| 10 | +# define __CPROVER_ERRNO_H_INCLUDED |
| 11 | +#endif |
| 12 | + |
8 | 13 | int __VERIFIER_nondet_int(void);
|
9 | 14 |
|
10 |
| -int fcntl(int fd, int cmd, ...) |
| 15 | +int __CPROVER_fcntl(int fd, int cmd) |
11 | 16 | {
|
12 | 17 | __CPROVER_HIDE:;
|
| 18 | + if(fd < 0) |
| 19 | + { |
| 20 | + errno = EBADF; |
| 21 | + return -1; |
| 22 | + } |
| 23 | + |
13 | 24 | int return_value=__VERIFIER_nondet_int();
|
14 | 25 | (void)fd;
|
15 | 26 | (void)cmd;
|
16 | 27 | return return_value;
|
17 | 28 | }
|
| 29 | + |
| 30 | +/* FUNCTION: fcntl */ |
| 31 | + |
| 32 | +int __CPROVER_fcntl(int, int); |
| 33 | + |
| 34 | +int fcntl(int fd, int cmd, ...) |
| 35 | +{ |
| 36 | + return __CPROVER_fcntl(fd, cmd); |
| 37 | +} |
| 38 | + |
| 39 | +/* FUNCTION: fcntl64 */ |
| 40 | + |
| 41 | +int __CPROVER_fcntl(int, int); |
| 42 | + |
| 43 | +int fcntl64(int fd, int cmd, ...) |
| 44 | +{ |
| 45 | + return __CPROVER_fcntl(fd, cmd); |
| 46 | +} |
| 47 | + |
| 48 | +/* FUNCTION: __CPROVER_open */ |
| 49 | + |
| 50 | +#ifndef __CPROVER_FCNTL_H_INCLUDED |
| 51 | +# include <fcntl.h> |
| 52 | +# define __CPROVER_FCNTL_H_INCLUDED |
| 53 | +#endif |
| 54 | + |
| 55 | +int __VERIFIER_nondet_int(void); |
| 56 | + |
| 57 | +int __CPROVER_open(const char *pathname, int flags) |
| 58 | +{ |
| 59 | +__CPROVER_HIDE:; |
| 60 | + int return_value = __VERIFIER_nondet_int(); |
| 61 | + __CPROVER_assume(return_value >= -1); |
| 62 | + (void)*pathname; |
| 63 | + (void)flags; |
| 64 | + return return_value; |
| 65 | +} |
| 66 | + |
| 67 | +/* FUNCTION: open */ |
| 68 | + |
| 69 | +int __CPROVER_open(const char *, int); |
| 70 | + |
| 71 | +int open(const char *pathname, int flags, ...) |
| 72 | +{ |
| 73 | + return __CPROVER_open(pathname, flags); |
| 74 | +} |
| 75 | + |
| 76 | +/* FUNCTION: open64 */ |
| 77 | + |
| 78 | +int __CPROVER_open(const char *, int); |
| 79 | + |
| 80 | +int open64(const char *pathname, int flags, ...) |
| 81 | +{ |
| 82 | + return __CPROVER_open(pathname, flags); |
| 83 | +} |
| 84 | + |
| 85 | +/* FUNCTION: __CPROVER_creat */ |
| 86 | + |
| 87 | +#ifndef __CPROVER_FCNTL_H_INCLUDED |
| 88 | +# include <fcntl.h> |
| 89 | +# define __CPROVER_FCNTL_H_INCLUDED |
| 90 | +#endif |
| 91 | + |
| 92 | +int __VERIFIER_nondet_int(void); |
| 93 | + |
| 94 | +int __CPROVER_creat(const char *pathname, mode_t mode) |
| 95 | +{ |
| 96 | +__CPROVER_HIDE:; |
| 97 | + int return_value = __VERIFIER_nondet_int(); |
| 98 | + __CPROVER_assume(return_value >= -1); |
| 99 | + (void)*pathname; |
| 100 | + (void)mode; |
| 101 | + return return_value; |
| 102 | +} |
| 103 | + |
| 104 | +/* FUNCTION: creat */ |
| 105 | + |
| 106 | +#ifndef __CPROVER_FCNTL_H_INCLUDED |
| 107 | +# include <fcntl.h> |
| 108 | +# define __CPROVER_FCNTL_H_INCLUDED |
| 109 | +#endif |
| 110 | + |
| 111 | +int __CPROVER_creat(const char *, mode_t); |
| 112 | + |
| 113 | +int creat(const char *pathname, mode_t mode) |
| 114 | +{ |
| 115 | + return __CPROVER_creat(pathname, mode); |
| 116 | +} |
| 117 | + |
| 118 | +/* FUNCTION: creat64 */ |
| 119 | + |
| 120 | +#ifndef __CPROVER_FCNTL_H_INCLUDED |
| 121 | +# include <fcntl.h> |
| 122 | +# define __CPROVER_FCNTL_H_INCLUDED |
| 123 | +#endif |
| 124 | + |
| 125 | +int __CPROVER_creat(const char *, mode_t); |
| 126 | + |
| 127 | +int creat64(const char *pathname, mode_t mode) |
| 128 | +{ |
| 129 | + return __CPROVER_creat(pathname, mode); |
| 130 | +} |
| 131 | + |
| 132 | +/* FUNCTION: __CPROVER_openat */ |
| 133 | + |
| 134 | +#ifndef __CPROVER_FCNTL_H_INCLUDED |
| 135 | +# include <fcntl.h> |
| 136 | +# define __CPROVER_FCNTL_H_INCLUDED |
| 137 | +#endif |
| 138 | + |
| 139 | +#ifndef __CPROVER_ERRNO_H_INCLUDED |
| 140 | +# include <errno.h> |
| 141 | +# define __CPROVER_ERRNO_H_INCLUDED |
| 142 | +#endif |
| 143 | + |
| 144 | +int __VERIFIER_nondet_int(void); |
| 145 | + |
| 146 | +int __CPROVER_openat(int dirfd, const char *pathname, int flags) |
| 147 | +{ |
| 148 | +__CPROVER_HIDE:; |
| 149 | + if(dirfd < 0) |
| 150 | + { |
| 151 | + errno = EBADF; |
| 152 | + return -1; |
| 153 | + } |
| 154 | + |
| 155 | + int return_value = __VERIFIER_nondet_int(); |
| 156 | + __CPROVER_assume(return_value >= -1); |
| 157 | + (void)dirfd; |
| 158 | + (void)*pathname; |
| 159 | + (void)flags; |
| 160 | + return return_value; |
| 161 | +} |
| 162 | + |
| 163 | +/* FUNCTION: openat */ |
| 164 | + |
| 165 | +int __CPROVER_openat(int dirfd, const char *pathname, int flags); |
| 166 | + |
| 167 | +int openat(int dirfd, const char *pathname, int flags, ...) |
| 168 | +{ |
| 169 | + return __CPROVER_openat(dirfd, pathname, flags); |
| 170 | +} |
| 171 | + |
| 172 | +/* FUNCTION: openat64 */ |
| 173 | + |
| 174 | +int __CPROVER_openat(int dirfd, const char *pathname, int flags); |
| 175 | + |
| 176 | +int openat64(int dirfd, const char *pathname, int flags, ...) |
| 177 | +{ |
| 178 | + return __CPROVER_openat(dirfd, pathname, flags); |
| 179 | +} |
0 commit comments