From 80236f0d60ce013134c1ed5422d148e541f70a4f Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 28 Feb 2007 14:35:26 +0000 Subject: r21585: Start syncing the monster that will become 3.0.25pre1 Still todo: * release notes * few minor outstanding patches * additional idmap man pages --- source/lib/system.c | 216 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 215 insertions(+), 1 deletion(-) (limited to 'source/lib/system.c') diff --git a/source/lib/system.c b/source/lib/system.c index 2e5f42307bd..20b31113ecd 100644 --- a/source/lib/system.c +++ b/source/lib/system.c @@ -43,6 +43,27 @@ +/******************************************************************* + A wrapper for memalign +********************************************************************/ + +void* sys_memalign( size_t align, size_t size ) +{ +#if defined(HAVE_MEMALIGN) + return memalign( align, size ); +#elif defined(HAVE_POSIX_MEMALIGN) + char *p = NULL; + int ret = posix_memalign( &p, align, size ); + if ( ret == 0 ) + return p; + + return NULL; +#else + DEBUG(0,("memalign functionalaity not available on this platform!\n")); + return NULL; +#endif +} + /******************************************************************* A wrapper for usleep in case we don't have one. ********************************************************************/ @@ -105,7 +126,6 @@ ssize_t sys_write(int fd, const void *buf, size_t count) return ret; } - /******************************************************************* A pread wrapper that will deal with EINTR and 64-bit file offsets. ********************************************************************/ @@ -174,6 +194,20 @@ ssize_t sys_sendto(int s, const void *msg, size_t len, int flags, const struct return ret; } +/******************************************************************* +A recv wrapper that will deal with EINTR. +********************************************************************/ + +ssize_t sys_recv(int fd, void *buf, size_t count, int flags) +{ + ssize_t ret; + + do { + ret = recv(fd, buf, count, flags); + } while (ret == -1 && errno == EINTR); + return ret; +} + /******************************************************************* A recvfrom wrapper that will deal with EINTR. ********************************************************************/ @@ -366,6 +400,31 @@ FILE *sys_fopen(const char *path, const char *type) #endif } + +/******************************************************************* + A flock() wrapper that will perform the kernel flock. +********************************************************************/ + +void kernel_flock(int fd, uint32 share_mode) +{ +#if HAVE_KERNEL_SHARE_MODES + int kernel_mode = 0; + if (share_mode == FILE_SHARE_WRITE) { + kernel_mode = LOCK_MAND|LOCK_WRITE; + } else if (share_mode == FILE_SHARE_READ) { + kernel_mode = LOCK_MAND|LOCK_READ; + } else if (share_mode == FILE_SHARE_NONE) { + kernel_mode = LOCK_MAND; + } + if (kernel_mode) { + flock(fd, kernel_mode); + } +#endif + ; +} + + + /******************************************************************* An opendir wrapper that will deal with 64 bit filesizes. ********************************************************************/ @@ -922,6 +981,82 @@ void sys_endpwent(void) Wrappers for getpwnam(), getpwuid(), getgrnam(), getgrgid() ****************************************************************************/ +#ifdef ENABLE_BUILD_FARM_HACKS + +/* + * In the build farm we want to be able to join machines to the domain. As we + * don't have root access, we need to bypass direct access to /etc/passwd + * after a user has been created via samr. Fake those users. + */ + +static struct passwd *fake_pwd; +static int num_fake_pwd; + +struct passwd *sys_getpwnam(const char *name) +{ + int i; + + for (i=0; i