mc-manual.xml fix new/delete expresions -> expression
[valgrind.git] / include / pub_tool_libcfile.h
blobff4c0d3a5768f0f8c260b19a051ae7e3d9afe69d
2 /*--------------------------------------------------------------------*/
3 /*--- File/socket-related libc stuff. pub_tool_libcfile.h ---*/
4 /*--------------------------------------------------------------------*/
6 /*
7 This file is part of Valgrind, a dynamic binary instrumentation
8 framework.
10 Copyright (C) 2000-2017 Julian Seward
11 jseward@acm.org
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, see <http://www.gnu.org/licenses/>.
26 The GNU General Public License is contained in the file COPYING.
29 #ifndef __PUB_TOOL_LIBCFILE_H
30 #define __PUB_TOOL_LIBCFILE_H
32 #include "pub_tool_basics.h" // VG_ macro
33 #include "pub_tool_vki.h" // vki_dirent et al.
35 /* ---------------------------------------------------------------------
36 File-related functions.
37 ------------------------------------------------------------------ */
39 /* To use this file you must first include pub_tool_vki.h. */
41 /* Note that VG_(stat) and VG_(fstat) write to a 'struct vg_stat*' and
42 not a 'struct vki_stat*' or a 'struct vki_stat64*'. 'struct
43 vg_stat*' is not the same as either of the vki_ versions. No
44 specific vki_stat{,64} kernel structure will work and is
45 consistently available on different architectures on Linux, so we
46 have to use this 'struct vg_stat' impedance-matching type
47 instead.
49 Also note that the fieldnames aren't prefixed with "st_". This is because
50 st_atime et al are macros in sys/stat.h on Darwin, and using those names
51 screws things up.
53 struct vg_stat {
54 ULong dev;
55 ULong ino;
56 ULong nlink;
57 UInt mode;
58 UInt uid;
59 UInt gid;
60 ULong rdev;
61 Long size;
62 ULong blksize;
63 ULong blocks;
64 ULong atime;
65 ULong atime_nsec;
66 ULong mtime;
67 ULong mtime_nsec;
68 ULong ctime;
69 ULong ctime_nsec;
72 extern SysRes VG_(mknod) ( const HChar* pathname, Int mode, UWord dev );
73 extern SysRes VG_(open) ( const HChar* pathname, Int flags, Int mode );
74 /* fd_open words like the open(2) system call:
75 returns fd if success, -1 otherwise */
76 extern Int VG_(fd_open) (const HChar* pathname, Int flags, Int mode);
77 extern void VG_(close) ( Int fd );
78 extern Int VG_(read) ( Int fd, void* buf, Int count);
79 extern Int VG_(write) ( Int fd, const void* buf, Int count);
80 extern Int VG_(pipe) ( Int fd[2] );
81 extern Off64T VG_(lseek) ( Int fd, Off64T offset, Int whence );
83 extern SysRes VG_(stat) ( const HChar* file_name, struct vg_stat* buf );
84 #if defined(VGO_freebsd)
85 extern SysRes VG_(lstat) ( const HChar* file_name, struct vg_stat* buf );
86 #endif
87 extern Int VG_(fstat) ( Int fd, struct vg_stat* buf );
88 extern SysRes VG_(dup) ( Int oldfd );
89 extern SysRes VG_(dup2) ( Int oldfd, Int newfd );
90 extern Int VG_(rename) ( const HChar* old_name, const HChar* new_name );
91 extern Int VG_(unlink) ( const HChar* file_name );
93 extern SysRes VG_(poll) (struct vki_pollfd *fds, Int nfds, Int timeout);
95 extern SSizeT VG_(readlink)( const HChar* path, HChar* buf, SizeT bufsiz);
97 #if defined(VGO_linux) || defined(VGO_solaris)
98 extern Int VG_(getdents64)( Int fd, struct vki_dirent64 *dirp, UInt count );
99 #endif
101 extern const HChar* VG_(basename)( const HChar* path );
102 extern const HChar* VG_(dirname) ( const HChar* path );
104 /* Return the name of a directory for temporary files. */
105 extern const HChar* VG_(tmpdir)(void);
107 /* Return the working directory at startup. The returned string is
108 persistent. Might be NULL if the current working directory doesn't
109 exist. */
110 extern const HChar *VG_(get_startup_wd) ( void );
112 #endif // __PUB_TOOL_LIBCFILE_H
114 /*--------------------------------------------------------------------*/
115 /*--- end ---*/
116 /*--------------------------------------------------------------------*/