Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 21 May 2006 15:22:48 +0200
From:      Viktor Vasilev <viktor.vasilev@stud.tu-darmstadt.de>
To:        freebsd-geom@freebsd.org
Subject:   Re: modifying the MBR through geom_mbr
Message-ID:  <200605211522.48757.viktor.vasilev@stud.tu-darmstadt.de>
In-Reply-To: <200605202315.11558.viktor.vasilev@stud.tu-darmstadt.de>
References:  <200605202315.11558.viktor.vasilev@stud.tu-darmstadt.de>

next in thread | previous in thread | raw e-mail | index | archive | help
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!



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200605211522.48757.viktor.vasilev>