+ pb_debug("Could not retrieve parameter '%s' for %s\n",
+ param, device->device_path);
+ errno = EINVAL;
+ } else {
+ errno = 0;
+ value = strtoul(tmp, NULL, 0);
+ }
+
+ /* Return errno and result directly */
+ return value;
+}
+
+/* Return the number of sectors on a block device. Zero represents an error */
+static uint64_t get_block_sectors(struct discover_device *device)
+{
+ unsigned long major, minor, sectors = 0;
+ char *attr, *buf = NULL;
+ struct stat sb;
+ int fd = -1;
+ ssize_t sz;
+
+ sectors = read_param_uint(device, "ID_PART_ENTRY_SIZE");
+ if (!errno)
+ return (uint64_t)sectors;
+ else
+ pb_debug("Error reading sector count for %s: %m\n",