Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/gpl2/lvm2/dist/lib/device Get sector size from devi...



details:   https://anonhg.NetBSD.org/src/rev/f41efd469b5f
branches:  trunk
changeset: 759998:f41efd469b5f
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Thu Dec 23 14:46:25 2010 +0000

description:
Get sector size from device properties using DIOCGDISKINFO and
use the disklabel (DIOCGDINFO) only as a fallback. This works
with wedges.

diffstat:

 external/gpl2/lvm2/dist/lib/device/dev-io.c |  19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)

diffs (44 lines):

diff -r 08e6a94f95ec -r f41efd469b5f external/gpl2/lvm2/dist/lib/device/dev-io.c
--- a/external/gpl2/lvm2/dist/lib/device/dev-io.c       Thu Dec 23 14:43:37 2010 +0000
+++ b/external/gpl2/lvm2/dist/lib/device/dev-io.c       Thu Dec 23 14:46:25 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dev-io.c,v 1.6 2009/12/02 01:53:25 haad Exp $  */
+/*     $NetBSD: dev-io.c,v 1.7 2010/12/23 14:46:25 mlelstv Exp $       */
 
 /*
  * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
@@ -41,6 +41,7 @@
 #elif __NetBSD__
 #  include <sys/disk.h>
 #  include <sys/disklabel.h>
+#  include <prop/proplib.h>
 #  include <sys/param.h>
 #else
 #  include <sys/disk.h>
@@ -133,14 +134,22 @@
        const char *name = dev_name(dev);
 #ifdef __NetBSD__
        struct disklabel        lab;
+       prop_dictionary_t       disk_dict, geom_dict;
+       uint32_t                secsize;
 #endif
 
        if ((dev->block_size == -1)) {
 #ifdef __NetBSD__
-               if (ioctl(dev_fd(dev), DIOCGDINFO, &lab) < 0) {
-                       dev->block_size = DEV_BSIZE;
-               } else
-                       dev->block_size = lab.d_secsize;
+               if (prop_dictionary_recv_ioctl(dev_fd(dev), DIOCGDISKINFO, &disk_dict)) {
+                       if (ioctl(dev_fd(dev), DIOCGDINFO, &lab) < 0) {
+                               dev->block_size = DEV_BSIZE;
+                       } else
+                               dev->block_size = lab.d_secsize;
+               } else {
+                       geom_dict = prop_dictionary_get(disk_dict, "geometry");
+                       prop_dictionary_get_uint32(geom_dict, "sector-size", &secsize);
+                       dev->block_size = secsize;
+               }
 #else
                if (ioctl(dev_fd(dev), BLKBSZGET, &dev->block_size) < 0) {
                        log_sys_error("ioctl BLKBSZGET", name);



Home | Main Index | Thread Index | Old Index