OSDN Git Service

Move i2o device parsing to linux-i2o.c
authorPeter Jones <pjones@redhat.com>
Wed, 6 Jun 2018 20:40:05 +0000 (16:40 -0400)
committerPeter Jones <pmjones@gmail.com>
Fri, 8 Jun 2018 19:11:37 +0000 (15:11 -0400)
This won't actually *work* yet, because the infrastructure to use it
(replacing "struct disk_info") won't land for a few more patches.

Signed-off-by: Peter Jones <pjones@redhat.com>
src/linux-i2o.c [new file with mode: 0644]
src/linux.c
src/linux.h

diff --git a/src/linux-i2o.c b/src/linux-i2o.c
new file mode 100644 (file)
index 0000000..e57c0cb
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * libefiboot - library for the manipulation of EFI boot variables
+ * Copyright 2012-2018 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of the
+ * License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "fix_coverity.h"
+
+#include <errno.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <stdint.h>
+#include <unistd.h>
+
+#include "efiboot.h"
+
+/*
+ * support for I2O devices
+ * ... probably doesn't work.
+ */
+static ssize_t
+parse_i2o(struct device *dev, const char *current UNUSED)
+{
+        debug(DEBUG, "entry");
+        /* I2O disks can have up to 16 partitions, or 4 bits worth. */
+        if (dev->major >= 80 && dev->major <= 87) {
+                dev->interface_type = i2o;
+                dev->disknum = 16*(dev->major-80) + (dev->minor >> 4);
+                set_part(dev, dev->minor & 0xF);
+        } else {
+                /* If it isn't those majors, it's not an i2o dev */
+                return 0;
+        }
+
+        char *block = strstr(current, "/block/");
+        if (!block)
+                return -1;
+        return block + 1 - current;
+}
+
+enum interface_type i2o_iftypes[] = { i2o, unknown };
+
+struct dev_probe HIDDEN i2o_parser = {
+        .name = "i2o",
+        .iftypes = i2o_iftypes,
+        .flags = DEV_PROVIDES_HD,
+        .parse = parse_i2o,
+        .create = NULL,
+};
index 8f27a17..0d6c0d3 100644 (file)
@@ -889,7 +889,6 @@ make_blockdev_path(uint8_t *buf, ssize_t size, struct disk_info *info)
             info->interface_type == usb ||
             info->interface_type == i1394 ||
             info->interface_type == fibre ||
-            info->interface_type == i2o ||
             info->interface_type == md)) {
                uint32_t tosser;
                int tmpoff;
@@ -1006,14 +1005,6 @@ eb_disk_info_from_fd(int fd, struct disk_info *info)
                return 1;
        }
 
-        /* I2O disks can have up to 16 partitions, or 4 bits worth. */
-       if (info->major >= 80 && info->major <= 87) {
-               info->interface_type = i2o;
-               info->disknum = 16*(info->major-80) + (info->minor >> 4);
-               info->part    = (info->minor & 0xF);
-               return 0;
-       }
-
        rc = sysfs_readlink(&driver, "dev/block/%"PRIu64":%"PRIu32"/device/driver",
                            info->major, info->minor);
        if (rc > 0) {
index 0b3ad42..97907bc 100644 (file)
@@ -259,6 +259,7 @@ extern ssize_t parse_scsi_link(const char *current, uint32_t *host,
 #define set_part(x, y) /* XXX remove later */
 
 /* device support implementations */
+extern struct dev_probe i2o_parser;
 extern struct dev_probe scsi_parser;
 extern struct dev_probe ata_parser;