Package: efivar / 30-2

0001-linux-fix-device-major-minor-handling.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
From 9d8ed784455f73593143e8316f7ca156986dae37 Mon Sep 17 00:00:00 2001
From: Nicolas George <george@nsup.org>
Date: Sun, 13 Nov 2016 19:04:30 +0100
Subject: [PATCH] linux: fix device major/minor handling.

The current code fails when minor >= 256 because the higher
bits are kept in major.

Fix: Debian bug #844237
---
 src/linux.c | 10 +++++-----
 src/linux.h |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/linux.c b/src/linux.c
index b995887..68e93fd 100644
--- a/src/linux.c
+++ b/src/linux.c
@@ -55,7 +55,7 @@ set_disk_and_part_name(struct disk_info *info)
 	char *linkbuf;
 	ssize_t rc;
 
-	rc = sysfs_readlink(&linkbuf, "/sys/dev/block/%"PRIu64":%hhu",
+	rc = sysfs_readlink(&linkbuf, "/sys/dev/block/%"PRIu64":%"PRIu32,
 		      info->major, info->minor);
 	if (rc < 0)
 		return -1;
@@ -918,11 +918,11 @@ eb_disk_info_from_fd(int fd, struct disk_info *info)
 		return 1;
 	}
 	if (S_ISBLK(buf.st_mode)) {
-		info->major = buf.st_rdev >> 8;
-		info->minor = buf.st_rdev & 0xFF;
+		info->major = major(buf.st_rdev);
+		info->minor = minor(buf.st_rdev);
 	} else if (S_ISREG(buf.st_mode)) {
-		info->major = buf.st_dev >> 8;
-		info->minor = buf.st_dev & 0xFF;
+		info->major = major(buf.st_dev);
+		info->minor = minor(buf.st_dev);
 	} else {
 		printf("Cannot stat non-block or non-regular file\n");
 		return 1;
diff --git a/src/linux.h b/src/linux.h
index c9d0f2b..7f7bc86 100644
--- a/src/linux.h
+++ b/src/linux.h
@@ -75,7 +75,7 @@ struct disk_info {
 	unsigned int disknum;
 	unsigned char part;
 	uint64_t major;
-	unsigned char minor;
+	uint32_t minor;
 	uint32_t edd10_devicenum;
 
 	struct pci_root_info pci_root;
-- 
2.7.4