10 const char * generate_pathname(void)
12 const char *pathname
= get_filename();
17 if (pathname
== NULL
) /* handle -n correctly. */
20 /* 90% chance of returning an unmangled filename */
21 if ((rand() % 100) < 90)
24 /* Create a bogus filename. */
25 newpath
= malloc(page_size
); // FIXME: We leak this.
27 return pathname
; // give up.
29 len
= strlen(pathname
);
32 if ((rand() % 100) == 0) {
33 memset(newpath
, 0, page_size
);
37 generate_random_page(newpath
);
39 /* sometimes, just complete junk. */
43 /* Sometimes, pathname + junk */
45 (void) strncpy(newpath
, pathname
, len
);
47 /* make it look relative to cwd */
50 (void) strncpy(newpath
+ 2, pathname
, len
);
53 /* Sometimes, remove all /'s */
55 for (i
= 0; i
< len
; i
++) {
56 if (newpath
[i
] == '/')
61 /* 50/50 chance of making it look like a dir */