~ubuntu-branches/ubuntu/vivid/cctools/vivid

« back to all changes in this revision

Viewing changes to parrot/src/pfs_table.h

  • Committer: Bazaar Package Importer
  • Author(s): Michael Hanke
  • Date: 2011-05-07 09:05:00 UTC
  • Revision ID: james.westby@ubuntu.com-20110507090500-lqpmdtwndor6e7os
Tags: upstream-3.3.2
ImportĀ upstreamĀ versionĀ 3.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
Copyright (C) 2003-2004 Douglas Thain and the University of Wisconsin
 
3
Copyright (C) 2005- The University of Notre Dame
 
4
This software is distributed under the GNU General Public License.
 
5
See the file COPYING for details.
 
6
*/
 
7
 
 
8
#ifndef PFS_TABLE_H
 
9
#define PFS_TABLE_H
 
10
 
 
11
#include "pfs_types.h"
 
12
#include "pfs_refcount.h"
 
13
#include "pfs_name.h"
 
14
 
 
15
class pfs_file;
 
16
class pfs_pointer;
 
17
class pfs_service;
 
18
 
 
19
#define PFS_MAX_RESOLVE_DEPTH   8
 
20
 
 
21
class pfs_table : public pfs_refcount {
 
22
public:
 
23
        pfs_table();
 
24
        ~pfs_table();
 
25
        pfs_table * fork();
 
26
        void close_on_exec();
 
27
 
 
28
        /* file descriptor creation */
 
29
        int     open( const char *path, int flags, mode_t mode, int force_cache );
 
30
        int     pipe( int *fds );
 
31
        void    attach( int logical, int physical, int flags, mode_t mode, const char *name );
 
32
 
 
33
        /* operations on open files */
 
34
        int             close( int fd );
 
35
        pfs_ssize_t     read( int fd, void *data, pfs_size_t length );
 
36
        pfs_ssize_t     write( int fd, const void *data, pfs_size_t length );
 
37
        pfs_ssize_t     pread( int fd, void *data, pfs_size_t length, pfs_off_t offset );
 
38
        pfs_ssize_t     pwrite( int fd, const void *data, pfs_size_t length, pfs_off_t offset );
 
39
        pfs_ssize_t     readv( int fd, const struct iovec *vector, int count );
 
40
        pfs_ssize_t     writev( int fd, const struct iovec *vector, int count );
 
41
        pfs_off_t       lseek( int fd, pfs_off_t offset, int whence );
 
42
 
 
43
        int             ftruncate( int fd, pfs_off_t length );
 
44
        int             fstat( int fd, struct pfs_stat *buf );
 
45
        int             fstatfs( int fd, struct pfs_statfs *buf );
 
46
        int             fsync( int fd );
 
47
        int             fchdir( int fd );
 
48
        int             fcntl( int fd, int cmd, void *arg );
 
49
        int             ioctl( int fd, int cmd, void *arg );
 
50
        int             fchmod( int fd, mode_t mode );
 
51
        int             fchown( int fd, uid_t uid, gid_t gid );
 
52
        int             flock( int fd, int op );
 
53
 
 
54
        /* operations on the table itself */
 
55
        int     select( int n, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *timeout );
 
56
        int     poll( struct pollfd *ufds, unsigned int nfds, int timeout );  
 
57
        int     chdir( const char *path );
 
58
        char *  getcwd( char *path, pfs_size_t size );
 
59
        int     dup( int old );
 
60
        int     dup2( int old, int nfd );
 
61
 
 
62
        int     get_real_fd( int fd );
 
63
        int     get_full_name( int fd, char *name );
 
64
        int     get_local_name( int fd, char *name );
 
65
 
 
66
        /* operations on services */
 
67
        int     stat( const char *name, struct pfs_stat *buf );
 
68
        int     statfs( const char *path, struct pfs_statfs *buf );
 
69
        int     lstat( const char *name, struct pfs_stat *buf );
 
70
        int     access( const char *name, mode_t mode );
 
71
        int     chmod( const char *name, mode_t mode );
 
72
        int     chown( const char *name, uid_t uid, gid_t gid );
 
73
        int     lchown( const char *name, uid_t uid, gid_t gid );
 
74
        int     truncate( const char *path, pfs_off_t length );
 
75
        int     utime( const char *path, struct utimbuf *buf );
 
76
        int     unlink( const char *name );
 
77
        int     rename( const char *old_name, const char *new_name );
 
78
        int     link( const char *oldpath, const char *newpath );
 
79
        int     symlink( const char *oldpath, const char *newpath );
 
80
        int     readlink( const char *path, char *buf, pfs_size_t size );
 
81
        int     mknod( const char *path, mode_t mode, dev_t dev );
 
82
        int     mkdir( const char *path, mode_t mode );
 
83
        int     rmdir( const char *path );
 
84
        struct dirent * fdreaddir( int fd );
 
85
 
 
86
        /* custom Parrot syscalls */
 
87
        int     mkalloc( const char *path, pfs_ssize_t size, mode_t mode );
 
88
        int     lsalloc( const char *path, char *alloc_path, pfs_ssize_t *total, pfs_ssize_t *inuse );
 
89
        int     whoami( const char *path, char *buf, int size );
 
90
        int     getacl( const char *path, char *buf, int size );
 
91
        int     setacl( const char *path, const char *subject, const char *rights );
 
92
        int     locate( const char *path, char *buf, int size );
 
93
        int     copyfile( const char *source, const char *target );
 
94
        int     copyfile_slow( const char *source, const char *target );
 
95
        int     md5( const char *path, unsigned char *digest );
 
96
        int     md5_slow( const char *path, unsigned char *digest );
 
97
        
 
98
        /* network operations */
 
99
        int     socket( int domain, int type, int protocol );
 
100
        int     socketpair( int domain, int type, int protocol, int *fds );
 
101
        int     accept( int fd, struct sockaddr *addr, int * addrlen );
 
102
 
 
103
        void    follow_symlink( struct pfs_name *pname, int depth = 0 );
 
104
        int     resolve_name( const char *cname, pfs_name *pname, bool do_follow_symlink = true, int depth = 0 );
 
105
 
 
106
        pfs_file * open_object( const char *path, int flags, mode_t mode, int force_cache );
 
107
 
 
108
        int find_empty( int lowest );
 
109
private:
 
110
        int search_dup2( int ofd, int search );
 
111
 
 
112
        int count_pointer_uses( pfs_pointer *p );
 
113
        int count_file_uses( pfs_file *f );
 
114
 
 
115
        void collapse_path( const char *short_path, char *long_path, int remove_dotdot );
 
116
        void complete_path( const char *short_path, char *long_path );
 
117
 
 
118
        int         pointer_count;
 
119
        pfs_pointer **pointers;
 
120
        int         *fd_flags;
 
121
        char        working_dir[PFS_PATH_MAX];
 
122
};
 
123
 
 
124
#endif
 
125
 
 
126
 
 
127