Thread (5 messages) 5 messages, 3 authors, 2012-07-20

Re: [PATCH] Btrfs-progs: detect if the disk we are formatting is a ssd

From: Chris Mason <hidden>
Date: 2012-07-20 18:38:59

On Fri, Jul 20, 2012 at 12:20:56PM -0600, Josef Bacik wrote:
On Fri, Jul 20, 2012 at 12:18:59PM -0600, Zach Brown wrote:
quoted
quoted
+static int is_ssd(const char *file)
+{
+	char *dev = strrchr(file, '/');
 [ ... ]
quoted
+	snprintf(path, PATH_MAX, "/sys/block/%s/queue/rotational", dev);
+	fd = open(path, O_RDONLY);
Hmm, this doesn't seem right.  The last path component can have nothing
to do with the underlying device name.  And /sys/block doesn't have
entries for partition devices.

After some poking around (and hints from Eric), it looks like the thing
to do is stat the file to find that it's a block device and then use
blkid_devno_to_wholedisk().  That parses the link from
/sys/dev/block/$maj:$min to find the containing device.

Then it'll work for partitions and nutty udev vanity symlinks.
Partitions are for losers.
Winners make a separate /boot, even when using syslinux to boot directly
off btrfs (syslinux is awesome everyone, switch now).

-chris
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help