From owner-cvs-all Sun Sep 8 7:21:32 2002 Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7BBFB37B400; Sun, 8 Sep 2002 07:21:19 -0700 (PDT) Received: from smtp0.adl1.internode.on.net (smtp0.adl1.internode.on.net [203.16.214.194]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5D43C43E65; Sun, 8 Sep 2002 07:21:18 -0700 (PDT) (envelope-from doconnor@gsoft.com.au) Received: from midget.dons.net.au (ppp286.sa.padsl.internode.on.net [150.101.244.29]) by smtp0.adl1.internode.on.net (8.12.4/8.12.4) with ESMTP id g88ELBml077423; Sun, 8 Sep 2002 23:51:11 +0930 (CST) Received: from localhost (root@localhost [127.0.0.1]) by midget.dons.net.au (8.12.2/8.12.2) with ESMTP id g88EHbq1004095; Sun, 8 Sep 2002 23:47:38 +0930 (CST) (envelope-from doconnor@gsoft.com.au) Subject: Re: cvs commit: src/sbin/mount_nfs mount_nfs.c From: "Daniel O'Connor" To: Peter Wemm Cc: cvs-committers@FreeBSD.ORG, cvs-all@FreeBSD.ORG In-Reply-To: <200209061959.g86JxTS9019217@freefall.freebsd.org> References: <200209061959.g86JxTS9019217@freefall.freebsd.org> Content-Type: multipart/mixed; boundary="=-twYZ1F1WDLc8G0iotaBM" X-Mailer: Ximian Evolution 1.0.8 Date: 08 Sep 2002 23:51:08 +0930 Message-Id: <1031494869.1246.33.camel@chowder.dons.net.au> Mime-Version: 1.0 X-Spam-Score: -2.8 () IN_REP_TO,PORN_10 X-Scanned-By: MIMEDefang 2.16 (www . roaringpenguin . com / mimedefang) Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --=-twYZ1F1WDLc8G0iotaBM Content-Type: text/plain Content-Transfer-Encoding: 7bit On Sat, 2002-09-07 at 05:29, Peter Wemm wrote: > Bandaid for mount_nfs segfaulting with the more obscure mount options > in /etc/fstab. This isn't a real fix though and I'm still not sure > why it started failing. mount(8) breaks up the nfs args into seperate > repeated '-o option=value' arguments. But, the altflags variable that > we use to track things is incrementally built up each time we see the > next option and shows us the cumulative set of flags, not just the > flag that we are currently looking at. As a result, the strstr hack > for looking up flags in a giant -o opt=val,opt=val, etc string was failing > and causing a segfault. I do not know what changed recently that caused > this to suddenly break, but the code has been rather bogus for some time. Hah, well I'm glad it wasn't just me... Any chance of MFC'ing this change? You left a debugging statement in too (See first part of the diff), and made some gratuitous tab/space changes. I've attached a diff for stable. Interestingly this still crashes -> /sbin/mount -onodev,soft,intr,acregmin=0,acregmax=0,acdirmin=0,acdirmax=0 127.0.0.1:foo /usr/home/darius/abc But this doesn't -> /sbin/mount_nfs -onodev,soft,intr,acregmin=0,acregmax=0,acdirmin=0,acdirmax=0 127.0.0.1:foo /usr/home/darius/abc In the former case mount_nfs crashes.. I can't see how that is possible though :( -- Daniel O'Connor software and network engineer for Genesis Software - http://www.gsoft.com.au "The nice thing about standards is that there are so many of them to choose from." -- Andrew Tanenbaum GPG Fingerprint - 9A8C 569F 685A D928 5140 AE4B 319B 41F4 5D17 FDD5 --=-twYZ1F1WDLc8G0iotaBM Content-Disposition: attachment; filename=mount_nfs-fix Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; name=mount_nfs-fix; charset=ISO-8859-1 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/ncvs/src/sbin/mount_nfs/mount_nfs.c,v retrieving revision 1.55 retrieving revision 1.56 diff -u -p -r1.55 -r1.56 --- src/sbin/mount_nfs/mount_nfs.c 2002/08/26 13:08:23 1.55 +++ src/sbin/mount_nfs/mount_nfs.c 2002/09/06 19:59:29 1.56 @@ -45,7 +45,7 @@ static const char copyright[] =3D static char sccsid[] =3D "@(#)mount_nfs.c 8.11 (Berkeley) 5/4/95"; #endif static const char rcsid[] =3D - "$FreeBSD: /home/ncvs/src/sbin/mount_nfs/mount_nfs.c,v 1.55 2002/08/26 1= 3:08:23 iedowse Exp $"; + "$FreeBSD: /home/ncvs/src/sbin/mount_nfs/mount_nfs.c,v 1.56 2002/09/06 1= 9:59:29 peter Exp $"; #endif /* not lint */ =20 #include @@ -326,46 +326,58 @@ main(argc, argv) altflags |=3D ALTF_NFSV3; getmntopts(optarg, mopts, &mntflags, &altflags); set_flags(&altflags, &nfsargsp->flags, FALSE); +printf("altflags=3D %x, optarg =3D %s\n", altflags, optarg); /* * Handle altflags which don't map directly to * mount flags. */ - if(altflags & ALTF_BG) + if (altflags & ALTF_BG) opflags |=3D BGRND; - if(altflags & ALTF_MNTUDP) + if (altflags & ALTF_MNTUDP) mnttcp_ok =3D 0; - if(altflags & ALTF_TCP) { + if (altflags & ALTF_TCP) { nfsargsp->sotype =3D SOCK_STREAM; nfsproto =3D IPPROTO_TCP; } - if(altflags & ALTF_PORT) { + if (altflags & ALTF_PORT) { /* * XXX Converting from a string to an int * and back again is silly, and we should * allow /etc/services names. */ - asprintf(&portspec, "%d", - atoi(strstr(optarg, "port=3D") + 5)); - if (portspec =3D=3D NULL) - err(1, "asprintf"); + p =3D strstr(optarg, "port=3D"); + if (p) { + asprintf(&portspec, "%d", + atoi(p + 5)); + if (portspec =3D=3D NULL) + err(1, "asprintf"); + } } mountmode =3D ANY; - if(altflags & ALTF_NFSV2) + if (altflags & ALTF_NFSV2) mountmode =3D V2; - if(altflags & ALTF_NFSV3) + if (altflags & ALTF_NFSV3) mountmode =3D V3; - if(altflags & ALTF_ACREGMIN) - nfsargsp->acregmin =3D atoi(strstr(optarg, - "acregmin=3D") + 9); - if(altflags & ALTF_ACREGMAX) - nfsargsp->acregmax =3D atoi(strstr(optarg, - "acregmax=3D") + 9); - if(altflags & ALTF_ACDIRMIN) - nfsargsp->acdirmin =3D atoi(strstr(optarg, - "acdirmin=3D") + 9); - if(altflags & ALTF_ACDIRMAX) - nfsargsp->acdirmax =3D atoi(strstr(optarg, - "acdirmax=3D") + 9); + if (altflags & ALTF_ACREGMIN) { + p =3D strstr(optarg, "acregmin=3D"); + if (p) + nfsargsp->acregmin =3D atoi(p + 9); + } + if (altflags & ALTF_ACREGMAX) { + p =3D strstr(optarg, "acregmax=3D"); + if (p) + nfsargsp->acregmax =3D atoi(p + 9); + } + if (altflags & ALTF_ACDIRMIN) { + p =3D strstr(optarg, "acdirmin=3D"); + if (p) + nfsargsp->acdirmin =3D atoi(p + 9); + } + if (altflags & ALTF_ACDIRMAX) { + p =3D strstr(optarg, "acdirmax=3D"); + if (p) + nfsargsp->acdirmax =3D atoi(p + 9); + } break; case 'P': /* obsolete for NFSMNT_RESVPORT, now default */ --=-twYZ1F1WDLc8G0iotaBM-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message