Re: mdadm --detail showing annoying device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Stephane Bunel a écrit :
Mario 'BitKoenig' Holbe a écrit :
Neil Brown <neilb@xxxxxxx> wrote:
On Wednesday October 21, stephane.bunel@xxxxxxxxxxxxxxxxx wrote:
        0       8        0        0      active sync   /dev/char/21:0
        1       8       16        1      active sync   /dev/char/21:1
What is a block device doing in /dev/char ???  There should only be
character devices in there.

major 21 are usually SCSI generic devices (/dev/sg) and they are char...
crw-rw----  1 root root  21, 0 Oct 10 21:48 /dev/sg0
crw-rw----  1 root root  21, 1 Oct 10 21:48 /dev/sg1

The question is, why do they appear at mdadm --detail

mdadm performs a physical walk to not follow symbolic links (cf nftw( FTW_PHYS ) in map_dev() ). But using stat() mdadm finaly follow the symbolic link and so returns the same type/major/minor as the targeted link.

lstat() is identical to stat(), except that if path is a symbolic link, then the link itself is stat-ed, not the file that it refers to.


#ls -la /dev/char/21:0
lrwxrwxrwx 1 root root 13 2009-10-16 18:12 /dev/char/21:0 -> ../raid_disk0

Tested from Python:
 >>> import os, stat

Using stat:
 >>> mode = os.stat( '/dev/char/21:0' )[ stat.ST_MODE ]
 >>> stat.S_ISBLK( mode )
True

using lstat():
 >>> mode = os.lstat( '/dev/char/21:0' )[ stat.ST_MODE ]
 >>> stat.S_ISBLK( mode )
False


Just for fun ;-)

--- util.c.orig	2009-10-22 17:54:11.000000000 +0200
+++ util.c	2009-10-22 17:55:09.000000000 +0200
@@ -468,7 +468,7 @@
 	struct stat st;

 	if (S_ISLNK(stb->st_mode)) {
-		if (stat(name, &st) != 0)
+		if (lstat(name, &st) != 0)
 			return 0;
 		stb = &st;
 	}



Stéphane Bunel.

--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux