From owner-svn-src-all@FreeBSD.ORG Mon Jan 12 08:22:37 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 35185106566C; Mon, 12 Jan 2009 08:22:37 +0000 (UTC) (envelope-from obrien@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 086EC8FC29; Mon, 12 Jan 2009 08:22:37 +0000 (UTC) (envelope-from obrien@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n0C8MaeS057864; Mon, 12 Jan 2009 08:22:36 GMT (envelope-from obrien@svn.freebsd.org) Received: (from obrien@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n0C8MaRh057863; Mon, 12 Jan 2009 08:22:36 GMT (envelope-from obrien@svn.freebsd.org) Message-Id: <200901120822.n0C8MaRh057863@svn.freebsd.org> From: "David E. O'Brien" Date: Mon, 12 Jan 2009 08:22:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r187093 - head/sbin/mount X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Jan 2009 08:22:38 -0000 Author: obrien Date: Mon Jan 12 08:22:36 2009 New Revision: 187093 URL: http://svn.freebsd.org/changeset/base/187093 Log: Use a dynamically grown buffer for building the argv for the sub-mounts. Also fix RCSid spamage. Inspired by patch from: Christoph Mallon Modified: head/sbin/mount/mount.c Modified: head/sbin/mount/mount.c ============================================================================== --- head/sbin/mount/mount.c Mon Jan 12 07:45:03 2009 (r187092) +++ head/sbin/mount/mount.c Mon Jan 12 08:22:36 2009 (r187093) @@ -31,16 +31,14 @@ static const char copyright[] = "@(#) Copyright (c) 1980, 1989, 1993, 1994\n\ The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint #if 0 static char sccsid[] = "@(#)mount.c 8.25 (Berkeley) 5/8/95"; #endif -static const char rcsid[] = - "$FreeBSD$"; #endif /* not lint */ +#include +__FBSDID("$FreeBSD$"); + #include #include #include @@ -70,10 +68,8 @@ static const char rcsid[] = int debug, fstab_style, verbose; -#define MAX_ARGS 100 struct cpa { - char *a[MAX_ARGS]; - ssize_t m; + char **a; int c; }; @@ -507,9 +503,14 @@ hasopt(const char *mntopts, const char * static void append_arg(struct cpa *sa, char *arg) { - if (sa->c >= sa->m) - errx(1, "Cannot process more than %zd mount arguments", sa->m); + static int a_sz; + if (sa->c + 1 == a_sz) { + a_sz = a_sz == 0 ? 8 : a_sz * 2; + sa->a = realloc(sa->a, sizeof(sa->a) * a_sz); + if (sa->a == NULL) + errx(1, "realloc failed"); + } sa->a[++sa->c] = arg; } @@ -521,6 +522,7 @@ mountfs(const char *vfstype, const char struct statfs sf; int i, ret; char *optbuf, execname[PATH_MAX], mntpath[PATH_MAX]; + static int mnt_argv_inited; /* resolve the mountpoint with realpath(3) */ (void)checkpath(name, mntpath); @@ -555,7 +557,10 @@ mountfs(const char *vfstype, const char /* Construct the name of the appropriate mount command */ (void)snprintf(execname, sizeof(execname), "mount_%s", vfstype); - mnt_argv.m = MAX_ARGS; + if (!mnt_argv_inited) { + mnt_argv_inited++; + mnt_argv.a = NULL; + } mnt_argv.c = -1; append_arg(&mnt_argv, execname); mangle(optbuf, &mnt_argv);