aboutsummaryrefslogtreecommitdiff
path: root/sbin/sysinstall/utils.c
diff options
context:
space:
mode:
authorPoul-Henning Kamp <phk@FreeBSD.org>1994-10-21 02:14:54 +0000
committerPoul-Henning Kamp <phk@FreeBSD.org>1994-10-21 02:14:54 +0000
commit4752baca4ae288e3268dd8c1d87fad5de4b61ba9 (patch)
tree5bb0542cb766d0160e8e83871c5350b3da2c1e56 /sbin/sysinstall/utils.c
parent091b0456f4cd9432edb77e80420f9565ad504b32 (diff)
Notes
Diffstat (limited to 'sbin/sysinstall/utils.c')
-rw-r--r--sbin/sysinstall/utils.c66
1 files changed, 14 insertions, 52 deletions
diff --git a/sbin/sysinstall/utils.c b/sbin/sysinstall/utils.c
index 59f467a60744..662ef4cc66a0 100644
--- a/sbin/sysinstall/utils.c
+++ b/sbin/sysinstall/utils.c
@@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
- * $Id: utils.c,v 1.3 1994/10/20 06:48:40 phk Exp $
+ * $Id: utils.c,v 1.4 1994/10/20 19:30:56 ache Exp $
*
*/
@@ -43,11 +43,13 @@ void
Fatal(char *fmt, ...)
{
char *p;
+ int i = errno;
va_list ap;
p = Malloc(2048);
va_start(ap,fmt);
vsnprintf(p, 2048, fmt, ap);
va_end(ap);
+ sprintf(p+strlen(p),"\nErrno= %d, %s.",i,strerror(i));
dialog_msgbox("Fatal", p, 12, 75, 1);
free(p);
end_dialog();
@@ -90,52 +92,6 @@ StrAlloc(char *str)
return p;
}
-int
-exec(char *cmd, char *args, ...)
-{
- int pid, w, status;
- char **argv = NULL;
- int arg = 0;
- int no_args = 0;
- va_list ap;
- struct stat dummy;
-
- if (stat(cmd, &dummy) == -1) {
- sprintf(errmsg, "Executable %s does not exist\n", cmd);
- return(-1);
- }
-
- va_start(ap, args);
- do {
- if (arg == no_args) {
- no_args += 10;
- if (!(argv = realloc(argv, no_args * sizeof(char *)))) {
- sprintf(errmsg, "Failed to allocate memory during exec of %s\n", cmd);
- return(-1);
- }
- if (arg == 0)
- argv[arg++] = (char *)args;
- }
- } while ((argv[arg++] = va_arg(ap, char *)));
- va_end(ap);
-
- if ((pid = fork()) == 0) {
- execv(cmd, argv);
- exit(1);
- }
-
- while ((w = wait(&status)) != pid && w != -1)
- ;
-
- free(argv);
- if (w == -1) {
- sprintf(errmsg, "Child process %s terminated abnormally\n", cmd);
- return(-1);
- }
-
- return(0);
-}
-
void
MountUfs(char *device, char *prefix, char *mountpoint, int do_mkdir)
{
@@ -153,11 +109,7 @@ MountUfs(char *device, char *prefix, char *mountpoint, int do_mkdir)
strcat(pbuf,mountpoint);
if(do_mkdir && access(pbuf,R_OK)) {
- TellEm("mkdir %s",pbuf);
- if (mkdir(pbuf,S_IRWXU) == -1) {
- Fatal("Couldn't create directory %s: %s\n",
- pbuf,strerror(errno));
- }
+ Mkdir(pbuf);
}
strcpy(dbuf,"/dev/");
@@ -170,3 +122,13 @@ MountUfs(char *device, char *prefix, char *mountpoint, int do_mkdir)
dbuf, pbuf, strerror(errno));
}
}
+
+void
+Mkdir(char *path)
+{
+ TellEm("mkdir %s",path);
+ if (mkdir(path, S_IRWXU) == -1) {
+ Fatal("Couldn't create directory %s: %s\n",
+ path,strerror(errno));
+ }
+}