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 aims are:
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
36 - to support the philosophy of Samba to expose the features of
37 the OS within the SMB model. In general whatever file/printer/variable
38 expansions/etc make sense to the OS should be acceptable to Samba.
42 /*******************************************************************
43 this replaces the normal select() system call
44 return if some data has arrived on one of the file descriptors
46 ********************************************************************/
48 static int pollfd(int fd)
54 #elif defined(TCRDCHK)
55 (void)ioctl(fd, TCRDCHK, &r);
57 (void)ioctl(fd, FIONREAD, &r);
63 int sys_select(fd_set *fds,struct timeval *tval)
75 if (FD_ISSET(i,fds) && pollfd(i)>0) {
82 memcpy((void *)fds,(void *)&fds2,sizeof(fds2));
86 if (tval && tval->tv_sec < counter) return(0);
93 int sys_select(fd_set *fds,struct timeval *tval)
99 if (tval) memcpy((void *)&t2,(void *)tval,sizeof(t2));
101 selrtn = select(16,SELECT_CAST fds,NULL,NULL,tval?&t2:NULL);
102 } while (selrtn<0 && errno == EINTR);
109 /*******************************************************************
110 just a unlink wrapper
111 ********************************************************************/
112 int sys_unlink(char *fname)
114 return(unlink(dos_to_unix(fname,False)));
118 /*******************************************************************
119 a simple open() wrapper
120 ********************************************************************/
121 int sys_open(char *fname,int flags,int mode)
123 return(open(dos_to_unix(fname,False),flags,mode));
127 /*******************************************************************
128 a simple opendir() wrapper
129 ********************************************************************/
130 DIR *sys_opendir(char *dname)
132 return(opendir(dos_to_unix(dname,False)));
136 /*******************************************************************
138 ********************************************************************/
139 int sys_stat(char *fname,struct stat *sbuf)
141 return(stat(dos_to_unix(fname,False),sbuf));
144 /*******************************************************************
146 ********************************************************************/
147 int sys_lstat(char *fname,struct stat *sbuf)
149 return(lstat(dos_to_unix(fname,False),sbuf));
153 /*******************************************************************
154 mkdir() gets a wrapper
155 ********************************************************************/
156 int sys_mkdir(char *dname,int mode)
158 return(mkdir(dos_to_unix(dname,False),mode));
162 /*******************************************************************
164 ********************************************************************/
165 int sys_rmdir(char *dname)
167 return(rmdir(dos_to_unix(dname,False)));
171 /*******************************************************************
172 I almost forgot chdir()
173 ********************************************************************/
174 int sys_chdir(char *dname)
176 return(chdir(dos_to_unix(dname,False)));
180 /*******************************************************************
182 ********************************************************************/
183 int sys_utime(char *fname,struct utimbuf *times)
185 return(utime(dos_to_unix(fname,False),times));
188 /*******************************************************************
190 ********************************************************************/
191 int sys_rename(char *from, char *to)
195 strcpy (zfrom, dos_to_unix (from, False));
196 strcpy (zto, dos_to_unix (to, False));
197 return rename (zfrom, zto);
199 return rename (from, to);
204 /*******************************************************************
205 chown isn't used much but OS/2 doesn't have it
206 ********************************************************************/
207 int sys_chown(char *fname,int uid,int gid)
210 DEBUG(1,("Warning - chown(%s,%d,%d) not done\n",fname,uid,gid));
212 return(chown(fname,uid,gid));
216 /*******************************************************************
217 os/2 also doesn't have chroot
218 ********************************************************************/
219 int sys_chroot(char *dname)
222 DEBUG(1,("Warning - chroot(%s) not done\n",dname));
224 return(chroot(dname));