blob: 3b4d7cef711a474c3ee4631b8ca6973b8acb6df7 [file] [log] [blame]
njneb8896b2005-06-04 20:03:55 +00001
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
sewardj03f8d3f2012-08-05 15:46:46 +000010 Copyright (C) 2000-2012 Julian Seward
njneb8896b2005-06-04 20:03:55 +000011 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
sewardj9a66bb92006-10-17 01:38:13 +000038/* To use this file you must first include pub_tool_vki.h. */
39
sewardjec61b652008-08-19 07:03:04 +000040/* 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
njn9c20ece2009-05-20 02:02:30 +000046 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*/
sewardjec61b652008-08-19 07:03:04 +000052struct vg_stat {
njn9c20ece2009-05-20 02:02:30 +000053 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;
sewardjec61b652008-08-19 07:03:04 +000069};
70
florian19f91bb2012-11-10 22:29:54 +000071extern SysRes VG_(mknod) ( const HChar* pathname, Int mode, UWord dev );
72extern SysRes VG_(open) ( const HChar* pathname, Int flags, Int mode );
sewardj3b290482011-05-06 21:02:55 +000073/* fd_open words like the open(2) system call:
74 returns fd if success, -1 otherwise */
florian19f91bb2012-11-10 22:29:54 +000075extern Int VG_(fd_open) (const HChar* pathname, Int flags, Int mode);
sewardj92645592005-07-23 09:18:34 +000076extern void VG_(close) ( Int fd );
77extern Int VG_(read) ( Int fd, void* buf, Int count);
78extern Int VG_(write) ( Int fd, const void* buf, Int count);
79extern Int VG_(pipe) ( Int fd[2] );
tomc17c6ef2011-07-13 09:02:14 +000080extern Off64T VG_(lseek) ( Int fd, Off64T offset, Int whence );
njneb8896b2005-06-04 20:03:55 +000081
florian19f91bb2012-11-10 22:29:54 +000082extern SysRes VG_(stat) ( const HChar* file_name, struct vg_stat* buf );
sewardjec61b652008-08-19 07:03:04 +000083extern Int VG_(fstat) ( Int fd, struct vg_stat* buf );
sewardj45f4e7c2005-09-27 19:20:21 +000084extern SysRes VG_(dup) ( Int oldfd );
njnfad98372008-10-12 19:53:28 +000085extern SysRes VG_(dup2) ( Int oldfd, Int newfd );
florian19f91bb2012-11-10 22:29:54 +000086extern Int VG_(rename) ( const HChar* old_name, const HChar* new_name );
87extern Int VG_(unlink) ( const HChar* file_name );
njneb8896b2005-06-04 20:03:55 +000088
sewardj3b290482011-05-06 21:02:55 +000089extern Int VG_(poll) (struct vki_pollfd *fds, Int nfds, Int timeout);
90
florian19f91bb2012-11-10 22:29:54 +000091extern Int VG_(readlink)( const HChar* path, HChar* buf, UInt bufsize );
njncda2f0f2009-05-18 02:12:08 +000092extern Int VG_(getdents)( Int fd, struct vki_dirent *dirp, UInt count );
njneb8896b2005-06-04 20:03:55 +000093
florian6bd9dc12012-11-23 16:17:43 +000094extern const HChar* VG_(basename)( const HChar* path );
95extern const HChar* VG_(dirname) ( const HChar* path );
njnf76d27a2009-05-28 01:53:07 +000096
weidendod585c922011-10-17 18:12:48 +000097/* Return the name of a directory for temporary files. */
98extern const HChar* VG_(tmpdir)(void);
99
sewardj198f34f2007-07-09 23:13:07 +0000100/* Copy the working directory at startup into buf[0 .. size-1], or return
101 False if buf is too small. */
florian19f91bb2012-11-10 22:29:54 +0000102extern Bool VG_(get_startup_wd) ( HChar* buf, SizeT size );
sewardj198f34f2007-07-09 23:13:07 +0000103
njneb8896b2005-06-04 20:03:55 +0000104#endif // __PUB_TOOL_LIBCFILE_H
105
106/*--------------------------------------------------------------------*/
107/*--- end ---*/
108/*--------------------------------------------------------------------*/