This patch fixes most of current reasons to generate compiler warnings.
The changes consist of:
- adding missing casts
- hiding or unhiding function declarations
- including headers where missing
- add __UNCONST when assigning a const char * to a char *
- adding missing return statements
- changing some types from unsigned to signed, as the code seems to want
signed ints
- converting old-style function definitions to current style (i.e.,
void func(param1, param2) short param1, param2; {...} to
void func (short param1, short param2) {...})
- making the compiler silent about signed vs unsigned comparisons. We
have too many of those in the new libc to fix.
A number of bugs in the test set were fixed. These bugs were never
triggered with our old libc. Consequently, these tests are now forced to
link with the new libc or they will generate errors (in particular tests 43
and 55).
Most changes in NetBSD libc are limited to moving aroudn "#ifndef __minix"
or stuff related to Minix-specific things (code in sys-minix or gen/minix).
_PROTOTYPE( int devman_usb_device_remove, (struct devman_usb_dev *dev));
_PROTOTYPE( void devman_usb_device_delete, (struct devman_usb_dev *udev));
_PROTOTYPE( int devman_handle_msg, (message *m));
-_PROTOTYPE( int devman_usb_init,(devman_usb_bind_cb_t bind_cb,
- devman_usb_bind_cb_t unbind_cb));
+_PROTOTYPE( void devman_usb_init, (devman_usb_bind_cb_t bind_cb,
+ devman_usb_bind_cb_t unbind_cb) );
#endif
#ifndef _CTYPE_H
#define _CTYPE_H
-#ifndef _MINIX_ANSI_H
#include <minix/ansi.h>
-#endif
extern char __ctype[]; /* property array defined in chartab.c */
_PROTOTYPE( int toascii, (int _c) ); /* convert to 7-bit ASCII */
/* Macros for identifying character classes. */
-#define isalnum(c) ((__ctype+1)[c]&(_U|_L|_N))
-#define isalpha(c) ((__ctype+1)[c]&(_U|_L))
-#define iscntrl(c) ((__ctype+1)[c]&_C)
-#define isgraph(c) ((__ctype+1)[c]&(_P|_U|_L|_N))
-#define ispunct(c) ((__ctype+1)[c]&_P)
-#define isspace(c) ((__ctype+1)[c]&_S)
-#define isxdigit(c) ((__ctype+1)[c]&(_N|_X))
+#define isalnum(c) ((__ctype+1)[(unsigned char)(c)]&(_U|_L|_N))
+#define isalpha(c) ((__ctype+1)[(unsigned char)(c)]&(_U|_L))
+#define iscntrl(c) ((__ctype+1)[(unsigned char)(c)]&_C)
+#define isgraph(c) ((__ctype+1)[(unsigned char)(c)]&(_P|_U|_L|_N))
+#define ispunct(c) ((__ctype+1)[(unsigned char)(c)]&_P)
+#define isspace(c) ((__ctype+1)[(unsigned char)(c)]&_S)
+#define isxdigit(c) ((__ctype+1)[(unsigned char)(c)]&(_N|_X))
#define isdigit(c) ((unsigned) ((c)-'0') < 10)
#define islower(c) ((unsigned) ((c)-'a') < 26)
struct archive_entry **e, struct archive_entry **f)
{
struct links_entry *le;
+#ifndef __minix
struct archive_entry *t;
+#endif
*f = NULL; /* Default: Don't return a second entry. */
int64_t entry_padding;
int64_t realsize;
#else
- size_t entry_bytes_remaining;
+ int32_t entry_bytes_remaining;
off_t entry_offset;
off_t entry_padding;
- size_t realsize;
+ int32_t realsize;
#endif
struct sparse_block *sparse_list;
struct sparse_block *sparse_last;
#ifndef __minix
int64_t bytes_skipped;
#else
- size_t bytes_skipped;
+ int32_t bytes_skipped;
#endif
struct tar* tar;
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
+#include <unistd.h>
#define mmap minix_mmap
#define munmap minix_munmap
/* Nonblocking write(). (See asyn_read()). */
{
asynfd_t *afd;
- ssize_t result;
asyn->asyn_more++;
return r;
}
-static int in_group(uid_t uid, gid_t gid)
-{
- int r, i;
- int size;
- gid_t *list;
-
- size = sysconf(_SC_NGROUPS_MAX);
- list = malloc(size * sizeof(gid_t));
-
- if (list == NULL) {
- return 0;
- }
-
- r= getgroups(size, list);
- if (r == -1) {
- free(list);
- return 0;
- }
-
- for (i = 0; i < r; i++) {
- if (gid == list[i]) {
- free(list);
- return 1;
- }
- }
-
- free(list);
- return 0;
-}
-
-
static int _uds_bind(int socket, const struct sockaddr *address,
socklen_t address_len, struct sockaddr_un *uds_addr)
{
#include <minix/const.h>
#include <minix/devman.h>
#include <minix/safecopies.h>
+#include <minix/sysutil.h>
+#include <minix/ds.h>
#include "local.h"
PUBLIC int devman_init()
{
int res;
- message msg;
/* get the endpoint of the HCD */
res = ds_retrieve_label_endpt("devman", &devman_ep);
#include <minix/const.h>
#include <minix/devman.h>
#include <minix/usb.h>
+#include <minix/sysutil.h>
#include "local.h"
/****************************************************************************
* devman_usb_init *
***************************************************************************/
-PUBLIC int devman_usb_init
+PUBLIC void devman_usb_init
(int (*_bind_cb) (struct devman_usb_bind_cb_data *data, endpoint_t ep),
int (*_unbind_cb) (struct devman_usb_bind_cb_data *data, endpoint_t ep))
{
int arg;
#endif
int d;
- char *ap;
#ifdef INET6
+ char *ap;
char hname[INET6_ADDRSTRLEN];
#endif
{
assert(fp == stdout || fp == stderr);
- puts(s);
+ return puts(s);
}
#include <errno.h>
#include <assert.h>
-static int no_debug = -1;
#define CHECK_DBG(statement)
#if _EM_WSIZE == _EM_PSIZE
#include <minix/libminixfs.h>
#include <minix/dmap.h>
#include <minix/u64.h>
+#include <minix/sysutil.h>
#include <sys/param.h>
#include <errno.h>
#include <minix/vfsif.h>
#include <minix/type.h>
+#include <minix/syslib.h>
#include <assert.h>
+#include <string.h>
#include "minixfs.h"
source %= RANDOM_SOURCES;
r_next= rand->bin[source].r_next;
- read_tsc(&tsc_high, &tsc_low);
+ read_tsc((u32_t *) &tsc_high, (u32_t *) &tsc_low);
rand->bin[source].r_buf[r_next] = tsc_low;
if (rand->bin[source].r_size < RANDOM_ELEMENTS) {
rand->bin[source].r_size ++;
#include "syslib.h"
#include <timers.h>
+#include <minix/sysutil.h>
PRIVATE timer_t *timers = NULL;
PRIVATE int expiring = 0;
return;
}
- read_tsc(&timingdata->starttimes[HIGHCOUNT],
- &timingdata->starttimes[LOWCOUNT]);
+ read_tsc((u32_t *) &timingdata->starttimes[HIGHCOUNT],
+ (u32_t *) &timingdata->starttimes[LOWCOUNT]);
}
void util_timer_end(util_timingdata_t *timingdata)
unsigned long h, l, d = 0;
int bin;
- read_tsc(&h, &l);
+ read_tsc((u32_t *) &h, (u32_t *) &l);
if (!timingdata->starttimes[HIGHCOUNT]) {
panic("timer stopped but not started");
return;
#include <stddef.h>
#include <ctype.h>
#include <limits.h>
+#include <string.h>
/* vprintf() uses kputc() to print characters. */
void kputc(int c);
int _vprintf(const char *fmt, va_list argp)
{
- __fvprintf(__xfputc, fmt, argp, stdout);
+ return __fvprintf(__xfputc, fmt, argp, stdout);
}
int _vfprintf(FILE *fp, const char *fmt, va_list argp)
{
- __fvprintf(__xfputc, fmt, argp, fp);
+ return __fvprintf(__xfputc, fmt, argp, fp);
}
#endif
#endif
ud->urb_completion(urb);
} else {
- printf("WARN: _usb_urb_complete: did not find URB with ID %d", urb_id);
+ printf("WARN: _usb_urb_complete: did not find URB with ID %ld", urb_id);
}
}
void
pw_init(void)
{
+#ifndef __minix
struct rlimit rlim;
-#ifndef __minix
/* Unlimited resource limits. */
rlim.rlim_cur = rlim.rlim_max = RLIM_INFINITY;
(void)setrlimit(RLIMIT_CPU, &rlim);
linep = line;
if (chown(line, getuid(), ttygid) == 0 &&
chmod(line, mode) == 0 &&
+#ifndef __minix
revoke(line) == 0 &&
+#endif
(slave = open(line, O_RDWR, 0)) != -1) {
+#ifndef __minix
gotit:
+#endif
*amaster = master;
*aslave = slave;
if (name)
#include <minix/const.h>
#include <minix/ipc.h>
#include <minix/com.h>
+#include <minix/syslib.h>
#include "vassert.h"
VAssert_StateWrapper vassert_state ALIGNED(VASSERT_PAGE_SIZE);
static sigjmp_buf segv_jmp;
+void libvassert_process_backdoor(uint32, uint32, uint32, reg_t *, reg_t *,
+ reg_t *, reg_t *);
+
/*
*---------------------------------------------------------------------
*
* to adjust the given address for segments)
*/
- if(sys_umap(SELF, D, page_address, 1, &ph)) {
+ if(sys_umap(SELF, D, page_address, 1, (phys_bytes *) &ph)) {
printf("VAssert_Init: sys_umap failed\n");
return -1;
}
line = fparseln(tf, &len, &lineno, NULL, FPARSELN_UNESCALL);
if (line == NULL) {
if (errno != 0)
- warn(__func__);
+ warn("%s", __func__);
return NULL;
}
for (p = line; *p && isspace((unsigned char)*p); p++)
__weak_alias(getdomainname, _getdomainname)
#endif
-int getdomainname(char *domain, size_t size)
+int getdomainname(char *result, size_t size)
{
char nodename[256];
- char *dot;
+ char *domain;
if (gethostname(nodename, sizeof(nodename)) < 0)
return -1;
nodename[sizeof(nodename)-1]= 0;
- if ((dot= strchr(nodename, '.')) == nil) dot= ".";
+ if ((domain = strchr(nodename, '.')) != NULL)
+ strncpy(result, domain+1, size);
+ else
+ result[0] = '\0';
- strncpy(domain, dot+1, size);
- if (size > 0) domain[size-1]= 0;
+ if (size > 0) result[size-1]= 0;
return 0;
}
#include <sys/cdefs.h>
#include "namespace.h"
-#define _MINIX
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
* bits) followed by a '+' (set bits).
*/
mode_t
-getmode(bbox, omode)
- const void *bbox;
- mode_t omode;
+getmode(const void *bbox, mode_t omode)
{
const BITCMD *set;
mode_t clrval, newmode, value;
#define STANDARD_BITS (S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO)
void *
-setmode(p)
- const char *p;
+setmode(const char *p)
{
int serrno;
char op, *ep;
}
static BITCMD *
-addcmd(set, op, who, oparg, mask)
- BITCMD *set;
- mode_t oparg, who, op, mask;
+addcmd(BITCMD *set, mode_t op, mode_t who, mode_t oparg, mode_t mask)
{
_DIAGASSERT(set != NULL);
{
va_list ap;
struct rlimit rlimit;
- long int new_limit, result;
+ long int result;
+#ifndef __minix
+ long int new_limit;
+#endif
va_start(ap, cmd);
} __link_set_all_categories = {
.__ls_length = 7,
.__ls_items = {
- [0] = &_generic_LC_ALL_desc,
- [1] = &_dummy_LC_COLLATE_desc,
+ [0] = __UNCONST(&_generic_LC_ALL_desc),
+ [1] = __UNCONST(&_dummy_LC_COLLATE_desc),
#ifdef WITH_RUNE
- [2] = &_citrus_LC_CTYPE_desc,
- [3] = &_citrus_LC_MONETARY_desc,
- [4] = &_citrus_LC_NUMERIC_desc,
- [5] = &_citrus_LC_TIME_desc,
- [6] = &_citrus_LC_MESSAGES_desc,
+ [2] = __UNCONST(&_citrus_LC_CTYPE_desc),
+ [3] = __UNCONST(&_citrus_LC_MONETARY_desc),
+ [4] = __UNCONST(&_citrus_LC_NUMERIC_desc),
+ [5] = __UNCONST(&_citrus_LC_TIME_desc),
+ [6] = __UNCONST(&_citrus_LC_MESSAGES_desc),
#else
- [2] = &_localeio_LC_CTYPE_desc,
- [3] = &_localeio_LC_MONETARY_desc,
- [4] = &_localeio_LC_NUMERIC_desc,
- [5] = &_localeio_LC_TIME_desc,
- [6] = &_localeio_LC_MESSAGES_desc,
+ [2] = __UNCONST(&_localeio_LC_CTYPE_desc),
+ [3] = __UNCONST(&_localeio_LC_MONETARY_desc),
+ [4] = __UNCONST(&_localeio_LC_NUMERIC_desc),
+ [5] = __UNCONST(&_localeio_LC_TIME_desc),
+ [6] = __UNCONST(&_localeio_LC_MESSAGES_desc),
#endif
},
};
{
#ifndef __minix
int mib[2];
-#endif
size_t len;
+#endif
if (__stack_chk_guard[0] != 0)
return;
static int getnameinfo_link __P((const struct sockaddr *, socklen_t, char *,
socklen_t, char *, socklen_t, int));
-#endif /* __minix */
static int hexname __P((const u_int8_t *, size_t, char *, socklen_t));
+#endif /* __minix */
/*
* Top-level getnameinfo() code. Look at the address family, and pick an
(size_t)sdl->sdl_alen, host, hostlen);
}
}
-#endif /* !__minix */
static int
hexname(cp, len, host, hostlen)
}
return 0;
}
+#endif /* !__minix */
memset(&addr, 0, sizeof(addr));
memset(&netmask, 0, sizeof(netmask));
ifa.ifa_next = NULL;
- ifa.ifa_name = "ip";
+ ifa.ifa_name = __UNCONST("ip");
addr.sin_family = netmask.sin_family = AF_INET;
ifa.ifa_addr = (struct sockaddr *) &addr;
ifa.ifa_netmask = (struct sockaddr *) &netmask;
if(fd < 0) {
char *ipd;
- if(!(ipd=getenv("IP_DEVICE")))
- ipd="/dev/ip";
+
+ if(!(ipd = getenv("IP_DEVICE")))
+ ipd = __UNCONST("/dev/ip");
if((fd = open(ipd, O_RDWR)) < 0)
return -1;
}
char hbuf[NI_MAXHOST];
char sbuf[NI_MAXSERV];
- alen = alen;
-
if ((statp->options & RES_DEBUG) != 0U) {
if (getnameinfo(address, (socklen_t)alen, hbuf, sizeof(hbuf),
sbuf, sizeof(sbuf), niflags)) {
#include <ssp/ssp.h>
#include <string.h>
+#include <ssp/string.h>
#undef memcpy
+#if __SSP_FORTIFY_LEVEL > 0
+
void *
__memcpy_chk(void * __restrict dst, const void * __restrict src, size_t len,
size_t slen)
__chk_fail();
return memcpy(dst, src, len);
}
+
+#endif
#undef memmove
+#if __SSP_FORTIFY_LEVEL > 0
+
void *
__memmove_chk(void *dst, void *src, size_t len,
size_t slen)
__chk_fail();
return memmove(dst, src, len);
}
+
+#endif
#undef memset
+#if __SSP_FORTIFY_LEVEL > 0
+
void *
__memset_chk(void * __restrict dst, int val, size_t len, size_t slen)
{
__chk_fail();
return memset(dst, val, len);
}
+
+#endif
#include <ssp/ssp.h>
#include <string.h>
+#if __SSP_FORTIFY_LEVEL > 0
+
char *
__strcat_chk(char * __restrict dst, const char * __restrict src, size_t slen)
{
*d = '\0';
return dst;
}
+
+#endif
#undef memcpy
+#if __SSP_FORTIFY_LEVEL > 0
+
char *
__strcpy_chk(char * __restrict dst, const char * __restrict src, size_t slen)
{
return memcpy(dst, src, len + 1);
}
+
+#endif
#include <string.h>
#include <stdio.h>
+#if __SSP_FORTIFY_LEVEL > 0
+
char *
__strncat_chk(char * __restrict dst, const char * __restrict src, size_t len,
size_t slen)
*d = '\0';
return dst;
}
+
+#endif
#undef strncpy
+#if __SSP_FORTIFY_LEVEL > 0
+
char *
__strncpy_chk(char * __restrict dst, const char * __restrict src, size_t len,
size_t slen)
return strncpy(dst, src, len);
}
+
+#endif
#endif
#endif /* LIBC_SCCS and not lint */
-#if defined(__NetBSD__)
+#if defined(__NetBSD__) || defined(__minix)
#include "namespace.h"
#include <monetary.h>
#endif
#if !HAVE_STRMODE
void
-strmode(mode, p)
- mode_t mode;
- char *p;
+strmode(mode_t mode, char *p)
{
_DIAGASSERT(p != NULL);
#include <limits.h>
#include <string.h>
+/* libc-private interface */
+int __getcwd(char *, size_t);
+
static int addpath(const char *path, char **ap, const char *entry)
/* Add the name of a directory entry at the front of the path being built.
* Note that the result always starts with a slash.
struct stat above, current, tmp;
struct dirent *entry;
DIR *d;
- char *p, *up, *dotdot;
+ char *p, *up;
+ const char *dotdot = "..";
int cycle;
if (path == NULL || size <= 1) { errno= EINVAL; return -1; }
if (stat(".", ¤t) < 0) return -1;
while (1) {
- dotdot= "..";
if (stat(dotdot, &above) < 0) { recover(p); return -1; }
if (above.st_dev == current.st_dev
return r;
}
-static int in_group(uid_t uid, gid_t gid)
-{
- int r, i;
- int size;
- gid_t *list;
-
- size = sysconf(_SC_NGROUPS_MAX);
- list = malloc(size * sizeof(gid_t));
-
- if (list == NULL) {
- return 0;
- }
-
- r= getgroups(size, list);
- if (r == -1) {
- free(list);
- return 0;
- }
-
- for (i = 0; i < r; i++) {
- if (gid == list[i]) {
- free(list);
- return 1;
- }
- }
-
- free(list);
- return 0;
-}
-
-
static int _uds_bind(int sock, const struct sockaddr *address,
socklen_t address_len, struct sockaddr_un *uds_addr)
{
{
message m;
m.m1_i1 = ngroups;
- m.m1_p1 = arr;
+ m.m1_p1 = (char *) arr;
return(_syscall(PM_PROC_NR, GETGROUPS, &m));
}
#include <sys/cdefs.h>
-#include <lib.h>
#include "namespace.h"
+#include <lib.h>
#include <unistd.h>
+#include <string.h>
pid_t getsid(pid_t p)
{
int use_existing = 0;
/* Default values. */
- if (type == NULL) type = FSDEFAULT;
- if (args == NULL) args = "";
+ if (type == NULL) type = __UNCONST(FSDEFAULT);
+ if (args == NULL) args = __UNCONST("");
reuse = 0;
/* Check mount flags */
sprintf(label, "fs_%.12s", p);
} else {
if (stat(name, &statbuf) < 0) return -1;
- sprintf(label, "fs_%04x%x", statbuf.st_dev, statbuf.st_ino);
+ sprintf(label, "fs_%04x%llx", statbuf.st_dev, statbuf.st_ino);
}
} else {
/* label to long? */
{
struct msg_control msg_ctrl;
struct sockaddr_un *dest_addr;
- int i, r;
+ int r;
if (flags != 0) {
#if DEBUG
int r;
nwio_tcpopt_t tcpopt;
nwio_udpopt_t udpopt;
- struct sockaddr_un uds_addr;
int uds_sotype = -1;
r= ioctl(sock, NWIOGTCPOPT, &tcpopt);
new->st_ctimespec.tv_sec = prev->st_ctime;
}
+int _stat(const char *name, struct stat *buffer);
-int _stat(name, buffer)
-const char *name;
-struct stat *buffer;
+int _stat(const char *name, struct stat *buffer)
{
message m;
int r;
return r;
}
-int _fstat(fd, buffer)
-int fd;
-struct stat *buffer;
+int _fstat(int fd, struct stat *buffer);
+
+int _fstat(int fd, struct stat *buffer)
{
message m;
int r;
return r;
}
-int _lstat(name, buffer)
-const char *name;
-struct stat *buffer;
+int _lstat(const char *name, struct stat *buffer);
+
+int _lstat(const char *name, struct stat *buffer)
{
message m;
int r;
#include <sys/cdefs.h>
#include "namespace.h"
#include <lib.h>
+#include <sys/utsname.h>
int sysuname(int req, int field, char *value, size_t len)
{
int fd, opt;
const struct termios *t;
{
+#ifndef __minix
struct termios localterm;
+#endif
_DIAGASSERT(fd != -1);
_DIAGASSERT(t != NULL);
#endif /* __minix */
switch (opt & ~TCSASOFT) {
case TCSANOW:
- return (ioctl(fd, TIOCSETA, t));
+ return (ioctl(fd, TIOCSETA, __UNCONST(t)));
case TCSADRAIN:
- return (ioctl(fd, TIOCSETAW, t));
+ return (ioctl(fd, TIOCSETAW, __UNCONST(t)));
case TCSAFLUSH:
- return (ioctl(fd, TIOCSETAF, t));
+ return (ioctl(fd, TIOCSETAF, __UNCONST(t)));
default:
errno = EINVAL;
return (-1);
#include <fcntl.h>
#include <pwd.h>
#include <grp.h>
+#include <stdio.h>
/*
* group_from_gid()
static void __test_sse(void)
{
+#ifndef __minix
size_t oldlen = sizeof(__HAS_SSE);
int rv;
-#ifndef __minix
rv = sysctlbyname("machdep.sse", &__HAS_SSE, &oldlen, NULL, 0);
if (rv == -1)
#endif
#define _SYSTEM 1
#include <lib.h>
#include <unistd.h>
+#include <string.h>
/* return -1, when the query itself or the processing of query has errors.
* return 1, when there are more processes waiting to be queried.
PUBLIC int vm_watch_exit(endpoint_t ep)
{
message m;
- int r;
memset(&m, 0, sizeof(m));
m.VM_WE_EP = ep;
#include <sys/ctype_bits.h>
-#define isdigit(c) ((int)((_ctype_ + 1)[(c)] & _CTYPE_N))
-#define islower(c) ((int)((_ctype_ + 1)[(c)] & _CTYPE_L))
-#define isspace(c) ((int)((_ctype_ + 1)[(c)] & _CTYPE_S))
-#define ispunct(c) ((int)((_ctype_ + 1)[(c)] & _CTYPE_P))
-#define isupper(c) ((int)((_ctype_ + 1)[(c)] & _CTYPE_U))
-#define isalpha(c) ((int)((_ctype_ + 1)[(c)] & (_CTYPE_U|_CTYPE_L)))
-#define isxdigit(c) ((int)((_ctype_ + 1)[(c)] & (_CTYPE_N|_CTYPE_X)))
-#define isalnum(c) ((int)((_ctype_ + 1)[(c)] & (_CTYPE_U|_CTYPE_L|_CTYPE_N)))
-#define isprint(c) ((int)((_ctype_ + 1)[(c)] & (_CTYPE_P|_CTYPE_U|_CTYPE_L|_CTYPE_N|_CTYPE_B)))
-#define isgraph(c) ((int)((_ctype_ + 1)[(c)] & (_CTYPE_P|_CTYPE_U|_CTYPE_L|_CTYPE_N)))
-#define iscntrl(c) ((int)((_ctype_ + 1)[(c)] & _CTYPE_C))
-#define tolower(c) ((int)((_tolower_tab_ + 1)[(c)]))
-#define toupper(c) ((int)((_toupper_tab_ + 1)[(c)]))
+#define isdigit(c) ((int)((_ctype_ + 1)[(unsigned char)(c)] & _CTYPE_N))
+#define islower(c) ((int)((_ctype_ + 1)[(unsigned char)(c)] & _CTYPE_L))
+#define isspace(c) ((int)((_ctype_ + 1)[(unsigned char)(c)] & _CTYPE_S))
+#define ispunct(c) ((int)((_ctype_ + 1)[(unsigned char)(c)] & _CTYPE_P))
+#define isupper(c) ((int)((_ctype_ + 1)[(unsigned char)(c)] & _CTYPE_U))
+#define isalpha(c) ((int)((_ctype_ + 1)[(unsigned char)(c)] & (_CTYPE_U|_CTYPE_L)))
+#define isxdigit(c) ((int)((_ctype_ + 1)[(unsigned char)(c)] & (_CTYPE_N|_CTYPE_X)))
+#define isalnum(c) ((int)((_ctype_ + 1)[(unsigned char)(c)] & (_CTYPE_U|_CTYPE_L|_CTYPE_N)))
+#define isprint(c) ((int)((_ctype_ + 1)[(unsigned char)(c)] & (_CTYPE_P|_CTYPE_U|_CTYPE_L|_CTYPE_N|_CTYPE_B)))
+#define isgraph(c) ((int)((_ctype_ + 1)[(unsigned char)(c)] & (_CTYPE_P|_CTYPE_U|_CTYPE_L|_CTYPE_N)))
+#define iscntrl(c) ((int)((_ctype_ + 1)[(unsigned char)(c)] & _CTYPE_C))
+#define tolower(c) ((int)((_tolower_tab_ + 1)[(unsigned char)(c)]))
+#define toupper(c) ((int)((_toupper_tab_ + 1)[(unsigned char)(c)]))
#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
#define isascii(c) ((unsigned)(c) <= 0177)
#include <sys/cdefs.h>
+__BEGIN_DECLS
+int __cmsg_alignbytes(void);
+__END_DECLS
__BEGIN_DECLS
int accept(int, struct sockaddr * __restrict, socklen_t * __restrict);
#define OPEN_MAX __MINIX_OPEN_MAX /* max open files per process */
#endif
#define PATH_MAX __MINIX_PATH_MAX /* # chars in a path name */
-#define PIPE_BUF 7168 /* # bytes in atomic write to a pipe */
+#define PIPE_BUF 32768 /* # bytes in atomic write to a pipe */
#define BC_BASE_MAX INT_MAX /* max ibase/obase values in bc(1) */
#define BC_DIM_MAX 65535 /* max array elements in bc(1) */
__aconst char *crypt(const char *, const char *);
int encrypt(char *, int);
char *getpass(const char *);
-#ifndef __minix
pid_t getsid(pid_t);
-#endif /* !__minix */
#endif
int nfssvc(int, void *);
#ifndef __minix
int profil(char *, size_t, u_long, u_int);
+#endif /* !__minix */
#ifndef __PSIGNAL_DECLARED
#define __PSIGNAL_DECLARED
/* also in signal.h */
void psignal(int, const char *);
#endif /* __PSIGNAL_DECLARED */
-#endif /* !__minix */
int rcmd(char **, int, const char *, const char *, const char *, int *);
#ifdef __minix
int reboot(int, ...);
AFLAGS+=-D__ASSEMBLY__ -D_EM_WSIZE=4
-CFLAGS+= -fno-builtin -Wall -march=i586
+CFLAGS+= -fno-builtin -Wall -march=i586 -Wno-sign-compare
# Makefile for the tests.
GCC?=gcc
-CFLAGS= -O0 -D_MINIX -D_POSIX_SOURCE -g
+CFLAGS= -O0 -D_MINIX -D_POSIX_SOURCE -g -Wall -Werror
.if ${COMPILER_TYPE} == "gnu"
CFLAGS+= -D_NETBSD_SOURCE
LIBS+= -lm -lcompat_minix
test21 test22 test23 test25 test26 test27 test28 test29 \
test30 test31 test32 test34 test35 test36 test37 test38 \
test39 t10a t11a t11b test40 t40a t40b t40c t40d t40e t40f test41 \
- test42 test45 test47 test48 test49 test50 test51 test52 test53 \
- test54 test55 test56 test58
+ test42 test45 test47 test49 test50 test51 test52 test53 \
+ test54 test56 test58
BIGOBJ= test20 test24
ROOTOBJ= test11 test33 test43 test44 test46
-GCCOBJ= test45-gcc test49-gcc
+GCCOBJ= test45-gcc test48 test49-gcc test55
GCCFPUOBJ= test51-gcc test52-gcc
OTHEROBJ= test57 test59
}
void do_parent(void) {
- int fd_sock, fd_new, yes = 1, exitstatus;
+#ifndef _MINIX
+ int yes = 1;
+#endif
+ int fd_sock, fd_new, exitstatus;
int sockets[NUMCHILDREN], i;
fd_set fds_read, fds_write, fds_error;
fd_set fds_compare_read, fds_compare_write;
my_addr.sin_port = htons(MYPORT); /* Short, network byte order */
my_addr.sin_addr.s_addr = INADDR_ANY;
/* Normally we'd zerofill sin_zero, but there is no such thing on Minix */
-#ifndef _MINIX
+#ifndef _MINIX
memset(my_addr.sin_zero, '\0', sizeof my_addr.sin_zero);
#endif
{
int pid, k;
- if (pid = fork()) {
+ if ((pid = fork()) != 0) {
wait(&n); /* wait for some child (any one) */
} else {
k = execl(name[n], (char *) 0);
int n, etc_uid;
uid_t ruid, euid;
char *lnamep, *cnamep, *p;
- char array[L_cuserid], save[L_cuserid], save2[L_cuserid];
+#define MAXLINELEN 200
+ char array[MAXLINELEN], save[L_cuserid], save2[L_cuserid];
FILE *stream;
subtest = 3;
/* Check login against passwd file. First lookup login in /etc/passwd. */
if (n == 0) return; /* if login not found, don't look it up */
if ( (stream = fopen(passwd_file, "r")) == NULL) e(8);
- while (fgets(array, L_cuserid, stream) != NULL) {
+ while (fgets(array, sizeof(array), stream) != NULL) {
if (strncmp(array, save, n) == 0) {
p = &array[0]; /* hunt for uid */
while (*p != ':') p++;
int argc;
char *argv[];
{
- char buffer[PATH_MAX + 1];
int n, mask, i;
/* Create filenames for MAXOPEN files, the *filenames[] array. */
****************************************************************************/
int main(int argc, char **argv)
{
- char buffer[PATH_MAX + 1];
int n, i;
/* Create filenames for MAXOPEN files, the *file[] array. */
#include <unistd.h>
#include <stdio.h>
-#define MAX_ERROR 4
+#define MAX_ERROR 3
#define NB 30L
#define NBOUNDS 6
-int errct, subtest, passes, pipesigs;
+int subtest, passes, pipesigs;
long t1;
char aa[100];
long bounds[NBOUNDS] = {7, 9, 50, 519, 520, 40000L};
char buff[30000];
+#include "common.c"
+
_PROTOTYPE(int main, (int argc, char *argv[]));
_PROTOTYPE(void test19a, (void));
_PROTOTYPE(void test19b, (void));
_PROTOTYPE(void test19g, (void));
_PROTOTYPE(void clraa, (void));
_PROTOTYPE(void pipecatcher, (int s));
-_PROTOTYPE(void e, (int n));
-_PROTOTYPE(void quit, (void));
int main(argc, argv)
int argc;
char *argv[];
{
- char buffer[PATH_MAX + 1];
int i, m;
- m = (argc == 2 ? atoi(argv[1]) : 0xFFFF);
+ start(19);
- system("rm -rf DIR_19; mkdir DIR_19");
- chdir("DIR_19");
+ m = (argc == 2 ? atoi(argv[1]) : 0xFFFF);
- printf("Test 19 ");
- fflush(stdout);
for (i = 0; i < 4; i++) {
if (m & 0001) test19a();
if (m & 0002) test19b();
pipesigs++;
}
-void e(n)
-int n;
-{
- int err_num = errno; /* save errno in case printf clobbers it */
-
- printf("Subtest %d, error %d errno=%d ", subtest, n, errno);
- fflush(stdout); /* aargh! Most results go to stdout and are
- * messed up by perror going to stderr.
- * Should replace perror by printf and strerror
- * in all the tests.
- */
- errno = err_num; /* restore errno, just in case */
- perror("");
- if (errct++ > MAX_ERROR) {
- printf("Too many errors; test aborted\n");
- chdir("..");
- system("rm -rf DIR*");
- exit(1);
- }
-}
-
-void quit()
-{
-
- chdir("..");
- system("rm -rf DIR*");
-
- if (errct == 0) {
- printf("ok\n");
- exit(0);
- } else {
- printf("%d errors\n", errct);
- exit(1);
- }
-}
-
#include <stdio.h>
#define ITERATIONS 1
-#define MAX_ERROR 4
+#define MAX_ERROR 3
#include "common.c"
char *argv[];
{
- char buffer[PATH_MAX + 1];
int i, m = 0xFFFF;
- sync();
+ start(21);
if (argc == 2) m = atoi(argv[1]);
- start(21);
for (i = 0; i < ITERATIONS; i++) {
if (m & 00001) test21a();
if (m & 00002) test21b();
int main(int argc, char *argv[])
{
- char buffer[PATH_MAX + 1];
int i, m = 0xFFFF;
sync();
Chdir("DIR_27"); /* back to test dir */
/* Check on ToLongName etc. */
-#ifdef _POSIX_NO_TRUNC
-# if _POSIX_NO_TRUNC - 0 != -1
- if (stat(ToLongName, &st) != -1) e(4); /* name is too long */
- if (errno != ENAMETOOLONG) e(5);
-# endif
-#else
-# include "error, this case requires dynamic checks and is not handled"
-#endif
if (stat(ToLongPath, &st) != -1) e(6); /* path is too long */
if (errno != ENAMETOOLONG) e(7);
int other = 0, dot = 0, dotdot = 0; /* dirent counters */
int r; /* Intermediate result */
int rmdir_result; /* tmp var */
- nlink_t nlink;
- static char bar[20];
int stat_loc, does_truncate;
subtest = 2;
if (mkdir("foo", 0777) != 0) e(21);
System("touch foo/xyzzy");
-#if 0
- /* Test what happens if the parent link count > LINK_MAX. */
- /* This takes too long. */
- for (nlink = 1; nlink < LINK_MAX; nlink++) { /* make all */
- sprintf(bar, "foo/bar.%d", nlink);
- if (link("foo/xyzzy", bar) != 0) e(24);
- }
- if (stat("foo/xyzzy", &st) != 0) e(25); /* foo now */
- if (st.st_nlink != LINK_MAX) e(26); /* is full */
- if (link("foo/xyzzy", "nono") != -1) e(27); /* no more */
- if (errno != EMLINK) e(28); /* entrys. */
- System("rm -rf foo/nono"); /* Just in case. */
-#endif
/* Test if rmdir removes only empty dirs */
if (rmdir("foo") != -1) e(29);/* not empty */
#include <stdio.h>
#define ITERATIONS 10
-#define MAX_ERROR 4
+#define MAX_ERROR 3
#define SIZE 64
-int errct, subtest;
+int subtest;
char el_weirdo[] = "\n\t\\\e@@!!##\e\e\n\n";
+#include "common.c"
+
_PROTOTYPE(int main, (int argc, char *argv []));
_PROTOTYPE(void test3a, (void));
-_PROTOTYPE(void test3b, (void));
_PROTOTYPE(void test3c, (void));
_PROTOTYPE(void test3d, (void));
_PROTOTYPE(void test3e, (void));
-_PROTOTYPE(void quit, (void));
_PROTOTYPE(void e, (int n));
int main(argc, argv)
int argc;
char *argv[];
{
- char buffer[PATH_MAX + 1];
int i, m = 0xFFFF;
- sync();
-
-
+ start(3);
if (argc == 2) m = atoi(argv[1]);
- printf("Test 3 ");
- fflush(stdout); /* have to flush for child's benefit */
-
- system("rm -rf DIR_03; mkdir DIR_03");
- chdir("DIR_03");
-
for (i = 0; i < ITERATIONS; i++) {
if (m & 0001) test3a();
- if (m & 0002) test3b();
if (m & 0004) test3c();
if (m & 0010) test3d();
if (m & 0020) test3e();
}
-void test3b()
-{
-/* Test uname. */
-
- struct utsname u; /* contains all kinds of system ids */
-
- subtest = 2;
-#if 0
- errno = -2000; /* None of these calls set errno. */
- if (uname(&u) != 0) e(1);
- if (strcmp(u.sysname, "MINIX") != 0
- && strcmp(u.sysname, "Minix") != 0) e(2); /* only one defined */
-#endif
-}
-
void test3c()
{
/* Test getenv. Asume HOME, PATH, and LOGNAME exist (not strictly required).*/
if (sysconf(_SC_JOB_CONTROL) >= 0) e(5); /* no job control! */
}
-void quit()
-{
- chdir("..");
- system("rm -rf DIR*");
-
- if (errct == 0) {
- printf("ok\n");
- exit(0);
- } else {
- printf("%d errors\n", errct);
- exit(4);
- }
-}
-
-void e(n)
-int n;
-{
- int err_num = errno; /* save errno in case printf clobbers it */
-
- printf("Subtest %d, error %d errno=%d ", subtest, n, errno);
- errno = err_num; /* restore errno, just in case */
- perror("");
- if (errct++ > MAX_ERROR) {
- printf("Test aborted. Too many errors: ");
- chdir("..");
- system("rm -rf DIR*");
- exit(1);
- }
-}
void test_attach()
{
pid_t pid;
- int r, status;
subtest = 9;
#include <sys/stat.h>
#include <unistd.h>
-#define MAX_ERROR 4
+#define MAX_ERROR 3
-static int errct = 0;
-static const char *executable, *subtest;
+int subtest;
+static const char *executable;
-#define ERR (e(__LINE__))
-
-static void e(int n)
-{
- printf("File %s, error line %d, errno %d: %s\n",
- subtest, n, errno, strerror(errno));
-
- if (errct++ > MAX_ERROR)
- {
- printf("Too many errors; test aborted\n");
- exit(1);
- }
-}
+#include "common.c"
-static void quit(void)
-{
- if (errct == 0)
- {
- printf("ok\n");
- exit(0);
- }
- else
- {
- printf("%d errors\n", errct);
- exit(1);
- }
-}
+#define ERR (e(__LINE__))
static char *remove_last_path_component(char *path)
{
expected_errno2 = check_path_components(path);
/* run realpath */
- subtest = path;
errno = 0;
resolved_path = realpath(path, buffer);
{
if (resolved_path) ERR;
if (errno != expected_errno && errno != expected_errno2) ERR;
- subtest = NULL;
return;
}
if (!resolved_path)
{
ERR;
- subtest = NULL;
return;
}
errno = 0;
if (lstat(resolved_path, &statbuf[1]) < 0) { ERR; return; }
if ((statbuf[1].st_mode & S_IFMT) != S_IFDIR) ERR;
}
- subtest = NULL;
}
static void check_realpath_step_by_step(const char *path, int expected_errno)
/* loop through subdirectories (including . and ..) */
if (!(dir = opendir(path)))
{
- if (errno != ENOENT && errno != ENOTDIR)
+ /* Opening some special files might result in errors when the
+ * corresponding hardware is not present, or simply when access
+ * rights prohibit access (e.g., /dev/log).
+ */
+ if (errno != ENOTDIR
+ && errno != ENXIO && errno != EIO && errno != EACCES) {
ERR;
+ }
return;
}
- while (dirent = readdir(dir))
+ while ((dirent = readdir(dir)) != NULL)
{
/* build path */
if (!pathncat(pathsub, sizeof(pathsub), path, dirent->d_name))
}
#define PATH_DEPTH 4
-#define PATH_BASE "/t43"
+#define PATH_BASE "/."
#define L(x) PATH_BASE "/link_" #x ".tmp"
static char basepath[PATH_MAX + 1];
static char *addbasepath(char *buffer, const char *path)
{
size_t basepathlen, pathlen;
- int slashlen;
/* assumption: both start with slash and neither end with it */
assert(basepath[0] == '/');
return buffer;
}
-static void cleanup(const char *path)
-{
- DIR *dir;
- struct dirent *dirent;
- char pathsub[PATH_MAX + 1];
- struct stat statbuf;
-
- /* determine file type, avoid following links */
- if (lstat(path, &statbuf) < 0)
- {
- if (errno != ENOENT) ERR;
- return;
- }
-
- /* only recursively process directories (NOT symlinks!) */
- if ((statbuf.st_mode & S_IFMT) != S_IFDIR)
- {
- if (unlink(path) < 0) ERR;
- return;
- }
-
- /* loop through subdirectories (excluding . and ..) */
- if (!(dir = opendir(path)))
- {
- ERR;
- return;
- }
- while (dirent = readdir(dir))
- {
- /* ignore current and parent directories */
- if (strcmp(dirent->d_name, ".") == 0 ||
- strcmp(dirent->d_name, "..") == 0)
- continue;
-
- /* build path */
- if (!pathncat(pathsub, sizeof(pathsub), path, dirent->d_name))
- {
- ERR;
- continue;
- }
-
- /* delete path */
- cleanup(pathsub);
- }
- if (closedir(dir) < 0) ERR;
-
- /* remove the (now empty) directory itself */
- if (rmdir(path) < 0) ERR;
-}
-
static void test_dirname(const char *path, const char *exp)
{
char buffer[PATH_MAX];
int main(int argc, char **argv)
{
char buffer1[PATH_MAX + 1], buffer2[PATH_MAX + 1];
+ subtest = 1;
/* initialize */
- printf("Test 43 ");
- fflush(stdout);
+ start(43);
executable = argv[0];
getcwd(basepath, sizeof(basepath));
- cleanup(addbasepath(buffer1, PATH_BASE));
/* prepare some symlinks to make it more difficult */
- if (mkdir(addbasepath(buffer1, PATH_BASE), S_IRWXU) < 0) ERR;
if (symlink("/", addbasepath(buffer1, L(1))) < 0) ERR;
if (symlink(basepath, addbasepath(buffer1, L(2))) < 0) ERR;
check_realpath_step_by_step(addbasepath(buffer1, L(5)), ELOOP);
/* delete the symlinks */
- cleanup(addbasepath(buffer1, PATH_BASE));
+ cleanup();
/* also test dirname */
test_dirname("", ".");
#include <stdlib.h>
#include <unistd.h>
+#if defined(__clang__)
+#pragma clang diagnostic ignored "-Wtautological-compare"
+#endif
+
#define MAX_ERROR 4
static int errct;
* must have super user privileges.
*/
- int r, i, nogroups;
+ int i;
gid_t *grouplist, *grouplist2;
long ngroups_max;
* the imaginary group, and readable, writable, and both by everyone else (2).
*/
- int r, i, round, test_result;
+ int i, round;
gid_t *grouplist;
long ngroups_max;
#define ROUNDS 8
static void test_remainder_value(double x, double y)
{
int mode_old;
- double r1, r2, z;
+ double r1, r2;
assert(y != 0);
#include <string.h>
#include <unistd.h>
-#define MAX_ERRORS 8
+#define MAX_ERRORS 3
static int errct;
static void test_getaddrinfo(
const char *nodename,
+ int nodename_numerical,
const char *servname,
+ int servname_numerical,
int passhints,
int flags,
int family,
struct addrinfo hints;
struct sockaddr_in *sockaddr_in;
int ai_count_dgram, ai_count_stream, r;
-
+
/* some parameters are only meaningful with hints */
assert(passhints || !flags);
assert(passhints || family == AF_UNSPEC);
assert(passhints || !socktype);
+ /* a combination of parameters don't make sense to test */
+ if (nodename == NULL && servname == NULL) return;
+ if (nodename == NULL && (flags & AI_NUMERICHOST)) return;
+ if (servname == NULL && (flags & AI_NUMERICSERV)) return;
+
/* initialize hints */
memset(&hints, 0, sizeof(hints));
hints.ai_flags = flags;
hints.ai_family = family;
hints.ai_socktype = socktype;
- hints.ai_family = family;
/* perform query and test result */
ai = (struct addrinfo *) 0xDEADBEEF;
ntohs(sockaddr_in->sin_port));
}
- /* is canonical supplied? */
- if (exp_canonname &&
- (!ai_cur->ai_canonname || !*ai_cur->ai_canonname))
- test_getaddrinfo_err(7,
- TEST_GETADDRINFO_ERR_PARAMS,
- "(anything)", ai_cur->ai_canonname);
-
- if (!exp_canonname && ai_cur->ai_canonname)
- test_getaddrinfo_err(8,
- TEST_GETADDRINFO_ERR_PARAMS,
- NULL, ai_cur->ai_canonname);
+ /* If a hostname is numeric, there can't be a canonical name.
+ * Instead, the returned canonname (if requested) will be
+ * identical to the supplied hostname */
+ if (nodename != NULL && nodename_numerical &&
+ (flags & AI_CANONNAME)) {
+ if (strncmp(ai_cur->ai_canonname, nodename,
+ strlen(nodename)))
+ test_getaddrinfo_err(11,
+ TEST_GETADDRINFO_ERR_PARAMS,
+ nodename, ai_cur->ai_canonname);
+ } else {
+ /* is canonical supplied? */
+ if (exp_canonname && nodename &&
+ (!ai_cur->ai_canonname || !*ai_cur->ai_canonname))
+ test_getaddrinfo_err(7,
+ TEST_GETADDRINFO_ERR_PARAMS,
+ "(anything)", ai_cur->ai_canonname);
+
+ if (!exp_canonname && ai_cur->ai_canonname)
+ test_getaddrinfo_err(8,
+ TEST_GETADDRINFO_ERR_PARAMS,
+ NULL, ai_cur->ai_canonname);
+ }
/* move to next result */
ai_cur = ai_cur->ai_next;
}
- /* check number of results */
- if (ai_count_dgram != ((socktype == SOCK_STREAM) ? 0 : 1))
- test_getaddrinfo_err_nr(9, TEST_GETADDRINFO_ERR_PARAMS,
+ /* If socket type is non-zero, make sure we got what we wanted. Else
+ * any result is okay. */
+ if (socktype) {
+ if (ai_count_dgram != ((socktype == SOCK_STREAM) ? 0 : 1))
+ test_getaddrinfo_err_nr(9, TEST_GETADDRINFO_ERR_PARAMS,
(socktype == SOCK_STREAM) ? 0 : 1, ai_count_dgram);
- if (ai_count_stream != ((socktype == SOCK_DGRAM) ? 0 : 1))
- test_getaddrinfo_err_nr(10, TEST_GETADDRINFO_ERR_PARAMS,
+ if (ai_count_stream != ((socktype == SOCK_DGRAM) ? 0 : 1))
+ test_getaddrinfo_err_nr(10, TEST_GETADDRINFO_ERR_PARAMS,
(socktype == SOCK_DGRAM) ? 0 : 1, ai_count_stream);
+ }
/* clean up */
freeaddrinfo(ai);
int need_network;
int exp_result;
} hosts[] = {
- { NULL, 0x7f000001, 1, 1, 0, 0 },
- { "0.0.0.0", 0x00000000, 1, 0, 0, 0, },
- { "0.0.0.255", 0x000000ff, 1, 0, 0, 0, },
- { "0.0.255.0", 0x0000ff00, 1, 0, 0, 0, },
- { "0.255.0.0", 0x00ff0000, 1, 0, 0, 0, },
- { "255.0.0.0", 0xff000000, 1, 0, 0, 0, },
- { "127.0.0.1", 0x7f000001, 1, 0, 0, 0, },
- { "localhost", 0x7f000001, 0, 1, 0, 0, },
- { "minix3.org", 0x82251414, 0, 1, 1, 0, },
- { "", 0x00000000, 1, 0, 0, (1 << EAI_NONAME) },
- { "256.256.256.256", 0x00000000, 1, 0, 0, (1 << EAI_NONAME) },
- { "minix3.xxx", 0x00000000, 0, 0, 1, (1 << EAI_NONAME) }};
+ { NULL, 0x7f000001, 1, 1, 0, 0 },
+ { "0.0.0.0", 0x00000000, 1, 0, 0, 0 },
+ { "0.0.0.255", 0x000000ff, 1, 0, 0, 0 },
+ { "0.0.255.0", 0x0000ff00, 1, 0, 0, 0 },
+ { "0.255.0.0", 0x00ff0000, 1, 0, 0, 0 },
+ { "255.0.0.0", 0xff000000, 1, 0, 0, 0 },
+ { "127.0.0.1", 0x7f000001, 1, 0, 0, 0 },
+ { "localhost", 0x7f000001, 0, 1, 0, 0, },
+ { "minix3.org", 0x82251414, 0, 1, 1, 0, },
+ { "", 0x00000000, 1, 0, 0, (1<<EAI_NONAME)|(1<<EAI_FAIL)|(1<<EAI_NODATA)},
+ { "256.256.256.256",0x00000000, 1, 0, 0, (1<<EAI_NONAME)|(1<<EAI_FAIL)|(1<<EAI_NODATA)},
+ { "minix3.xxx", 0x00000000, 0, 0, 1, (1<<EAI_NONAME)|(1<<EAI_FAIL)|(1<<EAI_NODATA)}};
static struct
{
{ "echo", 7, 0, 0, 0 },
{ "ftp", 21, 0, SOCK_STREAM, 0 },
{ "tftp", 69, 0, SOCK_DGRAM , 0 },
- { "-1", 0, 1, 0, (1 << EAI_SERVICE) },
- { "", 0, 1, 0, (1 << EAI_SERVICE) },
+ { "-1", 0, 1, 0, (1<<EAI_NONAME) | (1<<EAI_SERVICE) },
+ { "", 0, 1, 0, (1<<EAI_NONAME) | (1<<EAI_SERVICE) },
{ "65537", 0, 1, 0, (1 << EAI_SERVICE) },
{ "XXX", 0, 0, 0, (1 << EAI_SERVICE) }};
} families[] = {
{ AF_UNSPEC, 0 },
{ AF_INET, 0 },
- { AF_UNSPEC + AF_INET + 1, (1 << EAI_FAMILY) }};
+ { AF_UNSPEC + AF_INET + 1, (1 << EAI_FAMILY) }};
static struct
{
{ 0, 0 },
{ SOCK_STREAM, 0 },
{ SOCK_DGRAM, 0 },
- { SOCK_STREAM + SOCK_DGRAM + 1, (1 << EAI_SOCKTYPE) }};
+ { SOCK_STREAM + SOCK_DGRAM + 1,
+ (1 << EAI_SOCKTYPE) | (1 << EAI_FAIL) | (1 << EAI_NONAME) }};
#define LENGTH(a) (sizeof((a)) / sizeof((a)[0]))
static void test_getaddrinfo_all(int use_network)
{
int flag_PASSIVE, flag_CANONNAME, flag_NUMERICHOST, flag_NUMERICSERV;
- int exp_results, flags, i, j, k, l, needhints, passhints;
+ int exp_results, flags, i, j, k, l, passhints;
unsigned long ipaddr;
/* loop through various parameter values */
for (flag_CANONNAME = 0; flag_CANONNAME < 2; flag_CANONNAME++)
for (flag_NUMERICHOST = 0; flag_NUMERICHOST < 2; flag_NUMERICHOST++)
for (flag_NUMERICSERV = 0; flag_NUMERICSERV < 2; flag_NUMERICSERV++)
+ for (passhints = 0; passhints < 2; passhints++)
{
/* skip tests that need but cannot use network */
if (!use_network && hosts[i].need_network)
(flag_NUMERICHOST ? AI_NUMERICHOST : 0) |
(flag_NUMERICSERV ? AI_NUMERICSERV : 0);
+ /* some options require hints */
+ if (families[k].value != AF_UNSPEC ||
+ socktypes[l].value != 0 || flags) {
+ passhints = 1;
+ }
+
/* flags may influence IP address */
ipaddr = hosts[i].ipaddr;
if (!hosts[i].nodename && flag_PASSIVE)
exp_results |= (1 << EAI_NONAME);
if (flag_NUMERICSERV && !services[j].numeric)
- exp_results |= (1 << EAI_SERVICE);
+ exp_results |= (1 << EAI_NONAME);
- if (services[j].socktype && socktypes[l].value != services[j].socktype)
- exp_results |= (1 << EAI_SERVICE);
+ /* When we don't pass hints, getaddrinfo will find suitable
+ * settings for us. If we do pass hints, there might be
+ * conflicts.
+ */
+ if (passhints) {
+ /* Can't have conflicting socket types */
+ if (services[j].socktype &&
+ socktypes[l].value &&
+ socktypes[l].value != services[j].socktype) {
+ exp_results |= (1 << EAI_SERVICE);
+ }
+ }
/* with no reason for failure, we demand success */
if (!exp_results)
exp_results |= (1 << 0);
- /* some options require hints */
- needhints = (families[k].value != AF_UNSPEC ||
- socktypes[l].value != 0 || flags) ? 1 : 0;
- for (passhints = needhints; passhints < 2; passhints++)
- {
- /* test getaddrinfo function */
- test_getaddrinfo(
- hosts[i].nodename,
- services[j].servname,
- passhints,
- flags,
- families[k].value,
- socktypes[l].value,
- exp_results,
- htonl(ipaddr),
- flag_CANONNAME && hosts[i].canonname,
- htons(services[j].port));
- }
+ /* test getaddrinfo function */
+ test_getaddrinfo(
+ hosts[i].nodename,
+ hosts[i].numeric,
+ services[j].servname,
+ services[j].numeric,
+ passhints,
+ flags,
+ families[k].value,
+ socktypes[l].value,
+ exp_results,
+ htonl(ipaddr),
+ flag_CANONNAME && hosts[i].canonname,
+ htons(services[j].port));
}
}
/* determine expected result */
exp_results = 0;
- if (!buflens[k] && !buflens[l])
- exp_results |= (1 << EAI_NONAME);
nodename = flag_NUMERICHOST ? ipaddrs[i].nodenum : ipaddrs[i].nodename;
if (buflens[k] > 0 && buflens[k] <= strlen(nodename))
- exp_results |= (1 << EAI_OVERFLOW);
+ exp_results |= (1 << EAI_OVERFLOW) | (1 << EAI_MEMORY);
socktypemismatch =
(flag_DGRAM && ports[j].socktype == SOCK_STREAM) ||
servname = (flag_NUMERICSERV || socktypemismatch) ?
ports[j].servnum : ports[j].servname;
if (buflens[l] > 0 && buflens[l] <= strlen(servname))
- exp_results |= (1 << EAI_OVERFLOW);
+ exp_results |= (1 << EAI_OVERFLOW) | (1 << EAI_MEMORY);
- if (flag_NAMEREQD && (!ipaddrs[i].havename | flag_NUMERICHOST) && buflens[k])
+ if (flag_NAMEREQD && (!ipaddrs[i].havename || flag_NUMERICHOST) && buflens[k])
exp_results |= (1 << EAI_NONAME);
/* with no reason for failure, we demand success */
static int can_use_network(void)
{
- pid_t pid;
int status;
/* try to ping minix3.org */
use_network = can_use_network();
if (!use_network)
printf("Warning: no network\n");
-
test_getaddrinfo_all(use_network);
test_getnameinfo_all();
#include <string.h>
#define ITERATIONS 2
-#define MAX_ERROR 4
+#define MAX_ERROR 3
-int errct;
int subtest;
int zero[1024];
-
int sigmap[5] = {9, 10, 11};
+#include "common.c"
+
_PROTOTYPE(int main, (int argc, char *argv[]));
_PROTOTYPE(void test5a, (void));
_PROTOTYPE(void parent, (int childpid));
_PROTOTYPE(void test5h, (void));
_PROTOTYPE(void test5i, (void));
_PROTOTYPE(void ex, (void));
-_PROTOTYPE(void e, (int n));
-_PROTOTYPE(void quit, (void));
-
-#ifdef _ANSI
-void (*Signal(int _sig, void (*_func)(int)))(int);
-#define SIG_ZERO ((void (*)(int))0) /* default signal handling */
-#else
-sighandler_t Signal();
-/* void (*Signal()) (); */
-#define SIG_ZERO ((void (*)())0) /* default signal handling */
-#endif
_VOLATILE int childsigs, parsigs, alarms;
{
int i, m = 0x7777;
- printf("Test 5 ");
- fflush(stdout); /* have to flush for child's benefit */
-
- system("rm -rf DIR_05; mkdir DIR_05");
- chdir("DIR_05");
+ start(5);
for (i = 0; i < ITERATIONS; i++) {
if (m & 0001) test5a();
for (zp = &zero[0]; zp < &zero[1024]; zp++)
if (*zp != 0) flag = 1;
if (flag) e(0); /* check if bss is cleared to 0 */
- if (Signal(1, func1) == SIG_ERR) e(1);
- if (Signal(10, func10) < SIG_ZERO) e(2);
+ if (signal(1, func1) == SIG_ERR) e(1);
+ if (signal(10, func10) == SIG_ERR) e(2);
parpid = getpid();
- if (childpid = fork()) {
+ if ((childpid = fork()) != 0) {
if (childpid < 0) ex();
parent(childpid);
} else {
child(parpid);
}
- if (Signal(1, SIG_DFL) < SIG_ZERO) e(4);
- if (Signal(10, SIG_DFL) < SIG_ZERO) e(5);
+ if (signal(1, SIG_DFL) == SIG_ERR) e(4);
+ if (signal(10, SIG_DFL) == SIG_ERR) e(5);
}
void parent(childpid)
void func1(s)
int s; /* for ANSI */
{
- if (Signal(1, func1) < SIG_ZERO) e(10);
+ if (signal(1, func1) == SIG_ERR) e(10);
childsigs++;
}
void func10(s)
int s; /* for ANSI */
{
- if (Signal(10, func10) < SIG_ZERO) e(11);
+ if (signal(10, func10) == SIG_ERR) e(11);
parsigs++;
}
int cpid, n, pid;
subtest = 1;
- if ((pid = fork())) {
+ if ((pid = fork()) != 0) {
if (pid < 0) ex();
- if ((pid = fork())) {
+ if ((pid = fork()) != 0) {
if (pid < 0) ex();
- if (cpid = fork()) {
+ if ((cpid = fork()) != 0) {
if (cpid < 0) ex();
if (kill(cpid, 9) < 0) e(12);
if (wait(&n) < 0) e(13);
/* Test exit status codes for processes killed by signals. */
subtest = 3;
for (i = 0; i < 2; i++) {
- if (pid = fork()) {
+ if ((pid = fork()) != 0) {
if (pid < 0) ex();
sleep(2); /* wait for child to pause */
if (kill(pid, sigmap[i]) < 0) {
subtest = 4;
alarms = 0;
for (i = 0; i < 8; i++) {
- Signal(SIGALRM, funcalrm);
+ signal(SIGALRM, funcalrm);
alarm(1);
pause();
if (alarms != i + 1) e(24);
int n, j;
subtest = 5;
- if (Signal(8, func8) < SIG_ZERO) e(25);
- if (n = fork()) {
+ if (signal(8, func8) == SIG_ERR) e(25);
+ if ((n = fork()) != 0) {
/* Parent must delay to give child a chance to pause. */
if (n < 0) ex();
sleep(1);
if (kill(n, 8) < 0) e(26);
if (wait(&n) < 0) e(27);
- if (Signal(8, SIG_DFL) < SIG_ZERO) e(28);
+ if (signal(8, SIG_DFL) == SIG_ERR) e(28);
} else {
j = pause();
if (errno != EINTR && -errno != EINTR) e(29);
int n;
subtest = 7;
- Signal(11, func11);
- Signal(11, SIG_IGN);
+ signal(11, func11);
+ signal(11, SIG_IGN);
n = getpid();
if (kill(n, 11) != 0) e(1);
- Signal(11, SIG_DFL);
+ signal(11, SIG_DFL);
}
void funcalrm(s)
subtest = 8;
unlink("XXX.test5");
- if (Signal(8, func8) < SIG_ZERO) e(1);
+ if (signal(8, func8) == SIG_ERR) e(1);
pipe(fd);
- if (n = fork()) {
+ if ((n = fork()) != 0) {
/* Parent must delay to give child a chance to pause. */
if (n < 0) ex();
while (access("XXX.test5", 0) != 0) /* just wait */ ;
unlink("XXX.test5");
if (kill(n, 8) < 0) e(2);
if (wait(&n) < 0) e(3);
- if (Signal(8, SIG_DFL) < SIG_ZERO) e(4);
+ if (signal(8, SIG_DFL) == SIG_ERR) e(4);
if (close(fd[0]) != 0) e(5);
if (close(fd[1]) != 0) e(6);
} else {
pipe(fd);
unlink("XXXxxxXXX");
- if ( (pid = fork())) {
+ if ((pid = fork()) != 0) {
/* Parent */
/* Wait until child has started and has created the XXXxxxXXX file. */
while (access("XXXxxxXXX", 0) != 0) /* loop */ ;
exit(1);
}
-void e(n)
-int n;
-{
- int err_num = errno; /* save errno in case printf clobbers it */
-
- printf("Subtest %d, error %d errno=%d ", subtest, n, errno);
- errno = err_num; /* restore errno, just in case */
- perror("");
- if (errct++ > MAX_ERROR) {
- printf("Too many errors; test aborted\n");
- chdir("..");
- system("rm -rf DIR*");
- exit(1);
- }
-}
-
-#ifdef _ANSI
-void (*Signal(int a, void (*b)(int)))(int)
-#else
-sighandler_t Signal(a, b)
-int a;
-void (*b)();
-#endif
-{
- if (signal(a, (void (*) ()) b) == (void (*)()) -1)
- return(SIG_ERR);
- else
- return(SIG_ZERO);
-}
-
-void quit()
-{
-
- chdir("..");
- system("rm -rf DIR*");
-
- if (errct == 0) {
- printf("ok\n");
- exit(0);
- } else {
- printf("%d errors\n", errct);
- exit(1);
- }
-}
int argc;
char *argv[];
{
- int i, j, m = 0xFFFF;
+ int j, m = 0xFFFF;
start(50);
prepare();
off_t size;
{
off_t off;
- int i, fd, r;
+ int fd, r;
if ((fd = open(TESTFILE, O_RDWR|O_CREAT|O_EXCL, 0600)) < 0) e(1001);
off_t osize;
off_t nsize;
{
- int fd, r;
+ int fd;
fd = make_file(osize);
{
int status;
subtest = 4;
- n = n;
+
+ (void) n; /* Avoid warning about unused parameter */
if (wait(&status) == -1) err(1);
static void err(int line)
{
/* print error information */
- printf("error line %d; i=0x%.8x%.8x; j=0x%.8x%.8x; k=0x%.8x%.8x\n",
+ printf("error line %d; i=0x%.8lx%.8lx; j=0x%.8lx%.8lx; k=0x%.8lx%.8lx\n",
line,
ex64hi(i), ex64lo(i),
ex64hi(j), ex64lo(j),
size_t size;
ssize_t nwritten;
ssize_t nread;
- char *filename;
+ char *filename = "pwrite_test_XXXXXXX";
int i;
subtest = 1;
- if((filename = mktemp("pwrite_test_XXXXXXX")) == NULL) e(1);
- if((fd = open(filename, O_CREAT|O_RDWR)) < 0) e(2);
+ if ((fd = mkstemp(filename)) < 0) e(1);
size = 1 + rand() % 4096;
off = rand();
- if((wbuf = malloc(sizeof(char)*size)) == NULL) e(3);
+ if((wbuf = malloc(sizeof(char)*size)) == NULL) e(2);
for(i = 0; i < size; i++) {
wbuf[i] = 1 + rand()%127;
}
- if((nwritten = pwrite(fd, wbuf, size, off)) < 0) e(4);
- if((rbuf = malloc(sizeof(char)*nwritten)) == NULL) e(5);
- if((nread = pread(fd, rbuf, nwritten, off)) < 0) e(6);
- if(strncmp(rbuf, wbuf, nread) != 0) e(7);
+ if ((nwritten = pwrite(fd, wbuf, size, off)) < 0) e(3);
+ if ((rbuf = malloc(sizeof(char)*nwritten)) == NULL) e(4);
+ if ((nread = pread(fd, rbuf, nwritten, off)) < 0) e(5);
+ if (strncmp(rbuf, wbuf, nread) != 0) e(6);
close(fd);
free(wbuf);
#define TRIALS 10
#define SIZE 65536
-#define TMPPATH "/usr/tmp/"
+#define MAX_ERROR 3
-char *create_file(void)
+int subtest;
+char *filename = "statvfs_test_XXXXXX";
+#include "common.c"
+
+void create_file(void)
{
char buf[SIZE]={0};
char *p;
ssize_t ntowrite, nwritten;
int fd;
- char *filename;
-
- if((filename = mktemp(TMPPATH "statvfs_test_XXXXXXX")) == NULL) {
- err(1, "mktemp failed");
- }
- if((fd = open(filename, O_CREAT|O_WRONLY)) < 0) {
- err(1, "open failed");
- }
+ subtest = 2;
+ if ((fd = mkstemp(filename)) < 0) e(1);
ntowrite = SIZE;
p = &buf[0];
- while(ntowrite > 0) {
- if((nwritten = write(fd, p, ntowrite)) < 0) {
- err(1, "write failed");
- }
+ while (ntowrite > 0) {
+ if ((nwritten = write(fd, p, ntowrite)) < 0) e(2);
p += nwritten;
ntowrite -= nwritten;
}
- close(fd);
-
- return filename;
+ if (close(fd) < 0) e(3);
}
int main(int argc, char *argv[])
unsigned long f_namemax, f_namemax_new;
int i;
- printf("Test 55 ");
-
- for(i = 0; i < TRIALS; i++) {
- int r;
- char *filename;
+ start(55);
- if(statvfs(TMPPATH, &stats) < 0) {
- perror("statvfs failed");
- return 1;
- }
+ subtest = 1;
+ for(i = 0; i < TRIALS; i++) {
+ if (statvfs(".", &stats) < 0) e(1);
f_bsize = stats.f_bsize ;
f_frsize = stats.f_frsize ;
f_flag = stats.f_flag ;
f_namemax = stats.f_namemax;
- filename = create_file();
-
- r = statvfs(TMPPATH, &stats);
+ create_file();
- unlink(filename);
-
- if(r < 0) {
- perror("statvfs failed");
- return 1;
- }
+ if (statvfs(".", &stats) < 0) e(2);
+ if (unlink(filename) < 0) e(3);
f_bsize_new = stats.f_bsize ;
- f_frsize_new = stats.f_frsize ;
- f_blocks_new = stats.f_blocks ;
- f_bfree_new = stats.f_bfree ;
- f_bavail_new = stats.f_bavail ;
- f_files_new = stats.f_files ;
- f_ffree_new = stats.f_ffree ;
- f_favail_new = stats.f_favail ;
- f_fsid_new = stats.f_fsid ;
- f_flag_new = stats.f_flag ;
- f_namemax_new = stats.f_namemax;
-
- if ((f_bsize == f_bsize_new) &&
- (f_frsize == f_frsize_new) &&
- (f_blocks == f_blocks_new) &&
- (f_bfree > f_bfree_new) &&
- (f_bavail > f_bavail_new) &&
- (f_files == f_files_new) &&
- (f_ffree == f_ffree_new + 1) &&
- (f_favail == f_favail_new + 1) &&
- (f_fsid == f_fsid_new) &&
- (f_flag == f_flag_new) &&
- (f_namemax == f_namemax_new) ) {
- printf("ok\n");
- return 0;
+ f_frsize_new = stats.f_frsize ;
+ f_blocks_new = stats.f_blocks ;
+ f_bfree_new = stats.f_bfree ;
+ f_bavail_new = stats.f_bavail ;
+ f_files_new = stats.f_files ;
+ f_ffree_new = stats.f_ffree ;
+ f_favail_new = stats.f_favail ;
+ f_fsid_new = stats.f_fsid ;
+ f_flag_new = stats.f_flag ;
+ f_namemax_new = stats.f_namemax;
+
+ if (!((f_bsize == f_bsize_new) &&
+ (f_frsize == f_frsize_new) &&
+ (f_blocks == f_blocks_new) &&
+ (f_bfree > f_bfree_new) &&
+ (f_bavail > f_bavail_new) &&
+ (f_files == f_files_new) &&
+ (f_ffree == f_ffree_new + 1) &&
+ (f_favail == f_favail_new + 1) &&
+ (f_fsid == f_fsid_new) &&
+ (f_flag == f_flag_new) &&
+ (f_namemax == f_namemax_new))) {
+ e(4);
}
}
- return 1;
+ quit();
+ return(-1);
}
void test_listen(void)
{
- int sd;
int rc;
debug("entering test_listen()");
int rc;
int sd;
int option_value;
- int option_value_orig;
socklen_t option_len;
debug("entering test_sockopts()");
*/
void test_xfer_server(pid_t pid)
{
- struct ucred credentials;
socklen_t ucred_length;
int i;
int on;
int client_sd;
struct sockaddr_un addr;
struct sockaddr_un client_addr;
- uid_t euid;
- gid_t egid;
on = 1;
status = 0;
int sd;
int rc;
char buf[BUFSIZE];
- uid_t uid;
- gid_t gid;
debug("[client] entering test_xfer_client()");
errct = 0; /* reset error count */
#include <unistd.h>
#include <stdio.h>
-#define MAX_ERROR 4
+#define MAX_ERROR 3
-int errct;
int subtest = 1;
int zilch[5000];
-char curdir[PATH_MAX];
+
+#include "common.c"
_PROTOTYPE(int main, (int argc, char *argv []));
_PROTOTYPE(void test6a, (void));
_PROTOTYPE(void test6b, (void));
-_PROTOTYPE(void test6c, (void));
-_PROTOTYPE(void e, (int n));
-_PROTOTYPE(void quit, (void));
int main(argc, argv)
int argc;
char *argv[];
{
- char buffer[PATH_MAX + 1];
int i, m = 0xFFFF;
- sync();
-
if (argc == 2) m = atoi(argv[1]);
- printf("Test 6 ");
- fflush(stdout);
-
- getcwd(curdir, PATH_MAX);
- system("rm -rf DIR_06; mkdir DIR_06");
- chdir("DIR_06");
+ start(6);
for (i = 0; i < 70; i++) {
if (m & 00001) test6a();
if (m & 00002) test6b();
- if (m & 00004) test6c();
}
quit();
kill(getpid(), SIGQUIT);
}
-void test6c()
-{
-/* Test mknod, chdir, chmod, chown, access. */
-
- int i, j;
- struct stat s;
-
- subtest = 3;
- if (getuid() != 0) return;
- for (j = 0; j < 2; j++) {
- umask(0);
-
- if (chdir("/") < 0) e(1);
- if (mknod("dir", 040700, 0) < 0) e(2);
- if (link("/", "/dir/..") < 0) e(3);
- if (mknod("T3a", 0777, 0) < 0) e(4);
- if (mknod("/dir/T3b", 0777, 0) < 0) e(5);
- if (mknod("dir/T3c", 0777, 0) < 0) e(6);
- if ((i = open("/dir/T3b", 0)) < 0) e(7);
- if (close(i) < 0) e(8);
- if ((i = open("dir/T3c", O_RDONLY)) < 0) e(9);
- if (close(i) < 0) e(10);
- if (chdir("dir") < 0) e(11);
- if ((i = open("T3b", 0)) < 0) e(12);
- if (close(i) < 0) e(13);
- if ((i = open("../T3a", O_RDONLY)) < 0) e(14);
- if (close(i) < 0) e(15);
- if ((i = open("../dir/../dir/../dir/../dir/../dir/T3c", O_RDONLY)) < 0)
- e(16);
- if (close(i) < 0) e(17);
-
- if (chmod("../dir/../dir/../dir/../dir/../T3a", 0123) < 0) e(18);
- if (stat("../dir/../dir/../dir/../T3a", &s) < 0) e(19);
- if ((s.st_mode & 077777) != 0123) e(20);
- if (chmod("../dir/../dir/../T3a", 0456) < 0) e(21);
- if (stat("../T3a", &s) < 0) e(22);
- if ((s.st_mode & 077777) != 0456) e(23);
- if (chown("../dir/../dir/../T3a", 20, 30) < 0) e(24);
- if (stat("../T3a", &s) < 0) e(25);
- if (s.st_uid != 20) e(26);
- if (s.st_gid != 30) e(27);
-
- if ((i = open("/T3c", O_RDONLY)) >= 0) e(28);
- if ((i = open("/T3a", O_RDONLY)) < 0) e(29);
- if (close(i) < 0) e(30);
-
- if (access("/T3a", 4) < 0) e(31);
- if (access("/dir/T3b", 4) < 0) e(32);
- if (access("/dir/T3d", 4) >= 0) e(33);
-
- if (unlink("T3b") < 0) e(34);
- if (unlink("T3c") < 0) e(35);
- if (unlink("..") < 0) e(36);
- if (chdir("/") < 0) e(37);
- if (unlink("dir") < 0) e(38);
- if (unlink("/T3a") < 0) e(39);
- }
-
-}
-
-void e(n)
-int n;
-{
-
- int err_num = errno; /* save errno in case printf clobbers it */
-
- printf("Subtest %d, error %d errno=%d ", subtest, n, errno);
- errno = err_num; /* restore errno, just in case */
- perror("");
- if (errct++ > MAX_ERROR) {
- printf("Too many errors; test aborted\n");
- chdir("..");
- system("rm -rf DIR*");
- exit(1);
- }
-}
-
-void quit()
-{
-
- chdir("..");
- system("rm -rf DIR*");
-
- chdir(curdir);
- system("rm -rf DIR*");
- if (errct == 0) {
- printf("ok\n");
- exit(0);
- } else {
- printf("%d errors\n", errct);
- exit(1);
- }
-}
char *
addr()
{
- char a;
+ char a, *ret;
- return &a;
+ ret = &a;
+ return(ret);
}
void garbage()
main(int argc, char **argv)
{
int i, ch;
- GElf_Addr startaddr, endaddr;
+ GElf_Addr startaddr;
startaddr = BOOTPROG_LOAD_START;