xref: /csrg-svn/usr.bin/uucp/port/mkdir.c (revision 62391)
148654Sbostic /*-
2*62391Sbostic  * Copyright (c) 1985, 1993
3*62391Sbostic  *	The Regents of the University of California.  All rights reserved.
448654Sbostic  *
548654Sbostic  * %sccs.include.proprietary.c%
648654Sbostic  */
748654Sbostic 
818478Sralph #ifndef lint
9*62391Sbostic static char sccsid[] = "@(#)mkdir.c	8.1 (Berkeley) 06/06/93";
1048654Sbostic #endif /* not lint */
1118478Sralph 
1218478Sralph #ifndef BSD4_2
1318478Sralph #include <stdio.h>
1423613Sbloom 
1518478Sralph /*
1618478Sralph  * make a directory. Also make sure that the directory is owned
1718478Sralph  * by the right userid
1818478Sralph  */
mkdir(path,mode)1918478Sralph mkdir(path, mode)
2018478Sralph char *path;
2118478Sralph int mode;
2218478Sralph {
2318478Sralph 	int pid, status, w;
2418478Sralph 
2518478Sralph 	if (pid=fork()) {
2618478Sralph 		while ((w = wait(&status)) != pid && w != -1)
2718478Sralph 			;
2818478Sralph 		(void) chmod(path, mode);
2918478Sralph 	} else {
3023613Sbloom 		(void) umask(~mode);
3118478Sralph 		(void) execlp("mkdir", "mkdir", path, (char *)NULL);
3218478Sralph 		perror(path);
3318478Sralph 		_exit(1);
3418478Sralph 	}
3523613Sbloom 	return status;
3618478Sralph }
3718478Sralph #endif !BSD4_2
38