#include <net/netlib.h>
#include <time.h>
-
#define NUMBER 12
void main(void) {
FD_SET(fd3, &fds_read); /* fd3 => O_WRONLY */
FD_SET(fd4, &fds_read); /* fd4 => O_WRONLY */
-
/* make a select call where none of them are ready (don't use fd5 and fd6) */
/* create a timeout as well */
timeout.tv_sec = 5;
printf("* Dump RESULTING fds_write:\n");
dump_fdset(&fds_write);
-
/* close and delete dummy files */
close(fd1);
close(fd2);
char data[1024];
} udp_buffer_t;
-
int udp_conf(char *host, long port, udp_io_hdr_t *header)
{
/* configures UDP connection */
return netfd;
}
-
int main(int argc,char *argv[]) {
int fd;
ssize_t data_read;
char data[1024];
} udp_buffer_t;
-
int udp_conf(char *host, long port, udp_io_hdr_t *header)
{
/* configures UDP connection */
if ((fd = udp_conf(argv[1], PORT, &buffer_send.header) ) < 0)
exit(-1);
-
while (1)
{
return netfd;
}
-
int main(int argc,char *argv[]) {
int fd;
ssize_t data_read;
printf("Waiting for messages on port: %ld\n", PORT);
fflush(stdout);
-
/* get a first message so we know who is the client and we can harass it
afterwards */
return netfd;
}
-
int main(int argc,char *argv[]) {
int fd;
ssize_t data_read;
return netfd;
}
-
int main(int argc,char *argv[]) {
int fd;
ssize_t data_read;
return netfd;
}
-
int main(int argc,char *argv[]) {
int fd;
ssize_t data_read;
#include <string.h>
#include <limits.h>
-
void main(void) {
fd_set fds_read, fds_write;
int retval;
#include <limits.h>
#include <string.h>
-
void main(void) {
fd_set fds_read, fds_write;
int retval;
*
* Ben Gras
*/
-
#include <time.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <string.h>
#include <signal.h>
#include <libutil.h>
-
char name[100];
-
void pipehandler(int sig)
{
-
}
-
#define CHILDFD 1
#define PARENTFD 0
-
void do_child(int pty_fds[])
{
/* reads from pipe and prints out the data */
fd_set fds_read;
fd_set fds_exception;
struct timeval timeout;
-
signal(SIGPIPE, pipehandler);
signal(SIGUSR1, pipehandler);
-
/* first, close the write part, since it is not needed */
close(pty_fds[PARENTFD]);
exit(0);
}
-
void do_parent(int pty_fds[])
{
char data[1024];
int retval;
fd_set fds_write;
-
signal(SIGPIPE, pipehandler);
signal(SIGUSR1, pipehandler);
-
/* first, close the read part of pty, since it is not needed */
close(pty_fds[CHILDFD]);
-
/* now enter a loop of read user input, and writing it to the pty */
while (1) {
FD_ZERO(&fds_write);
fprintf(stderr, "Parent: Error in select\n");
exit(-1);
}
-
printf("Input data: ");
if(!gets(data)) {
printf("parent: eof; exiting\n");
exit(-1);
} else printf("wrote %d\n", retval);
}
-
/* got exit from user */
close(pty_fds[PARENTFD]); /* close pty, let child know we're done */
wait(&retval);
printf("Child exited with status: %d\n", retval);
exit(0);
}
-
int main(int argc, char *argv[])
{
int ptys[2];
int retval;
int pid;
-
if(openpty(&ptys[0], &ptys[1], name, NULL, NULL) < 0) {
perror("openpty");
return 1;
fprintf(stderr, "Error forking\n");
exit(-1);
}
-
if (pid == 0) /* child proc */
do_child(ptys);
else
do_parent(ptys);
-
/* not reached */
return 0;
}
}
}
-
void parent1(childpid)
int childpid;
{
exit(gct);
}
-
void quit()
{
close(fd);
}
-
void cr_file(name, size)
char *name;
int size;
return(0);
}
-
void test11a()
{
/* Test exec */
int n, fd;
char aa[4];
-
subtest = 1;
if (fork()) {
}
}
-
-
void test11b()
{
int n;
name[7] = ((pid * pid) & 037) + 33;
name[8] = 0;
-
for (i = 0; i < TRIALS; i++) {
if ( (fd0 = creat(name, 0777)) < 0) e(1);
if (write(fd0, name, 20) != 20) e(2);
if (close(fd0) != 0) e(4);
}
-
fd0 = creat(name, 0777);
write(fd0, name, 20);
unlink(name);
return(-1); /* impossible */
}
-
void e(n)
int n;
{
(void) memmove(one + 2, one + 1, 8);
equal(one, "abbcdefgh", 14);
-
/* Memccpy - first test like memcpy, then the search part
* The SVID, the only place where memccpy is mentioned, says overlap
* might fail, so we don't try it. Besides, it's hard to see the
return(-1); /* impossible */
}
-
void test16a()
{
/* Test atime, ctime, and mtime. */
if (unlink("T16.k") != 0) e(86);
}
-
void get_times(name, a, c, m)
char *name;
time_t *a, *c, *m;
*m = s.st_mtime;
}
-
-
void e(n)
int n;
{
umask(022);
} /* test */
-
-
/* "t1.c" created by Rene Montsma and Menno Wilcke */
/*****************************************************************************
check(CREAT, EISDIR);
} /* test02 */
-
-
void test08()
{
/* Test chdir to searchable dir */
/* New page */\f
-
/* "t4.c", created by Rene Montsma and Menno Wilcke */
/*****************************************************************************
} /* test10 */
-
int link_alot(bigboss)
char *bigboss;
{
/* New page */\f
-
void comp_stats(stbf1, stbf2)
struct stat *stbf1, *stbf2;
{
/* New page */\f
-
/* "t5.c", created by Rene Montsma and Menno Wilcke */
-
-
void comp_inodes(m, m1)
int m, m1; /* twee filedes's */
{
* *
*****************************************************************************/
-
int open_alot()
{
int i;
_PROTOTYPE(void chmod_8_dirs, (int sw));
_PROTOTYPE(void quit, (void));
-
/*****************************************************************************
* TEST *
****************************************************************************/
return(0);
}
-
-
void test()
{
umask(0); /* not honest, but i always forget */
umask(022);
} /* test */
-
-
-
-
-
/* "t1.c" created by Rene Montsma and Menno Wilcke */
/*****************************************************************************
if ((tempvalue = umask(0)) != 0) err(2, UMASK, "values");
-
/* Now test all possible modes of umask on a file */
for (newvalue = MASK; newvalue >= 0; newvalue -= 0111) {
tempvalue = umask(newvalue);
err(7, UMASK, "umask may influence rest of tests!");
} /* test01 */
-
-
/*****************************************************************************
* test CREAT *
****************************************************************************/
check(CREAT, EISDIR);
} /* test02 */
-
-
-
-
/*****************************************************************************
* test WRITE *
****************************************************************************/
}
} /* test03 */
-
void write_standards(filedes, a)
int filedes;
char a[];
#endif
} /* write_standards */
-
-
-
-
-
/* "t2.c", created by Rene Montsma and Menno Wilcke */
-
/*****************************************************************************
* test READ *
****************************************************************************/
}
} /* test04 */
-
void read_standards(filedes, a)
int filedes;
char a[];
else if (read(filedes, b, ARSIZE) != READ_EOF)
err(11, READ, "read beyond endoffile");
-
/* Try giving read wrong input: wrong filedes */
if (read(FAIL, b, ARSIZE) != FAIL)
err(2, READ, "filedes");
else
check(READ, EBADF);
-
/* Wrong length */
if (read(filedes, b, -ARSIZE) != FAIL)
err(2, READ, "length");
check(READ, EINVAL);
} /* read_standards */
-
-
void read_more(filedes, a)
int filedes;
char a[];
else
check(OPEN, EACCES);
-
/* Unlink testfile */
try_unlink("file05");
-
/* File is not readable */
if (open("drwx/-wx", R) != FAIL)
err(11, OPEN, "open unreadable file for reading");
check(CLOSE, EBADF);
} /* test05 */
-
void try_open(fname, mode, test)
int mode, test;
char *fname;
if (n != FAIL) try_close(n, fname); /* cleanup */
} /* try_open */
-
-
/*****************************************************************************
* test LSEEK *
****************************************************************************/
}
-
-
-
/* "t3.c", created by Rene Montsma and Menno Wilcke */
-
/*****************************************************************************
* test ACCESS *
****************************************************************************/
if (chdir("..") != OK) err(5, CHDIR, "'..'");
-
/* Check several wrong combinations */
/* File does not exist */
if (access("non-file", 0) != FAIL)
} /* test07 */
-
void access_standards()
{
int i, mode = 0;
for (i = 0; i < 8; i++) try_access(fnames[mode], i, OK);
} /* access_standards */
-
-
void try_access(fname, mode, test)
int mode, test;
char *fname;
err(100, ACCESS, "incorrect access on a file (try_access)");
} /* try_access */
-
-
-
-
-
-
/* "support.c", created by Rene Montsma and Menno Wilcke */
-
/* Err, make_and_fill_dirs, init_array, clear_array, comp_array,
try_close, try_unlink, Remove, get_mode, check, open_alot,
close_alot, clean_up_the_mess.
*/
-
/***********************************************************************
* EXTENDED FIONS *
**********************************************************************/
printf(s);
}
-
/*****************************************************************************
* *
* ERR(or) messages *
nlcr();
} /* err */
-
/*****************************************************************************
* *
* MAKE_AND_FILL_DIRS *
} /* make_and_fill_dirs */
-
-
void put_file_in_dir(dirname, mode)
char *dirname;
int mode;
{
int nr;
-
if (chdir(dirname) != OK)
err(5, CHDIR, "to dirname (put_f_in_dir)");
else {
}
} /* put_file_in_dir */
-
/*****************************************************************************
* *
* MISCELLANEOUS *
* *
*****************************************************************************/
-
void init_array(a)
char *a;
{
} /* clear_array */
-
int comp_array(a, b, range)
char *a, *b;
int range;
}
} /* comp_array */
-
void try_close(filedes, name)
int filedes;
char *name;
if (close(filedes) != OK) err(5, CLOSE, name);
} /* try_close */
-
void try_unlink(fname)
char *fname;
{
if (unlink(fname) != 0) err(5, UNLINK, fname);
} /* try_unlink */
-
void Remove(fdes, fname)
int fdes;
char *fname;
try_unlink(fname);
} /* Remove */
-
int get_mode(name)
char *name;
{
return(stbf1.st_mode & 07777); /* take last 4 bits */
} /* get_mode */
-
/*****************************************************************************
* *
* CHECK *
* *
*****************************************************************************/
-
void check(scall, number)
int number;
char *scall;
}
}
-
/*****************************************************************************
* *
* ALOT-functions *
* *
*****************************************************************************/
-
-
-
int open_alot()
{
int i;
return(i);
} /* open_alot */
-
int close_alot(number)
int number;
{
return(number - count); /* return number of closed files */
} /* close_alot */
-
/*****************************************************************************
* *
* CLEAN UP THE MESS *
* *
*****************************************************************************/
-
void clean_up_the_mess()
{
int i;
if (chdir("..") != OK) err(5, CHDIR, "to '..'");
}
-
/* Before unlinking files in some dirs, make them writable */
chmod_8_dirs(RWX);
}
}
-
-
void quit()
{
_PROTOTYPE(void e, (int n));
_PROTOTYPE(void quit, (void));
-
int main(argc, argv)
int argc;
char *argv[];
if (unlink("T19.a3") != 0) e(32);
}
-
void test19b()
{
/* Test open with O_APPEND and O_TRUNC. */
unlink("T19.b1");
}
-
void test19c()
{
/* Test program for open(), close(), creat(), read(), write(), lseek(). */
if (unlink("T19.d1") != 0) e(20);
}
-
-
void test19e()
{
/* Test link, unlink, stat, fstat, dup, umask. */
}
}
-
void test19g()
{
/* Test POSIX calls for pipe, read, write, lseek and close. */
if (unlink("T19.g1") != 0) e(60);
}
-
void clraa()
{
int i;
for (i = 0; i < 100; i++) aa[i] = 0;
}
-
void pipecatcher(s)
int s; /* it is supposed to have an arg */
{
pipesigs++;
}
-
void e(n)
int n;
{
}
}
-
return(-1); /* impossible */
}
-
void test2a()
{
/* Test pipes */
}
}
-
void test2b()
{
int fd[2], n;
}
}
-
-
void test2c()
{
int n;
if (errno != ECHILD) e(26);
}
-
void test2e()
{
}
-
void test2f()
{
/* test getpid, getppid, getuid, etc. */
if (getgroups(0, g) != 0) e(3);
}
-
void sigpip(s)
int s; /* for ANSI */
{
* getcwd()
*/
-
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
return;
}
-
void test20b()
{
/* Subtest 4. Test error handling. */
}
-
void test20c()
{
/* Subtest 5. See what happens if we open too many directory streams. */
if (system("rmdir Dir") != 0) e(33);
}
-
void test20e()
{
/* Test open. */
if (unlink("T20f") < 0) e(54);
}
-
void test20g()
{
/* Test link and unlink. */
}
-
void test21e()
{
/* Test error conditions. */
if (rmdir("D1") != 0) e(11);
}
-
void test21g()
{
int fd, D1_before, D1_after, D2_before, D2_after, x_link, y_link;
if (rmdir("D1") != 0) e(12);
}
-
void test21n()
{
int D1_before, D1_after, D2_before, D2_after, x_link, y_link;
if (rmdir("D2") != 0) e(19);
}
-
void test21o()
{
/* Test trying to remove . and .. */
if (rmdir("D1") != 0) e(14);
}
-
int get_link(name)
char *name;
{
return(statbuf.st_nlink);
}
-
void e(n)
int n;
{
errno = 0;
}
-
void quit()
{
Chdir("..");
if (chdir(cwd) != 0) e(58);
}
-
void makelongnames()
{
register int i;
ToLongPath[PATH_MAX] = '\0'; /* inc ToLongPath by one */
}
-
/* The following code, is take from pwd written by Adri Koppes */
/* My_getcwd() helper. */
return(retval);
}
-
char *my_getcwd(buf, size)
char *buf;
int size;
return buf;
}
-
void e(n)
int n;
{
errno = 0;
}
-
void quit()
{
Chdir("..");
char ToLongName[NAME_MAX + 2]; /* Name of maximum +1 length */
char ToLongPath[PATH_MAX + 1]; /* Same for path, both too long */
-
void main(argc, argv)
int argc;
char *argv[];
if (closedir(dirp) != 0) e(34); /* close parent's foo */
}
-
void test24b()
{
/* See what happens with too many dir's open. Check if file size seems ok,
if (closedir(dirp[2]) != 0) e(27);
}
-
void test24c()
{
/* Test whether wrong things go wrong right. */
subtest = oldsubtest;
}
-
void makelongnames()
{
register int i;
ToLongPath[PATH_MAX] = '\0'; /* inc ToLongPath by one */
}
-
void e(n)
int n;
{
errno = 0;
}
-
void quit()
{
Chdir("..");
if (!(EXCLUDE(O_RDWR, ADDIT))) e(7);
}
-
void test25b()
{ /* Test normal operation. */
}
}
-
void test25c()
{ /* Test normal operation Part two. */
int fd1, fd2;
MaxPath[strlen(MaxPath) - 1] = '/'; /* make ././.../a */
}
-
void test25e()
{
int fd;
ToLongPath[PATH_MAX - 1] = '/';
}
-
void makelongnames()
{
register int i;
ToLongPath[PATH_MAX] = '\0'; /* inc ToLongPath by one */
}
-
-
void e(n)
int n;
{
errno = 0;
}
-
void quit()
{
Chdir("..");
subtest = 1;
System("rm -rf ../DIR_26/*");
-
System("echo -n hihaho > hihaho");
if ((fd = open("hihaho", O_RDONLY)) != 3) e(1);
if (lseek(fd, (off_t) 3, SEEK_SET) != (off_t) 3) e(2);
}
}
-
void e(n)
int n;
{
errno = 0;
}
-
void quit()
{
Chdir("..");
quit();
}
-
void test27a()
{ /* Test Normal operation. */
struct stat st1, st2;
System("rm -rf ../DIR_27/*");
}
-
void makelongnames()
{
register int i;
errno = 0;
}
-
void quit()
{
Chdir("..");
quit();
}
-
void test28a()
{
int mode; /* used in for loop */
if (st.st_mtime >= time2) e(44);
}
-
void test28b()
{ /* Test critical values. */
struct stat st;
System("rm -rf foo"); /* clean up */
}
-
void makelongnames()
{
register int i;
ToLongPath[PATH_MAX] = '\0'; /* inc ToLongPath by one */
}
-
void e(n)
int n;
{
errno = 0;
}
-
void quit()
{
Chdir("..");
}
}
-
void test29b()
{
int i, fd, stat_loc;
if (strcmp(buf, "one two three four") != 0) e(17);
if (close(fd) != 0) e(18);
-
/* Non written bytes in regular files should be zero. */
memset(buf2, '\0', BUF_SIZE);
if ((fd = open("bigfile", O_RDWR | O_CREAT, 0644)) != 3) e(19);
}
}
-
void setsignumber(signum)
int signum;
{
errno = 0;
}
-
void quit()
{
Chdir("..");
}
}
-
-
void e(n)
int n;
{
quit();
}
-
void test30a()
{ /* Test normal operation. */
MaxPath[strlen(MaxPath) - 1] = '/'; /* make ././.../a */
}
-
void test30c()
{
int fd;
ToLongPath[PATH_MAX - 1] = '/';
}
-
void makelongnames()
{
register int i;
ToLongPath[PATH_MAX] = '\0'; /* inc ToLongPath by one */
}
-
-
void e(n)
int n;
{
errno = 0;
}
-
void quit()
{
Chdir("..");
quit();
}
-
void test31a()
{ /* Test normal operation. */
MaxPath[strlen(MaxPath) - 1] = '/'; /* make ././.../a */
}
-
void test31c()
{
subtest = 3;
ToLongPath[PATH_MAX - 1] = '/';
}
-
void makelongnames()
{
register int i;
errno = 0;
}
-
void quit()
{
Chdir("..");
ToLongPath[PATH_MAX] = '\0'; /* inc ToLongPath by one */
}
-
-
void e(n)
int n;
{
errno = 0;
}
-
void quit()
{
Chdir("..");
}
}
-
-
void test33b()
{
int stat_loc; /* For the wait(&stat_loc) call. */
}
}
-
void makelongnames()
{
register int i;
ToLongPath[PATH_MAX] = '\0'; /* inc ToLongPath by one */
}
-
-
void e(n)
int n;
{
errno = 0;
}
-
void quit()
{
Chdir("..");
if (chmod("foo", 0777) != 0) e(5);
if (utime("foo", NULL) != 0) e(6);
-
-
System("rm -rf ../DIR_35/*");
}
System("rm -rf ../DIR_35/*");
}
-
-
void makelongnames()
{
register int i;
PathTooLong[PATH_MAX] = '\0'; /* inc PathTooLong by one */
}
-
-
void e(n)
int n;
{
errno = 0;
}
-
void quit()
{
Chdir("..");
}
}
-
/* Getids returns a valid uid and gid. Is used PASSWD FILE.
** It assumes the following format for a passwd file line:
** <user_name>:<passwd>:<uid>:<gid>:<other_stuff>
_PROTOTYPE(int provided_option, (int _option, int _minimum_value));
_PROTOTYPE(int variating_option, (int _option, int _minimum_value));
-
char *testdirs[] = {
"/",
"/etc",
System("rm -rf ../DIR_36/*");
}
-
void makelongnames()
{
register int i;
ToLongPath[PATH_MAX] = '\0'; /* inc ToLongPath by one */
}
-
-
void e(n)
int n;
{
errno = 0;
}
-
void quit()
{
Chdir("..");
return 0;
}
-
int provided_option(option, minimum)
int option, minimum;
{
return 0;
}
-
int variating_option(option, minimum)
int option, minimum;
{
if (close(tube[1]) != 0) e(59);
}
-
void test37b()
{
int tube[2], child2parent[2], parent2child[2];
for (i = 3; i < OPEN_MAX; i++) (void) close(i);
}
-
void e(n)
int n;
{
errno = 0;
}
-
void quit()
{
if (errct == 0) {
if (strncmp(buf, "o!", 2) != 0) e(21);
if (close(fd) != 0) e(22);
-
System("rm -rf ../DIR_38/*");
}
System("rm -rf ../DIR_38/*");
}
-
-
void e(n)
int n;
{
errno = 0;
}
-
void quit()
{
Chdir("..");
fl.l_type = F_RDLCK;
if (fcntl(fd7, F_SETLK, &fl) == -1) e(10);
-
switch (fork()) {
case -1: printf("Can't fork\n"); break;
case 0:
System("rm -f ../DIR_39/*\n");
}
-
/* This routine checks that fds 0 through 4, 7 and 8 are open and the rest
** is closed. It also checks if we can lock the first 10 bytes on fd no. 3
** and 4. It should not be possible to lock fd no. 3, but it should be
ToLongPath[PATH_MAX] = '\0'; /* inc ToLongPath by one */
}
-
-
void e(n)
int n;
{
errno = 0;
}
-
void quit()
{
Chdir("..");
return(-1); /* impossible */
}
-
void subr()
{
if ( (pid0 = fork()) != 0) {
ToLongPath[PATH_MAX] = '\0'; /* inc ToLongPath by one */
}
-
void e(n)
int n;
{
errno = 0;
}
-
void quit()
{
chdir("..");
_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 */
return(-1); /* impossible */
}
-
-
void test5a()
{
int parpid, childpid, flag, *zp;
e(38);
}
-
void test5b()
{
int cpid, n, pid;
}
}
-
void test5c()
{
int n, i, pid, wpid;
}
}
-
-
void test5e()
{
/* When a signal knocks a processes out of WAIT or PAUSE, it is supposed to
}
}
-
void test5f()
{
int i, j, k, n;
}
}
-
void test5g()
{
int n;
alarms++;
}
-
void test5h()
{
/* When a signal knocks a processes out of PIPE, it is supposed to
unlink("XXXxxxXXX");
}
-
void ex()
{
int e = errno;
exit(1);
}
-
void e(n)
int n;
{
return(SIG_ZERO);
}
-
void quit()
{
return(-1); /* impossible */
}
-
-
void test6a()
{
/* Test sbrk() and brk(). */
if (sbrk(0) != addr) e(12);
}
-
void test6b()
{
int i, err;
kill(getpid(), SIGQUIT);
}
-
-
void test6c()
{
/* Test mknod, chdir, chmod, chown, access. */
* pipe(), mkfifo(), fcntl()
*/
-
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
_PROTOTYPE(void sigfunc, (int s));
_PROTOTYPE(void quit, (void));
-
int main(argc, argv)
int argc;
char *argv[];
for (i = 3; i < OPEN_MAX; i++) close(i);
}
-
void test7b()
{
/* Test mkfifo(). */
if (unlink("T7.b") != 0) e(28);
}
-
void test7c()
{
/* Test fcntl(). */
if (close(newfd2) != 0) e(48);
}
-
void test7d()
{
/* Test file locking. */
close(xfd);
}
-
void test7g()
{
/* Test to see if SETLKW unlocks when the needed lock becomes available. */
close(xfd);
}
-
void test7h()
{
/* Test to see what happens if two processed block on the same lock. */
}
}
-
/* Check EMFILE. */
for (i = xfd + 1; i < OPEN_MAX; i++) open("T7.i", 0); /* use up all fds */
errno = 0;
for (i = xfd; i < OPEN_MAX; i++) if (close(i) != 0) e(29);
}
-
void test7j()
{
/* Test file locking with two processes. */
exit(0);
}
-
int set(how, first, last)
int how, first, last;
{
system("rm -rf DIR_08; mkdir DIR_08");
chdir("DIR_08");
-
for (i = 0; i < ITERATIONS; i++) {
iteration = i;
if (m & 0000001) test8a();
return(-1); /* impossible */
}
-
void test8a()
{
/* Test signal set management. */
return(-1); /* impossible */
}
-
void test9a()
{
register p;