From owner-freebsd-commit Tue Mar 5 21:33:08 1996 Return-Path: owner-commit Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id VAA10212 for freebsd-commit-outgoing; Tue, 5 Mar 1996 21:33:08 -0800 (PST) Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id VAA10185 for cvs-all-outgoing; Tue, 5 Mar 1996 21:33:00 -0800 (PST) Received: from silvia.HIP.Berkeley.EDU (silvia.HIP.Berkeley.EDU [136.152.64.181]) by freefall.freebsd.org (8.7.3/8.7.3) with ESMTP id VAA10179 Tue, 5 Mar 1996 21:32:55 -0800 (PST) Received: (from asami@localhost) by silvia.HIP.Berkeley.EDU (8.7.4/8.6.9) id VAA13683; Tue, 5 Mar 1996 21:32:41 -0800 (PST) Date: Tue, 5 Mar 1996 21:32:41 -0800 (PST) Message-Id: <199603060532.VAA13683@silvia.HIP.Berkeley.EDU> To: CVS-committers@freefall.freebsd.org, cvs-all@freefall.freebsd.org, cvs-sbin@freefall.freebsd.org In-reply-to: <199603060411.UAA13389@silvia.HIP.Berkeley.EDU> (asami@cs.berkeley.edu) Subject: Re: cvs commit: src/sbin/mount mount.c From: asami@cs.berkeley.edu (Satoshi Asami) Sender: owner-commit@FreeBSD.ORG Precedence: bulk * But anyway, people don't try this at home...the patch is totally * bogus, sizeof(array of "char *"s) will not return the total number of * characters used by the strings. ;) * * I'll send out another one after dinner.... Ok, this one should be ok. I also converted a "do-while" to a "for", I don't know why it had to be three lines instead of one.... === Index: mount.c =================================================================== RCS file: /usr/cvs/src/sbin/mount/mount.c,v retrieving revision 1.9 diff -c -r1.9 mount.c *** mount.c 1996/03/03 08:44:22 1.9 --- mount.c 1996/03/06 05:29:50 *************** *** 327,339 **** exit(mount_ufs(argc, (char * const *) argv)); /* Go find an executable. */ ! edir = edirs; ! do { (void)snprintf(execname, sizeof(execname), "%s/mount_%s", *edir, vfstype); execv(execname, (char * const *)argv); ! warn("exec %s for %s", execname, name); ! } while (*++edir != NULL); exit(1); /* NOTREACHED */ default: /* Parent. */ --- 327,354 ---- exit(mount_ufs(argc, (char * const *) argv)); /* Go find an executable. */ ! for (edir = edirs; *edir; edir++) { (void)snprintf(execname, sizeof(execname), "%s/mount_%s", *edir, vfstype); execv(execname, (char * const *)argv); ! } ! if (errno == ENOENT) { ! int len = 0; ! char *tmp; ! for (edir = edirs; *edir; edir++) ! len += strlen(*edir) + 2; /* ", " */ ! if ((tmp = malloc(len)) == NULL) { ! warn(NULL); ! exit(1); ! } ! tmp[0] = '\0'; ! for (edir = edirs; *edir; edir++) { ! strcat(tmp, *edir); ! if (edir[1] != NULL) ! strcat(tmp, ", "); ! } ! warn("exec mount_%s not found in %s", vfstype, tmp); ! } exit(1); /* NOTREACHED */ default: /* Parent. */ === I know it's more complicated than necessary (I can probably get away with "char tmp[100]" or some such), but I don't want it to break when someone decides to add 30 directories to the list.... :) Satoshi