Commit 0948aa6d authored by Christoph Hellwig's avatar Christoph Hellwig

[PATCH] improved bdevname

parent 72007d2d
......@@ -99,25 +99,32 @@ char *disk_name(struct gendisk *hd, int part, char *buf)
#ifdef CONFIG_DEVFS_FS
if (hd->devfs_name[0] != '\0') {
if (part)
sprintf(buf, "%s/part%d", hd->devfs_name, part);
snprintf(buf, BDEVNAME_SIZE, "%s/part%d",
hd->devfs_name, part);
else if (hd->minors != 1)
sprintf(buf, "%s/disc", hd->devfs_name);
snprintf(buf, BDEVNAME_SIZE, "%s/disc", hd->devfs_name);
else
sprintf(buf, "%s", hd->devfs_name);
snprintf(buf, BDEVNAME_SIZE, "%s", hd->devfs_name);
return buf;
}
#endif
if (!part)
sprintf(buf, "%s", hd->disk_name);
snprintf(buf, BDEVNAME_SIZE, "%s", hd->disk_name);
else if (isdigit(hd->disk_name[strlen(hd->disk_name)-1]))
sprintf(buf, "%sp%d", hd->disk_name, part);
snprintf(buf, BDEVNAME_SIZE, "%sp%d", hd->disk_name, part);
else
sprintf(buf, "%s%d", hd->disk_name, part);
snprintf(buf, BDEVNAME_SIZE, "%s%d", hd->disk_name, part);
return buf;
}
const char *bdevname(struct block_device *bdev, char *buf)
{
int part = MINOR(bdev->bd_dev) - bdev->bd_disk->first_minor;
return disk_name(bdev->bd_disk, part, buf);
}
static struct parsed_partitions *
check_partition(struct gendisk *hd, struct block_device *bdev)
{
......@@ -417,7 +424,7 @@ void del_gendisk(struct gendisk *disk)
struct dev_name {
struct list_head list;
dev_t dev;
char namebuf[64];
char namebuf[BDEVNAME_SIZE];
char *name;
};
......
......@@ -8,7 +8,7 @@
enum { MAX_PART = 256 };
struct parsed_partitions {
char name[40];
char name[BDEVNAME_SIZE];
struct {
sector_t from;
sector_t size;
......
......@@ -1068,10 +1068,7 @@ extern int chrdev_open(struct inode *, struct file *);
/* fs/block_dev.c */
#define BDEVNAME_SIZE 32 /* Largest string for a blockdev identifier */
extern const char *__bdevname(dev_t, char *buffer);
extern inline const char *bdevname(struct block_device *bdev, char *buffer)
{
return __bdevname(bdev->bd_dev, buffer);
}
extern const char *bdevname(struct block_device *bdev, char *buffer);
extern struct block_device *lookup_bdev(const char *);
extern struct block_device *open_bdev_excl(const char *, int, int, void *);
extern void close_bdev_excl(struct block_device *, int);
......
......@@ -515,6 +515,7 @@ EXPORT_SYMBOL(vsprintf);
EXPORT_SYMBOL(vsnprintf);
EXPORT_SYMBOL(vsscanf);
EXPORT_SYMBOL(__bdevname);
EXPORT_SYMBOL(bdevname);
EXPORT_SYMBOL(cdevname);
EXPORT_SYMBOL(simple_strtoull);
EXPORT_SYMBOL(simple_strtoul);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment