2 /*--------------------------------------------------------------------*/
3 /*--- File/socket-related libc stuff. pub_tool_libcfile.h ---*/
4 /*--------------------------------------------------------------------*/
7 This file is part of Valgrind, a dynamic binary instrumentation
10 Copyright (C) 2000-2010 Julian Seward
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.
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.
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
28 The GNU General Public License is contained in the file COPYING.
31 #ifndef __PUB_TOOL_LIBCFILE_H
32 #define __PUB_TOOL_LIBCFILE_H
34 /* ---------------------------------------------------------------------
35 File-related functions.
36 ------------------------------------------------------------------ */
38 /* To use this file you must first include pub_tool_vki.h. */
40 /* Note that VG_(stat) and VG_(fstat) write to a 'struct vg_stat*' and
41 not a 'struct vki_stat*' or a 'struct vki_stat64*'. 'struct
42 vg_stat*' is not the same as either of the vki_ versions. No
43 specific vki_stat{,64} kernel structure will work and is
44 consistently available on different architectures on Linux, so we
45 have to use this 'struct vg_stat' impedance-matching type
48 Also note that the fieldnames aren't prefixed with "st_". This is because
49 st_atime et al are macros in sys/stat.h on Darwin, and using those names
71 extern SysRes VG_(mknod) ( const Char* pathname, Int mode, UWord dev );
72 extern SysRes VG_(open) ( const Char* pathname, Int flags, Int mode );
73 /* fd_open words like the open(2) system call:
74 returns fd if success, -1 otherwise */
75 extern Int VG_(fd_open) (const Char* pathname, Int flags, Int mode);
76 extern void VG_(close) ( Int fd );
77 extern Int VG_(read) ( Int fd, void* buf, Int count);
78 extern Int VG_(write) ( Int fd, const void* buf, Int count);
79 extern Int VG_(pipe) ( Int fd[2] );
80 extern OffT VG_(lseek) ( Int fd, OffT offset, Int whence );
82 extern SysRes VG_(stat) ( const Char* file_name, struct vg_stat* buf );
83 extern Int VG_(fstat) ( Int fd, struct vg_stat* buf );
84 extern SysRes VG_(dup) ( Int oldfd );
85 extern SysRes VG_(dup2) ( Int oldfd, Int newfd );
86 extern Int VG_(rename) ( const Char* old_name, const Char* new_name );
87 extern Int VG_(unlink) ( const Char* file_name );
89 extern Int VG_(poll) (struct vki_pollfd *fds, Int nfds, Int timeout);
91 extern Int VG_(readlink)( const Char* path, Char* buf, UInt bufsize );
92 extern Int VG_(getdents)( Int fd, struct vki_dirent *dirp, UInt count );
94 extern Char* VG_(basename)( const Char* path );
95 extern Char* VG_(dirname) ( const Char* path );
97 /* Copy the working directory at startup into buf[0 .. size-1], or return
98 False if buf is too small. */
99 extern Bool VG_(get_startup_wd) ( Char* buf, SizeT size );
101 #endif // __PUB_TOOL_LIBCFILE_H
103 /*--------------------------------------------------------------------*/
105 /*--------------------------------------------------------------------*/