2 Unix SMB/Netbios implementation.
5 Copyright (C) Derrell Lipman 2003-2005
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #include <sys/select.h>
28 #include <sys/types.h>
35 extern int smbw_fd_map
[__FD_SETSIZE
];
36 extern int smbw_ref_count
[__FD_SETSIZE
];
37 extern char smbw_cwd
[PATH_MAX
];
38 extern char smbw_prefix
[];
40 typedef struct SMBW_stat
{
41 unsigned long s_dev
; /* device */
42 unsigned long s_ino
; /* inode */
43 unsigned long s_mode
; /* protection */
44 unsigned long s_nlink
; /* number of hard links */
45 unsigned long s_uid
; /* user ID of owner */
46 unsigned long s_gid
; /* group ID of owner */
47 unsigned long s_rdev
; /* device type (if inode device) */
48 unsigned long long s_size
; /* total size, in bytes */
49 unsigned long s_blksize
; /* blocksize for filesystem I/O */
50 unsigned long s_blocks
; /* number of blocks allocated */
51 unsigned long s_atime
; /* time of last access */
52 unsigned long s_mtime
; /* time of last modification */
53 unsigned long s_ctime
; /* time of last change */
56 typedef struct SMBW_dirent
{
57 unsigned long d_ino
; /* inode number */
58 unsigned long long d_off
; /* offset to the next dirent */
59 unsigned long d_reclen
; /* length of this record */
60 unsigned long d_type
; /* type of file */
61 char d_name
[256]; /* filename */
62 char d_comment
[256]; /* comment */
65 struct kernel_sigaction
{
66 __sighandler_t k_sa_handler
;
67 unsigned long sa_flags
;
71 typedef struct SMBW_libc
73 /* write() is first, to allow debugging */
74 ssize_t (* write
)(int fd
, void *buf
, size_t count
);
75 int (* open
)(char *name
, int flags
, mode_t mode
);
76 int (* _open
)(char *name
, int flags
, mode_t mode
) ;
77 int (* __open
)(char *name
, int flags
, mode_t mode
) ;
78 int (* open64
)(char *name
, int flags
, mode_t mode
);
79 int (* _open64
)(char *name
, int flags
, mode_t mode
) ;
80 int (* __open64
)(char *name
, int flags
, mode_t mode
) ;
81 ssize_t (* pread
)(int fd
, void *buf
, size_t size
, off_t ofs
);
82 ssize_t (* pread64
)(int fd
, void *buf
, size_t size
, off64_t ofs
);
83 ssize_t (* pwrite
)(int fd
, void *buf
, size_t size
, off_t ofs
);
84 ssize_t (* pwrite64
)(int fd
, void *buf
, size_t size
, off64_t ofs
);
85 int (* close
)(int fd
);
86 int (* __close
)(int fd
);
87 int (* _close
)(int fd
);
88 int (* fcntl
)(int fd
, int cmd
, long arg
);
89 int (* __fcntl
)(int fd
, int cmd
, long arg
);
90 int (* _fcntl
)(int fd
, int cmd
, long arg
);
91 int (* getdents
)(int fd
, struct dirent
*dirp
, unsigned int count
);
92 int (* __getdents
)(int fd
, struct dirent
*dirp
, unsigned int count
);
93 int (* _getdents
)(int fd
, struct dirent
*dirp
, unsigned int count
);
94 int (* getdents64
)(int fd
, struct dirent64
*dirp
, unsigned int count
);
95 off_t (* lseek
)(int fd
, off_t offset
, int whence
);
96 off_t (* __lseek
)(int fd
, off_t offset
, int whence
);
97 off_t (* _lseek
)(int fd
, off_t offset
, int whence
);
98 off64_t (* lseek64
)(int fd
, off64_t offset
, int whence
);
99 off64_t (* __lseek64
)(int fd
, off64_t offset
, int whence
);
100 off64_t (* _lseek64
)(int fd
, off64_t offset
, int whence
);
101 ssize_t (* read
)(int fd
, void *buf
, size_t count
);
102 ssize_t (* __read
)(int fd
, void *buf
, size_t count
);
103 ssize_t (* _read
)(int fd
, void *buf
, size_t count
);
104 ssize_t (* __write
)(int fd
, void *buf
, size_t count
);
105 ssize_t (* _write
)(int fd
, void *buf
, size_t count
);
106 int (* access
)(char *name
, int mode
);
107 int (* chmod
)(char *name
, mode_t mode
);
108 int (* fchmod
)(int fd
, mode_t mode
);
109 int (* chown
)(char *name
, uid_t owner
, gid_t group
);
110 int (* fchown
)(int fd
, uid_t owner
, gid_t group
);
111 int (* __xstat
)(int vers
, char *name
, struct stat
*st
);
112 char * ( *getcwd
)(char *buf
, size_t size
);
113 int (* mkdir
)(char *name
, mode_t mode
);
114 int (* __fxstat
)(int vers
, int fd
, struct stat
*st
);
115 int (* __lxstat
)(int vers
, char *name
, struct stat
*st
);
116 int (* stat
)(char *name
, struct stat
*st
);
117 int (* lstat
)(char *name
, struct stat
*st
);
118 int (* fstat
)(int fd
, struct stat
*st
);
119 int (* unlink
)(char *name
);
120 int (* utime
)(char *name
, struct utimbuf
*tvp
);
121 int (* utimes
)(char *name
, struct timeval
*tvp
);
122 int (* readlink
)(char *path
, char *buf
, size_t bufsize
);
123 int (* rename
)(char *oldname
, char *newname
);
124 int (* rmdir
)(char *name
);
125 int (* symlink
)(char *topath
, char *frompath
);
127 int (* dup2
)(int oldfd
, int newfd
);
128 DIR * (* opendir
)(char *name
);
129 struct dirent
* (* readdir
)(DIR *dir
);
130 int (* closedir
)(DIR *dir
);
131 off_t (* telldir
)(DIR *dir
);
132 void (* seekdir
)(DIR *dir
, off_t offset
);
133 int (* creat
)(char *path
, mode_t mode
);
134 int (* creat64
)(char *path
, mode_t mode
);
135 int (* __xstat64
)(int ver
, char *name
, struct stat64
*st64
);
136 int (* stat64
)(char *name
, struct stat64
*st64
);
137 int (* __fxstat64
)(int ver
, int fd
, struct stat64
*st64
);
138 int (* fstat64
)(int fd
, struct stat64
*st64
);
139 int (* __lxstat64
)(int ver
, char *name
, struct stat64
*st64
);
140 int (* lstat64
)(char *name
, struct stat64
*st64
);
141 int (* _llseek
)(unsigned int fd
, unsigned long offset_high
, unsigned long offset_low
, loff_t
*result
, unsigned int whence
);
142 struct dirent64
* (* readdir64
)(DIR *dir
);
143 int (* readdir_r
)(DIR *dir
, struct dirent
*entry
, struct dirent
**result
);
144 int (* readdir64_r
)(DIR *dir
, struct dirent64
*entry
, struct dirent64
**result
);
145 int (* setxattr
)(const char *fname
,
150 int (* lsetxattr
)(const char *fname
,
155 int (* fsetxattr
)(int smbw_fd
,
160 int (* getxattr
)(const char *fname
,
164 int (* lgetxattr
)(const char *fname
,
168 int (* fgetxattr
)(int smbw_fd
,
172 int (* removexattr
)(const char *fname
,
174 int (* lremovexattr
)(const char *fname
,
176 int (* fremovexattr
)(int smbw_fd
,
178 int (* listxattr
)(const char *fname
,
181 int (* llistxattr
)(const char *fname
,
184 int (* flistxattr
)(int smbw_fd
,
187 int (* chdir
)(const char *path
);
188 int (* fchdir
)(int fd
);
189 pid_t (* fork
)(void);
190 int (* select
)(int n
,
194 struct timeval
*timeout
);
195 int (* _select
)(int n
,
199 struct timeval
*timeout
);
200 int (* __select
)(int n
,
204 struct timeval
*timeout
);
205 } SMBW_libc_pointers
;
207 extern SMBW_libc_pointers smbw_libc
;
209 #endif /* __WRAPPER_H__ */