1
0
mirror of https://github.com/samba-team/samba.git synced 2025-08-03 04:22:09 +03:00

r3441: some include file cleanups and general housekeeping

This commit is contained in:
Andrew Tridgell
2004-11-01 20:21:54 +00:00
committed by Gerald (Jerry) Carter
parent 05dd840b6f
commit 73ea8ee6c2
26 changed files with 147 additions and 650 deletions

View File

@ -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