mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-30 06:10:56 +00:00
cifs: convert to print_hex_dump() instead of custom implementation
This patch converts custom dumper to use native print_hex_dump() instead. The cifs_dump_mem() will have an offsets per each line which differs it from the original code. In the dump_smb() we may use native print_hex_dump() as well. It will show slightly different output in ASCII part when character is unprintable, otherwise it keeps same structure. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Steve French <steve.french@primarydata.com>
This commit is contained in:
parent
28e2aed244
commit
55d83e0dbb
2 changed files with 4 additions and 49 deletions
|
@ -34,27 +34,10 @@
|
||||||
void
|
void
|
||||||
cifs_dump_mem(char *label, void *data, int length)
|
cifs_dump_mem(char *label, void *data, int length)
|
||||||
{
|
{
|
||||||
int i, j;
|
|
||||||
int *intptr = data;
|
|
||||||
char *charptr = data;
|
|
||||||
char buf[10], line[80];
|
|
||||||
|
|
||||||
printk(KERN_DEBUG "%s: dump of %d bytes of data at 0x%p\n",
|
printk(KERN_DEBUG "%s: dump of %d bytes of data at 0x%p\n",
|
||||||
label, length, data);
|
label, length, data);
|
||||||
for (i = 0; i < length; i += 16) {
|
print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 16, 4,
|
||||||
line[0] = 0;
|
data, length, true);
|
||||||
for (j = 0; (j < 4) && (i + j * 4 < length); j++) {
|
|
||||||
sprintf(buf, " %08x", intptr[i / 4 + j]);
|
|
||||||
strcat(line, buf);
|
|
||||||
}
|
|
||||||
buf[0] = ' ';
|
|
||||||
buf[2] = 0;
|
|
||||||
for (j = 0; (j < 16) && (i + j < length); j++) {
|
|
||||||
buf[1] = isprint(charptr[i + j]) ? charptr[i + j] : '.';
|
|
||||||
strcat(line, buf);
|
|
||||||
}
|
|
||||||
printk(KERN_DEBUG "%s\n", line);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_CIFS_DEBUG
|
#ifdef CONFIG_CIFS_DEBUG
|
||||||
|
|
|
@ -513,39 +513,11 @@ is_valid_oplock_break(char *buffer, struct TCP_Server_Info *srv)
|
||||||
void
|
void
|
||||||
dump_smb(void *buf, int smb_buf_length)
|
dump_smb(void *buf, int smb_buf_length)
|
||||||
{
|
{
|
||||||
int i, j;
|
|
||||||
char debug_line[17];
|
|
||||||
unsigned char *buffer = buf;
|
|
||||||
|
|
||||||
if (traceSMB == 0)
|
if (traceSMB == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 0, j = 0; i < smb_buf_length; i++, j++) {
|
print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_NONE, 8, 2, buf,
|
||||||
if (i % 8 == 0) {
|
smb_buf_length, true);
|
||||||
/* have reached the beginning of line */
|
|
||||||
printk(KERN_DEBUG "| ");
|
|
||||||
j = 0;
|
|
||||||
}
|
|
||||||
printk("%0#4x ", buffer[i]);
|
|
||||||
debug_line[2 * j] = ' ';
|
|
||||||
if (isprint(buffer[i]))
|
|
||||||
debug_line[1 + (2 * j)] = buffer[i];
|
|
||||||
else
|
|
||||||
debug_line[1 + (2 * j)] = '_';
|
|
||||||
|
|
||||||
if (i % 8 == 7) {
|
|
||||||
/* reached end of line, time to print ascii */
|
|
||||||
debug_line[16] = 0;
|
|
||||||
printk(" | %s\n", debug_line);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (; j < 8; j++) {
|
|
||||||
printk(" ");
|
|
||||||
debug_line[2 * j] = ' ';
|
|
||||||
debug_line[1 + (2 * j)] = ' ';
|
|
||||||
}
|
|
||||||
printk(" | %s\n", debug_line);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in a new issue