129 lines
4.1 KiB
Diff
129 lines
4.1 KiB
Diff
diff -up util-linux-ng-2.17.1/shlibs/blkid/src/topology/ioctl.c.kzak util-linux-ng-2.17.1/shlibs/blkid/src/topology/ioctl.c
|
|
--- util-linux-ng-2.17.1/shlibs/blkid/src/topology/ioctl.c.kzak 2010-03-03 14:40:53.000000000 +0100
|
|
+++ util-linux-ng-2.17.1/shlibs/blkid/src/topology/ioctl.c 2010-03-03 15:08:36.000000000 +0100
|
|
@@ -44,11 +44,18 @@ static int probe_ioctl_tp(blkid_probe pr
|
|
|
|
for (i = 0; i < ARRAY_SIZE(topology_vals); i++) {
|
|
struct topology_val *val = &topology_vals[i];
|
|
- unsigned int data;
|
|
+ unsigned int data = 0;
|
|
int rc;
|
|
|
|
- if (ioctl(pr->fd, val->ioc, &data) == -1)
|
|
+ if (val->ioc == BLKALIGNOFF) {
|
|
+ int sdata = 0;
|
|
+ if (ioctl(pr->fd, val->ioc, &sdata) == -1)
|
|
+ goto nothing;
|
|
+ data = sdata < 0 ? 0 : sdata;
|
|
+
|
|
+ } else if (ioctl(pr->fd, val->ioc, &data) == -1)
|
|
goto nothing;
|
|
+
|
|
rc = val->set_result(pr, (unsigned long) data);
|
|
if (rc)
|
|
goto err;
|
|
diff -up util-linux-ng-2.17.1/shlibs/blkid/src/topology/sysfs.c.kzak util-linux-ng-2.17.1/shlibs/blkid/src/topology/sysfs.c
|
|
--- util-linux-ng-2.17.1/shlibs/blkid/src/topology/sysfs.c.kzak 2010-03-03 14:39:56.000000000 +0100
|
|
+++ util-linux-ng-2.17.1/shlibs/blkid/src/topology/sysfs.c 2010-03-03 15:14:32.000000000 +0100
|
|
@@ -12,6 +12,7 @@
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
#include <stdint.h>
|
|
+#include <inttypes.h>
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
#include <unistd.h>
|
|
@@ -19,15 +20,14 @@
|
|
|
|
#include "topology.h"
|
|
|
|
-static unsigned long dev_topology_attribute(const char *attribute,
|
|
- dev_t dev, dev_t *primary)
|
|
+static int dev_topology_attribute(const char *attribute,
|
|
+ dev_t dev, dev_t *primary, int64_t *result)
|
|
{
|
|
const char *sysfs_fmt_str = "/sys/dev/block/%d:%d/%s";
|
|
char path[PATH_MAX];
|
|
int len;
|
|
FILE *fp = NULL;
|
|
struct stat info;
|
|
- unsigned long result = 0UL;
|
|
|
|
len = snprintf(path, sizeof(path), sysfs_fmt_str,
|
|
major(dev), minor(dev), attribute);
|
|
@@ -58,7 +58,7 @@ static unsigned long dev_topology_attrib
|
|
goto err;
|
|
}
|
|
|
|
- if (fscanf(fp, "%lu", &result) != 1) {
|
|
+ if (fscanf(fp, "%" SCNd64, result) != 1) {
|
|
DBG(DEBUG_LOWPROBE, printf(
|
|
"topology: %s: unexpected file format\n", path));
|
|
goto err;
|
|
@@ -67,15 +67,15 @@ static unsigned long dev_topology_attrib
|
|
fclose(fp);
|
|
|
|
DBG(DEBUG_LOWPROBE,
|
|
- printf("topology: attribute %s = %lu\n", attribute, result));
|
|
+ printf("topology: attribute %s = %"PRId64"\n", attribute, *result));
|
|
|
|
- return result;
|
|
+ return 0;
|
|
err:
|
|
if (fp)
|
|
fclose(fp);
|
|
DBG(DEBUG_LOWPROBE,
|
|
printf("topology: failed to read %s attribute\n", attribute));
|
|
- return 0;
|
|
+ return -1;
|
|
}
|
|
|
|
/*
|
|
@@ -107,17 +107,16 @@ static int probe_sysfs_tp(blkid_probe pr
|
|
|
|
for (i = 0; i < ARRAY_SIZE(topology_vals); i++) {
|
|
struct topology_val *val = &topology_vals[i];
|
|
- unsigned long data;
|
|
+ int64_t data = 0;
|
|
|
|
- /*
|
|
- * Don't bother reporting any of the topology information
|
|
- * if it's zero.
|
|
- */
|
|
- data = dev_topology_attribute(val->sysfs_name, dev, &pri_dev);
|
|
- if (!data)
|
|
+ if (dev_topology_attribute(val->sysfs_name, dev,
|
|
+ &pri_dev, &data))
|
|
continue;
|
|
|
|
- rc = val->set_result(pr, data);
|
|
+ if (!strcmp(val->sysfs_name, "alignment_offset") && data < 0)
|
|
+ data = 0;
|
|
+
|
|
+ rc = val->set_result(pr, (unsigned long) data);
|
|
if (rc)
|
|
goto err;
|
|
count++;
|
|
diff -up util-linux-ng-2.17.1/shlibs/blkid/src/topology/topology.c.kzak util-linux-ng-2.17.1/shlibs/blkid/src/topology/topology.c
|
|
--- util-linux-ng-2.17.1/shlibs/blkid/src/topology/topology.c.kzak 2010-03-03 15:15:42.000000000 +0100
|
|
+++ util-linux-ng-2.17.1/shlibs/blkid/src/topology/topology.c 2010-03-03 15:06:43.000000000 +0100
|
|
@@ -43,6 +43,10 @@
|
|
* @ALIGNMENT_OFFSET: indicates how many bytes the beginning o the device is
|
|
* offset from the disk's natural alignment.
|
|
*
|
|
+ * The NAME=value tags are not defined when the corresponding topology value
|
|
+ * is zero. The MINIMUM_IO_SIZE should be always defined if kernel provides
|
|
+ * topology information.
|
|
+ *
|
|
* Binary interface:
|
|
*
|
|
* blkid_probe_get_tolology()
|
|
@@ -214,6 +218,8 @@ static int topology_set_value(blkid_prob
|
|
|
|
if (!chn)
|
|
return -1;
|
|
+ if (!data)
|
|
+ return 0; /* ignore zeros */
|
|
|
|
if (chn->binary) {
|
|
unsigned long *v =
|