robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 1 | /* |
robert.swiecki@gmail.com | 3b630b4 | 2015-02-16 10:53:53 +0000 | [diff] [blame] | 2 | * |
robert.swiecki@gmail.com | 8118985 | 2015-02-14 23:44:55 +0000 | [diff] [blame] | 3 | * honggfuzz - file operations |
| 4 | * ----------------------------------------- |
robert.swiecki@gmail.com | 3b630b4 | 2015-02-16 10:53:53 +0000 | [diff] [blame] | 5 | * |
robert.swiecki@gmail.com | 772b33d | 2015-02-14 20:35:00 +0000 | [diff] [blame] | 6 | * Author: Robert Swiecki <swiecki@google.com> |
robert.swiecki@gmail.com | 3b630b4 | 2015-02-16 10:53:53 +0000 | [diff] [blame] | 7 | * |
robert.swiecki@gmail.com | 772b33d | 2015-02-14 20:35:00 +0000 | [diff] [blame] | 8 | * Copyright 2010-2015 by Google Inc. All Rights Reserved. |
robert.swiecki@gmail.com | 3b630b4 | 2015-02-16 10:53:53 +0000 | [diff] [blame] | 9 | * |
| 10 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 11 | * not use this file except in compliance with the License. You may obtain |
robert.swiecki@gmail.com | 772b33d | 2015-02-14 20:35:00 +0000 | [diff] [blame] | 12 | * a copy of the License at |
robert.swiecki@gmail.com | 3b630b4 | 2015-02-16 10:53:53 +0000 | [diff] [blame] | 13 | * |
robert.swiecki@gmail.com | 772b33d | 2015-02-14 20:35:00 +0000 | [diff] [blame] | 14 | * http://www.apache.org/licenses/LICENSE-2.0 |
robert.swiecki@gmail.com | 3b630b4 | 2015-02-16 10:53:53 +0000 | [diff] [blame] | 15 | * |
robert.swiecki@gmail.com | 772b33d | 2015-02-14 20:35:00 +0000 | [diff] [blame] | 16 | * Unless required by applicable law or agreed to in writing, software |
| 17 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
| 19 | * implied. See the License for the specific language governing |
| 20 | * permissions and limitations under the License. |
robert.swiecki@gmail.com | 3b630b4 | 2015-02-16 10:53:53 +0000 | [diff] [blame] | 21 | * |
robert.swiecki@gmail.com | 772b33d | 2015-02-14 20:35:00 +0000 | [diff] [blame] | 22 | */ |
robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 23 | |
Jagger | 876a74c | 2016-02-09 22:09:11 +0100 | [diff] [blame] | 24 | #ifndef _HF_FILES_H_ |
| 25 | #define _HF_FILES_H_ |
robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 26 | |
Robert Swiecki | e8f8e8d | 2016-10-03 23:51:32 +0200 | [diff] [blame] | 27 | #include "common.h" |
| 28 | |
robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 29 | #include <stdint.h> |
Jagger | 4aac9fe | 2016-08-28 17:35:48 +0200 | [diff] [blame] | 30 | #include <sys/mman.h> |
robert.swiecki@gmail.com | 66ee275 | 2015-02-16 20:49:44 +0000 | [diff] [blame] | 31 | #include <unistd.h> |
| 32 | |
robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 33 | extern bool files_init(honggfuzz_t * hfuzz); |
| 34 | |
Robert Swiecki | 92a3136 | 2017-02-24 16:21:40 +0100 | [diff] [blame] | 35 | extern bool files_getNext(honggfuzz_t * hfuzz, char *fname, bool rewind); |
| 36 | |
Robert Swiecki | decf14b | 2016-03-31 15:09:28 +0200 | [diff] [blame] | 37 | extern ssize_t files_readFileToBufMax(char *fileName, uint8_t * buf, size_t fileMaxSz); |
robert.swiecki@gmail.com | 4a7a9d8 | 2015-03-01 01:25:16 +0000 | [diff] [blame] | 38 | |
robert.swiecki@gmail.com | dc8403e | 2015-03-01 01:33:00 +0000 | [diff] [blame] | 39 | extern bool files_writeBufToFile(char *fileName, uint8_t * buf, size_t fileSz, int flags); |
robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 40 | |
robert.swiecki@gmail.com | 26a9ab7 | 2015-02-22 13:41:18 +0000 | [diff] [blame] | 41 | extern bool files_writeToFd(int fd, uint8_t * buf, size_t fileSz); |
robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 42 | |
robert.swiecki@gmail.com | ad6af22 | 2015-02-14 01:56:08 +0000 | [diff] [blame] | 43 | extern bool files_writeStrToFd(int fd, char *str); |
| 44 | |
Robert Swiecki | decf14b | 2016-03-31 15:09:28 +0200 | [diff] [blame] | 45 | extern ssize_t files_readFromFd(int fd, uint8_t * buf, size_t fileSz); |
robert.swiecki@gmail.com | 26a9ab7 | 2015-02-22 13:41:18 +0000 | [diff] [blame] | 46 | |
robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 47 | extern bool files_writePatternToFd(int fd, off_t size, unsigned char p); |
| 48 | |
groebert@google.com | 1bd4c21 | 2013-06-19 11:13:56 +0000 | [diff] [blame] | 49 | extern bool files_exists(char *fileName); |
| 50 | |
Robert Swiecki | decf14b | 2016-03-31 15:09:28 +0200 | [diff] [blame] | 51 | extern const char *files_basename(char *fileName); |
groebert@google.com | 1c7e3b0 | 2013-06-19 09:27:38 +0000 | [diff] [blame] | 52 | |
robert.swiecki@gmail.com | 4f1124f | 2015-04-21 17:12:22 +0000 | [diff] [blame] | 53 | extern bool files_parseDictionary(honggfuzz_t * hfuzz); |
| 54 | |
Robert Swiecki | c1deec8 | 2017-04-27 02:42:12 +0200 | [diff] [blame] | 55 | extern bool files_copyFile(const char *source, const char *destination, bool * dstExists, |
Robert Swiecki | 87ca211 | 2017-04-27 12:03:53 +0200 | [diff] [blame] | 56 | bool try_link); |
Anestis Bechtsoudis | 7d42f9d | 2015-09-06 14:30:20 +0300 | [diff] [blame] | 57 | |
Anestis Bechtsoudis | ee5316d | 2015-09-27 19:11:48 +0300 | [diff] [blame] | 58 | extern bool files_parseBlacklist(honggfuzz_t * hfuzz); |
| 59 | |
Anestis Bechtsoudis | ecb0a66 | 2015-09-27 18:19:46 +0300 | [diff] [blame] | 60 | extern uint8_t *files_mapFile(char *fileName, off_t * fileSz, int *fd, bool isWritable); |
Anestis Bechtsoudis | d59af69 | 2015-09-21 15:15:05 +0300 | [diff] [blame] | 61 | |
Jagger | 41e7ffc | 2016-07-23 03:50:32 +0200 | [diff] [blame] | 62 | extern uint8_t *files_mapFileShared(char *fileName, off_t * fileSz, int *fd); |
| 63 | |
Jagger | 5b81a50 | 2016-09-07 20:48:32 +0200 | [diff] [blame] | 64 | extern void *files_mapSharedMem(size_t sz, int *fd, const char *dir); |
Jagger | 08a7e27 | 2016-08-28 17:25:41 +0200 | [diff] [blame] | 65 | |
Anestis Bechtsoudis | 413cb13 | 2016-02-07 12:59:00 +0200 | [diff] [blame] | 66 | extern bool files_readPidFromFile(const char *fileName, pid_t * pidPtr); |
| 67 | |
Anestis Bechtsoudis | ba68b38 | 2016-10-29 20:44:15 +0300 | [diff] [blame] | 68 | extern size_t files_parseSymbolFilter(const char *inFIle, char ***filterList); |
| 69 | |
robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 70 | #endif |