diff options
| author | David S. Miller <davem@davemloft.net> | 2016-01-13 00:21:27 -0500 | 
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2016-01-13 00:21:27 -0500 | 
| commit | ddb5388ffd0ad75d07e7b78181a0b579824ba6f0 (patch) | |
| tree | be1e2bd103c69d7bbace3fffd97bc3d714bbc3d7 /lib/vsprintf.c | |
| parent | ccdf6ce6a8dba374668ae9b4d763e19903611c38 (diff) | |
| parent | 67990608c8b95d2b8ccc29932376ae73d5818727 (diff) | |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux
Diffstat (limited to 'lib/vsprintf.c')
| -rw-r--r-- | lib/vsprintf.c | 29 | 
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index f9cee8e1233c..ac3f9476b776 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -31,6 +31,9 @@  #include <linux/dcache.h>  #include <linux/cred.h>  #include <net/addrconf.h> +#ifdef CONFIG_BLOCK +#include <linux/blkdev.h> +#endif  #include <asm/page.h>		/* for PAGE_SIZE */  #include <asm/sections.h>	/* for dereference_function_descriptor() */ @@ -613,6 +616,26 @@ char *dentry_name(char *buf, char *end, const struct dentry *d, struct printf_sp  	return buf;  } +#ifdef CONFIG_BLOCK +static noinline_for_stack +char *bdev_name(char *buf, char *end, struct block_device *bdev, +		struct printf_spec spec, const char *fmt) +{ +	struct gendisk *hd = bdev->bd_disk; +	 +	buf = string(buf, end, hd->disk_name, spec); +	if (bdev->bd_part->partno) { +		if (isdigit(hd->disk_name[strlen(hd->disk_name)-1])) { +			if (buf < end) +				*buf = 'p'; +			buf++; +		} +		buf = number(buf, end, bdev->bd_part->partno, spec); +	} +	return buf; +} +#endif +  static noinline_for_stack  char *symbol_string(char *buf, char *end, void *ptr,  		    struct printf_spec spec, const char *fmt) @@ -1443,6 +1466,7 @@ int kptr_restrict __read_mostly;   *           (default assumed to be phys_addr_t, passed by reference)   * - 'd[234]' For a dentry name (optionally 2-4 last components)   * - 'D[234]' Same as 'd' but for a struct file + * - 'g' For block_device name (gendisk + partition number)   * - 'C' For a clock, it prints the name (Common Clock Framework) or address   *       (legacy clock framework) of the clock   * - 'Cn' For a clock, it prints the name (Common Clock Framework) or address @@ -1600,6 +1624,11 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,  		return dentry_name(buf, end,  				   ((const struct file *)ptr)->f_path.dentry,  				   spec, fmt); +#ifdef CONFIG_BLOCK +	case 'g': +		return bdev_name(buf, end, ptr, spec, fmt); +#endif +  	}  	spec.flags |= SMALL;  	if (spec.field_width == -1) {  | 
