2 Unix SMB/Netbios implementation.
5 Copyright (C) Andrew Tridgell 1992-1995
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.
24 extern int DEBUGLEVEL;
27 The idea is that this file will eventually have wrappers around all
28 important system calls in samba. The aim is twofold:
30 - to enable easier porting by putting OS dependent stuff in here
32 - to allow for hooks into other "pseudo-filesystems"
34 - to allow easier integration of things like the japanese extensions
38 /*******************************************************************
39 this replaces the normal select() system call
40 return if some data has arrived on one of the file descriptors
42 ********************************************************************/
44 static int pollfd(int fd)
50 #elif defined(TCRDCHK)
51 (void)ioctl(fd, TCRDCHK, &r);
53 (void)ioctl(fd, FIONREAD, &r);
59 int sys_select(fd_set *fds,struct timeval *tval)
71 if (FD_ISSET(i,fds) && pollfd(i)>0) {
78 memcpy((void *)fds,(void *)&fds2,sizeof(fds2));
82 if (tval && tval->tv_sec < counter) return(0);
89 int sys_select(fd_set *fds,struct timeval *tval)
95 if (tval) memcpy((void *)&t2,(void *)tval,sizeof(t2));
97 selrtn = select(16,SELECT_CAST fds,NULL,NULL,tval?&t2:NULL);
98 } while (selrtn<0 && errno == EINTR);
105 /*******************************************************************
106 just a unlink wrapper
107 ********************************************************************/
108 int sys_unlink(char *fname)
110 return(unlink(dos_to_unix(fname,False)));
114 /*******************************************************************
115 a simple open() wrapper
116 ********************************************************************/
117 int sys_open(char *fname,int flags,int mode)
119 return(open(dos_to_unix(fname,False),flags,mode));
123 /*******************************************************************
124 a simple opendir() wrapper
125 ********************************************************************/
126 DIR *sys_opendir(char *dname)
128 return(opendir(dos_to_unix(dname,False)));
132 /*******************************************************************
134 ********************************************************************/
135 int sys_stat(char *fname,struct stat *sbuf)
137 return(stat(dos_to_unix(fname,False),sbuf));
140 /*******************************************************************
142 ********************************************************************/
143 int sys_lstat(char *fname,struct stat *sbuf)
145 return(lstat(dos_to_unix(fname,False),sbuf));
149 /*******************************************************************
150 mkdir() gets a wrapper
151 ********************************************************************/
152 int sys_mkdir(char *dname,int mode)
154 return(mkdir(dos_to_unix(dname,False),mode));
158 /*******************************************************************
160 ********************************************************************/
161 int sys_rmdir(char *dname)
163 return(rmdir(dos_to_unix(dname,False)));
167 /*******************************************************************
168 I almost forgot chdir()
169 ********************************************************************/
170 int sys_chdir(char *dname)
172 return(chdir(dos_to_unix(dname,False)));
176 /*******************************************************************
178 ********************************************************************/
179 int sys_utime(char *fname,struct utimbuf *times)
181 return(utime(dos_to_unix(fname,False),times));
184 /*******************************************************************
186 ********************************************************************/
187 int sys_rename(char *from, char *to)
191 strcpy (zfrom, dos_to_unix (from, False));
192 strcpy (zto, dos_to_unix (to, False));
193 return rename (zfrom, zto);
195 return rename (from, to);
200 /*******************************************************************
201 chown isn't used much but OS/2 doesn't have it
202 ********************************************************************/
203 int sys_chown(char *fname,int uid,int gid)
206 DEBUG(1,("Warning - chown(%s,%d,%d) not done\n",fname,uid,gid));
208 return(chown(fname,uid,gid));
212 /*******************************************************************
213 os/2 also doesn't have chroot
214 ********************************************************************/
215 int sys_chroot(char *dname)
218 DEBUG(1,("Warning - chroot(%s) not done\n",dname));
220 return(chroot(dname));