pub_core_libcfile.h revision cf3f7181d94bd6f9f060b917c59a976ab899762d
1 2/*--------------------------------------------------------------------*/ 3/*--- File/socket-related libc stuff. pub_core_libcfile.h ---*/ 4/*--------------------------------------------------------------------*/ 5 6/* 7 This file is part of Valgrind, a dynamic binary instrumentation 8 framework. 9 10 Copyright (C) 2000-2009 Julian Seward 11 jseward@acm.org 12 13 This program is free software; you can redistribute it and/or 14 modify it under the terms of the GNU General Public License as 15 published by the Free Software Foundation; either version 2 of the 16 License, or (at your option) any later version. 17 18 This program is distributed in the hope that it will be useful, but 19 WITHOUT ANY WARRANTY; without even the implied warranty of 20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 General Public License for more details. 22 23 You should have received a copy of the GNU General Public License 24 along with this program; if not, write to the Free Software 25 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 26 02111-1307, USA. 27 28 The GNU General Public License is contained in the file COPYING. 29*/ 30 31#ifndef __PUB_CORE_LIBCFILE_H 32#define __PUB_CORE_LIBCFILE_H 33 34//-------------------------------------------------------------------- 35// PURPOSE: This module contains all the libc code that relates to 36// files and sockets: opening, reading, writing, etc. 37// To use, you must first include: pub_core_vki.h 38//-------------------------------------------------------------------- 39 40#include "pub_tool_libcfile.h" 41 42/* Move an fd into the Valgrind-safe range */ 43extern Int VG_(safe_fd) ( Int oldfd ); 44extern Int VG_(fcntl) ( Int fd, Int cmd, Addr arg ); 45 46/* Convert an fd into a filename */ 47extern Bool VG_(resolve_filename) ( Int fd, HChar* buf, Int n_buf ); 48 49/* Return the size of a file, or -1 in case of error */ 50extern Long VG_(fsize) ( Int fd ); 51 52/* Is the file a directory? */ 53extern Bool VG_(is_dir) ( const HChar* f ); 54 55/* Default destination port to be used in logging over a network, if 56 none specified. */ 57#define VG_CLO_DEFAULT_LOGPORT 1500 58 59extern Int VG_(connect_via_socket)( UChar* str ); 60 61extern UInt VG_(htonl) ( UInt x ); 62extern UInt VG_(ntohl) ( UInt x ); 63extern UShort VG_(htons) ( UShort x ); 64extern UShort VG_(ntohs) ( UShort x ); 65 66extern Int VG_(socket) ( Int domain, Int type, Int protocol ); 67 68extern Int VG_(write_socket)( Int sd, void *msg, Int count ); 69extern Int VG_(getsockname) ( Int sd, struct vki_sockaddr *name, Int *namelen ); 70extern Int VG_(getpeername) ( Int sd, struct vki_sockaddr *name, Int *namelen ); 71extern Int VG_(getsockopt) ( Int sd, Int level, Int optname, 72 void *optval, Int *optlen ); 73 74extern Int VG_(access) ( const HChar* path, Bool irusr, Bool iwusr, 75 Bool ixusr ); 76 77/* Is the file executable? Returns: 0 = success, non-0 is failure */ 78extern Int VG_(check_executable)(/*OUT*/Bool* is_setuid, 79 const HChar* f, Bool allow_setuid); 80 81/* DDD: Note this moves (or at least, is believed to move) the file pointer 82 on Linux and AIX5 but doesn't on Darwin. This inconsistency should 83 be fixed. (In other words, why isn't the Linux/AIX5 version implemented in 84 terms of pread()?) */ 85extern SysRes VG_(pread) ( Int fd, void* buf, Int count, OffT offset ); 86 87/* Create and open (-rw------) a tmp file name incorporating said arg. 88 Returns -1 on failure, else the fd of the file. If fullname is 89 non-NULL, the file's name is written into it. The number of bytes 90 written is guaranteed not to exceed 64+strlen(part_of_name). */ 91extern Int VG_(mkstemp) ( HChar* part_of_name, /*OUT*/HChar* fullname ); 92 93/* Record the process' working directory at startup. Is intended to 94 be called exactly once, at startup, before the working directory 95 changes. Return True for success, False for failure, so that the 96 caller can bomb out suitably without creating module cycles if 97 there is a problem. The saved value can later be acquired by 98 calling VG_(get_startup_wd) (in pub_tool_libcfile.h). */ 99extern Bool VG_(record_startup_wd) ( void ); 100 101/* Whether or not the proc filesystem has been mounted at the /proc 102 mountpoint. */ 103extern Bool VG_(is_procfs_mounted)(void); 104 105#endif // __PUB_CORE_LIBCFILE_H 106 107/*--------------------------------------------------------------------*/ 108/*--- end ---*/ 109/*--------------------------------------------------------------------*/ 110