Skip to contentSkip to conversation

btrfs-progs: mkfs: increase buffer size in is_ssd

PATCH Applied Michael Lass 2 participants 2 messages Nov 8, 2015 – Nov 13, 2015 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs-progs: mkfs: increase buffer size in is_ssd

In current versions of util-linux the buffer passed to blkid_devno_to_wholedisk has to be sufficiently large to not only hold the device name but the complete target of the /sys/dev/block/<maj:min> symlink. This was changed only recently in 4419ffb9eff5801fdbd385a4a6199b3877f802ad.

The small buffer size currently can lead to failure of is_ssd due to truncated device names:

readlink("/sys/dev/block/254:7", "../../devices/virtual/block/dm-", 31) = 31 open("/sys/block/dm-/queue/rotational", O_RDONLY) = -1 ENOENT (No such file or directory)

---
 mkfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mkfs.c +1 -1
index 0ea39f3..db69ab9 100644
@@ -1102,7 +1102,7 @@ static int zero_output_file(int out_fd, u64 size, u32 sectorsize)
 static int is_ssd(const char *file)
 {
 	blkid_probe probe;
-	char wholedisk[32];
+	char wholedisk[PATH_MAX];
 	char sysfs_path[PATH_MAX];
 	dev_t devno;
 	int fd;
Signature · 1 line
2.6.2
Applied
#1 lore raw
Quoted 5 lines · Michael Lass

In current versions of util-linux the buffer passed to blkid_devno_to_wholedisk has to be sufficiently large to not only hold the device name but the complete target of the /sys/dev/block/<maj:min> symlink. This was changed only recently in 4419ffb9eff5801fdbd385a4a6199b3877f802ad.

Quoted 7 lines

The small buffer size currently can lead to failure of is_ssd due to truncated device names:

readlink("/sys/dev/block/254:7", "../../devices/virtual/block/dm-", 31) = 31 open("/sys/block/dm-/queue/rotational", O_RDONLY) = -1 ENOENT (No such file or directory)

Applied, thanks.