/* locate block based on pointer, then check whether it is valid */
block = (struct block *) page_round_down(
- (unsigned long) ((struct block *) ptr - 1));
+ (unsigned long) ((struct block *) __UNCONST(ptr) - 1));
block_check(block);
LOG(("block_find; block=0x%x\n", block));
return block;
break;
}
- if (_devices[i].dev!= NULL) {
+ if (i >= MAX_DEVS) {
DEBUG_MSG("Too much devices...");
} else {
_devices[i].dev = dev;
char *buf;
int i, rv = 0;
+ memset(&foo, '\0', sizeof(foo));
+
if (!args || !args->argv || !args->argc || !proc)
return 0;
if ((fp = fopen(_PATH_PROC "hz", "r")) != NULL)
{
- r = fscanf(fp, "%lu", &hz);
+ r = fscanf(fp, "%u", &hz);
fclose(fp);
#include <string.h>
#include <utime.h>
-PUBLIC int utime(name, timp)
-_CONST char *name;
-_CONST struct utimbuf *timp;
+PUBLIC int utime(const char *name, const struct utimbuf *timp)
{
message m;
m.m2_l2 = timp->modtime;
m.m2_i1 = strlen(name) + 1;
}
- m.m2_p1 = (char *) name;
+ m.m2_p1 = (char *) __UNCONST(name);
return(_syscall(VFS_PROC_NR, UTIME, &m));
}
}
/* Get connected, output the message to the local logger. */
+#ifndef __minix
if (data == &sdata)
mutex_lock(&syslog_mutex);
+#endif
opened = !data->opened;
if (opened)
openlog_unlocked_r(data->log_tag, data->log_stat, 0, data);
(void)close(fd);
}
+#ifndef __minix
if (data == &sdata)
mutex_unlock(&syslog_mutex);
+#endif
if (data != &sdata && opened) {
/* preserve log tag */
void
openlog_r(const char *ident, int logstat, int logfac, struct syslog_data *data)
{
+#ifndef __minix
if (data == &sdata)
mutex_lock(&syslog_mutex);
+#endif
openlog_unlocked_r(ident, logstat, logfac, data);
+#ifndef __minix
if (data == &sdata)
mutex_unlock(&syslog_mutex);
+#endif
}
void
closelog_r(struct syslog_data *data)
{
+#ifndef __minix
if (data == &sdata)
mutex_lock(&syslog_mutex);
+#endif
(void)close(data->log_file);
data->log_file = -1;
data->connected = 0;
data->log_tag = NULL;
+#ifndef __minix
if (data == &sdata)
mutex_unlock(&syslog_mutex);
+#endif
}
int
{
message m;
- m.m1_p1 = (char *) mcp;
+ m.m1_p1 = (char *) __UNCONST(mcp);
return(_syscall(PM_PROC_NR, SETMCONTEXT, &m));
}
nwio_tcpconf_t tcpconf;
struct sockaddr_in *sinp;
- sinp= (struct sockaddr_in *)address;
+ sinp= (struct sockaddr_in *) __UNCONST(address);
if (sinp->sin_family != AF_INET || address_len < sizeof(*sinp))
{
#if DEBUG
nwio_udpopt_t udpopt;
struct sockaddr_in *sinp;
- sinp= (struct sockaddr_in *)address;
+ sinp= (struct sockaddr_in *) __UNCONST(address);
if (sinp->sin_family != AF_INET || address_len < sizeof(*sinp))
{
#if DEBUG
did_mknod = 0;
- r = mknod(((struct sockaddr_un *) address)->sun_path,
+ r = mknod(((struct sockaddr_un *) __UNCONST(address))->sun_path,
S_IFSOCK|S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH, 0);
if (r == -1 && errno != EEXIST) {
}
/* perform the bind */
- r= ioctl(sock, NWIOSUDSADDR, (void *) address);
+ r= ioctl(sock, NWIOSUDSADDR, (void *) __UNCONST(address));
if (r == -1 && did_mknod) {
/* bind() failed in pfs, so we roll back the
* file system change
*/
- unlink(((struct sockaddr_un *) address)->sun_path);
+ unlink(((struct sockaddr_un *) __UNCONST(address))->sun_path);
}
return r;
m.m1_i1 = strlen(name) + 1;
m.m1_i2 = owner;
m.m1_i3 = grp;
- m.m1_p1 = (char *) name;
+ m.m1_p1 = (char *) __UNCONST(name);
return(_syscall(VFS_PROC_NR, CHOWN, &m));
}
errno= EINVAL;
return -1;
}
- sinp= (struct sockaddr_in *)address;
+ sinp= (struct sockaddr_in *) __UNCONST(address);
if (sinp->sin_family != AF_INET)
{
errno= EINVAL;
errno= EINVAL;
return -1;
}
- sinp= (struct sockaddr_in *)address;
+ sinp= (struct sockaddr_in *) __UNCONST(address);
if (sinp->sin_family != AF_INET)
{
errno= EINVAL;
}
/* perform the connect */
- return ioctl(sock, NWIOSUDSCONN, (void *) address);
+ return ioctl(sock, NWIOSUDSCONN, (void *) __UNCONST(address));
}
/* We can finally make the system call. */
m.m1_i1 = strlen(path) + 1;
m.m1_i2 = frame_size;
- m.m1_p1 = (char *) path;
+ m.m1_p1 = (char *) __UNCONST(path);
m.m1_p2 = frame;
/* Clear unused fields */
__weak_alias(link, _link)
#endif
-PUBLIC int link(name, name2)
-_CONST char *name, *name2;
+PUBLIC int link(const char *name, const char *name2)
{
message m;
m.m1_i1 = strlen(name) + 1;
m.m1_i2 = strlen(name2) + 1;
- m.m1_p1 = (char *) name;
- m.m1_p2 = (char *) name2;
+ m.m1_p1 = (char *) __UNCONST(name);
+ m.m1_p2 = (char *) __UNCONST(name2);
return(_syscall(VFS_PROC_NR, LINK, &m));
}
#include <string.h>
-void _loadname(name, msgptr)
-const char *name;
-message *msgptr;
+void _loadname(const char *name, message *msgptr)
{
/* This function is used to load a string into a type m3 message. If the
* string fits in the message, it is copied there. If not, a pointer to
k = strlen(name) + 1;
msgptr->m3_i1 = k;
- msgptr->m3_p1 = (char *) name;
+ msgptr->m3_p1 = (char *) __UNCONST(name);
if (k <= M3_STRING) strcpy(msgptr->m3_ca1, name);
}
PUBLIC int closefrom(int fd)
{
- int f, ok = 0, e;
+ int f, ok = 0, e = 0;
for(f = fd; f < __MINIX_OPEN_MAX; f++) {
if(close(f) >= 0)
ok = 1;
len_key = strlen(name)+1;
- m.RS_NAME = (char *) name;
+ m.RS_NAME = (char *) __UNCONST(name);
m.RS_NAME_LEN = len_key;
if (_syscall(RS_PROC_NR, RS_LOOKUP, &m) != -1) {
m.m1_i1 = strlen(name) + 1;
m.m1_i2 = mode;
- m.m1_p1 = (char *) name;
+ m.m1_p1 = (char *) __UNCONST(name);
return(_syscall(VFS_PROC_NR, MKDIR, &m));
}
m.m1_i1 = strlen(name) + 1;
m.m1_i2 = mode;
m.m1_i3 = dev;
- m.m1_p1 = (char *) name;
+ m.m1_p1 = (char *) __UNCONST(name);
m.m1_p2 = (char *) ((int) 0); /* obsolete size field */
return(_syscall(VFS_PROC_NR, MKNOD, &m));
}
* an int, the mode was passed as an int.
*/
m.m1_i3 = va_arg(argp, int);
- m.m1_p1 = (char *) name;
+ m.m1_p1 = (char *) __UNCONST(name);
} else {
_loadname(name, &m);
m.m3_i2 = flags;
__weak_alias(readlink, _readlink)
#endif
-int readlink(name, buffer, bufsiz)
-const char *name;
-char *buffer;
-size_t bufsiz;
+int readlink(const char *name, char *buffer, size_t bufsiz)
{
message m;
m.m1_i1 = strlen(name) + 1;
m.m1_i2 = bufsiz;
- m.m1_p1 = (char *) name;
+ m.m1_p1 = (char *) __UNCONST(name);
m.m1_p2 = (char *) buffer;
return(_syscall(VFS_PROC_NR, RDLNK, &m));
#include <string.h>
#include <stdio.h>
-int rename(name, name2)
-const char *name, *name2;
+int rename(const char *name, const char *name2)
{
message m;
m.m1_i1 = strlen(name) + 1;
m.m1_i2 = strlen(name2) + 1;
- m.m1_p1 = (char *) name;
- m.m1_p2 = (char *) name2;
+ m.m1_p1 = (char *) __UNCONST(name);
+ m.m1_p2 = (char *) __UNCONST(name2);
return(_syscall(VFS_PROC_NR, RENAME, &m));
}
errno= EINVAL;
return -1;
}
- sinp= (struct sockaddr_in *)dest_addr;
+ sinp= (struct sockaddr_in *) __UNCONST(dest_addr);
if (sinp->sin_family != AF_INET)
{
errno= EAFNOSUPPORT;
}
/* set the target address */
- r= ioctl(sock, NWIOSUDSTADDR, (void *) dest_addr);
+ r= ioctl(sock, NWIOSUDSTADDR, (void *) __UNCONST(dest_addr));
if (r == -1) {
return r;
}
{
message m;
- m.m1_p1 = (char *) gidset;
+ m.m1_p1 = (char *) __UNCONST(gidset);
m.m1_i1 = ngroups;
return(_syscall(PM_PROC_NR, SETGROUPS, &m));
if (value == NULL) return(EINVAL);
m.m1_i1 = which;
- m.m1_p1 = (char *) value;
+ m.m1_p1 = (char *) __UNCONST(value);
m.m1_p2 = (char *) ovalue;
return _syscall(PM_PROC_NR, ITIMER, &m);
errno= EINVAL;
return -1;
}
- i= *(int *)option_value;
+ i= *(const int *)option_value;
if (!i)
{
/* At the moment there is no way to turn off
errno= EINVAL;
return -1;
}
- i= *(int *)option_value;
+ i= *(const int *)option_value;
if (!i)
{
/* At the moment there is no way to turn off
errno= EINVAL;
return -1;
}
- i= *(int *)option_value;
+ i= *(const int *)option_value;
if (i > 32*1024)
{
/* The receive buffer is limited to 32K at the moment.
errno= EINVAL;
return -1;
}
- i= *(int *)option_value;
+ i= *(const int *)option_value;
if (i > 32*1024)
{
/* The send buffer is limited to 32K at the moment.
errno= EINVAL;
return -1;
}
- i= *(int *)option_value;
+ i= *(const int *)option_value;
if (i)
{
/* At the moment there is no way to turn on
errno= EINVAL;
return -1;
}
- size= *(size_t *)option_value;
+ size= *(const size_t *)option_value;
return ioctl(sock, NWIOSUDSRCVBUF, &size);
}
errno= EINVAL;
return -1;
}
- size= *(size_t *)option_value;
+ size= *(const size_t *)option_value;
return ioctl(sock, NWIOSUDSSNDBUF, &size);
}
errno= EINVAL;
return -1;
}
- i= *(int *)option_value;
+ i= *(const int *)option_value;
if (!i)
{
/* At the moment there is no way to turn off
errno= EINVAL;
return -1;
}
- i= *(int *)option_value;
+ i= *(const int *)option_value;
if (!i)
{
/* credentials can always be received. */
int __sigreturn(void);
-int sigaction(sig, act, oact)
-int sig;
-const struct sigaction *act;
-struct sigaction *oact;
+int sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
{
message m;
m.m1_i2 = sig;
- /* XXX - yet more type puns because message struct is short of types. */
- m.m1_p1 = (char *) act;
+ m.m1_p1 = (char *) __UNCONST(act);
m.m1_p2 = (char *) oact;
m.m1_p3 = (char *) __sigreturn;
struct minix_prev_stat old_sb;
m.m1_i1 = strlen(name) + 1;
- m.m1_p1 = (char *) name;
+ m.m1_p1 = (char *) __UNCONST(name);
m.m1_p2 = (char *) buffer;
if((r = _syscall(VFS_PROC_NR, STAT, &m)) >= 0 || errno != ENOSYS)
* User has struct stat (buffer), VFS still fills minix_prev_stat.
*/
m.m1_i1 = strlen(name) + 1;
- m.m1_p1 = (char *) name;
+ m.m1_p1 = (char *) __UNCONST(name);
m.m1_p2 = (char *) &old_sb;
if((r = _syscall(VFS_PROC_NR, PREV_STAT, &m)) < 0)
struct minix_prev_stat old_sb;
m.m1_i1 = strlen(name) + 1;
- m.m1_p1 = (char *) name;
+ m.m1_p1 = (char *) __UNCONST(name);
m.m1_p2 = (char *) buffer;
if((r = _syscall(VFS_PROC_NR, LSTAT, &m)) >= 0 || errno != ENOSYS)
* User has struct stat (buffer), VFS still fills minix_prev_stat.
*/
m.m1_i1 = strlen(name) + 1;
- m.m1_p1 = (char *) name;
+ m.m1_p1 = (char *) __UNCONST(name);
m.m1_p2 = (char *) &old_sb;
if((r = _syscall(VFS_PROC_NR, PREV_LSTAT, &m)) < 0)
__weak_alias(statvfs, _statvfs)
#endif
-int statvfs(name, buffer)
-const char *name;
-struct statvfs *buffer;
+int statvfs(const char *name, struct statvfs *buffer)
{
message m;
m.STATVFS_LEN = strlen(name) + 1;
- m.STATVFS_NAME = (char *) name;
+ m.STATVFS_NAME = (char *) __UNCONST(name);
m.STATVFS_BUF = (char *) buffer;
return(_syscall(VFS_PROC_NR, STATVFS, &m));
}
#include <string.h>
#include <unistd.h>
-int symlink(name, name2)
-const char *name, *name2;
+int symlink(const char *name, const char *name2)
{
message m;
m.m1_i1 = strlen(name) + 1;
m.m1_i2 = strlen(name2) + 1;
- m.m1_p1 = (char *) name;
- m.m1_p2 = (char *) name2;
+ m.m1_p1 = (char *) __UNCONST(name);
+ m.m1_p2 = (char *) __UNCONST(name2);
return(_syscall(VFS_PROC_NR, SYMLINK, &m));
}
int truncate(const char *_path, off_t _length)
{
message m;
- m.m2_p1 = (char *) _path;
+ m.m2_p1 = (char *) __UNCONST(_path);
m.m2_i1 = strlen(_path)+1;
m.m2_l1 = _length;
__weak_alias(write, _write)
#endif
-ssize_t write(fd, buffer, nbytes)
-int fd;
-const void *buffer;
-size_t nbytes;
+ssize_t write(int fd, const void *buffer, size_t nbytes)
{
message m;
m.m1_i1 = fd;
m.m1_i2 = nbytes;
- m.m1_p1 = (char *) buffer;
+ m.m1_p1 = (char *) __UNCONST(buffer);
return(_syscall(VFS_PROC_NR, WRITE, &m));
}
GCC?=gcc
CFLAGS= -O0 -D_MINIX -D_POSIX_SOURCE -g -Wall -Werror
.if ${COMPILER_TYPE} == "gnu"
-CFLAGS+= -D_NETBSD_SOURCE
+CFLAGS+= -D_NETBSD_SOURCE -fno-builtin
LIBS+= -lm -lcompat_minix
.endif
CFLAGS-GCC= $(CFLAGS) -Wall -D_NETBSD_SOURCE
if (getpid() == pid)
if (fork() == 0) {
- execl("t10a", (char *) 0);
+ execl("t10a", "t10a", (char *) 0);
exit(0);
}
if (getpid() == pid)
if (fork() == 0) {
- execl("t10b", (char *) 0);
+ execl("t10b", "t10b", (char *) 0);
exit(0);
}
if (getpid() == pid)
if (fork() == 0) {
- execl("t10c", (char *) 0);
+ execl("t10c", "t10c", (char *) 0);
exit(0);
}
if (getpid() == pid)
if (fork() == 0) {
- execl("t10d", (char *) 0);
+ execl("t10d", "t10d", (char *) 0);
exit(0);
}
if ((pid = fork()) != 0) {
wait(&n); /* wait for some child (any one) */
} else {
- k = execl(name[n], (char *) 0);
+ k = execl(name[n], name[n], (char *) 0);
errct++;
printf("Child execl didn't take. file=%s errno=%d\n", name[n], errno);
rmfiles();
* bits on. If a bug lets it unexpectedly succeed, the child
* will print an error message since the arguments are wrong.
*/
- execl("t11a", (char *) 0, envp); /* should fail -- no X bits */
+ execl("t11a", "t11a", (char *) 0); /* should fail -- no X bits */
/* Control should come here after the failed execl(). */
chmod("t11a", 06555);
test20d();
}
quit();
+
+ return(-1); /* Unreachable */
}
void test20a()
if (m & 020000) test21o();
}
quit();
+
+ return(-1); /* Unreachable */
}
void test21a()
}
quit();
+
+ return (-1); /* Unreachable */
}
void test22a()
if (m & 0004) test24c();
}
quit();
+
+ return(-1); /* Unreachable */
}
void test24a()
if (m & 020) test25e();
}
quit();
+
+ return(-1); /* Unreachable */
}
void test25a()
if (m & 0004) test26c();
}
quit();
+
+ return(-1); /* Unreachable */
}
void test26a()
if (m & 0004) test27c();
}
quit();
+
+ return(-1); /* Unreachable */
}
void test27a()
if (m & 0004) test28c();
}
quit();
+
+ return(-1); /* Unreachable */
}
void test28a()
if (m & 0004) test29c();
}
quit();
+
+ return(-1); /* Unreachable */
}
void test29a()
if (m & 0004) test30c();
}
quit();
+
+ return(-1); /* Unreachable */
}
void test30a()
if (m & 0004) test32c();
}
quit();
+
+ return(-1); /* Unreachable */
}
#define BUF_SIZE 1024
if (m & 0004) test34c();
}
quit();
+
+ return(-1); /* Unreachable */
}
void test34a()
}
quit();
+
+ return(-1); /* Unreachable */
}
void test37a()
if (m & 0004) test38c();
}
quit();
+
+ return(-1); /* Unreachable */
}
void test38a()
int main(int argc, char *argv[])
{
start(39);
+ test39a();
quit();
+ return(-1); /* Unreachable */
}
void test39a()
group_test(); /* Perform some tests that mimic actual use */
quit();
+
+ return(-1); /* Unreachable */
}
void limit_test() {
/* this was all */
quit();
+
+ return(-1); /* Unreachable */
}
start(54);
do_test();
quit();
+ return(-1); /* Unreachable */
}
start(58);
do_test();
quit();
+ return(-1); /* Unreachable */
}
#include <setjmp.h>
#define ITERATIONS 4
-#define MAX_ERROR 4
+#define MAX_ERROR 3
#define ITEMS 32
#define READ 10
#define WRITE 20
char buf[ITEMS] = {0,1,2,3,4,5,6,7,8,9,8,7,6,5,4,3,2,1,0,1,2,3,4,5,6,7,8,9};
-int subtest, errct, xfd;
+#include "common.c"
+
+int subtes, xfd;
int whence = SEEK_SET, func_code = F_SETLK;
extern char **environ;
_PROTOTYPE(void cloexec_test, (void));
_PROTOTYPE(int set, (int how, int first, int last));
_PROTOTYPE(int locked, (int b));
-_PROTOTYPE(void e, (int n));
_PROTOTYPE(void sigfunc, (int s));
-_PROTOTYPE(void quit, (void));
int main(argc, argv)
int argc;
int i, m = 0xFFFF;
- sync();
-
if (argc == 2) m = atoi(argv[1]);
if (m == 0) cloexec_test(); /* important; do not remove this! */
- printf("Test 7 ");
- fflush(stdout);
- system("rm -rf DIR_07; mkdir DIR_07");
- chdir("DIR_07");
+ start(7);
for (i = 0; i < ITERATIONS; i++) {
if (m & 00001) timed_test(test7a);
return(WEXITSTATUS(status));
}
-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);
- 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 sigfunc(s)
int s; /* for ANSI */
{
}
-void quit()
-{
-
- chdir("..");
- system("rm -rf DIR*");
-
- if (errct == 0) {
- printf("ok\n");
- exit(0);
- } else {
- printf("%d errors\n", errct);
- exit(1);
- }
-}