From owner-freebsd-geom@FreeBSD.ORG Sun May 21 13:22:51 2006 Return-Path: X-Original-To: freebsd-geom@freebsd.org Delivered-To: freebsd-geom@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8480916A421 for ; Sun, 21 May 2006 13:22:51 +0000 (UTC) (envelope-from viktor.vasilev@stud.tu-darmstadt.de) Received: from lnx130.hrz.tu-darmstadt.de (lnx130.hrz.tu-darmstadt.de [130.83.174.24]) by mx1.FreeBSD.org (Postfix) with ESMTP id E168943D45 for ; Sun, 21 May 2006 13:22:50 +0000 (GMT) (envelope-from viktor.vasilev@stud.tu-darmstadt.de) Received: from mailserver3.hrz.tu-darmstadt.de (lnx115.hrz.tu-darmstadt.de [130.83.174.27]) by lnx130.hrz.tu-darmstadt.de (8.13.4/8.12.10) with ESMTP id k4LDMnG0016795 for ; Sun, 21 May 2006 15:22:49 +0200 Received: from [130.83.20.203] (helo=ABC216.ram1st.wh.tu-darmstadt.de) by mailserver3.hrz.tu-darmstadt.de with esmtpsa (TLS-1.0:DHE_RSA_AES_256_CBC_SHA:32) (Exim 4.50) id 1FhntR-0004Kj-AL for freebsd-geom@freebsd.org; Sun, 21 May 2006 15:22:49 +0200 From: Viktor Vasilev To: freebsd-geom@freebsd.org Date: Sun, 21 May 2006 15:22:48 +0200 User-Agent: KMail/1.9.1 References: <200605202315.11558.viktor.vasilev@stud.tu-darmstadt.de> In-Reply-To: <200605202315.11558.viktor.vasilev@stud.tu-darmstadt.de> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200605211522.48757.viktor.vasilev@stud.tu-darmstadt.de> Subject: Re: modifying the MBR through geom_mbr X-BeenThere: freebsd-geom@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: GEOM-specific discussions and implementations List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 May 2006 13:22:51 -0000 On Saturday 20 May 2006 23:15 Viktor Vasilev wrote: > I've been looking at the fdisk code while porting gnu parted to freebsd > and I'm confused, and don't know what the right way to update the MBR is. > Currently the code uses the same gctl's as fdisk.c:write_disk() and > gctl_issue returns "Geom not found". I've dug a little and it seems that > this message is produced by sys/geom/geom_ctl.c:gctl_get_geom(), because > the geom name wasn't found in the list. So it seems it'll never succeed > at modifying the MBR of ad6 like this: > > grq = gctl_get_handle(); > gctl_ro_param(grq, "verb", -1, "write MBR"); > gctl_ro_param(grq, "class", -1, "MBR"); > gctl_ro_param(grq, "geom", -1, "ad6"); > gctl_ro_param(grq, "data", ssize, mbr_buf); > ... fdisk has the same behaviour - it can't commit the MBR to the disk using gctl's and gets the same "Geom not found" error. It appears that as soon as /dev/ad6 is opened for writing, the slice entries in /dev disappear. Before opening /dev/ad6 for writing: 0 DISK ad6 251000193024 512 hd 16 sc 63 1 MBR ad6s3 9993715200 512 i 2 o 20003880960 ty 131 1 MBR ad6s2 10001940480 512 i 1 o 10001940480 ty 131 1 MBR ad6s1 10001908224 512 i 0 o 32256 ty 131 After opening /dev/ad6 for writing: 0 DISK ad6 251000193024 512 hd 16 sc 63 A workaround: If I close or open /dev/ad6 read-only, then the above gctl sequence succeeds. Can anyone clarify this behaviour? Cheers, Vik -- PGP Key: 0xE09DC8D8/6799 4011 EBDE 6412 05A1 090C DBDF 5887 E09D C8D8 Signed/encrypted mail welcome!