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>
36 # define __FD_SETSIZE 256
39 extern int smbw_fd_map[__FD_SETSIZE];
40 extern int smbw_ref_count[__FD_SETSIZE];
41 extern char smbw_cwd[PATH_MAX];
42 extern char smbw_prefix[];
44 typedef struct SMBW_stat {
45 unsigned long s_dev; /* device */
46 unsigned long s_ino; /* inode */
47 unsigned long s_mode; /* protection */
48 unsigned long s_nlink; /* number of hard links */
49 unsigned long s_uid; /* user ID of owner */
50 unsigned long s_gid; /* group ID of owner */
51 unsigned long s_rdev; /* device type (if inode device) */
52 unsigned long long s_size; /* total size, in bytes */
53 unsigned long s_blksize; /* blocksize for filesystem I/O */
54 unsigned long s_blocks; /* number of blocks allocated */
55 unsigned long s_atime; /* time of last access */
56 unsigned long s_mtime; /* time of last modification */
57 unsigned long s_ctime; /* time of last change */
60 typedef struct SMBW_dirent {
61 unsigned long d_ino; /* inode number */
62 unsigned long long d_off; /* offset to the next dirent */
63 unsigned long d_reclen; /* length of this record */
64 unsigned long d_type; /* type of file */
65 char d_name[256]; /* filename */
66 char d_comment[256]; /* comment */
69 struct kernel_sigaction {
70 __sighandler_t k_sa_handler;
71 unsigned long sa_flags;
75 typedef struct SMBW_libc
77 /* write() is first, to allow debugging */
78 ssize_t (* write)(int fd, void *buf, size_t count);
79 int (* open)(char *name, int flags, mode_t mode);
80 int (* _open)(char *name, int flags, mode_t mode) ;
81 int (* __open)(char *name, int flags, mode_t mode) ;
82 int (* open64)(char *name, int flags, mode_t mode);
83 int (* _open64)(char *name, int flags, mode_t mode) ;
84 int (* __open64)(char *name, int flags, mode_t mode) ;
85 ssize_t (* pread)(int fd, void *buf, size_t size, off_t ofs);
86 ssize_t (* pread64)(int fd, void *buf, size_t size, off64_t ofs);
87 ssize_t (* pwrite)(int fd, void *buf, size_t size, off_t ofs);
88 ssize_t (* pwrite64)(int fd, void *buf, size_t size, off64_t ofs);
89 int (* close)(int fd);
90 int (* __close)(int fd);
91 int (* _close)(int fd);
92 int (* fcntl)(int fd, int cmd, long arg);
93 int (* __fcntl)(int fd, int cmd, long arg);
94 int (* _fcntl)(int fd, int cmd, long arg);
95 int (* getdents)(int fd, struct dirent *dirp, unsigned int count);
96 int (* __getdents)(int fd, struct dirent *dirp, unsigned int count);
97 int (* _getdents)(int fd, struct dirent *dirp, unsigned int count);
98 int (* getdents64)(int fd, struct dirent64 *dirp, unsigned int count);
99 off_t (* lseek)(int fd, off_t offset, int whence);
100 off_t (* __lseek)(int fd, off_t offset, int whence);
101 off_t (* _lseek)(int fd, off_t offset, int whence);
102 off64_t (* lseek64)(int fd, off64_t offset, int whence);
103 off64_t (* __lseek64)(int fd, off64_t offset, int whence);
104 off64_t (* _lseek64)(int fd, off64_t offset, int whence);
105 ssize_t (* read)(int fd, void *buf, size_t count);
106 ssize_t (* __read)(int fd, void *buf, size_t count);
107 ssize_t (* _read)(int fd, void *buf, size_t count);
108 ssize_t (* __write)(int fd, void *buf, size_t count);
109 ssize_t (* _write)(int fd, void *buf, size_t count);
110 int (* access)(char *name, int mode);
111 int (* chmod)(char *name, mode_t mode);
112 int (* fchmod)(int fd, mode_t mode);
113 int (* chown)(char *name, uid_t owner, gid_t group);
114 int (* fchown)(int fd, uid_t owner, gid_t group);
115 int (* __xstat)(int vers, char *name, struct stat *st);
116 char * ( *getcwd)(char *buf, size_t size);
117 int (* mkdir)(char *name, mode_t mode);
118 int (* __fxstat)(int vers, int fd, struct stat *st);
119 int (* __lxstat)(int vers, char *name, struct stat *st);
120 int (* stat)(char *name, struct stat *st);
121 int (* lstat)(char *name, struct stat *st);
122 int (* fstat)(int fd, struct stat *st);
123 int (* unlink)(char *name);
124 int (* utime)(char *name, struct utimbuf *tvp);
125 int (* utimes)(char *name, struct timeval *tvp);
126 int (* readlink)(char *path, char *buf, size_t bufsize);
127 int (* rename)(char *oldname, char *newname);
128 int (* rmdir)(char *name);
129 int (* symlink)(char *topath, char *frompath);
131 int (* dup2)(int oldfd, int newfd);
132 DIR * (* opendir)(char *name);
133 struct dirent * (* readdir)(DIR *dir);
134 int (* closedir)(DIR *dir);
135 off_t (* telldir)(DIR *dir);
136 void (* seekdir)(DIR *dir, off_t offset);
137 int (* creat)(char *path, mode_t mode);
138 int (* creat64)(char *path, mode_t mode);
139 int (* __xstat64)(int ver, char *name, struct stat64 *st64);
140 int (* stat64)(char *name, struct stat64 *st64);
141 int (* __fxstat64)(int ver, int fd, struct stat64 *st64);
142 int (* fstat64)(int fd, struct stat64 *st64);
143 int (* __lxstat64)(int ver, char *name, struct stat64 *st64);
144 int (* lstat64)(char *name, struct stat64 *st64);
145 int (* _llseek)(unsigned int fd, unsigned long offset_high, unsigned long offset_low, loff_t *result, unsigned int whence);
146 struct dirent64 * (* readdir64)(DIR *dir);
147 int (* readdir_r)(DIR *dir, struct dirent *entry, struct dirent **result);
148 int (* readdir64_r)(DIR *dir, struct dirent64 *entry, struct dirent64 **result);
149 int (* setxattr)(const char *fname,
154 int (* lsetxattr)(const char *fname,
159 int (* fsetxattr)(int smbw_fd,
164 int (* getxattr)(const char *fname,
168 int (* lgetxattr)(const char *fname,
172 int (* fgetxattr)(int smbw_fd,
176 int (* removexattr)(const char *fname,
178 int (* lremovexattr)(const char *fname,
180 int (* fremovexattr)(int smbw_fd,
182 int (* listxattr)(const char *fname,
185 int (* llistxattr)(const char *fname,
188 int (* flistxattr)(int smbw_fd,
191 int (* chdir)(const char *path);
192 int (* fchdir)(int fd);
193 pid_t (* fork)(void);
194 int (* select)(int n,
198 struct timeval *timeout);
199 int (* _select)(int n,
203 struct timeval *timeout);
204 int (* __select)(int n,
208 struct timeval *timeout);
209 } SMBW_libc_pointers;
211 extern SMBW_libc_pointers smbw_libc;
213 #endif /* __WRAPPER_H__ */