diff options
Diffstat (limited to 'source4/lib')
-rw-r--r-- | source4/lib/cmdline/popt_common.c | 2 | ||||
-rw-r--r-- | source4/lib/dprintf.c | 6 | ||||
-rw-r--r-- | source4/lib/genrand.c | 4 | ||||
-rw-r--r-- | source4/lib/pidfile.c | 8 | ||||
-rw-r--r-- | source4/lib/replace.c | 2 | ||||
-rw-r--r-- | source4/lib/signal.c | 2 | ||||
-rw-r--r-- | source4/lib/system.c | 187 | ||||
-rw-r--r-- | source4/lib/util.c | 42 | ||||
-rw-r--r-- | source4/lib/util_file.c | 94 | ||||
-rw-r--r-- | source4/lib/util_sock.c | 2 | ||||
-rw-r--r-- | source4/lib/xfile.c | 4 |
11 files changed, 38 insertions, 315 deletions
diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 05e92866b2..bd46373d58 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -175,7 +175,7 @@ static void get_password_file(struct cmdline_auth_info *a) sscanf(p, "%d", &fd); close_it = False; } else if ((p = getenv("PASSWD_FILE")) != NULL) { - fd = sys_open(p, O_RDONLY, 0); + fd = open(p, O_RDONLY, 0); pstrcpy(spec, p); if (fd < 0) { fprintf(stderr, "Error opening PASSWD_FILE %s: %s\n", diff --git a/source4/lib/dprintf.c b/source4/lib/dprintf.c index fe939f0e8d..5538c490ce 100644 --- a/source4/lib/dprintf.c +++ b/source4/lib/dprintf.c @@ -31,7 +31,7 @@ #include "includes.h" - int d_vfprintf(FILE *f, const char *format, va_list ap) +int d_vfprintf(FILE *f, const char *format, va_list ap) _PRINTF_ATTRIBUTE(2,0) { char *p, *p2; int ret, maxlen, clen; @@ -77,7 +77,7 @@ again: } - int d_fprintf(FILE *f, const char *format, ...) +int d_fprintf(FILE *f, const char *format, ...) _PRINTF_ATTRIBUTE(2,3) { int ret; va_list ap; @@ -91,7 +91,7 @@ again: static FILE *outfile; - int d_printf(const char *format, ...) +int d_printf(const char *format, ...) _PRINTF_ATTRIBUTE(1,2) { int ret; va_list ap; diff --git a/source4/lib/genrand.c b/source4/lib/genrand.c index 72e4997596..11771b32c9 100644 --- a/source4/lib/genrand.c +++ b/source4/lib/genrand.c @@ -118,7 +118,7 @@ static void do_filehash(const char *fname, unsigned char *the_hash) unsigned char tmp_md4[16]; int fd, n; - fd = sys_open(fname,O_RDONLY,0); + fd = open(fname,O_RDONLY,0); if (fd == -1) return; @@ -152,7 +152,7 @@ static int do_reseed(BOOL use_fd, int fd) if (fd != -1) return fd; - fd = sys_open( "/dev/urandom", O_RDONLY,0); + fd = open( "/dev/urandom", O_RDONLY,0); if(fd >= 0) return fd; } diff --git a/source4/lib/pidfile.c b/source4/lib/pidfile.c index 989f19b323..f8041a2005 100644 --- a/source4/lib/pidfile.c +++ b/source4/lib/pidfile.c @@ -37,7 +37,7 @@ pid_t pidfile_pid(const char *name) slprintf(pidFile, sizeof(pidFile)-1, "%s/%s.pid", lp_piddir(), name); - fd = sys_open(pidFile, O_NONBLOCK | O_RDONLY, 0644); + fd = open(pidFile, O_NONBLOCK | O_RDONLY, 0644); if (fd == -1) { return 0; } @@ -54,7 +54,7 @@ pid_t pidfile_pid(const char *name) goto noproc; } - if (fcntl_lock(fd,SMB_F_SETLK,0,1,F_RDLCK)) { + if (fcntl_lock(fd,F_SETLK,0,1,F_RDLCK)) { /* we could get the lock - it can't be a Samba process */ goto noproc; } @@ -85,14 +85,14 @@ void pidfile_create(const char *name) exit(1); } - fd = sys_open(pidFile, O_NONBLOCK | O_CREAT | O_WRONLY | O_EXCL, 0644); + fd = open(pidFile, O_NONBLOCK | O_CREAT | O_WRONLY | O_EXCL, 0644); if (fd == -1) { DEBUG(0,("ERROR: can't open %s: Error was %s\n", pidFile, strerror(errno))); exit(1); } - if (fcntl_lock(fd,SMB_F_SETLK,0,1,F_WRLCK)==False) { + if (fcntl_lock(fd,F_SETLK,0,1,F_WRLCK)==False) { DEBUG(0,("ERROR: %s : fcntl lock of file %s failed. Error was %s\n", name, pidFile, strerror(errno))); exit(1); diff --git a/source4/lib/replace.c b/source4/lib/replace.c index 4ed99c833c..c23c65c8c8 100644 --- a/source4/lib/replace.c +++ b/source4/lib/replace.c @@ -27,7 +27,7 @@ /******************************************************************* ftruncate for operating systems that don't have it ********************************************************************/ - int ftruncate(int f,SMB_OFF_T l) + int ftruncate(int f,off_t l) { struct flock fl; diff --git a/source4/lib/signal.c b/source4/lib/signal.c index bff4b91c1a..00fc214639 100644 --- a/source4/lib/signal.c +++ b/source4/lib/signal.c @@ -27,7 +27,7 @@ static void sig_cld(int signum) { - while (sys_waitpid((pid_t)-1,(int *)NULL, WNOHANG) > 0) + while (waitpid((pid_t)-1,(int *)NULL, WNOHANG) > 0) ; /* diff --git a/source4/lib/system.c b/source4/lib/system.c index e8a944d8f8..1407e7474e 100644 --- a/source4/lib/system.c +++ b/source4/lib/system.c @@ -128,193 +128,6 @@ ssize_t sys_sendto(int s, const void *msg, size_t len, int flags, const struct return ret; } -/******************************************************************* -A recvfrom wrapper that will deal with EINTR. -********************************************************************/ - -ssize_t sys_recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen) -{ - ssize_t ret; - - do { - ret = recvfrom(s, buf, len, flags, from, fromlen); - } while (ret == -1 && errno == EINTR); - return ret; -} - -/******************************************************************* -A fcntl wrapper that will deal with EINTR. -********************************************************************/ - -int sys_fcntl_ptr(int fd, int cmd, void *arg) -{ - int ret; - - do { - ret = fcntl(fd, cmd, arg); - } while (ret == -1 && errno == EINTR); - return ret; -} - -/******************************************************************* -A fcntl wrapper that will deal with EINTR. -********************************************************************/ - -int sys_fcntl_long(int fd, int cmd, long arg) -{ - int ret; - - do { - ret = fcntl(fd, cmd, arg); - } while (ret == -1 && errno == EINTR); - return ret; -} - -/******************************************************************* -A stat() wrapper that will deal with 64 bit filesizes. -********************************************************************/ - -int sys_stat(const char *fname,SMB_STRUCT_STAT *sbuf) -{ - int ret; -#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T) && defined(HAVE_STAT64) - ret = stat64(fname, sbuf); -#else - ret = stat(fname, sbuf); -#endif - /* we always want directories to appear zero size */ - if (ret == 0 && S_ISDIR(sbuf->st_mode)) sbuf->st_size = 0; - return ret; -} - -/******************************************************************* - An fstat() wrapper that will deal with 64 bit filesizes. -********************************************************************/ - -int sys_fstat(int fd,SMB_STRUCT_STAT *sbuf) -{ - int ret; -#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T) && defined(HAVE_FSTAT64) - ret = fstat64(fd, sbuf); -#else - ret = fstat(fd, sbuf); -#endif - /* we always want directories to appear zero size */ - if (ret == 0 && S_ISDIR(sbuf->st_mode)) sbuf->st_size = 0; - return ret; -} - -/******************************************************************* - An lstat() wrapper that will deal with 64 bit filesizes. -********************************************************************/ - -int sys_lstat(const char *fname,SMB_STRUCT_STAT *sbuf) -{ - int ret; -#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T) && defined(HAVE_LSTAT64) - ret = lstat64(fname, sbuf); -#else - ret = lstat(fname, sbuf); -#endif - /* we always want directories to appear zero size */ - if (ret == 0 && S_ISDIR(sbuf->st_mode)) sbuf->st_size = 0; - return ret; -} - -/******************************************************************* - An ftruncate() wrapper that will deal with 64 bit filesizes. -********************************************************************/ - -int sys_ftruncate(int fd, SMB_OFF_T offset) -{ -#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T) && defined(HAVE_FTRUNCATE64) - return ftruncate64(fd, offset); -#else - return ftruncate(fd, offset); -#endif -} - -/******************************************************************* - An lseek() wrapper that will deal with 64 bit filesizes. -********************************************************************/ - -SMB_OFF_T sys_lseek(int fd, SMB_OFF_T offset, int whence) -{ -#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T) && defined(HAVE_LSEEK64) - return lseek64(fd, offset, whence); -#else - return lseek(fd, offset, whence); -#endif -} - -/******************************************************************* - A creat() wrapper that will deal with 64 bit filesizes. -********************************************************************/ - -int sys_creat(const char *path, mode_t mode) -{ -#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_CREAT64) - return creat64(path, mode); -#else - /* - * If creat64 isn't defined then ensure we call a potential open64. - * JRA. - */ - return sys_open(path, O_WRONLY | O_CREAT | O_TRUNC, mode); -#endif -} - -/******************************************************************* - An open() wrapper that will deal with 64 bit filesizes. -********************************************************************/ - -int sys_open(const char *path, int oflag, mode_t mode) -{ -#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OPEN64) - return open64(path, oflag, mode); -#else - return open(path, oflag, mode); -#endif -} - -/******************************************************************* - An fopen() wrapper that will deal with 64 bit filesizes. -********************************************************************/ - -FILE *sys_fopen(const char *path, const char *type) -{ -#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_FOPEN64) - return fopen64(path, type); -#else - return fopen(path, type); -#endif -} - -/******************************************************************* - A readdir wrapper that will deal with 64 bit filesizes. -********************************************************************/ - -struct smb_dirent *sys_readdir(DIR *dirp) -{ -#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_READDIR64) - return readdir64(dirp); -#else - return readdir(dirp); -#endif -} - -/******************************************************************* -The wait() calls vary between systems -********************************************************************/ - -int sys_waitpid(pid_t pid,int *status,int options) -{ -#ifdef HAVE_WAITPID - return waitpid(pid,status,options); -#else /* HAVE_WAITPID */ - return wait4(pid, status, options, NULL); -#endif /* HAVE_WAITPID */ -} /******************************************************************* System wrapper for getwd diff --git a/source4/lib/util.c b/source4/lib/util.c index 97d3d5dd1b..07dc182580 100644 --- a/source4/lib/util.c +++ b/source4/lib/util.c @@ -40,13 +40,13 @@ const char *tmpdir(void) /******************************************************************* Check if a file exists - call vfs_file_exist for samba files. ********************************************************************/ -BOOL file_exist(const char *fname,SMB_STRUCT_STAT *sbuf) +BOOL file_exist(const char *fname, struct stat *sbuf) { - SMB_STRUCT_STAT st; + struct stat st; if (!sbuf) sbuf = &st; - if (sys_stat(fname,sbuf) != 0) + if (stat(fname,sbuf) != 0) return(False); return((S_ISREG(sbuf->st_mode)) || (S_ISFIFO(sbuf->st_mode))); @@ -58,9 +58,9 @@ BOOL file_exist(const char *fname,SMB_STRUCT_STAT *sbuf) time_t file_modtime(const char *fname) { - SMB_STRUCT_STAT st; + struct stat st; - if (sys_stat(fname,&st) != 0) + if (stat(fname,&st) != 0) return(0); return(st.st_mtime); @@ -70,15 +70,15 @@ time_t file_modtime(const char *fname) Check if a directory exists. ********************************************************************/ -BOOL directory_exist(const char *dname,SMB_STRUCT_STAT *st) +BOOL directory_exist(const char *dname,struct stat *st) { - SMB_STRUCT_STAT st2; + struct stat st2; BOOL ret; if (!st) st = &st2; - if (sys_stat(dname,st) != 0) + if (stat(dname,st) != 0) return(False); ret = S_ISDIR(st->st_mode); @@ -90,12 +90,12 @@ BOOL directory_exist(const char *dname,SMB_STRUCT_STAT *st) /******************************************************************* Returns the size in bytes of the named file. ********************************************************************/ -SMB_OFF_T get_file_size(char *file_name) +off_t get_file_size(char *file_name) { - SMB_STRUCT_STAT buf; + struct stat buf; buf.st_size = 0; - if(sys_stat(file_name,&buf) != 0) - return (SMB_OFF_T)-1; + if(stat(file_name,&buf) != 0) + return (off_t)-1; return(buf.st_size); } @@ -120,9 +120,9 @@ void close_low_fds(BOOL stderr_too) if (i == 2 && !stderr_too) continue; - fd = sys_open("/dev/null",O_RDWR,0); + fd = open("/dev/null",O_RDWR,0); if (fd < 0) - fd = sys_open("/dev/null",O_WRONLY,0); + fd = open("/dev/null",O_WRONLY,0); if (fd < 0) { DEBUG(0,("Can't open /dev/null\n")); return; @@ -155,13 +155,13 @@ int set_blocking(int fd, BOOL set) #endif #endif - if((val = sys_fcntl_long(fd, F_GETFL, 0)) == -1) + if((val = fcntl(fd, F_GETFL, 0)) == -1) return -1; if(set) /* Turn blocking on - ie. clear nonblock flag */ val &= ~FLAG_TO_SET; else val |= FLAG_TO_SET; - return sys_fcntl_long( fd, F_SETFL, val); + return fcntl( fd, F_SETFL, val); #undef FLAG_TO_SET } @@ -198,7 +198,7 @@ void become_daemon(BOOL Fork) setsid(); #elif defined(TIOCNOTTY) { - int i = sys_open("/dev/tty", O_RDWR, 0); + int i = open("/dev/tty", O_RDWR, 0); if (i != -1) { ioctl(i, (int) TIOCNOTTY, (char *)0); close(i); @@ -509,9 +509,9 @@ BOOL process_exists(pid_t pid) is dealt with in posix.c ****************************************************************************/ -BOOL fcntl_lock(int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type) +BOOL fcntl_lock(int fd, int op, off_t offset, off_t count, int type) { - SMB_STRUCT_FLOCK lock; + struct flock lock; int ret; DEBUG(8,("fcntl_lock %d %d %.0f %.0f %d\n",fd,op,(double)offset,(double)count,type)); @@ -522,13 +522,13 @@ BOOL fcntl_lock(int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type) lock.l_len = count; lock.l_pid = 0; - ret = sys_fcntl_ptr(fd,op,&lock); + ret = fcntl(fd,op,&lock); if (ret == -1 && errno != 0) DEBUG(3,("fcntl_lock: fcntl lock gave errno %d (%s)\n",errno,strerror(errno))); /* a lock query */ - if (op == SMB_F_GETLK) { + if (op == F_GETLK) { if ((ret != -1) && (lock.l_type != F_UNLCK) && (lock.l_pid != 0) && diff --git a/source4/lib/util_file.c b/source4/lib/util_file.c index c4f794db0e..0093de9517 100644 --- a/source4/lib/util_file.c +++ b/source4/lib/util_file.c @@ -20,96 +20,6 @@ #include "includes.h" -static int gotalarm; - -/*************************************************************** - Signal function to tell us we timed out. -****************************************************************/ - -static void gotalarm_sig(void) -{ - gotalarm = 1; -} - -/*************************************************************** - Lock or unlock a fd for a known lock type. Abandon after waitsecs - seconds. -****************************************************************/ - -BOOL do_file_lock(int fd, int waitsecs, int type) -{ - SMB_STRUCT_FLOCK lock; - int ret; - void (*oldsig_handler)(int); - - gotalarm = 0; - oldsig_handler = CatchSignal(SIGALRM, SIGNAL_CAST gotalarm_sig); - - lock.l_type = type; - lock.l_whence = SEEK_SET; - lock.l_start = 0; - lock.l_len = 1; - lock.l_pid = 0; - - alarm(waitsecs); - /* Note we must *NOT* use sys_fcntl here ! JRA */ - ret = fcntl(fd, SMB_F_SETLKW, &lock); - alarm(0); - CatchSignal(SIGALRM, SIGNAL_CAST oldsig_handler); - - if (gotalarm) { - DEBUG(0, ("do_file_lock: failed to %s file.\n", - type == F_UNLCK ? "unlock" : "lock")); - return False; - } - - return (ret == 0); -} - - -/*************************************************************** - Lock an fd. Abandon after waitsecs seconds. -****************************************************************/ - -BOOL file_lock(int fd, int type, int secs, int *plock_depth) -{ - if (fd < 0) - return False; - - (*plock_depth)++; - - if ((*plock_depth) == 0) - { - if (!do_file_lock(fd, secs, type)) { - DEBUG(10,("file_lock: locking file failed, error = %s.\n", - strerror(errno))); - return False; - } - } - - return True; -} - -/*************************************************************** - Unlock an fd. Abandon after waitsecs seconds. -****************************************************************/ - -BOOL file_unlock(int fd, int *plock_depth) -{ - BOOL ret=True; - - if(*plock_depth == 1) - ret = do_file_lock(fd, 5, F_UNLCK); - - (*plock_depth)--; - - if(!ret) - DEBUG(10,("file_unlock: unlocking file failed, error = %s.\n", - strerror(errno))); - return ret; -} - - /************************************************************************* gets a line out of a file. line is of format "xxxx:xxxxxx:xxxxx:". @@ -280,10 +190,10 @@ load a file into memory from a fd. char *fd_load(int fd, size_t *size) { - SMB_STRUCT_STAT sbuf; + struct stat sbuf; char *p; - if (sys_fstat(fd, &sbuf) != 0) return NULL; + if (fstat(fd, &sbuf) != 0) return NULL; p = (char *)malloc(sbuf.st_size+1); if (!p) return NULL; diff --git a/source4/lib/util_sock.c b/source4/lib/util_sock.c index 638c44f705..0cb23920f1 100644 --- a/source4/lib/util_sock.c +++ b/source4/lib/util_sock.c @@ -162,7 +162,7 @@ ssize_t read_udp_socket(int fd, char *buf, size_t len, struct sockaddr_in sock; socklen_t socklen = sizeof(sock); - ret = (ssize_t)sys_recvfrom(fd,buf,len, 0, (struct sockaddr *)&sock, &socklen); + ret = recvfrom(fd,buf,len, 0, (struct sockaddr *)&sock, &socklen); if (ret <= 0) { DEBUG(2,("read socket failed. ERRNO=%s\n",strerror(errno))); return 0; diff --git a/source4/lib/xfile.c b/source4/lib/xfile.c index e01723904f..8572bd857a 100644 --- a/source4/lib/xfile.c +++ b/source4/lib/xfile.c @@ -109,7 +109,7 @@ XFILE *x_fopen(const char *fname, int flags, mode_t mode) ret->open_flags = flags; - ret->fd = sys_open(fname, flags, mode); + ret->fd = open(fname, flags, mode); if (ret->fd == -1) { SAFE_FREE(ret); return NULL; @@ -379,5 +379,5 @@ off_t x_tseek(XFILE *f, off_t offset, int whence) } f->flags &= ~X_FLAG_EOF; - return (off_t)sys_lseek(f->fd, offset, whence); + return lseek(f->fd, offset, whence); } |