Esempio n. 1
0
int
msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg)
{
    int ret;

    ENTER_CANCEL_POINT(1);
    ret = HIDDEN(msgsnd)(msqid, msgp, msgsz, msgflg);
    LEAVE_CANCEL_POINT(ret == -1);
    return (ret);
}
Esempio n. 2
0
int
nanosleep(const struct timespec *timeout, struct timespec *remainder)
{
	int ret;

	ENTER_CANCEL_POINT(1);
	ret = HIDDEN(nanosleep)(timeout, remainder);
	LEAVE_CANCEL_POINT(1);
	return (ret);
}
Esempio n. 3
0
int
msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg)
{
	int ret;

	ENTER_CANCEL_POINT(1);
	ret = HIDDEN(msgrcv)(msqid, msgp, msgsz, msgtyp, msgflg);
	LEAVE_CANCEL_POINT(ret == -1);
	return (ret);
}
Esempio n. 4
0
int
connect(int s, const struct sockaddr *name, socklen_t namelen)
{
	int ret;

	ENTER_CANCEL_POINT(1);
	ret = HIDDEN(connect)(s, name, namelen);
	LEAVE_CANCEL_POINT(ret == -1);
	return (ret);
}
Esempio n. 5
0
int
closefrom(int fd)
{
	int ret;

	ENTER_CANCEL_POINT(0);
	ret = HIDDEN(closefrom)(fd);
	LEAVE_CANCEL_POINT(1);
	return (ret);
}
Esempio n. 6
0
int
poll(struct pollfd *fds, nfds_t nfds, int timeout)
{
	int ret;

	ENTER_CANCEL_POINT(1);
	ret = HIDDEN(poll)(fds, nfds, timeout);
	LEAVE_CANCEL_POINT(ret == -1);
	return (ret);
}
Esempio n. 7
0
ssize_t
recvmsg(int fd, struct msghdr *msg, int flags)
{
    ssize_t ret;

    ENTER_CANCEL_POINT(1);
    ret = HIDDEN(recvmsg)(fd, msg, flags);
    LEAVE_CANCEL_POINT(ret == -1);
    return (ret);
}
Esempio n. 8
0
int
wait4(pid_t wpid, int *status, int options, struct rusage *rusage)
{
	int ret;

	ENTER_CANCEL_POINT(1);
	ret = HIDDEN(wait4)(wpid, status, options, rusage);
	LEAVE_CANCEL_POINT(ret <= 0);
	return (ret);
}
Esempio n. 9
0
ssize_t
sendmsg(int s, const struct msghdr *msg, int flags)
{
	ssize_t ret;

	ENTER_CANCEL_POINT(1);
	ret = HIDDEN(sendmsg)(s, msg, flags);
	LEAVE_CANCEL_POINT(ret <= 0);
	return (ret);
}
Esempio n. 10
0
int
select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
    struct timeval *timeout)
{
	int ret;

	ENTER_CANCEL_POINT(1);
	ret = HIDDEN(select)(nfds, readfds, writefds, exceptfds, timeout);
	LEAVE_CANCEL_POINT(ret == -1);
	return (ret);
}
static int* find_a(char *str,char* _latest)
{
	char *link = _latest;
	int len = strlen(str);
	while (link)
	{
		if (!HIDDEN(link[sizeof(int*)]) && ((int)(RFLAGS(link[sizeof(int)])) == len) && (!strncmp(link+1+sizeof(int*), str, (int)(RFLAGS(link[sizeof(int*)])))))
		{
			return TOIP(link);
		}
		link = (char*)*(TOIP(link));
	}
	return 0;
}
Esempio n. 12
0
#include "objs/politics.h"
#include "objs/type.h"

#define HIDDEN(ident, name)		{-1, 0, 0, name, ident},
#define INDEPENDANT(ident, name)	{-1, 1, 0, name, ident},
#define DEPENDANT(ident, name)		{-1, 1, 1, name, ident},
#define LINE_END			{0,  0, 0, NULL,  NULL}

static struct answer line1[] = {
	INDEPENDANT(gc_type, "type")
	INDEPENDANT(gc_dress, "dress")
	INDEPENDANT(gc_height, "height")
	INDEPENDANT(gc_weight, "weight")
	INDEPENDANT(gc_age, "age")
	INDEPENDANT(gc_computers, "computers")
	HIDDEN(gc_unix_type, "unix type")
	DEPENDANT(gc_unix, "unix")
	INDEPENDANT(gc_perl, "perl")
	INDEPENDANT(gc_linux, "linux")
	INDEPENDANT(gc_emacs, "emacs")
	INDEPENDANT(gc_www, "WWW")
	INDEPENDANT(gc_usenet, "usenet")
	INDEPENDANT(gc_oracle, "oracle")
	INDEPENDANT(gc_kibo, "kibo")
	INDEPENDANT(gc_windows, "windows")
	LINE_END
};

static struct answer line2[] = {
	INDEPENDANT(gc_os2, "OS/2")
	INDEPENDANT(gc_mac, "mac")
Esempio n. 13
0
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#include <fcntl.h>
#include <stdarg.h>
#include "cancel.h"

int
open(const char *path, int flags, ...)
{
	va_list ap;
	mode_t mode = 0;
	int ret;

	if (flags & O_CREAT) {
		va_start(ap, flags);
		mode = va_arg(ap, int);
		va_end(ap);
	}

	ENTER_CANCEL_POINT(1);
	ret = HIDDEN(open)(path, flags, mode);
	LEAVE_CANCEL_POINT(ret == -1);

	return (ret);
}
DEF_CANCEL(open);
Esempio n. 14
0
/*
 * sysconf --
 *	get configurable system variables.
 *
 * XXX
 * POSIX 1003.1 (ISO/IEC 9945-1, 4.8.1.3) states that the variable values
 * not change during the lifetime of the calling process.  This would seem
 * to require that any change to system limits kill all running processes.
 * A workaround might be to cache the values when they are first retrieved
 * and then simply return the cached value on subsequent calls.  This is
 * less useful than returning up-to-date values, however.
 */
long
sysconf(int name)
{
	struct rlimit rl;
	size_t len;
	int mib[3], value, namelen, sverrno;

	len = sizeof(value);
	namelen = 2;

	switch (name) {
/* 1003.1 */
	case _SC_ARG_MAX:
		mib[0] = CTL_KERN;
		mib[1] = KERN_ARGMAX;
		break;
	case _SC_CHILD_MAX:
		if (getrlimit(RLIMIT_NPROC, &rl) != 0)
			return (-1);
		if (rl.rlim_cur == RLIM_INFINITY)
			return (-1);
		if (rl.rlim_cur > LONG_MAX) {
			errno = EOVERFLOW;
			return (-1);
		}
		return ((long)rl.rlim_cur);
	case _SC_CLK_TCK:
		return (CLK_TCK);
	case _SC_JOB_CONTROL:
		return (_POSIX_JOB_CONTROL);
	case _SC_NGROUPS_MAX:
		mib[0] = CTL_KERN;
		mib[1] = KERN_NGROUPS;
		break;
	case _SC_OPEN_MAX:
		if (getrlimit(RLIMIT_NOFILE, &rl) != 0)
			return (-1);
		if (rl.rlim_cur == RLIM_INFINITY)
			return (-1);
		if (rl.rlim_cur > LONG_MAX) {
			errno = EOVERFLOW;
			return (-1);
		}
		return ((long)rl.rlim_cur);
	case _SC_STREAM_MAX:
		if (getrlimit(RLIMIT_NOFILE, &rl) != 0)
			return (-1);
		if (rl.rlim_cur == RLIM_INFINITY)
			return (-1);
		if (rl.rlim_cur > LONG_MAX) {
			errno = EOVERFLOW;
			return (-1);
		}
		/*
		 * struct __sFILE currently has a limitation that
		 * file descriptors must fit in a signed short.
		 * This doesn't precisely capture the letter of POSIX
		 * but approximates the spirit.
		 */
		if (rl.rlim_cur > SHRT_MAX)
			return (SHRT_MAX);

		return ((long)rl.rlim_cur);
	case _SC_TZNAME_MAX:
		return (NAME_MAX);
	case _SC_SAVED_IDS:
		return (_POSIX_SAVED_IDS);
	case _SC_VERSION:
		mib[0] = CTL_KERN;
		mib[1] = KERN_POSIX1;
		break;

/* 1003.1b */
	case _SC_PAGESIZE:
		if (_pagesize != 0)
			return (_pagesize);
		mib[0] = CTL_HW;
		mib[1] = HW_PAGESIZE;
		break;
	case _SC_FSYNC:
		return (_POSIX_FSYNC);

/* 1003.1c */
	case _SC_LOGIN_NAME_MAX:
		return (LOGIN_NAME_MAX);

	case _SC_THREAD_SAFE_FUNCTIONS:
		return (_POSIX_THREAD_SAFE_FUNCTIONS);

	case _SC_GETGR_R_SIZE_MAX:
		return (_GR_BUF_LEN);

	case _SC_GETPW_R_SIZE_MAX:
		return (_PW_BUF_LEN);

/* 1003.2 */
	case _SC_BC_BASE_MAX:
		return (BC_BASE_MAX);
	case _SC_BC_DIM_MAX:
		return (BC_DIM_MAX);
	case _SC_BC_SCALE_MAX:
		return (BC_SCALE_MAX);
	case _SC_BC_STRING_MAX:
		return (BC_STRING_MAX);
	case _SC_COLL_WEIGHTS_MAX:
		return (COLL_WEIGHTS_MAX);
	case _SC_EXPR_NEST_MAX:
		return (EXPR_NEST_MAX);
	case _SC_LINE_MAX:
		return (LINE_MAX);
	case _SC_RE_DUP_MAX:
		return (RE_DUP_MAX);
	case _SC_2_VERSION:
		return (_POSIX2_VERSION);
	case _SC_2_C_BIND:
		return (_POSIX2_C_BIND);
	case _SC_2_C_DEV:
		return (_POSIX2_C_DEV);
	case _SC_2_CHAR_TERM:
		return (_POSIX2_CHAR_TERM);
	case _SC_2_FORT_DEV:
		return (_POSIX2_FORT_DEV);
	case _SC_2_FORT_RUN:
		return (_POSIX2_FORT_RUN);
	case _SC_2_LOCALEDEF:
		return (_POSIX2_LOCALEDEF);
	case _SC_2_SW_DEV:
		return (_POSIX2_SW_DEV);
	case _SC_2_UPE:
		return (_POSIX2_UPE);

/* XPG 4.2 */
	case _SC_XOPEN_SHM:
		mib[0] = CTL_KERN;
		mib[1] = KERN_SYSVSHM;
		if (sysctl(mib, namelen, &value, &len, NULL, 0) == -1)
			return (-1);
		if (value == 0)
			return (-1);
		return (value);
		break;
	case _SC_SEM_NSEMS_MAX:
		return (-1);
	case _SC_SEM_VALUE_MAX:
		return (SEM_VALUE_MAX);

/* Unsorted */
	case _SC_HOST_NAME_MAX:
		return (HOST_NAME_MAX);	/* does not include \0 */
	case _SC_MONOTONIC_CLOCK:
		return (_POSIX_MONOTONIC_CLOCK);
	case _SC_2_PBS:
	case _SC_2_PBS_ACCOUNTING:
	case _SC_2_PBS_CHECKPOINT:
	case _SC_2_PBS_LOCATE:
	case _SC_2_PBS_MESSAGE:
	case _SC_2_PBS_TRACK:
		return (_POSIX2_PBS);
	case _SC_ADVISORY_INFO:
		return (_POSIX_ADVISORY_INFO);
	case _SC_AIO_LISTIO_MAX:
	case _SC_AIO_MAX:
	case _SC_AIO_PRIO_DELTA_MAX:
		return (-1);
	case _SC_ASYNCHRONOUS_IO:
		return (_POSIX_ASYNCHRONOUS_IO);
	case _SC_ATEXIT_MAX:
		return (-1);
	case _SC_BARRIERS:
		return (_POSIX_BARRIERS);
	case _SC_CLOCK_SELECTION:
		return (_POSIX_CLOCK_SELECTION);
	case _SC_CPUTIME:
		return (_POSIX_CPUTIME);
	case _SC_DELAYTIMER_MAX:
		return (-1);
	case _SC_IOV_MAX:
		return (IOV_MAX);
	case _SC_IPV6:
#if _POSIX_IPV6 == 0
		sverrno = errno;
		value = socket(PF_INET6, SOCK_DGRAM, 0);
		errno = sverrno;
		if (value >= 0) {
			HIDDEN(close)(value);
			return (200112L);
		} else
			return (0);
#else
		return (_POSIX_IPV6);
#endif
	case _SC_MAPPED_FILES:
		return (_POSIX_MAPPED_FILES);
	case _SC_MEMLOCK:
		return (_POSIX_MEMLOCK);
	case _SC_MEMLOCK_RANGE:
		return (_POSIX_MEMLOCK_RANGE);
	case _SC_MEMORY_PROTECTION:
		return (_POSIX_MEMORY_PROTECTION);
	case _SC_MESSAGE_PASSING:
		return (_POSIX_MESSAGE_PASSING);
	case _SC_PRIORITIZED_IO:
		return (_POSIX_PRIORITIZED_IO);
	case _SC_PRIORITY_SCHEDULING:
		return (_POSIX_PRIORITY_SCHEDULING);
	case _SC_RAW_SOCKETS:
		return (_POSIX_RAW_SOCKETS);
	case _SC_READER_WRITER_LOCKS:
		return (_POSIX_READER_WRITER_LOCKS);
	case _SC_REALTIME_SIGNALS:
		return (_POSIX_REALTIME_SIGNALS);
	case _SC_REGEXP:
		return (_POSIX_REGEXP);
	case _SC_SEMAPHORES:
		return (_POSIX_SEMAPHORES);
	case _SC_SHARED_MEMORY_OBJECTS:
		return (_POSIX_SHARED_MEMORY_OBJECTS);
	case _SC_SHELL:
		return (_POSIX_SHELL);
	case _SC_SIGQUEUE_MAX:
		return (-1);
	case _SC_SPAWN:
		return (_POSIX_SPAWN);
	case _SC_SPIN_LOCKS:
		return (_POSIX_SPIN_LOCKS);
	case _SC_SPORADIC_SERVER:
		return (_POSIX_SPORADIC_SERVER);
	case _SC_SYNCHRONIZED_IO:
		return (_POSIX_SYNCHRONIZED_IO);
	case _SC_SYMLOOP_MAX:
		return (SYMLOOP_MAX);
	case _SC_THREAD_ATTR_STACKADDR:
		return (_POSIX_THREAD_ATTR_STACKADDR);
	case _SC_THREAD_ATTR_STACKSIZE:
		return (_POSIX_THREAD_ATTR_STACKSIZE);
	case _SC_THREAD_CPUTIME:
		return (_POSIX_THREAD_CPUTIME);
	case _SC_THREAD_DESTRUCTOR_ITERATIONS:
		return (PTHREAD_DESTRUCTOR_ITERATIONS);
	case _SC_THREAD_KEYS_MAX:
		return (PTHREAD_KEYS_MAX);
	case _SC_THREAD_PRIO_INHERIT:
		return (_POSIX_THREAD_PRIO_INHERIT);
	case _SC_THREAD_PRIO_PROTECT:
		return (_POSIX_THREAD_PRIO_PROTECT);
	case _SC_THREAD_PRIORITY_SCHEDULING:
		return (_POSIX_THREAD_PRIORITY_SCHEDULING);
	case _SC_THREAD_PROCESS_SHARED:
		return (_POSIX_THREAD_PROCESS_SHARED);
	case _SC_THREAD_ROBUST_PRIO_INHERIT:
		return (_POSIX_THREAD_ROBUST_PRIO_INHERIT);
	case _SC_THREAD_ROBUST_PRIO_PROTECT:
		return (_POSIX_THREAD_ROBUST_PRIO_PROTECT);
	case _SC_THREAD_SPORADIC_SERVER:
		return (_POSIX_THREAD_SPORADIC_SERVER);
	case _SC_THREAD_STACK_MIN:
		return (PTHREAD_STACK_MIN);
	case _SC_THREAD_THREADS_MAX:
		return (PTHREAD_THREADS_MAX);
	case _SC_THREADS:
		return (_POSIX_THREADS);
	case _SC_TIMEOUTS:
		return (_POSIX_TIMEOUTS);
	case _SC_TIMER_MAX:
		return (-1);
	case _SC_TIMERS:
		return (_POSIX_TIMERS);
	case _SC_TRACE:
	case _SC_TRACE_EVENT_FILTER:
	case _SC_TRACE_EVENT_NAME_MAX:
	case _SC_TRACE_INHERIT:
	case _SC_TRACE_LOG:
		return (_POSIX_TRACE);
	case _SC_TTY_NAME_MAX:
		return (TTY_NAME_MAX);
	case _SC_TYPED_MEMORY_OBJECTS:
		return (_POSIX_TYPED_MEMORY_OBJECTS);
	case _SC_V6_ILP32_OFF32:
		return (_POSIX_V6_ILP32_OFF32);
	case _SC_V6_ILP32_OFFBIG:
#if _POSIX_V6_ILP32_OFFBIG == 0
		if (sizeof(int) * CHAR_BIT == 32 &&
		    sizeof(long) * CHAR_BIT == 32 &&
		    sizeof(void *) * CHAR_BIT == 32 &&
		    sizeof(off_t) * CHAR_BIT >= 64)
			return 1;
		else
			return -1;
#else
		return (_POSIX_V6_ILP32_OFFBIG);
#endif
	case _SC_V6_LP64_OFF64:
#if _POSIX_V6_LP64_OFF64 == 0
		if (sizeof(int) * CHAR_BIT == 32 &&
		    sizeof(long) * CHAR_BIT == 64 &&
		    sizeof(void *) * CHAR_BIT == 64 &&
		    sizeof(off_t) * CHAR_BIT == 64)
			return 1;
		else
			return -1;
#else
		return (_POSIX_V6_LP64_OFF64);
#endif
	case _SC_V6_LPBIG_OFFBIG:
#if _POSIX_V6_LPBIG_OFFBIG == 0
		if (sizeof(int) * CHAR_BIT >= 32 &&
		    sizeof(long) * CHAR_BIT >= 64 &&
		    sizeof(void *) * CHAR_BIT >= 64 &&
		    sizeof(off_t) * CHAR_BIT >= 64)
			return 1;
		else
			return -1;
#else
		return (_POSIX_V6_LPBIG_OFFBIG);
#endif
	case _SC_V7_ILP32_OFF32:
		return (_POSIX_V7_ILP32_OFF32);
	case _SC_V7_ILP32_OFFBIG:
#if _POSIX_V7_ILP32_OFFBIG == 0
		if (sizeof(int) * CHAR_BIT == 32 &&
		    sizeof(long) * CHAR_BIT == 32 &&
		    sizeof(void *) * CHAR_BIT == 32 &&
		    sizeof(off_t) * CHAR_BIT >= 64)
			return 1;
		else
			return -1;
#else
		return (_POSIX_V7_ILP32_OFFBIG);
#endif
	case _SC_V7_LP64_OFF64:
#if _POSIX_V7_LP64_OFF64 == 0
		if (sizeof(int) * CHAR_BIT == 32 &&
		    sizeof(long) * CHAR_BIT == 64 &&
		    sizeof(void *) * CHAR_BIT == 64 &&
		    sizeof(off_t) * CHAR_BIT == 64)
			return 1;
		else
			return -1;
#else
		return (_POSIX_V7_LP64_OFF64);
#endif
	case _SC_V7_LPBIG_OFFBIG:
#if _POSIX_V7_LPBIG_OFFBIG == 0
		if (sizeof(int) * CHAR_BIT >= 32 &&
		    sizeof(long) * CHAR_BIT >= 64 &&
		    sizeof(void *) * CHAR_BIT >= 64 &&
		    sizeof(off_t) * CHAR_BIT >= 64)
			return 1;
		else
			return -1;
#else
		return (_POSIX_V7_LPBIG_OFFBIG);
#endif
	case _SC_XOPEN_CRYPT:
		return (_XOPEN_CRYPT);
	case _SC_XOPEN_ENH_I18N:
		return (_XOPEN_ENH_I18N);
	case _SC_XOPEN_LEGACY:
		return (_XOPEN_LEGACY);
	case _SC_XOPEN_REALTIME:
		return (_XOPEN_REALTIME);
	case _SC_XOPEN_REALTIME_THREADS:
		return (_XOPEN_REALTIME_THREADS);
	case _SC_XOPEN_STREAMS:
		return (_XOPEN_STREAMS);
	case _SC_XOPEN_UNIX:
		return (_XOPEN_UNIX);
	case _SC_XOPEN_UUCP:
		return (_XOPEN_UUCP);
#ifdef _XOPEN_VERSION
	case _SC_XOPEN_VERSION:
		return (_XOPEN_VERSION);
#endif

/* Extensions */
	case _SC_PHYS_PAGES:
	{
		int64_t physmem;

		mib[0] = CTL_HW;
		mib[1] = HW_PHYSMEM64;
		len = sizeof(physmem);
		if (sysctl(mib, namelen, &physmem, &len, NULL, 0) == -1)
			return (-1);
		return (physmem / getpagesize());
	}
	case _SC_AVPHYS_PAGES:
	{
		struct uvmexp uvmexp;

		mib[0] = CTL_VM;
		mib[1] = VM_UVMEXP;
		len = sizeof(uvmexp);
		if (sysctl(mib, namelen, &uvmexp, &len, NULL, 0) == -1)
			return (-1);
		return (uvmexp.free);
	}

	case _SC_NPROCESSORS_CONF:
		mib[0] = CTL_HW;
		mib[1] = HW_NCPU;
		break;
	case _SC_NPROCESSORS_ONLN:
		mib[0] = CTL_HW;
		mib[1] = HW_NCPUONLINE;
		break;

	default:
		errno = EINVAL;
		return (-1);
	}
	return (sysctl(mib, namelen, &value, &len, NULL, 0) == -1 ? -1 : value); 
}