8000 minix/minix/tests/test18.c at master · rcitach/minix · GitHub
[go: up one dir, main page]

Skip to content

Latest commit

 

History

History
1123 lines (924 loc) · 27.3 KB

test18.c

File metadata and controls

1123 lines (924 loc) · 27.3 KB
for (mode = 0; mode < 8; mode++) put_file_in_dir("drwx", mode);
put_file_in_dir("d-wx", RWX);
put_file_in_dir("dr-x", RWX);
put_file_in_dir("drw-", RWX);
chmod_8_dirs(8); /* 8 means; 8 different modes */
} /* make_and_fill_dirs */
void put_file_in_dir(dirname, mode)
char *dirname;
int mode;
/* Fill directory 'dirname' with file with mode 'mode'. */
{
int nr;
if (chdir(dirname) != OK) e(97);
else {
/* Creat the file */
if ((nr = creat(fnames[mode], mode * 0100)) < 0) e(98);
else
try_close(nr, fnames[mode]);
if (chdir("..") != OK) e(99);
}
} /* put_file_in_dir */
/*****************************************************************************
* *
* MISCELLANEOUS *
* *
*(all about arrays, 'try_close', 'try_unlink', 'Remove', 'get_mode') *
* *
*****************************************************************************/
void init_array(a)
char *a;
{
int i;
i = 0;
while (i++ < ARSIZE) *a++ = 'a' + (i % 26);
} /* init_array */
void clear_array(b)
char *b;
{
int i;
i = 0;
while (i++ < ARSIZE) *b++ = '0';
} /* clear_array */
int comp_array(a, b, range)
char *a, *b;
int range;
{
assert(range >= 0 && range <= ARSIZE);
while (range-- && (*a++ == *b++));
if (*--a == *--b)
return(OK);
else
return(FAIL);
} /* comp_array */
void try_close(filedes, name)
int filedes;
0