2 * FreeBSD install - a package for the installation and maintainance
3 * of non-core utilities.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
17 * Miscellaneous file access utilities.
21 #include <sys/cdefs.h>
22 __FBSDID("$FreeBSD$");
29 * Assuming dir is a desired directory name, make it and all intervening
30 * directories necessary.
34 make_hierarchy(char *dir
)
43 if ((cp2
= strchr(cp1
, '/')) !=NULL
)
53 if (vsystem("/bin/mkdir %s", dir
)) {
58 apply_perms(NULL
, dir
);
69 /* Using permission defaults, apply them as necessary */
71 apply_perms(const char *dir
, const char *arg
)
75 if (!dir
|| *arg
== '/') /* absolute path? */
81 if (vsystem("cd %s && /bin/chmod -R %s %s", cd_to
, Mode
, arg
))
82 warnx("couldn't change modes of '%s' to '%s'", arg
, Mode
);
84 if (vsystem("cd %s && /usr/sbin/chown -R %s:%s %s", cd_to
, Owner
, Group
, arg
))
85 warnx("couldn't change owner/group of '%s' to '%s:%s'",
90 if (vsystem("cd %s && /usr/sbin/chown -R %s %s", cd_to
, Owner
, arg
))
91 warnx("couldn't change owner of '%s' to '%s'", arg
, Owner
);
94 if (vsystem("cd %s && /usr/bin/chgrp -R %s %s", cd_to
, Group
, arg
))
95 warnx("couldn't change group of '%s' to '%s'", arg
, Group
);