public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lose xfs_hex_dump in favor of print_hex_dump
@ 2007-09-25  0:11 Eric Sandeen
  2007-09-25  0:32 ` Chris Wedgwood
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Sandeen @ 2007-09-25  0:11 UTC (permalink / raw)
  To: xfs-oss

No need for xfs to have its own hex dumping routine now that the
kernel has one.

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>

Index: linux-2.6-xfs/fs/xfs/xfs_error.c
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/xfs_error.c
+++ linux-2.6-xfs/fs/xfs/xfs_error.c
@@ -230,37 +230,6 @@ xfs_error_report(
 	}
 }
 
-STATIC void
-xfs_hex_dump(void *p, int length)
-{
-	__uint8_t *uip = (__uint8_t*)p;
-	int	i;
-	char	sbuf[128], *s;
-
-	s = sbuf;
-	*s = '\0';
-	for (i=0; i<length; i++, uip++) {
-		if ((i % 16) == 0) {
-			if (*s != '\0')
-				cmn_err(CE_ALERT, "%s\n", sbuf);
-			s = sbuf;
-			sprintf(s, "0x%x: ", i);
-			while( *s != '\0')
-				s++;
-		}
-		sprintf(s, "%02x ", *uip);
-
-		/*
-		 * the kernel sprintf is a void; user sprintf returns
-		 * the sprintf'ed string's length.  Find the new end-
-		 * of-string
-		 */
-		while( *s != '\0')
-			s++;
-	}
-	cmn_err(CE_ALERT, "%s\n", sbuf);
-}
-
 void
 xfs_corruption_error(
 	char		*tag,
Index: linux-2.6-xfs/fs/xfs/xfs_error.h
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/xfs_error.h
+++ linux-2.6-xfs/fs/xfs/xfs_error.h
@@ -174,6 +174,8 @@ extern void xfs_cmn_err(int panic_tag, i
 /* PRINTFLIKE3 */
 extern void xfs_fs_cmn_err(int level, struct xfs_mount *mp, char *fmt, ...);
 
+extern void xfs_hex_dump(void *p, int length);
+
 #define xfs_fs_repair_cmn_err(level, mp, fmt, args...) \
 	xfs_fs_cmn_err(level, mp, fmt "  Unmount and run xfs_repair.", ## args)
 
Index: linux-2.6-xfs/fs/xfs/support/debug.c
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/support/debug.c
+++ linux-2.6-xfs/fs/xfs/support/debug.c
@@ -81,3 +81,9 @@ assfail(char *expr, char *file, int line
 	printk("Assertion failed: %s, file: %s, line: %d\n", expr, file, line);
 	BUG();
 }
+
+void
+xfs_hex_dump(void *p, int length)
+{
+	print_hex_dump(KERN_ALERT, "", DUMP_PREFIX_OFFSET, 16, 1, p, length, 1);
+}

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] lose xfs_hex_dump in favor of print_hex_dump
  2007-09-25  0:11 [PATCH] lose xfs_hex_dump in favor of print_hex_dump Eric Sandeen
@ 2007-09-25  0:32 ` Chris Wedgwood
  2007-09-25  1:31   ` Eric Sandeen
  0 siblings, 1 reply; 4+ messages in thread
From: Chris Wedgwood @ 2007-09-25  0:32 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: xfs-oss

On Mon, Sep 24, 2007 at 07:11:44PM -0500, Eric Sandeen wrote:

> +extern void xfs_hex_dump(void *p, int length);
> +

> +void
> +xfs_hex_dump(void *p, int length)
> +{
> +	print_hex_dump(KERN_ALERT, "", DUMP_PREFIX_OFFSET, 16, 1, p, length, 1);
> +}

Is this symbol exported/needed?  If not then why not make it a #define
or an inline in the header where you have the prototype?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] lose xfs_hex_dump in favor of print_hex_dump
  2007-09-25  0:32 ` Chris Wedgwood
@ 2007-09-25  1:31   ` Eric Sandeen
  2007-09-25  8:28     ` Christoph Hellwig
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Sandeen @ 2007-09-25  1:31 UTC (permalink / raw)
  To: Chris Wedgwood; +Cc: xfs-oss

Chris Wedgwood wrote:

> On Mon, Sep 24, 2007 at 07:11:44PM -0500, Eric Sandeen wrote:
> 
>> +extern void xfs_hex_dump(void *p, int length);
>> +
> 
>> +void
>> +xfs_hex_dump(void *p, int length)
>> +{
>> +	print_hex_dump(KERN_ALERT, "", DUMP_PREFIX_OFFSET, 16, 1, p, length, 1);
>> +}
> 
> Is this symbol exported/needed?  If not then why not make it a #define
> or an inline in the header where you have the prototype?

Yeah, I suppose that might be better....  I just followed the lead of
xfs_cmn_err etc.

The only reason I left a wrapper was for cattelan's BSD exploits 
(er, adventures)  ;-)  I could imagine it getting called from other places, 
but for now it only has one caller, xfs_corruption_error (so really, even 
the length argument is never anything other than 16...)


-Eric

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] lose xfs_hex_dump in favor of print_hex_dump
  2007-09-25  1:31   ` Eric Sandeen
@ 2007-09-25  8:28     ` Christoph Hellwig
  0 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2007-09-25  8:28 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: Chris Wedgwood, xfs-oss

On Mon, Sep 24, 2007 at 08:31:45PM -0500, Eric Sandeen wrote:
> >> +void
> >> +xfs_hex_dump(void *p, int length)
> >> +{
> >> +	print_hex_dump(KERN_ALERT, "", DUMP_PREFIX_OFFSET, 16, 1, p, length, 1);
> >> +}
> > 
> > Is this symbol exported/needed?  If not then why not make it a #define
> > or an inline in the header where you have the prototype?
> 
> Yeah, I suppose that might be better....  I just followed the lead of
> xfs_cmn_err etc.
> 
> The only reason I left a wrapper was for cattelan's BSD exploits 
> (er, adventures)  ;-)  I could imagine it getting called from other places, 
> but for now it only has one caller, xfs_corruption_error (so really, even 
> the length argument is never anything other than 16...)

No point in making anything in an absolute slowpath inline or a macro.
I think the patch is fine as-is.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-09-25  8:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-25  0:11 [PATCH] lose xfs_hex_dump in favor of print_hex_dump Eric Sandeen
2007-09-25  0:32 ` Chris Wedgwood
2007-09-25  1:31   ` Eric Sandeen
2007-09-25  8:28     ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox