• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 /*--------------------------------------------------------------------*/
3 /*--- File/socket-related libc stuff.          pub_tool_libcfile.h ---*/
4 /*--------------------------------------------------------------------*/
5 
6 /*
7    This file is part of Valgrind, a dynamic binary instrumentation
8    framework.
9 
10    Copyright (C) 2000-2010 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_TOOL_LIBCFILE_H
32 #define __PUB_TOOL_LIBCFILE_H
33 
34 /* ---------------------------------------------------------------------
35    File-related functions.
36    ------------------------------------------------------------------ */
37 
38 /* To use this file you must first include pub_tool_vki.h. */
39 
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
46    instead.
47 
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
50    screws things up.
51 */
52 struct vg_stat {
53    ULong   dev;
54    ULong   ino;
55    ULong   nlink;
56    UInt    mode;
57    UInt    uid;
58    UInt    gid;
59    ULong   rdev;
60    Long    size;
61    ULong   blksize;
62    ULong   blocks;
63    ULong   atime;
64    ULong   atime_nsec;
65    ULong   mtime;
66    ULong   mtime_nsec;
67    ULong   ctime;
68    ULong   ctime_nsec;
69 };
70 
71 extern SysRes VG_(open)   ( const Char* pathname, Int flags, Int mode );
72 extern void   VG_(close)  ( Int fd );
73 extern Int    VG_(read)   ( Int fd, void* buf, Int count);
74 extern Int    VG_(write)  ( Int fd, const void* buf, Int count);
75 extern Int    VG_(pipe)   ( Int fd[2] );
76 extern OffT   VG_(lseek)  ( Int fd, OffT offset, Int whence );
77 extern Int    VG_(ftruncate) ( Int fd, OffT length );
78 
79 extern SysRes VG_(stat)   ( const Char* file_name, struct vg_stat* buf );
80 extern Int    VG_(fstat)  ( Int   fd,        struct vg_stat* buf );
81 extern SysRes VG_(dup)    ( Int oldfd );
82 extern SysRes VG_(dup2)   ( Int oldfd, Int newfd );
83 extern Int    VG_(rename) ( const Char* old_name, const Char* new_name );
84 extern Int    VG_(unlink) ( const Char* file_name );
85 
86 extern Int    VG_(readlink)( const Char* path, Char* buf, UInt bufsize );
87 extern Int    VG_(getdents)( Int fd, struct vki_dirent *dirp, UInt count );
88 
89 extern Char*  VG_(basename)( const Char* path );
90 extern Char*  VG_(dirname) ( const Char* path );
91 
92 /* Copy the working directory at startup into buf[0 .. size-1], or return
93    False if buf is too small. */
94 extern Bool VG_(get_startup_wd) ( Char* buf, SizeT size );
95 
96 #endif   // __PUB_TOOL_LIBCFILE_H
97 
98 /*--------------------------------------------------------------------*/
99 /*--- end                                                          ---*/
100 /*--------------------------------------------------------------------*/
101