Re: [PATCH 007 of 7] md: Get name for block device in sysfs

2007-12-16 Thread Neil Brown
On Saturday December 15, [EMAIL PROTECTED] wrote:
 On Dec 14, 2007 7:26 AM, NeilBrown [EMAIL PROTECTED] wrote:
 
  Given an fd on a block device, returns a string like
 
  /block/sda/sda1
 
  which can be used to find related information in /sys.

 
 As pointed out to when you came up with the idea, we can't do this. A devpath
 is a path to the device and will not necessarily start with /block for block
 devices. It may start with /devices and can be much longer than
 BDEVNAME_SIZE*2  + 10.


When you say will not necessarily can I take that to mean that it
currently does, but it might (will) change??
In that case can we have the patch as it stands and when the path to
block devices in /sys changes, the ioctl can be changed at the same
time to match?

Or are you saying that as the kernel is today, some block devices
appear under /devices/..., in which case could you please give an
example?

Thanks,
NeilBrown
-
To unsubscribe from this list: send the line unsubscribe linux-raid in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 007 of 7] md: Get name for block device in sysfs

2007-12-15 Thread Kay Sievers
On Dec 14, 2007 7:26 AM, NeilBrown [EMAIL PROTECTED] wrote:

 Given an fd on a block device, returns a string like

 /block/sda/sda1

 which can be used to find related information in /sys.

 Ideally we should have an ioctl that works on char devices as well,
 but that seems far from trivial, so it seems reasonable to have
 this until the later can be implemented.

 Cc: Jens Axboe [EMAIL PROTECTED]
 Signed-off-by: Neil Brown [EMAIL PROTECTED]

 ### Diffstat output
  ./block/ioctl.c  |   13 +
  ./include/linux/fs.h |2 ++
  2 files changed, 15 insertions(+)

 diff .prev/block/ioctl.c ./block/ioctl.c
 --- .prev/block/ioctl.c 2007-12-14 17:18:50.0 +1100
 +++ ./block/ioctl.c 2007-12-14 16:15:41.0 +1100
 @@ -227,8 +227,21 @@ int blkdev_ioctl(struct inode *inode, st
 struct block_device *bdev = inode-i_bdev;
 struct gendisk *disk = bdev-bd_disk;
 int ret, n;
 +   char b[BDEVNAME_SIZE*2  + 10];

 switch(cmd) {
 +   case BLKGETNAME:
 +   strcpy(b, /block/);

As pointed out to when you came up with the idea, we can't do this. A devpath
is a path to the device and will not necessarily start with /block for block
devices. It may start with /devices and can be much longer than
BDEVNAME_SIZE*2  + 10.

Please do not apply!

Kay
-
To unsubscribe from this list: send the line unsubscribe linux-raid in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 007 of 7] md: Get name for block device in sysfs

2007-12-13 Thread NeilBrown

Given an fd on a block device, returns a string like

/block/sda/sda1

which can be used to find related information in /sys.

Ideally we should have an ioctl that works on char devices as well,
but that seems far from trivial, so it seems reasonable to have
this until the later can be implemented.

Cc: Jens Axboe [EMAIL PROTECTED]
Signed-off-by: Neil Brown [EMAIL PROTECTED]

### Diffstat output
 ./block/ioctl.c  |   13 +
 ./include/linux/fs.h |2 ++
 2 files changed, 15 insertions(+)

diff .prev/block/ioctl.c ./block/ioctl.c
--- .prev/block/ioctl.c 2007-12-14 17:18:50.0 +1100
+++ ./block/ioctl.c 2007-12-14 16:15:41.0 +1100
@@ -227,8 +227,21 @@ int blkdev_ioctl(struct inode *inode, st
struct block_device *bdev = inode-i_bdev;
struct gendisk *disk = bdev-bd_disk;
int ret, n;
+   char b[BDEVNAME_SIZE*2  + 10];
 
switch(cmd) {
+   case BLKGETNAME:
+   strcpy(b, /block/);
+   bdevname(bdev-bd_contains, b+7);
+   if (bdev-bd_contains != bdev) {
+   char *e = b + strlen(b);
+   *e++ = '/';
+   bdevname(bdev, e);
+   }
+   if (copy_to_user((char __user *)arg, b, strlen(b)+1))
+   return -EFAULT;
+   return 0;
+
case BLKFLSBUF:
if (!capable(CAP_SYS_ADMIN))
return -EACCES;

diff .prev/include/linux/fs.h ./include/linux/fs.h
--- .prev/include/linux/fs.h2007-12-14 17:18:50.0 +1100
+++ ./include/linux/fs.h2007-12-14 16:13:03.0 +1100
@@ -218,6 +218,8 @@ extern int dir_notify_enable;
 #define BLKTRACESTOP _IO(0x12,117)
 #define BLKTRACETEARDOWN _IO(0x12,118)
 
+#define BLKGETNAME _IOR(0x12, 119, char [1024])
+
 #define BMAP_IOCTL 1   /* obsolete - kept for compatibility */
 #define FIBMAP_IO(0x00,1)  /* bmap access */
 #define FIGETBSZ   _IO(0x00,2) /* get the block size used for bmap */
-
To unsubscribe from this list: send the line unsubscribe linux-raid in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html