xref: /csrg-svn/usr.bin/uucp/port/mkdir.c (revision 48654)
1*48654Sbostic /*-
2*48654Sbostic  * Copyright (c) 1985 The Regents of the University of California.
3*48654Sbostic  * All rights reserved.
4*48654Sbostic  *
5*48654Sbostic  * %sccs.include.proprietary.c%
6*48654Sbostic  */
7*48654Sbostic 
818478Sralph #ifndef lint
9*48654Sbostic static char sccsid[] = "@(#)mkdir.c	5.3 (Berkeley) 04/24/91";
10*48654Sbostic #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  */
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