xref: /minix3/minix/tests/test32.c (revision 433d6423c39e34ec4b79c950597bb2d236f886be)
1*433d6423SLionel Sambuc /* test32: rename()		Author: Jan-Mark Wams (jms@cs.vu.nl) */
2*433d6423SLionel Sambuc 
3*433d6423SLionel Sambuc #include <sys/types.h>
4*433d6423SLionel Sambuc #include <sys/stat.h>
5*433d6423SLionel Sambuc #include <sys/wait.h>
6*433d6423SLionel Sambuc #include <stdlib.h>
7*433d6423SLionel Sambuc #include <unistd.h>
8*433d6423SLionel Sambuc #include <string.h>
9*433d6423SLionel Sambuc #include <fcntl.h>
10*433d6423SLionel Sambuc #include <limits.h>
11*433d6423SLionel Sambuc #include <errno.h>
12*433d6423SLionel Sambuc #include <time.h>
13*433d6423SLionel Sambuc #include <stdio.h>
14*433d6423SLionel Sambuc 
15*433d6423SLionel Sambuc int max_error = 	4;
16*433d6423SLionel Sambuc #include "common.h"
17*433d6423SLionel Sambuc 
18*433d6423SLionel Sambuc #define ITERATIONS      2
19*433d6423SLionel Sambuc 
20*433d6423SLionel Sambuc #define System(cmd)	if (system(cmd) != 0) printf("``%s'' failed\n", cmd)
21*433d6423SLionel Sambuc #define Chdir(dir)	if (chdir(dir) != 0) printf("Can't goto %s\n", dir)
22*433d6423SLionel Sambuc #define Stat(a,b)	if (stat(a,b) != 0) printf("Can't stat %s\n", a)
23*433d6423SLionel Sambuc #define Creat(f)	if (close(creat(f,0777))!=0) printf("Can't creat %s\n",f)
24*433d6423SLionel Sambuc 
25*433d6423SLionel Sambuc 
26*433d6423SLionel Sambuc int superuser;
27*433d6423SLionel Sambuc char *MaxName;			/* Name of maximum length */
28*433d6423SLionel Sambuc char MaxPath[PATH_MAX];		/* Same for path */
29*433d6423SLionel Sambuc char *ToLongName;		/* Name of maximum +1 length */
30*433d6423SLionel Sambuc char ToLongPath[PATH_MAX + 1];	/* Same for path, both too long */
31*433d6423SLionel Sambuc 
32*433d6423SLionel Sambuc void test32a(void);
33*433d6423SLionel Sambuc void test32b(void);
34*433d6423SLionel Sambuc void test32c(void);
35*433d6423SLionel Sambuc void makelongnames(void);
36*433d6423SLionel Sambuc 
main(int argc,char * argv[])37*433d6423SLionel Sambuc int main(int argc, char *argv[])
38*433d6423SLionel Sambuc {
39*433d6423SLionel Sambuc   int i, m = 0xFFFF;
40*433d6423SLionel Sambuc 
41*433d6423SLionel Sambuc   start(32);
42*433d6423SLionel Sambuc 
43*433d6423SLionel Sambuc   if (argc == 2) m = atoi(argv[1]);
44*433d6423SLionel Sambuc   makelongnames();
45*433d6423SLionel Sambuc   superuser = (geteuid() == 0);
46*433d6423SLionel Sambuc 
47*433d6423SLionel Sambuc   for (i = 0; i < ITERATIONS; i++) {
48*433d6423SLionel Sambuc 	if (m & 0001) test32a();
49*433d6423SLionel Sambuc 	if (m & 0002) test32b();
50*433d6423SLionel Sambuc 	if (m & 0004) test32c();
51*433d6423SLionel Sambuc   }
52*433d6423SLionel Sambuc   quit();
53*433d6423SLionel Sambuc 
54*433d6423SLionel Sambuc   return(-1);	/* Unreachable */
55*433d6423SLionel Sambuc }
56*433d6423SLionel Sambuc 
57*433d6423SLionel Sambuc #define BUF_SIZE 1024
58*433d6423SLionel Sambuc 
test32a()59*433d6423SLionel Sambuc void test32a()
60*433d6423SLionel Sambuc {				/* Test normal operation. */
61*433d6423SLionel Sambuc   struct stat st1, st2;
62*433d6423SLionel Sambuc   int fd1, fd2;
63*433d6423SLionel Sambuc   time_t time1, time2, time3;
64*433d6423SLionel Sambuc   char buf[BUF_SIZE];
65*433d6423SLionel Sambuc 
66*433d6423SLionel Sambuc   subtest = 1;
67*433d6423SLionel Sambuc   System("rm -rf ../DIR_32/*");
68*433d6423SLionel Sambuc 
69*433d6423SLionel Sambuc   /* Test normal file renamal. */
70*433d6423SLionel Sambuc   System("echo haha > old");
71*433d6423SLionel Sambuc   Stat("old", &st1);
72*433d6423SLionel Sambuc   if (rename("old", "new") != 0) e(1);
73*433d6423SLionel Sambuc   Stat("new", &st2);
74*433d6423SLionel Sambuc 
75*433d6423SLionel Sambuc   /* The status of new should be the same as old. */
76*433d6423SLionel Sambuc   if (st1.st_dev != st2.st_dev) e(2);
77*433d6423SLionel Sambuc   if (st1.st_ino != st2.st_ino) e(3);
78*433d6423SLionel Sambuc   if (st1.st_mode != st2.st_mode) e(4);
79*433d6423SLionel Sambuc   if (st1.st_nlink != st2.st_nlink) e(5);
80*433d6423SLionel Sambuc   if (st1.st_uid != st2.st_uid) e(6);
81*433d6423SLionel Sambuc   if (st1.st_gid != st2.st_gid) e(7);
82*433d6423SLionel Sambuc   if (st1.st_rdev != st2.st_rdev) e(8);
83*433d6423SLionel Sambuc   if (st1.st_size != st2.st_size) e(9);
84*433d6423SLionel Sambuc   if (st1.st_atime != st2.st_atime) e(10);
85*433d6423SLionel Sambuc   if (st1.st_mtime != st2.st_mtime) e(11);
86*433d6423SLionel Sambuc   if (st1.st_ctime != st2.st_ctime) e(12);
87*433d6423SLionel Sambuc 
88*433d6423SLionel Sambuc   /* If new exists, it should be removed. */
89*433d6423SLionel Sambuc   System("ln new new2");
90*433d6423SLionel Sambuc   System("echo foobar > old");
91*433d6423SLionel Sambuc   Stat("old", &st1);
92*433d6423SLionel Sambuc   if (rename("old", "new") != 0) e(13);
93*433d6423SLionel Sambuc   Stat("new", &st2);
94*433d6423SLionel Sambuc 
95*433d6423SLionel Sambuc   /* The status of new should be the same as old. */
96*433d6423SLionel Sambuc   if (st1.st_dev != st2.st_dev) e(14);
97*433d6423SLionel Sambuc   if (st1.st_ino != st2.st_ino) e(15);
98*433d6423SLionel Sambuc   if (st1.st_mode != st2.st_mode) e(16);
99*433d6423SLionel Sambuc   if (st1.st_nlink != st2.st_nlink) e(17);
100*433d6423SLionel Sambuc   if (st1.st_uid != st2.st_uid) e(18);
101*433d6423SLionel Sambuc   if (st1.st_gid != st2.st_gid) e(19);
102*433d6423SLionel Sambuc   if (st1.st_rdev != st2.st_rdev) e(20);
103*433d6423SLionel Sambuc   if (st1.st_size != st2.st_size) e(21);
104*433d6423SLionel Sambuc   if (st1.st_atime != st2.st_atime) e(22);
105*433d6423SLionel Sambuc   if (st1.st_mtime != st2.st_mtime) e(23);
106*433d6423SLionel Sambuc   if (st1.st_ctime != st2.st_ctime) e(24);
107*433d6423SLionel Sambuc 
108*433d6423SLionel Sambuc   /* The link count on new2 should be one since the old new is removed. */
109*433d6423SLionel Sambuc   Stat("new2", &st1);
110*433d6423SLionel Sambuc   if (st1.st_nlink != 1) e(25);
111*433d6423SLionel Sambuc 
112*433d6423SLionel Sambuc   /* Check if status for "." is updated. */
113*433d6423SLionel Sambuc   System("> OLD");
114*433d6423SLionel Sambuc   Stat(".", &st1);
115*433d6423SLionel Sambuc   time(&time1);
116*433d6423SLionel Sambuc   while (time1 == time((time_t *)0))
117*433d6423SLionel Sambuc 	;
118*433d6423SLionel Sambuc   time(&time2);
119*433d6423SLionel Sambuc   rename("OLD", "NEW");
120*433d6423SLionel Sambuc   Stat(".", &st2);
121*433d6423SLionel Sambuc   time(&time3);
122*433d6423SLionel Sambuc   while (time3 == time((time_t *)0))
123*433d6423SLionel Sambuc 	;
124*433d6423SLionel Sambuc   time(&time3);
125*433d6423SLionel Sambuc   if (st1.st_ctime >= st2.st_ctime) e(26);
126*433d6423SLionel Sambuc   if (st1.st_mtime >= st2.st_mtime) e(27);
127*433d6423SLionel Sambuc   if (st1.st_ctime > time1) e(28);
128*433d6423SLionel Sambuc   if (st1.st_mtime > time1) e(29);
129*433d6423SLionel Sambuc   if (st1.st_ctime >= time2) e(30);
130*433d6423SLionel Sambuc   if (st1.st_mtime >= time2) e(31);
131*433d6423SLionel Sambuc   if (st2.st_ctime < time2) e(32);
132*433d6423SLionel Sambuc   if (st2.st_mtime < time2) e(33);
133*433d6423SLionel Sambuc   if (st2.st_ctime >= time3) e(34);
134*433d6423SLionel Sambuc   if (st2.st_mtime >= time3) e(35);
135*433d6423SLionel Sambuc 
136*433d6423SLionel Sambuc   /* If the new file is removed while it's open it should still be
137*433d6423SLionel Sambuc    * readable. */
138*433d6423SLionel Sambuc   System("rm -rf new NEW old OLD");
139*433d6423SLionel Sambuc   if ((fd1 = creat("new", 0644)) != 3) e(36);
140*433d6423SLionel Sambuc   if (write(fd1, "Hi there! I am Sammy the string", 33) != 33) e(37);
141*433d6423SLionel Sambuc   if (close(fd1) != 0) e(38);
142*433d6423SLionel Sambuc   if ((fd1 = creat("old", 0644)) != 3) e(39);
143*433d6423SLionel Sambuc   if (write(fd1, "I need a new name", 18) != 18) e(40);
144*433d6423SLionel Sambuc   if (close(fd1) != 0) e(41);
145*433d6423SLionel Sambuc   if ((fd1 = open("new", O_RDONLY)) != 3) e(42);
146*433d6423SLionel Sambuc   if ((fd2 = open("new", O_RDONLY)) != 4) e(43);
147*433d6423SLionel Sambuc   if (rename("old", "new") != 0) e(44);
148*433d6423SLionel Sambuc   if (stat("old", &st1) == 0) e(45);
149*433d6423SLionel Sambuc   if (close(fd1) != 0) e(46);
150*433d6423SLionel Sambuc   if ((fd1 = open("new", O_RDONLY)) != 3) e(47);
151*433d6423SLionel Sambuc   if (read(fd2, buf, BUF_SIZE) != 33) e(48);
152*433d6423SLionel Sambuc   if (strcmp(buf, "Hi there! I am Sammy the string") != 0) e(49);
153*433d6423SLionel Sambuc   if (read(fd1, buf, BUF_SIZE) != 18) e(50);
154*433d6423SLionel Sambuc   if (strcmp(buf, "I need a new name") != 0) e(51);
155*433d6423SLionel Sambuc   if (close(fd1) != 0) e(52);
156*433d6423SLionel Sambuc   if (close(fd2) != 0) e(53);
157*433d6423SLionel Sambuc }
158*433d6423SLionel Sambuc 
test32b()159*433d6423SLionel Sambuc void test32b()
160*433d6423SLionel Sambuc {
161*433d6423SLionel Sambuc   char MaxPath2[PATH_MAX];	/* Same for path */
162*433d6423SLionel Sambuc   char MaxName2[NAME_MAX + 1];	/* Name of maximum length */
163*433d6423SLionel Sambuc   int fd, i;
164*433d6423SLionel Sambuc   int stat_loc;
165*433d6423SLionel Sambuc   struct stat st;
166*433d6423SLionel Sambuc 
167*433d6423SLionel Sambuc   subtest = 2;
168*433d6423SLionel Sambuc   System("rm -rf ../DIR_32/*");
169*433d6423SLionel Sambuc 
170*433d6423SLionel Sambuc   /* Test maximal file name length. */
171*433d6423SLionel Sambuc   if ((fd = creat(MaxName, 0777)) != 3) e(1);
172*433d6423SLionel Sambuc   if (close(fd) != 0) e(2);
173*433d6423SLionel Sambuc   strcpy(MaxName2, MaxName);
174*433d6423SLionel Sambuc   MaxName2[strlen(MaxName2) - 1] ^= 1;
175*433d6423SLionel Sambuc   if (rename(MaxName, MaxName2) != 0) e(3);
176*433d6423SLionel Sambuc   if (rename(MaxName2, MaxName) != 0) e(4);
177*433d6423SLionel Sambuc   MaxName2[strlen(MaxName2) - 1] ^= 2;
178*433d6423SLionel Sambuc   if (rename(MaxName, MaxName2) != 0) e(5);
179*433d6423SLionel Sambuc   MaxPath[strlen(MaxPath) - 2] = '/';
180*433d6423SLionel Sambuc   MaxPath[strlen(MaxPath) - 1] = 'a';	/* make ././.../a */
181*433d6423SLionel Sambuc   if ((fd = creat(MaxPath, 0777)) != 3) e(6);
182*433d6423SLionel Sambuc   if (close(fd) != 0) e(7);
183*433d6423SLionel Sambuc   strcpy(MaxPath2, MaxPath);
184*433d6423SLionel Sambuc   MaxPath2[strlen(MaxPath2) - 1] ^= 1;
185*433d6423SLionel Sambuc   if (rename(MaxPath, MaxPath2) != 0) e(8);
186*433d6423SLionel Sambuc   if (rename(MaxPath2, MaxPath) != 0) e(9);
187*433d6423SLionel Sambuc   MaxPath2[strlen(MaxPath2) - 1] ^= 2;
188*433d6423SLionel Sambuc   if (rename(MaxPath, MaxPath2) != 0) e(10);
189*433d6423SLionel Sambuc   MaxPath[strlen(MaxPath) - 1] = '/';	/* make ././.../a */
190*433d6423SLionel Sambuc 
191*433d6423SLionel Sambuc   /* Test if linked files are renamable. */
192*433d6423SLionel Sambuc   System("> foo; ln foo bar");
193*433d6423SLionel Sambuc   if (rename("foo", "bar") != 0) e(11);
194*433d6423SLionel Sambuc   if (rename("bar", "foo") != 0) e(12);
195*433d6423SLionel Sambuc   System("ln foo foobar");
196*433d6423SLionel Sambuc   if (rename("foo", "foobar") != 0) e(13);
197*433d6423SLionel Sambuc   if (rename("bar", "foobar") != 0) e(14);
198*433d6423SLionel Sambuc 
199*433d6423SLionel Sambuc   /* Since the same files have the same links.... */
200*433d6423SLionel Sambuc   if (rename("bar", "bar") != 0) e(15);
201*433d6423SLionel Sambuc   if (rename("foo", "foo") != 0) e(16);
202*433d6423SLionel Sambuc   if (rename("foobar", "foobar") != 0) e(17);
203*433d6423SLionel Sambuc 
204*433d6423SLionel Sambuc   /* In ``rename(old, new)'' with new existing, there is always an new
205*433d6423SLionel Sambuc    * entry. */
206*433d6423SLionel Sambuc   for (i = 0; i < 5; i++) {
207*433d6423SLionel Sambuc 	System("echo old > old");
208*433d6423SLionel Sambuc 	System("echo news > new");
209*433d6423SLionel Sambuc 	switch (fork()) {
210*433d6423SLionel Sambuc 	    case -1:	printf("Can't fork\n");	break;
211*433d6423SLionel Sambuc 	    case 0:
212*433d6423SLionel Sambuc 		alarm(20);
213*433d6423SLionel Sambuc 		sleep(1);
214*433d6423SLionel Sambuc 		rename("old", "new");
215*433d6423SLionel Sambuc 		exit(0);
216*433d6423SLionel Sambuc 	    default:
217*433d6423SLionel Sambuc 		while (stat("old", &st) == 0)
218*433d6423SLionel Sambuc 			if (stat("new", &st) != 0) e(18);
219*433d6423SLionel Sambuc 		wait(&stat_loc);
220*433d6423SLionel Sambuc 		if (stat_loc != 0) e(19);	/* Alarm? */
221*433d6423SLionel Sambuc 	}
222*433d6423SLionel Sambuc   }
223*433d6423SLionel Sambuc 
224*433d6423SLionel Sambuc }
225*433d6423SLionel Sambuc 
test32c()226*433d6423SLionel Sambuc void test32c()
227*433d6423SLionel Sambuc {				/* Test behavior under error contitions. */
228*433d6423SLionel Sambuc   struct stat st1;
229*433d6423SLionel Sambuc   int stat_loc;
230*433d6423SLionel Sambuc 
231*433d6423SLionel Sambuc   subtest = 3;
232*433d6423SLionel Sambuc   System("rm -rf ../DIR_32/*");
233*433d6423SLionel Sambuc 
234*433d6423SLionel Sambuc   /* Test if we have access. */
235*433d6423SLionel Sambuc   system("chmod 777 noacc nowrite > /dev/null 2>/dev/null");
236*433d6423SLionel Sambuc   system("rm -rf noacc nowrite");
237*433d6423SLionel Sambuc 
238*433d6423SLionel Sambuc   System("mkdir noacc nowrite");
239*433d6423SLionel Sambuc   System("> noacc/file");
240*433d6423SLionel Sambuc   System("> nowrite/file");
241*433d6423SLionel Sambuc   System("> file");
242*433d6423SLionel Sambuc   System("chmod 677 noacc");
243*433d6423SLionel Sambuc   System("chmod 577 nowrite");
244*433d6423SLionel Sambuc   if (!superuser) {
245*433d6423SLionel Sambuc 	if (rename("noacc/file", "nono") != -1) e(1);
246*433d6423SLionel Sambuc 	if (errno != EACCES) e(2);
247*433d6423SLionel Sambuc 	if (rename("nowrite/file", "nono") != -1) e(3);
248*433d6423SLionel Sambuc 	if (errno != EACCES) e(4);
249*433d6423SLionel Sambuc 	if (rename("file", "noacc/file") != -1) e(5);
250*433d6423SLionel Sambuc 	if (errno != EACCES) e(6);
251*433d6423SLionel Sambuc 	if (rename("file", "nowrite/file") != -1) e(7);
252*433d6423SLionel Sambuc 	if (errno != EACCES) e(8);
253*433d6423SLionel Sambuc   }
254*433d6423SLionel Sambuc   if (superuser) {
255*433d6423SLionel Sambuc 	/* Super user heeft access. */
256*433d6423SLionel Sambuc 	if (rename("noacc/file", "noacc/yes") != 0) e(9);
257*433d6423SLionel Sambuc 	if (rename("nowrite/file", "nowrite/yes") != 0) e(10);
258*433d6423SLionel Sambuc 	if (rename("file", "yes") != 0) e(11);
259*433d6423SLionel Sambuc 	if (rename("noacc/yes", "noacc/file") != 0) e(12);
260*433d6423SLionel Sambuc 	if (rename("nowrite/yes", "nowrite/file") != 0) e(13);
261*433d6423SLionel Sambuc 	if (rename("yes", "file") != 0) e(14);
262*433d6423SLionel Sambuc   }
263*433d6423SLionel Sambuc   System("chmod 777 noacc nowrite");
264*433d6423SLionel Sambuc 
265*433d6423SLionel Sambuc   /* If rmdir() doesn't remove a directory, rename() shouldn't eighter. */
266*433d6423SLionel Sambuc   System("mkdir newdir olddir");
267*433d6423SLionel Sambuc   System("rm -rf /tmp/sema.11[ab]");
268*433d6423SLionel Sambuc   switch (fork()) {
269*433d6423SLionel Sambuc       case -1:	printf("Can't fork\n");	break;
270*433d6423SLionel Sambuc       case 0:
271*433d6423SLionel Sambuc 	alarm(20);
272*433d6423SLionel Sambuc 	switch (fork()) {
273*433d6423SLionel Sambuc 	    case -1:	printf("Can't fork\n");	break;
274*433d6423SLionel Sambuc 	    case 0:
275*433d6423SLionel Sambuc 		/* Child A. */
276*433d6423SLionel Sambuc 		alarm(20);
277*433d6423SLionel Sambuc 		if (chdir("newdir") != 0) e(15);
278*433d6423SLionel Sambuc 		Creat("/tmp/sema.11a");
279*433d6423SLionel Sambuc 		while (stat("/tmp/sema.11a", &st1) == 0) sleep(1);
280*433d6423SLionel Sambuc 		exit(0);
281*433d6423SLionel Sambuc 	    default:
282*433d6423SLionel Sambuc 		wait(&stat_loc);
283*433d6423SLionel Sambuc 		if (stat_loc != 0) e(16);	/* Alarm? */
284*433d6423SLionel Sambuc 	}
285*433d6423SLionel Sambuc 
286*433d6423SLionel Sambuc 	/* Child B. */
287*433d6423SLionel Sambuc 	if (chdir("olddir") != 0) e(17);
288*433d6423SLionel Sambuc 	Creat("/tmp/sema.11b");
289*433d6423SLionel Sambuc 	while (stat("/tmp/sema.11b", &st1) == 0) sleep(1);
290*433d6423SLionel Sambuc 	exit(0);
291*433d6423SLionel Sambuc       default:
292*433d6423SLionel Sambuc 	/* Wait for child A. It will keep ``newdir'' bussy. */
293*433d6423SLionel Sambuc 	while (stat("/tmp/sema.11a", &st1) == -1) sleep(1);
294*433d6423SLionel Sambuc 	if (rmdir("newdir") == -1) {
295*433d6423SLionel Sambuc 		if (rename("olddir", "newdir") != -1) e(18);
296*433d6423SLionel Sambuc 		if (errno != EBUSY) e(19);
297*433d6423SLionel Sambuc 	}
298*433d6423SLionel Sambuc 	(void) unlink("/tmp/sema.11a");
299*433d6423SLionel Sambuc 
300*433d6423SLionel Sambuc 	/* Wait for child B. It will keep ``olddir'' bussy. */
301*433d6423SLionel Sambuc 	while (stat("/tmp/sema.11b", &st1) == -1) sleep(1);
302*433d6423SLionel Sambuc 	if (rmdir("olddir") == -1) {
303*433d6423SLionel Sambuc 		if (rename("olddir", "newdir") != -1) e(20);
304*433d6423SLionel Sambuc 		if (errno != EBUSY) e(21);
305*433d6423SLionel Sambuc 	}
306*433d6423SLionel Sambuc 	(void) unlink("/tmp/sema.11b");
307*433d6423SLionel Sambuc 	wait(&stat_loc);
308*433d6423SLionel Sambuc 	if (stat_loc != 0) e(22);	/* Alarm? */
309*433d6423SLionel Sambuc   }
310*433d6423SLionel Sambuc }
311*433d6423SLionel Sambuc 
makelongnames()312*433d6423SLionel Sambuc void makelongnames()
313*433d6423SLionel Sambuc {
314*433d6423SLionel Sambuc   register int i;
315*433d6423SLionel Sambuc   int max_name_length;
316*433d6423SLionel Sambuc 
317*433d6423SLionel Sambuc   max_name_length = name_max("."); /* Aka NAME_MAX, but not every FS supports
318*433d6423SLionel Sambuc 				    * the same length, hence runtime check */
319*433d6423SLionel Sambuc   MaxName = malloc(max_name_length + 1);
320*433d6423SLionel Sambuc   ToLongName = malloc(max_name_length + 1 + 1); /* Name of maximum +1 length */
321*433d6423SLionel Sambuc   memset(MaxName, 'a', max_name_length);
322*433d6423SLionel Sambuc   MaxName[max_name_length] = '\0';
323*433d6423SLionel Sambuc 
324*433d6423SLionel Sambuc   for (i = 0; i < PATH_MAX - 1; i++) {	/* idem path */
325*433d6423SLionel Sambuc 	MaxPath[i++] = '.';
326*433d6423SLionel Sambuc 	MaxPath[i] = '/';
327*433d6423SLionel Sambuc   }
328*433d6423SLionel Sambuc   MaxPath[PATH_MAX - 1] = '\0';
329*433d6423SLionel Sambuc 
330*433d6423SLionel Sambuc   strcpy(ToLongName, MaxName);	/* copy them Max to ToLong */
331*433d6423SLionel Sambuc   strcpy(ToLongPath, MaxPath);
332*433d6423SLionel Sambuc 
333*433d6423SLionel Sambuc   ToLongName[max_name_length] = 'a';
334*433d6423SLionel Sambuc   ToLongName[max_name_length+1] = '\0';/* extend ToLongName by one too many */
335*433d6423SLionel Sambuc   ToLongPath[PATH_MAX - 1] = '/';
336*433d6423SLionel Sambuc   ToLongPath[PATH_MAX] = '\0';	/* inc ToLongPath by one */
337*433d6423SLionel Sambuc }
338