blob: 3ce652546f2e1a726ed640f905d4f648d52ca0d6 [file] [log] [blame]
robert.swiecki3bb518c2010-10-14 00:48:24 +00001/*
robert.swiecki@gmail.com3b630b42015-02-16 10:53:53 +00002 *
robert.swiecki@gmail.com81189852015-02-14 23:44:55 +00003 * honggfuzz - file operations
4 * -----------------------------------------
robert.swiecki@gmail.com3b630b42015-02-16 10:53:53 +00005 *
robert.swiecki@gmail.com772b33d2015-02-14 20:35:00 +00006 * Author: Robert Swiecki <swiecki@google.com>
robert.swiecki@gmail.com3b630b42015-02-16 10:53:53 +00007 *
robert.swiecki@gmail.com772b33d2015-02-14 20:35:00 +00008 * Copyright 2010-2015 by Google Inc. All Rights Reserved.
robert.swiecki@gmail.com3b630b42015-02-16 10:53:53 +00009 *
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.com772b33d2015-02-14 20:35:00 +000012 * a copy of the License at
robert.swiecki@gmail.com3b630b42015-02-16 10:53:53 +000013 *
robert.swiecki@gmail.com772b33d2015-02-14 20:35:00 +000014 * http://www.apache.org/licenses/LICENSE-2.0
robert.swiecki@gmail.com3b630b42015-02-16 10:53:53 +000015 *
robert.swiecki@gmail.com772b33d2015-02-14 20:35:00 +000016 * 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.com3b630b42015-02-16 10:53:53 +000021 *
robert.swiecki@gmail.com772b33d2015-02-14 20:35:00 +000022 */
robert.swiecki3bb518c2010-10-14 00:48:24 +000023
Jagger876a74c2016-02-09 22:09:11 +010024#ifndef _HF_FILES_H_
25#define _HF_FILES_H_
robert.swiecki3bb518c2010-10-14 00:48:24 +000026
Robert Swieckie8f8e8d2016-10-03 23:51:32 +020027#include "common.h"
28
robert.swiecki3bb518c2010-10-14 00:48:24 +000029#include <stdint.h>
Jagger4aac9fe2016-08-28 17:35:48 +020030#include <sys/mman.h>
robert.swiecki@gmail.com66ee2752015-02-16 20:49:44 +000031#include <unistd.h>
32
robert.swiecki3bb518c2010-10-14 00:48:24 +000033extern bool files_init(honggfuzz_t * hfuzz);
34
Robert Swiecki92a31362017-02-24 16:21:40 +010035extern bool files_getNext(honggfuzz_t * hfuzz, char *fname, bool rewind);
36
Robert Swieckidecf14b2016-03-31 15:09:28 +020037extern ssize_t files_readFileToBufMax(char *fileName, uint8_t * buf, size_t fileMaxSz);
robert.swiecki@gmail.com4a7a9d82015-03-01 01:25:16 +000038
robert.swiecki@gmail.comdc8403e2015-03-01 01:33:00 +000039extern bool files_writeBufToFile(char *fileName, uint8_t * buf, size_t fileSz, int flags);
robert.swiecki3bb518c2010-10-14 00:48:24 +000040
robert.swiecki@gmail.com26a9ab72015-02-22 13:41:18 +000041extern bool files_writeToFd(int fd, uint8_t * buf, size_t fileSz);
robert.swiecki3bb518c2010-10-14 00:48:24 +000042
robert.swiecki@gmail.comad6af222015-02-14 01:56:08 +000043extern bool files_writeStrToFd(int fd, char *str);
44
Robert Swieckidecf14b2016-03-31 15:09:28 +020045extern ssize_t files_readFromFd(int fd, uint8_t * buf, size_t fileSz);
robert.swiecki@gmail.com26a9ab72015-02-22 13:41:18 +000046
robert.swiecki3bb518c2010-10-14 00:48:24 +000047extern bool files_writePatternToFd(int fd, off_t size, unsigned char p);
48
groebert@google.com1bd4c212013-06-19 11:13:56 +000049extern bool files_exists(char *fileName);
50
Robert Swieckidecf14b2016-03-31 15:09:28 +020051extern const char *files_basename(char *fileName);
groebert@google.com1c7e3b02013-06-19 09:27:38 +000052
robert.swiecki@gmail.com4f1124f2015-04-21 17:12:22 +000053extern bool files_parseDictionary(honggfuzz_t * hfuzz);
54
Robert Swieckic1deec82017-04-27 02:42:12 +020055extern bool files_copyFile(const char *source, const char *destination, bool * dstExists,
Robert Swiecki87ca2112017-04-27 12:03:53 +020056 bool try_link);
Anestis Bechtsoudis7d42f9d2015-09-06 14:30:20 +030057
Anestis Bechtsoudisee5316d2015-09-27 19:11:48 +030058extern bool files_parseBlacklist(honggfuzz_t * hfuzz);
59
Anestis Bechtsoudisecb0a662015-09-27 18:19:46 +030060extern uint8_t *files_mapFile(char *fileName, off_t * fileSz, int *fd, bool isWritable);
Anestis Bechtsoudisd59af692015-09-21 15:15:05 +030061
Jagger41e7ffc2016-07-23 03:50:32 +020062extern uint8_t *files_mapFileShared(char *fileName, off_t * fileSz, int *fd);
63
Jagger5b81a502016-09-07 20:48:32 +020064extern void *files_mapSharedMem(size_t sz, int *fd, const char *dir);
Jagger08a7e272016-08-28 17:25:41 +020065
Anestis Bechtsoudis413cb132016-02-07 12:59:00 +020066extern bool files_readPidFromFile(const char *fileName, pid_t * pidPtr);
67
Anestis Bechtsoudisba68b382016-10-29 20:44:15 +030068extern size_t files_parseSymbolFilter(const char *inFIle, char ***filterList);
69
robert.swiecki3bb518c2010-10-14 00:48:24 +000070#endif