From owner-freebsd-arch@FreeBSD.ORG Wed Dec 22 19:42:46 2004 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F138816A4CE for ; Wed, 22 Dec 2004 19:42:46 +0000 (GMT) Received: from obsecurity.dyndns.org (CPE0050040655c8-CM00111ae02aac.cpe.net.cable.rogers.com [69.194.102.143]) by mx1.FreeBSD.org (Postfix) with ESMTP id C18CF43D1F for ; Wed, 22 Dec 2004 19:42:46 +0000 (GMT) (envelope-from kris@obsecurity.org) Received: by obsecurity.dyndns.org (Postfix, from userid 1000) id 2D80C512BF; Wed, 22 Dec 2004 11:42:46 -0800 (PST) Date: Wed, 22 Dec 2004 11:42:46 -0800 From: Kris Kennaway To: Jilles Tjoelker Message-ID: <20041222194246.GC49344@xor.obsecurity.org> References: <84301.1103663813@critter.freebsd.dk> <41C89672.3000808@freebsd.org> <20041221232354.GA28374@xor.obsecurity.org> <20041222135734.GA57242@stack.nl> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="5QAgd0e35j3NYeGe" Content-Disposition: inline In-Reply-To: <20041222135734.GA57242@stack.nl> User-Agent: Mutt/1.4.2.1i cc: arch@freebsd.org cc: Kris Kennaway Subject: Re: Forcefully unmounting devfs... X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Dec 2004 19:42:47 -0000 --5QAgd0e35j3NYeGe Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Dec 22, 2004 at 02:57:34PM +0100, Jilles Tjoelker wrote: > On Tue, Dec 21, 2004 at 03:23:54PM -0800, Kris Kennaway wrote: > > Unfortunately that's going to cause me a fair amount of pain, unless > > there's a simple way to kill all processes running in a given chroot >=20 > Not that hard, although it is a bit tricky because command names may > contain spaces, so something obvious like this does not work in the > general case: >=20 > fstat /chroot |awk '$4 =3D=3D "root" { print $3 }' >=20 > But the following seems more reliable, assuming the mount points do not > contain spaces: >=20 > #!/bin/sh >=20 > # USER CMD PID FD MOUNT INUM MODE SZ|DV R/W N= AME > # jilles zsh 57711 root / 2 drwxr-xr-x 1024 r / >=20 > D=3D"$1" > fstat "$D" | sed -Ene 's#^.* +([[:digit:]]+) +root +/[^ ]* +[[:digit:]]+ = +.......... +[[:digit:]]+ +(r|rw|w) +'"$D"'$#\1#p' >=20 > This would need some |xargs kill or similar. Thanks, I hadn't thought of using fstat. I'll give this a try! Kris --5QAgd0e35j3NYeGe Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.6 (FreeBSD) iD8DBQFByc41Wry0BWjoQKURAlPRAKDB6aIu/OeB5oOamwOzEkrfH3PCNQCg1zNu MqNbhiwJ6AJw9phmxTMOz3k= =kc2j -----END PGP SIGNATURE----- --5QAgd0e35j3NYeGe--