_PROTOTYPE(void cleanup, (void));
_PROTOTYPE(int does_fs_truncate, (void));
_PROTOTYPE(void e, (int n));
+_PROTOTYPE(int name_max, (char *path));
_PROTOTYPE(void quit, (void));
_PROTOTYPE(void rm_rf_dir, (int test_nr));
_PROTOTYPE(void rm_rf_ppdir, (int test_nr));
return(does_truncate);
}
+int name_max(char *path)
+{
+ struct statvfs stvfs;
+
+ if (statvfs(path, &stvfs) != 0) e(7779);
+ return(stvfs.f_namemax);
+}
+
void rm_rf_dir(test_nr)
int test_nr;
#define Chdir(dir) if (chdir(dir) != 0) printf("Can't goto %s\n", dir)
#define Stat(a,b) if (stat(a,b) != 0) printf("Can't stat %s\n", a)
-int errct = 0;
-int subtest = 1;
+#include "common.c"
+
int superuser;
-char MaxName[NAME_MAX + 1]; /* Name of maximum length */
-char MaxPath[PATH_MAX]; /* Same for path */
-char ToLongName[NAME_MAX + 2]; /* Name of maximum +1 length */
-char ToLongPath[PATH_MAX + 1]; /* Same for path, both too long */
_PROTOTYPE(void test20a, (void));
_PROTOTYPE(void test20b, (void));
_PROTOTYPE(void test20c, (void));
_PROTOTYPE(void test20d, (void));
_PROTOTYPE(int do_check, (void));
-_PROTOTYPE(void makelongnames, (void));
-_PROTOTYPE(void e, (int number));
-_PROTOTYPE(void quit, (void));
char executable[1024];
strcpy(executable, "../");
strcat(executable, argv[0]);
- printf("Test 20 ");
- fflush(stdout);
- System("rm -rf DIR_20; mkdir DIR_20");
- Chdir("DIR_20");
- makelongnames();
+ start(20);
superuser = (geteuid() == 0);
for (i = 0; i < ITERATIONS; i++) {
return retval;
}
-void makelongnames()
-{
- register int i;
-
- memset(MaxName, 'a', NAME_MAX);
- MaxName[NAME_MAX] = '\0';
- for (i = 0; i < PATH_MAX - 1; i++) { /* idem path */
- MaxPath[i++] = '.';
- MaxPath[i] = '/';
- }
- MaxPath[PATH_MAX - 1] = '\0';
-
- strcpy(ToLongName, MaxName); /* copy them Max to ToLong */
- strcpy(ToLongPath, MaxPath);
-
- ToLongName[NAME_MAX] = 'a';
- ToLongName[NAME_MAX + 1] = '\0'; /* extend ToLongName by one too many */
- ToLongPath[PATH_MAX - 1] = '/';
- ToLongPath[PATH_MAX] = '\0'; /* inc ToLongPath by one */
-}
-
-void e(n)
-int n;
-{
- int err_num = errno; /* Save in case printf clobbers it. */
-
- printf("Subtest %d, error %d errno=%d: ", subtest, n, errno);
- errno = err_num;
- perror("");
- if (errct++ > MAX_ERROR) {
- printf("Too many errors; test aborted\n");
- chdir("..");
- system("rm -rf DIR*");
- exit(1);
- }
- errno = 0;
-}
-
-void quit()
-{
- Chdir("..");
- System("rm -rf DIR_20");
-
- if (errct == 0) {
- printf("ok\n");
- exit(0);
- } else if (errct < 10000) {
- printf("%d errors\n", errct);
- exit(1);
- } else {
- printf("errors\n");
- exit(2);
- }
-}
#define ITERATIONS 1
#define MAX_ERROR 4
-int subtest, errct;
+#include "common.c"
_PROTOTYPE(int main, (int argc, char *argv []));
_PROTOTYPE(void test21a, (void));
_PROTOTYPE(void test21n, (void));
_PROTOTYPE(void test21o, (void));
_PROTOTYPE(int get_link, (char *name));
-_PROTOTYPE(void e, (int n));
-_PROTOTYPE(void quit, (void));
int main(argc, argv)
int argc;
sync();
if (argc == 2) m = atoi(argv[1]);
- printf("Test 21 ");
- fflush(stdout);
-
- system("rm -rf DIR_21; mkdir DIR_21");
- chdir("DIR_21");
+ start(21);
for (i = 0; i < ITERATIONS; i++) {
if (m & 00001) test21a();
if (m & 00002) test21b();
if (m & 020000) test21o();
}
quit();
- return(-1); /* impossible */
}
void test21a()
errno = 0;
if (mkdir("D1", 0777) != -1) e(8);
if (errno != EEXIST) e(9);
-#if NAME_MAX == 14
- if (mkdir("D1/ABCDEFGHIJKLMNOPQRSTUVWXYZ", 0777) != 0) e(10);
- if (access("D1/ABCDEFGHIJKLMN", 7 ) != 0) e(11);
- if (rmdir("D1/ABCDEFGHIJKLMNOPQ") != 0) e(12);
- if (access("D1/ABCDEFGHIJKLMN", 7 ) != -1) e(13);
-#endif
errno = 0;
if (mkdir("D1/D2/x", 0777) != -1) e(14);
if (errno != ENOENT) e(15);
return(statbuf.st_nlink);
}
-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*");
-
- if (errct == 0) {
- printf("ok\n");
- exit(0);
- } else {
- printf("%d errors\n", errct);
- exit(1);
- }
-}
#define Chdir(dir) if (chdir(dir) != 0) printf("Can't goto %s\n", dir)
#define Stat(a,b) if (stat(a,b) != 0) printf("Can't stat %s\n", a)
-int errct = 0; /* Total error counter. */
-int subtest = 1;
+#include "common.c"
_PROTOTYPE(void test22a, (void));
_PROTOTYPE(int mode, (char *filename));
sync();
if (argc == 2) m = atoi(argv[1]);
- printf("Test 22 ");
- fflush(stdout);
- system("chmod 777 DIR_22/* DIR_22/*/* > /dev/null 2>&1");
- System("rm -rf DIR_22; mkdir DIR_22");
- Chdir("DIR_22");
+ start(22);
for (i = 0; i < ITERATIONS; i++) {
if (m & 0001) test22a();
return 0777 ^ mode(arg);
}
-void e(n)
-int n;
-{
- int err_num = errno; /* Save in case printf clobbers it. */
-
- printf("Subtest %d, error %d errno=%d: ", subtest, n, errno);
- errno = err_num;
- perror("");
- if (errct++ > MAX_ERROR) {
- printf("Too many errors; test aborted\n");
- chdir("..");
- system("rm -rf DIR*");
- exit(1);
- }
- errno = 0;
-}
-
-void quit()
-{
- Chdir("..");
- system("chmod 777 ../DIR_22/* ../DIR_22/*/* > /dev/null 2>&1");
- System("rm -rf DIR_22");
-
- if (errct == 0) {
- printf("ok\n");
- exit(0);
- } else {
- printf("%d errors\n", errct);
- exit(1);
- }
-}
char cwd[PATH_MAX]; /* Space for path names. */
char cwd2[PATH_MAX];
char buf[PATH_MAX];
-char MaxName[NAME_MAX + 1]; /* Name of maximum length */
+char *MaxName; /* Name of maximum length */
char MaxPath[PATH_MAX]; /* Same for path */
-char ToLongName[NAME_MAX + 2]; /* Name of maximum +1 length */
+char *ToLongName; /* Name of maximum +1 length */
char ToLongPath[PATH_MAX + 1]; /* Same for path, both too long */
_PROTOTYPE(void test23a, (void));
_PROTOTYPE(void test23b, (void));
_PROTOTYPE(void test23c, (void));
_PROTOTYPE(void makelongnames, (void)); /* Fill MaxName etc. */
-_PROTOTYPE(char *last_index, (char *string, int ch));
-_PROTOTYPE(char *my_getcwd, (char *buf, int size));
int main(int argc, char *argv[])
{
System("rm -rf ../DIR_23/*");
- /* Fiddle with the size (2nt) parameter of `getcwd ()'. */
+ /* Fiddle with the size (2nd) parameter of `getcwd ()'. */
if (getcwd(cwd, PATH_MAX) != cwd) e(1); /* get cwd */
if (getcwd(buf, strlen(cwd)) != (char *) 0) e(2); /* size 1 to small */
if (errno != ERANGE) e(3);
void makelongnames()
{
register int i;
+ int max_name_length;
+
+ max_name_length = name_max("."); /* Aka NAME_MAX, but not every FS supports
+ * the same length, hence runtime check */
+ MaxName = malloc(max_name_length + 1);
+ ToLongName = malloc(max_name_length + 1 + 1); /* Name of maximum +1 length */
+ memset(MaxName, 'a', max_name_length);
+ MaxName[max_name_length] = '\0';
- memset(MaxName, 'a', NAME_MAX);
- MaxName[NAME_MAX] = '\0';
for (i = 0; i < PATH_MAX - 1; i++) { /* idem path */
MaxPath[i++] = '.';
MaxPath[i] = '/';
strcpy(ToLongName, MaxName); /* copy them Max to ToLong */
strcpy(ToLongPath, MaxPath);
- ToLongName[NAME_MAX] = 'a';
- ToLongName[NAME_MAX + 1] = '\0'; /* extend ToLongName by one too many */
+ ToLongName[max_name_length] = 'a';
+ ToLongName[max_name_length+1] = '\0';/* extend ToLongName by one too many */
ToLongPath[PATH_MAX - 1] = '/';
ToLongPath[PATH_MAX] = '\0'; /* inc ToLongPath by one */
}
-/* The following code, is take from pwd written by Adri Koppes */
-
-/* My_getcwd() helper. */
-char *last_index(string, ch)
-char *string;
-char ch;
-{
- register char *retval = '\0';
-
- while (*string != '\0') {
- if (*string == ch) retval = string;
- string++;
- }
- return(retval);
-}
-
-char *my_getcwd(buf, size)
-char *buf;
-int size;
-{ /* should be like getcwd() */
- int sd;
- register int fd;
- register char *n;
- char name[128];
- struct stat s, st, sk;
- struct direct d;
-
- if (size <= 0) return(char *) 0;
-
- *buf = '\0';
- *name = '\0';
- stat(".", &s);
- do {
- if ((fd = open("..", O_RDONLY)) < 0) return(char *) 0;
- st.st_dev = s.st_dev;
- st.st_ino = s.st_ino;
- stat("..", &s);
- Chdir("..");
- sd = sizeof(struct direct);
- if (s.st_dev == st.st_dev) {
- do {
- if (read(fd, (char *) &d, sd) < sd) return(char *) 0;
- } while (d.d_ino != st.st_ino);
- } else {
- do {
- if (read(fd, (char *) &d, sd) < sd) return(char *) 0;
- stat(d.d_name, &sk);
- } while ((sk.st_dev != st.st_dev) ||
- (sk.st_ino != st.st_ino));
- }
- close(fd);
- if (strcmp(".", d.d_name) != 0) {
- strcat(name, "/");
- strcat(name, d.d_name);
- }
- } while ((s.st_ino != st.st_ino) || (s.st_dev != st.st_dev));
- if (*name == '\0')
- strncat(buf, "/", size);
- else
- while ((n = last_index(name, '/')) != NULL) {
- n[NAME_MAX] = '\0';
- strncat(buf, n, size - strlen(buf));
- *n = '\0';
- }
- strncat(buf, name, size - strlen(buf));
- buf[size - 1] = '\0';
- Chdir(buf); /* get back there */
- return buf;
-}
-
int subtest = 1;
int superuser;
-char MaxName[NAME_MAX + 1]; /* Name of maximum length */
+char *MaxName; /* Name of maximum length */
char MaxPath[PATH_MAX]; /* Same for path */
-char ToLongName[NAME_MAX + 2]; /* Name of maximum +1 length */
+char *ToLongName; /* Name of maximum +1 length */
char ToLongPath[PATH_MAX + 1]; /* Same for path, both too long */
int main(int argc, char *argv[])
{
int i, m = 0xFFFF;
- sync();
+ start(24);
if (argc == 2) m = atoi(argv[1]);
- printf("Test 24 ");
- fflush(stdout);
- System("rm -rf DIR_24; mkdir DIR_24");
- Chdir("DIR_24");
makelongnames();
superuser = (geteuid() == 0);
int i, j; /* i = highest open dir count */
DIR *dirp[OVERFLOW_DIR_NR], *dp;
struct dirent *dep, *dep1, *dep2;
- char name[NAME_MAX + 2]; /* buffer for file name, and count */
+ char *name; /* buffer for file name, and count */
int dot = 0, dotdot = 0;
+ int max_name_length;
subtest = 2;
System("rm -rf ../DIR_24/*");
+ max_name_length = name_max(".");
+ name = malloc(max_name_length + 2);
+ memset(name, '\0', max_name_length + 2);
+
for (i = 0; i < OVERFLOW_DIR_NR; i++) {
dirp[i] = opendir("/");
if (dirp[i] == ((DIR *) NULL)) {
System("rm -rf foo; mkdir foo");
Chdir("foo");
name[0] = 0;
- for (i = 0; i <= NAME_MAX; i++) {
+ for (i = 0; i <= max_name_length; i++) {
if (strcat(name, "X") != name) e(5);
close(creat(name, 0666)); /* fails once on */
} /* XX..XX, 1 too long */
name[strlen(dep->d_name)] += 1; /* 'X' + 1 == 'Y' */
}
if (closedir(dp) != 0) e(7);
- for (i = 1; i <= NAME_MAX; i++) { /* Check if every length */
+ for (i = 1; i <= max_name_length; i++) { /* Check if every length */
if (name[i] != 'Y') e(8); /* has been seen once. */
}
/* Check upper and lower bound. */
if (name[0] != 'X') e(9);
- if (name[NAME_MAX + 1] != '\0') e(10);
+ if (name[max_name_length + 1] != '\0') e(10);
/* Now check if two simultaniouse open dirs do the same */
if ((dirp[1] = opendir("foo")) == ((DIR *) NULL)) e(11);
void makelongnames()
{
register int i;
+ int max_name_length;
+
+ max_name_length = name_max("."); /* Aka NAME_MAX, but not every FS supports
+ * the same length, hence runtime check */
+ MaxName = malloc(max_name_length + 1);
+ ToLongName = malloc(max_name_length + 1 + 1); /* Name of maximum +1 length */
+ memset(MaxName, 'a', max_name_length);
+ MaxName[max_name_length] = '\0';
- memset(MaxName, 'a', NAME_MAX);
- MaxName[NAME_MAX] = '\0';
for (i = 0; i < PATH_MAX - 1; i++) { /* idem path */
MaxPath[i++] = '.';
MaxPath[i] = '/';
strcpy(ToLongName, MaxName); /* copy them Max to ToLong */
strcpy(ToLongPath, MaxPath);
- ToLongName[NAME_MAX] = 'a';
- ToLongName[NAME_MAX + 1] = '\0'; /* extend ToLongName by one too many */
+ ToLongName[max_name_length] = 'a';
+ ToLongName[max_name_length+1] = '\0';/* extend ToLongName by one too many */
ToLongPath[PATH_MAX - 1] = '/';
ToLongPath[PATH_MAX] = '\0'; /* inc ToLongPath by one */
}
-
int subtest = 1;
int superuser;
-char MaxName[NAME_MAX + 1]; /* Name of maximum length */
+char *MaxName; /* Name of maximum length */
char MaxPath[PATH_MAX]; /* Same for path */
-char ToLongName[NAME_MAX + 2]; /* Name of maximum +1 length */
+char *ToLongName; /* Name of maximum +1 length */
char ToLongPath[PATH_MAX + 1]; /* Same for path, both too long */
_PROTOTYPE(void test25a, (void));
_PROTOTYPE(void test25d, (void));
_PROTOTYPE(void test25e, (void));
_PROTOTYPE(void makelongnames, (void));
-_PROTOTYPE(void e, (int number));
-_PROTOTYPE(void quit, (void));
int main(int argc, char *argv[])
{
sync();
- if (argc == 2) m = atoi(argv[1]);
start(25);
+ if (argc == 2) m = atoi(argv[1]);
makelongnames();
superuser = (geteuid() == 0);
if (m & 020) test25e();
}
quit();
- return 1;
}
void test25a()
void makelongnames()
{
register int i;
+ int max_name_length;
+
+ max_name_length = name_max("."); /* Aka NAME_MAX, but not every FS supports
+ * the same length, hence runtime check */
+ MaxName = malloc(max_name_length + 1);
+ ToLongName = malloc(max_name_length + 1 + 1); /* Name of maximum +1 length */
+ memset(MaxName, 'a', max_name_length);
+ MaxName[max_name_length] = '\0';
- memset(MaxName, 'a', NAME_MAX);
- MaxName[NAME_MAX] = '\0';
for (i = 0; i < PATH_MAX - 1; i++) { /* idem path */
MaxPath[i++] = '.';
MaxPath[i] = '/';
strcpy(ToLongName, MaxName); /* copy them Max to ToLong */
strcpy(ToLongPath, MaxPath);
- ToLongName[NAME_MAX] = 'a';
- ToLongName[NAME_MAX + 1] = '\0'; /* extend ToLongName by one too many */
+ ToLongName[max_name_length] = 'a';
+ ToLongName[max_name_length+1] = '\0';/* extend ToLongName by one too many */
ToLongPath[PATH_MAX - 1] = '/';
ToLongPath[PATH_MAX] = '\0'; /* inc ToLongPath by one */
}
#define Stat(a,b) if (stat(a,b) != 0) printf("Can't stat %s\n", a)
#define Mkfifo(f) if (mkfifo(f,0777)!=0) printf("Can't make fifo %s\n", f)
-int errct = 0;
-int subtest = 1;
-char MaxName[NAME_MAX + 1]; /* Name of maximum length */
-char MaxPath[PATH_MAX]; /* Same for path */
-char ToLongName[NAME_MAX + 2]; /* Name of maximum +1 length */
-char ToLongPath[PATH_MAX + 1]; /* Same for path, both too long */
+#include "common.c"
_PROTOTYPE(void test26a, (void));
_PROTOTYPE(void test26b, (void));
_PROTOTYPE(void test26c, (void));
-_PROTOTYPE(void e, (int number));
-_PROTOTYPE(void quit, (void));
int main(int argc, char *argv[])
{
sync();
if (argc == 2) m = atoi(argv[1]);
- printf("Test 26 ");
- fflush(stdout);
- System("rm -rf DIR_26; mkdir DIR_26");
- Chdir("DIR_26");
+
+ start(26);
for (i = 0; i < 10; i++) {
if (m & 0001) test26a();
}
}
-void e(n)
-int n;
-{
- int err_num = errno; /* Save in case printf clobbers it. */
-
- printf("Subtest %d, error %d errno=%d: ", subtest, n, errno);
- errno = err_num;
- perror("");
- if (errct++ > MAX_ERROR) {
- printf("Too many errors; test aborted\n");
- chdir("..");
- system("rm -rf DIR*");
- exit(1);
- }
- errno = 0;
-}
-
-void quit()
-{
- Chdir("..");
- System("rm -rf DIR_26");
-
- if (errct == 0) {
- printf("ok\n");
- exit(0);
- } else {
- printf("%d errors\n", errct);
- exit(1);
- }
-}
#define System(cmd) if (system(cmd) != 0) printf("``%s'' failed\n", cmd)
#define Chdir(dir) if (chdir(dir) != 0) printf("Can't goto %s\n", dir)
-int errct = 0;
-int subtest = 1;
+#include "common.c"
+
int superuser;
-char MaxName[NAME_MAX + 1]; /* Name of maximum length */
+char *MaxName; /* Name of maximum length */
char MaxPath[PATH_MAX];
-char ToLongName[NAME_MAX + 2]; /* Name of maximum +1 length */
+char *ToLongName; /* Name of maximum +1 length */
char ToLongPath[PATH_MAX + 1];
_PROTOTYPE(void test27a, (void));
_PROTOTYPE(void test27b, (void));
_PROTOTYPE(void test27c, (void));
_PROTOTYPE(void makelongnames, (void));
-_PROTOTYPE(void e, (int __n));
-_PROTOTYPE(void quit, (void));
int main(int argc, char *argv[])
{
int i, m = 0xFFFF;
- sync();
+ start(27);
if (argc == 2) m = atoi(argv[1]);
- printf("Test 27 ");
- fflush(stdout);
- System("rm -rf DIR_27; mkdir DIR_27");
- Chdir("DIR_27");
superuser = (getuid() == 0);
makelongnames();
void makelongnames()
{
register int i;
+ int max_name_length;
+
+ max_name_length = name_max("."); /* Aka NAME_MAX, but not every FS supports
+ * the same length, hence runtime check */
+ MaxName = malloc(max_name_length + 1);
+ ToLongName = malloc(max_name_length + 1 + 1); /* Name of maximum +1 length */
+ memset(MaxName, 'a', max_name_length);
+ MaxName[max_name_length] = '\0';
- memset(MaxName, 'a', NAME_MAX);
- MaxName[NAME_MAX] = '\0';
for (i = 0; i < PATH_MAX - 1; i++) { /* idem path */
MaxPath[i++] = '.';
MaxPath[i] = '/';
strcpy(ToLongName, MaxName); /* copy them Max to ToLong */
strcpy(ToLongPath, MaxPath);
- ToLongName[NAME_MAX] = 'a';
- ToLongName[NAME_MAX + 1] = '\0'; /* extend ToLongName by one too many */
+ ToLongName[max_name_length] = 'a';
+ ToLongName[max_name_length+1] = '\0';/* extend ToLongName by one too many */
ToLongPath[PATH_MAX - 1] = '/';
ToLongPath[PATH_MAX] = '\0'; /* inc ToLongPath by one */
}
-void e(n)
-int n;
-{
- int err_num = errno; /* Save in case printf clobbers it. */
-
- printf("Subtest %d, error %d errno=%d: ", subtest, n, errno);
- errno = err_num;
- perror("");
- if (errct++ > MAX_ERROR) {
- printf("Too many errors; test aborted\n");
- chdir("..");
- system("rm -rf DIR*");
- exit(1);
- }
- errno = 0;
-}
-
-void quit()
-{
- Chdir("..");
- System("rm -rf DIR_27");
-
- if (errct == 0) {
- printf("ok\n");
- exit(0);
- } else {
- printf("%d errors\n", errct);
- exit(1);
- }
-}
int subtest = 1;
int superuser;
-char MaxName[NAME_MAX + 1]; /* Name of maximum length */
+char *MaxName; /* Name of maximum length */
char MaxPath[PATH_MAX];
-char ToLongName[NAME_MAX + 2]; /* Name of maximum +1 length */
+char *ToLongName; /* Name of maximum +1 length */
char ToLongPath[PATH_MAX + 1];
_PROTOTYPE(void test28a, (void));
if (m & 0004) test28c();
}
quit();
- return 1;
}
void test28a()
void makelongnames()
{
register int i;
+ int max_name_length;
+
+ max_name_length = name_max("."); /* Aka NAME_MAX, but not every FS supports
+ * the same length, hence runtime check */
+ MaxName = malloc(max_name_length + 1);
+ ToLongName = malloc(max_name_length + 1 + 1); /* Name of maximum +1 length */
+ memset(MaxName, 'a', max_name_length);
+ MaxName[max_name_length] = '\0';
- memset(MaxName, 'a', NAME_MAX);
- MaxName[NAME_MAX] = '\0';
for (i = 0; i < PATH_MAX - 1; i++) { /* idem path */
MaxPath[i++] = '.';
MaxPath[i] = '/';
strcpy(ToLongName, MaxName); /* copy them Max to ToLong */
strcpy(ToLongPath, MaxPath);
- ToLongName[NAME_MAX] = 'a';
- ToLongName[NAME_MAX + 1] = '\0'; /* extend ToLongName by one too many */
+ ToLongName[max_name_length] = 'a';
+ ToLongName[max_name_length+1] = '\0';/* extend ToLongName by one too many */
ToLongPath[PATH_MAX - 1] = '/';
ToLongPath[PATH_MAX] = '\0'; /* inc ToLongPath by one */
}
-
#define IS_CLOEXEC(fd) ((fcntl(fd, F_GETFD) & FD_CLOEXEC) == FD_CLOEXEC)
#define SET_CLOEXEC(fd) fcntl(fd, F_SETFD, FD_CLOEXEC)
-int errct = 0;
-int subtest = 1;
+#include "common.c"
+
int superuser;
-char MaxName[NAME_MAX + 1]; /* Name of maximum length */
-char MaxPath[PATH_MAX]; /* Same for path */
-char ToLongName[NAME_MAX + 2]; /* Name of maximum +1 length */
-char ToLongPath[PATH_MAX + 1]; /* Same for path, both too long */
_PROTOTYPE(void test29a, (void));
_PROTOTYPE(void test29b, (void));
_PROTOTYPE(void test29c, (void));
-_PROTOTYPE(void e, (int number));
-_PROTOTYPE(void quit, (void));
int main(int argc, char *argv[])
{
sync();
if (argc == 2) m = atoi(argv[1]);
- printf("Test 29 ");
- fflush(stdout);
- System("rm -rf DIR_29; mkdir DIR_29");
- Chdir("DIR_29");
+
+ start(29);
superuser = (geteuid() == 0);
for (i = 0; i < ITERATIONS; i++) {
System("rm -rf ../DIR_29/*");
}
-
-void e(n)
-int n;
-{
- int err_num = errno; /* Save in case printf clobbers it. */
-
- printf("Subtest %d, error %d errno=%d: ", subtest, n, errno);
- errno = err_num;
- perror("");
- if (errct++ > MAX_ERROR) {
- printf("Too many errors; test aborted\n");
- chdir("..");
- system("rm -rf DIR*");
- exit(1);
- }
- errno = 0;
-}
-
-void quit()
-{
- Chdir("..");
- System("rm -rf DIR_29");
-
- if (errct == 0) {
- printf("ok\n");
- exit(0);
- } else {
- printf("%d errors\n", errct);
- exit(1);
- }
-}
#define Chdir(dir) if (chdir(dir) != 0) printf("Can't goto %s\n", dir)
#define Stat(a,b) if (stat(a,b) != 0) printf("Can't stat %s\n", a)
-int subtest = 1;
int superuser;
-char MaxName[NAME_MAX + 1]; /* Name of maximum length */
+char *MaxName; /* Name of maximum length */
char MaxPath[PATH_MAX]; /* Same for path */
-char ToLongName[NAME_MAX + 2]; /* Name of maximum +1 length */
+char *ToLongName; /* Name of maximum +1 length */
char ToLongPath[PATH_MAX + 1]; /* Same for path, both too long */
_PROTOTYPE(void test30a, (void));
_PROTOTYPE(void test30b, (void));
_PROTOTYPE(void test30c, (void));
_PROTOTYPE(void makelongnames, (void));
-_PROTOTYPE(void e, (int number));
-_PROTOTYPE(void quit, (void));
int main(int argc, char *argv[])
{
void makelongnames()
{
register int i;
+ int max_name_length;
+
+ max_name_length = name_max("."); /* Aka NAME_MAX, but not every FS supports
+ * the same length, hence runtime check */
+ MaxName = malloc(max_name_length + 1);
+ ToLongName = malloc(max_name_length + 1 + 1); /* Name of maximum +1 length */
+ memset(MaxName, 'a', max_name_length);
+ MaxName[max_name_length] = '\0';
- memset(MaxName, 'a', NAME_MAX);
- MaxName[NAME_MAX] = '\0';
for (i = 0; i < PATH_MAX - 1; i++) { /* idem path */
MaxPath[i++] = '.';
MaxPath[i] = '/';
strcpy(ToLongName, MaxName); /* copy them Max to ToLong */
strcpy(ToLongPath, MaxPath);
- ToLongName[NAME_MAX] = 'a';
- ToLongName[NAME_MAX + 1] = '\0'; /* extend ToLongName by one too many */
+ ToLongName[max_name_length] = 'a';
+ ToLongName[max_name_length+1] = '\0';/* extend ToLongName by one too many */
ToLongPath[PATH_MAX - 1] = '/';
ToLongPath[PATH_MAX] = '\0'; /* inc ToLongPath by one */
}
-
#define Chdir(dir) if (chdir(dir) != 0) printf("Can't goto %s\n", dir)
#define Stat(a,b) if (stat(a,b) != 0) printf("Can't stat %s\n", a)
-int subtest = 1;
int superuser;
-char MaxName[NAME_MAX + 1]; /* Name of maximum length */
+char *MaxName; /* Name of maximum length */
char MaxPath[PATH_MAX]; /* Same for path */
-char ToLongName[NAME_MAX + 2]; /* Name of maximum +1 length */
+char *ToLongName; /* Name of maximum +1 length */
char ToLongPath[PATH_MAX + 1]; /* Same for path, both too long */
_PROTOTYPE(void test31a, (void));
void makelongnames()
{
register int i;
+ int max_name_length;
+
+ max_name_length = name_max("."); /* Aka NAME_MAX, but not every FS supports
+ * the same length, hence runtime check */
+ MaxName = malloc(max_name_length + 1);
+ ToLongName = malloc(max_name_length + 1 + 1); /* Name of maximum +1 length */
+ memset(MaxName, 'a', max_name_length);
+ MaxName[max_name_length] = '\0';
- memset(MaxName, 'a', NAME_MAX);
- MaxName[NAME_MAX] = '\0';
for (i = 0; i < PATH_MAX - 1; i++) { /* idem path */
MaxPath[i++] = '.';
MaxPath[i] = '/';
strcpy(ToLongName, MaxName); /* copy them Max to ToLong */
strcpy(ToLongPath, MaxPath);
- ToLongName[NAME_MAX] = 'a';
- ToLongName[NAME_MAX + 1] = '\0'; /* extend ToLongName by one too many */
+ ToLongName[max_name_length] = 'a';
+ ToLongName[max_name_length+1] = '\0';/* extend ToLongName by one too many */
ToLongPath[PATH_MAX - 1] = '/';
ToLongPath[PATH_MAX] = '\0'; /* inc ToLongPath by one */
}
-
#define Stat(a,b) if (stat(a,b) != 0) printf("Can't stat %s\n", a)
#define Creat(f) if (close(creat(f,0777))!=0) printf("Can't creat %s\n",f)
-int errct = 0;
-int subtest = 1;
+#include "common.c"
+
int superuser;
-char MaxName[NAME_MAX + 1]; /* Name of maximum length */
+char *MaxName; /* Name of maximum length */
char MaxPath[PATH_MAX]; /* Same for path */
-char ToLongName[NAME_MAX + 2]; /* Name of maximum +1 length */
+char *ToLongName; /* Name of maximum +1 length */
char ToLongPath[PATH_MAX + 1]; /* Same for path, both too long */
_PROTOTYPE(void test32a, (void));
_PROTOTYPE(void test32b, (void));
_PROTOTYPE(void test32c, (void));
_PROTOTYPE(void makelongnames, (void));
-_PROTOTYPE(void e, (int number));
-_PROTOTYPE(void quit, (void));
int main(int argc, char *argv[])
{
int i, m = 0xFFFF;
- sync();
+ start(32);
+
if (argc == 2) m = atoi(argv[1]);
- printf("Test 32 ");
- fflush(stdout);
- System("rm -rf DIR_32; mkdir DIR_32");
- Chdir("DIR_32");
makelongnames();
superuser = (geteuid() == 0);
if (m & 0004) test32c();
}
quit();
- return 1;
}
#define BUF_SIZE 1024
void makelongnames()
{
register int i;
+ int max_name_length;
+
+ max_name_length = name_max("."); /* Aka NAME_MAX, but not every FS supports
+ * the same length, hence runtime check */
+ MaxName = malloc(max_name_length + 1);
+ ToLongName = malloc(max_name_length + 1 + 1); /* Name of maximum +1 length */
+ memset(MaxName, 'a', max_name_length);
+ MaxName[max_name_length] = '\0';
- memset(MaxName, 'a', NAME_MAX);
- MaxName[NAME_MAX] = '\0';
for (i = 0; i < PATH_MAX - 1; i++) { /* idem path */
MaxPath[i++] = '.';
MaxPath[i] = '/';
strcpy(ToLongName, MaxName); /* copy them Max to ToLong */
strcpy(ToLongPath, MaxPath);
- ToLongName[NAME_MAX] = 'a';
- ToLongName[NAME_MAX + 1] = '\0'; /* extend ToLongName by one too many */
+ ToLongName[max_name_length] = 'a';
+ ToLongName[max_name_length+1] = '\0';/* extend ToLongName by one too many */
ToLongPath[PATH_MAX - 1] = '/';
ToLongPath[PATH_MAX] = '\0'; /* inc ToLongPath by one */
}
-
-void e(n)
-int n;
-{
- int err_num = errno; /* Save in case printf clobbers it. */
-
- printf("Subtest %d, error %d errno=%d: ", subtest, n, errno);
- errno = err_num;
- perror("");
- if (errct++ > MAX_ERROR) {
- printf("Too many errors; test aborted\n");
- chdir("..");
- system("rm -rf DIR*");
- exit(1);
- }
- errno = 0;
-}
-
-void quit()
-{
- Chdir("..");
- System("rm -rf DIR_32");
-
- if (errct == 0) {
- printf("ok\n");
- exit(0);
- } else {
- printf("%d errors\n", errct);
- exit(1);
- }
-}
#define Chmod(a,b) if (chmod(a,b) != 0) printf("Can't chmod %s\n", a)
#define Mkfifo(f) if (mkfifo(f,0777)!=0) printf("Can't make fifo %s\n", f)
-int subtest = 1;
int superuser; /* nonzero if uid == euid (euid == 0 always) */
-char MaxName[NAME_MAX + 1]; /* Name of maximum length */
+char *MaxName; /* Name of maximum length */
char MaxPath[PATH_MAX]; /* Same for path */
-char ToLongName[NAME_MAX + 2]; /* Name of maximum +1 length */
+char *ToLongName; /* Name of maximum +1 length */
char ToLongPath[PATH_MAX + 1]; /* Same for path, both too long */
_PROTOTYPE(void test33a, (void));
void makelongnames()
{
register int i;
+ int max_name_length;
+
+ max_name_length = name_max("."); /* Aka NAME_MAX, but not every FS supports
+ * the same length, hence runtime check */
+ MaxName = malloc(max_name_length + 1);
+ ToLongName = malloc(max_name_length + 1 + 1); /* Name of maximum +1 length */
+ memset(MaxName, 'a', max_name_length);
+ MaxName[max_name_length] = '\0';
- memset(MaxName, 'a', NAME_MAX);
- MaxName[NAME_MAX] = '\0';
for (i = 0; i < PATH_MAX - 1; i++) { /* idem path */
MaxPath[i++] = '.';
MaxPath[i] = '/';
strcpy(ToLongName, MaxName); /* copy them Max to ToLong */
strcpy(ToLongPath, MaxPath);
- ToLongName[NAME_MAX] = 'a';
- ToLongName[NAME_MAX + 1] = '\0'; /* extend ToLongName by one too many */
+ ToLongName[max_name_length] = 'a';
+ ToLongName[max_name_length+1] = '\0';/* extend ToLongName by one too many */
ToLongPath[PATH_MAX - 1] = '/';
ToLongPath[PATH_MAX] = '\0'; /* inc ToLongPath by one */
}
-
/* This program uses /etc/passwd and assumes things about it's contents. */
#define PASSWD_FILE "/etc/passwd"
-int subtest = 1;
int superuser;
int I_can_chown;
-char MaxName[NAME_MAX + 1]; /* Name of maximum length */
+char *MaxName; /* Name of maximum length */
char MaxPath[PATH_MAX]; /* Same for path */
-char NameTooLong[NAME_MAX + 2]; /* Name of maximum +1 length */
+char *NameTooLong; /* Name of maximum +1 length */
char PathTooLong[PATH_MAX + 1]; /* Same for path, both too long */
_PROTOTYPE(void test34a, (void));
void makelongnames()
{
register int i;
+ int max_name_length;
+
+ max_name_length = name_max("."); /* Aka NAME_MAX, but not every FS supports
+ * the same length, hence runtime check */
+ MaxName = malloc(max_name_length + 1);
+ NameTooLong = malloc(max_name_length + 1 + 1); /* Name of maximum +1 length */
+ memset(MaxName, 'a', max_name_length);
+ MaxName[max_name_length] = '\0';
- memset(MaxName, 'a', NAME_MAX);
- MaxName[NAME_MAX] = '\0';
for (i = 0; i < PATH_MAX - 1; i++) { /* idem path */
MaxPath[i++] = '.';
MaxPath[i] = '/';
}
MaxPath[PATH_MAX - 1] = '\0';
- strcpy(NameTooLong, MaxName); /* copy them Max to TooLong */
+ strcpy(NameTooLong, MaxName); /* copy them Max to ToLong */
strcpy(PathTooLong, MaxPath);
- NameTooLong[NAME_MAX] = 'a';
- NameTooLong[NAME_MAX + 1] = '\0'; /* extend NameTooLong by one too many*/
+ NameTooLong[max_name_length] = 'a';
+ NameTooLong[max_name_length+1] = '\0';/* extend ToLongName by one too many */
PathTooLong[PATH_MAX - 1] = '/';
- PathTooLong[PATH_MAX] = '\0'; /* inc PathTooLong by one */
+ PathTooLong[PATH_MAX] = '\0'; /* inc ToLongPath by one */
}
/* Getids returns a valid uid and gid. Is used PASSWD FILE.
#define PASSWD_FILE "/etc/passwd"
-int subtest = 1;
int I_can_chown;
int superuser;
-char MaxName[NAME_MAX + 1]; /* Name of maximum length */
+char *MaxName; /* Name of maximum length */
char MaxPath[PATH_MAX]; /* Same for path */
-char NameTooLong[NAME_MAX + 2]; /* Name of maximum +1 length */
+char *NameTooLong; /* Name of maximum +1 length */
char PathTooLong[PATH_MAX + 1]; /* Same for path, both too long */
_PROTOTYPE(void test35a, (void));
void makelongnames()
{
register int i;
+ int max_name_length;
+
+ max_name_length = name_max("."); /* Aka NAME_MAX, but not every FS supports
+ * the same length, hence runtime check */
+ MaxName = malloc(max_name_length + 1);
+ NameTooLong = malloc(max_name_length + 1 + 1); /* Name of maximum +1 length */
+ memset(MaxName, 'a', max_name_length);
+ MaxName[max_name_length] = '\0';
- memset(MaxName, 'a', NAME_MAX);
- MaxName[NAME_MAX] = '\0';
for (i = 0; i < PATH_MAX - 1; i++) { /* idem path */
MaxPath[i++] = '.';
MaxPath[i] = '/';
}
MaxPath[PATH_MAX - 1] = '\0';
- strcpy(NameTooLong, MaxName); /* copy them Max to TooLong */
+ strcpy(NameTooLong, MaxName); /* copy them Max to ToLong */
strcpy(PathTooLong, MaxPath);
- NameTooLong[NAME_MAX] = 'a';
- NameTooLong[NAME_MAX + 1] = '\0'; /* extend NameTooLong by one too many*/
+ NameTooLong[max_name_length] = 'a';
+ NameTooLong[max_name_length+1] = '\0';/* extend ToLongName by one too many */
PathTooLong[PATH_MAX - 1] = '/';
- PathTooLong[PATH_MAX] = '\0'; /* inc PathTooLong by one */
+ PathTooLong[PATH_MAX] = '\0'; /* inc ToLongPath by one */
}
/* Getids returns a valid uid and gid. Is used PASSWD FILE.
#define Chdir(dir) if (chdir(dir) != 0) printf("Can't goto %s\n", dir)
#define Stat(a,b) if (stat(a,b) != 0) printf("Can't stat %s\n", a)
-int errct = 0;
-int subtest = 1;
+#include "common.c"
+
int superuser;
-char MaxName[NAME_MAX + 1]; /* Name of maximum length */
-char MaxPath[PATH_MAX]; /* Same for path */
-char ToLongName[NAME_MAX + 2]; /* Name of maximum +1 length */
-char ToLongPath[PATH_MAX + 1]; /* Same for path, both too long */
_PROTOTYPE(void test36a, (void));
_PROTOTYPE(void test36b, (void));
_PROTOTYPE(void test36c, (void));
_PROTOTYPE(void test36d, (void));
-_PROTOTYPE(void makelongnames, (void));
-_PROTOTYPE(void e, (int number));
-_PROTOTYPE(void quit, (void));
_PROTOTYPE(int not_provided_option, (int _option));
_PROTOTYPE(int provided_option, (int _option, int _minimum_value));
_PROTOTYPE(int variating_option, (int _option, int _minimum_value));
int i, m = 0xFFFF;
sync();
+ start(36);
if (argc == 2) m = atoi(argv[1]);
- printf("Test 36 ");
- fflush(stdout);
- System("rm -rf DIR_36; mkdir DIR_36");
- Chdir("DIR_36");
- makelongnames();
superuser = (geteuid() == 0);
for (i = 0; i < ITERATIONS; i++) {
System("rm -rf ../DIR_36/*");
}
-void makelongnames()
-{
- register int i;
-
- memset(MaxName, 'a', NAME_MAX);
- MaxName[NAME_MAX] = '\0';
- for (i = 0; i < PATH_MAX - 1; i++) { /* idem path */
- MaxPath[i++] = '.';
- MaxPath[i] = '/';
- }
- MaxPath[PATH_MAX - 1] = '\0';
-
- strcpy(ToLongName, MaxName); /* copy them Max to ToLong */
- strcpy(ToLongPath, MaxPath);
-
- ToLongName[NAME_MAX] = 'a';
- ToLongName[NAME_MAX + 1] = '\0'; /* extend ToLongName by one too many */
- ToLongPath[PATH_MAX - 1] = '/';
- ToLongPath[PATH_MAX] = '\0'; /* inc ToLongPath by one */
-}
-
-void e(n)
-int n;
-{
- int err_num = errno; /* Save in case printf clobbers it. */
-
- printf("Subtest %d, error %d errno=%d: ", subtest, n, errno);
- errno = err_num;
- perror("");
- if (errct++ > MAX_ERROR) {
- printf("Too many errors; test aborted\n");
- chdir("..");
- system("rm -rf DIR*");
- exit(1);
- }
- errno = 0;
-}
-
-void quit()
-{
- Chdir("..");
- System("rm -rf DIR_36");
-
- if (errct == 0) {
- printf("ok\n");
- exit(0);
- } else {
- printf("%d errors\n", errct);
- exit(1);
- }
-}
-
int not_provided_option(option)
int option;
{
#define SIGS 14
#define MAX_ERROR 4
-int iteration, cumsig, subtest, errct = 0, sig1, sig2;
+#include "common.c"
+
+int iteration, cumsig, sig1, sig2;
int sigarray[SIGS] = {SIGHUP, SIGILL, SIGTRAP, SIGABRT, SIGIOT,
SIGFPE, SIGUSR1, SIGSEGV, SIGUSR2, SIGPIPE, SIGALRM,
_PROTOTYPE(void catch15, (int signo));
_PROTOTYPE(void test37o, (void));
_PROTOTYPE(void clearsigstate, (void));
-_PROTOTYPE(void quit, (void));
_PROTOTYPE(void wait_for, (int pid));
-_PROTOTYPE(void e, (int n));
int main(argc, argv)
int argc;
sync();
- if (argc == 2) m = atoi(argv[1]);
-
- printf("Test 37 ");
- fflush(stdout); /* have to flush for child's benefit */
+ start(37);
- system("rm -rf DIR_37; mkdir DIR_37");
- chdir("DIR_37");
+ if (argc == 2) m = atoi(argv[1]);
for (i = 0; i < ITERATIONS; i++) {
iteration = i;
}
quit();
- return(-1); /* impossible */
}
void test37a()
sigprocmask(SIG_UNBLOCK, &sigset_var, (sigset_t *)NULL);
}
-void quit()
-{
-
- chdir("..");
- system("rm -rf DIR*");
-
- if (errct == 0) {
- printf("ok\n");
- exit(0);
- } else {
- printf("%d errors\n", errct);
- exit(4);
- }
-}
-
void wait_for(pid)
pid_t pid;
{
}
}
-void e(n)
-int n;
-{
- char msgbuf[80];
-
- sprintf(msgbuf, "Subtest %d, error %d errno=%d ", subtest, n, errno);
- perror(msgbuf);
- if (errct++ > MAX_ERROR) {
- fprintf(stderr, "Too many errors; test aborted\n");
- chdir("..");
- system("rm -rf DIR*");
- exit(1);
- }
-}
#define Chdir(dir) if (chdir(dir) != 0) printf("Can't goto %s\n", dir)
#define Stat(a,b) if (stat(a,b) != 0) printf("Can't stat %s\n", a)
-int errct = 0;
-int subtest = 1;
+#include "common.c"
+
int superuser;
int signumber = 0;
_PROTOTYPE(void test38b, (void));
_PROTOTYPE(void test38c, (void));
_PROTOTYPE(void setsignumber, (int _signumber));
-_PROTOTYPE(void e, (int number));
-_PROTOTYPE(void quit, (void));
int main(int argc, char *argv[])
{
int i, m = 0xFFFF;
sync();
+ start(38);
+
if (argc == 2) m = atoi(argv[1]);
- printf("Test 38 ");
- fflush(stdout);
- System("rm -rf DIR_38; mkdir DIR_38");
- Chdir("DIR_38");
superuser = (geteuid() == 0);
umask(0000);
if (m & 0004) test38c();
}
quit();
- return 1;
}
void test38a()
signumber = signum;
}
-void e(n)
-int n;
-{
- int err_num = errno; /* Save in case printf clobbers it. */
-
- printf("Subtest %d, error %d errno=%d: ", subtest, n, errno);
- errno = err_num;
- perror("");
- if (errct++ > MAX_ERROR) {
- printf("Too many errors; test aborted\n");
- chdir("..");
- system("rm -rf DIR*");
- exit(1);
- }
- errno = 0;
-}
-
-void quit()
-{
- Chdir("..");
- System("rm -rf DIR_38");
-
- if (errct == 0) {
- printf("ok\n");
- exit(0);
- } else {
- printf("%d errors\n", errct);
- exit(1);
- }
-}
#include <stdio.h>
#include <minix/endpoint.h>
#include <minix/sys_config.h>
+#define MAX_ERROR 1
+#include "common.c"
+
+_PROTOTYPE( void test39a, (void) );
int main(int argc, char *argv[])
{
- int g, p;
-
- printf("Test 39 ");
+ start(39);
+ quit();
+}
- for(g = 0; g <= _ENDPOINT_MAX_GENERATION; g++) {
- for(p = -MAX_NR_TASKS; p < _NR_PROCS; p++) {
- endpoint_t e;
- int mg, mp;
- e = _ENDPOINT(g, p);
- mg = _ENDPOINT_G(e);
- mp = _ENDPOINT_P(e);
- if(mg != g || mp != p) {
- printf("%d != %d || %d != %d\n", mg, g, mp, p);
- return 1;
- }
- if(g == 0 && e != p) {
- printf("%d != %d and g=0\n", e, p);
- return 1;
- }
- if(e == ANY || e == SELF || e == NONE) {
- printf("endpoint (%d,%d) is %d; ANY, SELF or NONE\n",
- g, p, e);
- return 1;
- }
- }
- }
+void test39a()
+{
+ int g, p;
- printf("ok\n");
+ subtest = 1;
- return 0;
+ for (g = 0; g <= _ENDPOINT_MAX_GENERATION; g++) {
+ for (p = -MAX_NR_TASKS; p < _NR_PROCS; p++) {
+ endpoint_t ept;
+ int mg, mp;
+ ept = _ENDPOINT(g, p);
+ mg = _ENDPOINT_G(ept);
+ mp = _ENDPOINT_P(ept);
+ if (mg != g || mp != p) e(1);
+ if (g == 0 && ept != p) e(2);
+ if (ept == ANY || ept == SELF || ept == NONE) e(3);
+ }
+ }
}
-
#define MAX_ERROR 4
#define TIMED 0
-static volatile int errct;
+#include "common.c"
+
static volatile int expect_SIGFPE;
static u64_t i, j, k;
static jmp_buf jmpbuf_SIGFPE, jmpbuf_main;
-static void quit(void)
-{
- if (errct == 0) {
- printf("ok\n");
- exit(0);
- } else {
- printf("%d errors\n", errct);
- exit(1);
- }
- assert(0); /* not reachable */
-}
-
static void err(int line)
{
/* print error information */
int main(void)
{
- printf("Test 53 ");
+ start(53);
/* set up signal handler to deal with div by zero */
if (setjmp(jmpbuf_main) == 0) {
/* this was all */
quit();
- assert(0); /* not reachable */
- return -1;
}