From owner-cvs-all Fri Feb 2 12:55:44 2001 Delivered-To: cvs-all@freebsd.org Received: from earth.backplane.com (earth-nat-cw.backplane.com [208.161.114.67]) by hub.freebsd.org (Postfix) with ESMTP id 3111D37B401; Fri, 2 Feb 2001 12:55:16 -0800 (PST) Received: (from dillon@localhost) by earth.backplane.com (8.11.1/8.9.3) id f12KtBL98916; Fri, 2 Feb 2001 12:55:11 -0800 (PST) (envelope-from dillon) Date: Fri, 2 Feb 2001 12:55:11 -0800 (PST) From: Matt Dillon Message-Id: <200102022055.f12KtBL98916@earth.backplane.com> To: Dima Dorfman Cc: mi@aldan.algebra.com, deischen@FreeBSD.ORG, cvs-committers@FreeBSD.ORG, cvs-all@FreeBSD.ORG Subject: Re: mdconfig config file (was: cvs commit: src/sys/i386/conf GENERI C) References: <20010202203201.9DC693E02@bazooka.unixfreak.org> Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG : :> :> (this whole thing is predicated on someone writing a mount_md wrapper :> for MD that mimics the options mount_mfs accepts, for compatibility). : :I'll do it. Would it be safe to assume that it's acceptable to write :a C program to parse the arguments, build command lines to :appropriately invoke disklabel, newfs, maybe tunefs, and mount, then :call system(3) to execute them? : : Dima Dorfman : dima@unixfreak.org Yes, though preferably I'd fork/exec the sub-programs (and use absolute paths) rather then use system(), because the mount program will be running during booting and its important to have it use as few system resources as possible in case the system is screwed up. We don't want it exec'ing /bin/sh. I've included a program below outlining what I mean. -Matt /* * test program */ #include #include #include #include #include #include static int simple_run(char **av); int main(int ac, char **av) { char *args[] = { "/bin/ls", "/", NULL }; int r; r = simple_run(args); printf("return code: %d\n", r); return(0); } static int simple_run(char **av) { pid_t pid; int status = 0; if ((pid = fork()) == 0) { execv(av[0], av); _exit(1); } if (pid < 0) { fprintf(stderr, "fork failed: %s\n", strerror(errno)); return(1); } while (waitpid(pid, &status, 0) != pid) ; return(WEXITSTATUS(status)); } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message