public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3, 15/16] xfsprogs: metadump: use printable characters for obfuscated names
@ 2011-02-18 21:21 Alex Elder
  2011-02-24  8:45 ` Dave Chinner
  0 siblings, 1 reply; 4+ messages in thread
From: Alex Elder @ 2011-02-18 21:21 UTC (permalink / raw)
  To: xfs

There is probably not much need for an extreme amount of randomness
in the obfuscated names produced in metadumps.  Limit the character
set used for (most of) these names to printable characters rather
than every permittable byte.  The result makes metadumps a bit more
natural to work with.

I chose the set of all upper- and lower-case letters, digits, and
the dash and underscore for the alphabet.  It could easily be
expanded to include others (or reduced for that matter).

This change also avoids ever having to retry after picking an
unusable character.

Signed-off-by: Alex Elder <aelder@sgi.com>

No significant changes in this version from the last version posted.

---
 db/metadump.c |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

Index: b/db/metadump.c
===================================================================
--- a/db/metadump.c
+++ b/db/metadump.c
@@ -412,12 +412,11 @@ nametable_add(xfs_dahash_t hash, int nam
 static inline uchar_t
 random_filename_char(void)
 {
-	uchar_t			c;
+	static uchar_t filename_alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+						"abcdefghijklmnopqrstuvwxyz"
+						"0123456789-_";
 
-	do {
-		c = random() % 127 + 1;
-	} while (c == '/');
-	return c;
+	return filename_alphabet[random() % (sizeof filename_alphabet - 1)];
 }
 
 /*

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [PATCH v3, 15/16] xfsprogs: metadump: use printable characters for obfuscated names
  2011-02-18 21:21 [PATCH v3, 15/16] xfsprogs: metadump: use printable characters for obfuscated names Alex Elder
@ 2011-02-24  8:45 ` Dave Chinner
  2011-02-25 18:13   ` Alex Elder
  0 siblings, 1 reply; 4+ messages in thread
From: Dave Chinner @ 2011-02-24  8:45 UTC (permalink / raw)
  To: Alex Elder; +Cc: xfs

On Fri, Feb 18, 2011 at 03:21:02PM -0600, Alex Elder wrote:
> There is probably not much need for an extreme amount of randomness
> in the obfuscated names produced in metadumps.  Limit the character
> set used for (most of) these names to printable characters rather
> than every permittable byte.  The result makes metadumps a bit more
> natural to work with.
> 
> I chose the set of all upper- and lower-case letters, digits, and
> the dash and underscore for the alphabet.  It could easily be
> expanded to include others (or reduced for that matter).
> 
> This change also avoids ever having to retry after picking an
> unusable character.
> 
> Signed-off-by: Alex Elder <aelder@sgi.com>
> 
> No significant changes in this version from the last version posted.
> 
> ---
>  db/metadump.c |    9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> Index: b/db/metadump.c
> ===================================================================
> --- a/db/metadump.c
> +++ b/db/metadump.c
> @@ -412,12 +412,11 @@ nametable_add(xfs_dahash_t hash, int nam
>  static inline uchar_t
>  random_filename_char(void)
>  {
> -	uchar_t			c;
> +	static uchar_t filename_alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
> +						"abcdefghijklmnopqrstuvwxyz"
> +						"0123456789-_";
>  
> -	do {
> -		c = random() % 127 + 1;
> -	} while (c == '/');
> -	return c;
> +	return filename_alphabet[random() % (sizeof filename_alphabet - 1)];
>  }

Why not just:

	do {
		c = random() % 127 + 1;
	} while (!isalnum(c));

	return c;

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [PATCH v3, 15/16] xfsprogs: metadump: use printable characters for obfuscated names
  2011-02-24  8:45 ` Dave Chinner
@ 2011-02-25 18:13   ` Alex Elder
  2011-03-03  5:06     ` Dave Chinner
  0 siblings, 1 reply; 4+ messages in thread
From: Alex Elder @ 2011-02-25 18:13 UTC (permalink / raw)
  To: Dave Chinner; +Cc: xfs

On Thu, 2011-02-24 at 19:45 +1100, Dave Chinner wrote:
> On Fri, Feb 18, 2011 at 03:21:02PM -0600, Alex Elder wrote:
> > There is probably not much need for an extreme amount of randomness
> > in the obfuscated names produced in metadumps.  Limit the character
> > set used for (most of) these names to printable characters rather
> > than every permittable byte.  The result makes metadumps a bit more
> > natural to work with.
> > 
> > I chose the set of all upper- and lower-case letters, digits, and
> > the dash and underscore for the alphabet.  It could easily be
> > expanded to include others (or reduced for that matter).
> > 
> > This change also avoids ever having to retry after picking an
> > unusable character.
> > 
> > Signed-off-by: Alex Elder <aelder@sgi.com>
> > 
> > No significant changes in this version from the last version posted.
> > 
> > ---
> >  db/metadump.c |    9 ++++-----
> >  1 file changed, 4 insertions(+), 5 deletions(-)
> > 
> > Index: b/db/metadump.c
> > ===================================================================
> > --- a/db/metadump.c
> > +++ b/db/metadump.c
> > @@ -412,12 +412,11 @@ nametable_add(xfs_dahash_t hash, int nam
> >  static inline uchar_t
> >  random_filename_char(void)
> >  {
> > -	uchar_t			c;
> > +	static uchar_t filename_alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
> > +						"abcdefghijklmnopqrstuvwxyz"
> > +						"0123456789-_";
> >  
> > -	do {
> > -		c = random() % 127 + 1;
> > -	} while (c == '/');
> > -	return c;
> > +	return filename_alphabet[random() % (sizeof filename_alphabet - 1)];
> >  }
> 
> Why not just:
> 
> 	do {
> 		c = random() % 127 + 1;
> 	} while (!isalnum(c));
> 
> 	return c;
> 

Mainly because I wasn't sure what people would want as an acceptable
alphabet to select from.  We could just use [a-z], for example, and
this way that could easily be changed without changing how the
function worked.  It's also locale-independent (which may or may not
be good I suppose).

Plus as an added bonus, it will never need to compute any
unnecessary random numbers, thereby saving about 12 CPU
cycles. :)

I don't really care much, but would lean toward leaving
it the way I have it.  Do you feel strongly that I should
change it?  Do you think [a-z] (islower()) would be even
better?

					-Alex


_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [PATCH v3, 15/16] xfsprogs: metadump: use printable characters for obfuscated names
  2011-02-25 18:13   ` Alex Elder
@ 2011-03-03  5:06     ` Dave Chinner
  0 siblings, 0 replies; 4+ messages in thread
From: Dave Chinner @ 2011-03-03  5:06 UTC (permalink / raw)
  To: Alex Elder; +Cc: xfs

On Fri, Feb 25, 2011 at 12:13:56PM -0600, Alex Elder wrote:
> On Thu, 2011-02-24 at 19:45 +1100, Dave Chinner wrote:
> > On Fri, Feb 18, 2011 at 03:21:02PM -0600, Alex Elder wrote:
> > > There is probably not much need for an extreme amount of randomness
> > > in the obfuscated names produced in metadumps.  Limit the character
> > > set used for (most of) these names to printable characters rather
> > > than every permittable byte.  The result makes metadumps a bit more
> > > natural to work with.
> > > 
> > > I chose the set of all upper- and lower-case letters, digits, and
> > > the dash and underscore for the alphabet.  It could easily be
> > > expanded to include others (or reduced for that matter).
> > > 
> > > This change also avoids ever having to retry after picking an
> > > unusable character.
> > > 
> > > Signed-off-by: Alex Elder <aelder@sgi.com>
> > > 
> > > No significant changes in this version from the last version posted.
> > > 
> > > ---
> > >  db/metadump.c |    9 ++++-----
> > >  1 file changed, 4 insertions(+), 5 deletions(-)
> > > 
> > > Index: b/db/metadump.c
> > > ===================================================================
> > > --- a/db/metadump.c
> > > +++ b/db/metadump.c
> > > @@ -412,12 +412,11 @@ nametable_add(xfs_dahash_t hash, int nam
> > >  static inline uchar_t
> > >  random_filename_char(void)
> > >  {
> > > -	uchar_t			c;
> > > +	static uchar_t filename_alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
> > > +						"abcdefghijklmnopqrstuvwxyz"
> > > +						"0123456789-_";
> > >  
> > > -	do {
> > > -		c = random() % 127 + 1;
> > > -	} while (c == '/');
> > > -	return c;
> > > +	return filename_alphabet[random() % (sizeof filename_alphabet - 1)];
> > >  }
> > 
> > Why not just:
> > 
> > 	do {
> > 		c = random() % 127 + 1;
> > 	} while (!isalnum(c));
> > 
> > 	return c;
> > 
> 
> Mainly because I wasn't sure what people would want as an acceptable
> alphabet to select from.  We could just use [a-z], for example, and
> this way that could easily be changed without changing how the
> function worked.  It's also locale-independent (which may or may not
> be good I suppose).

isalnum() allows locale specific characters, so allows a larger
number of potential characters than just the static table you
defined. That was the primary reasonn I suggested it - more random
characters to chose from means less probability of duplicates
occurring....

> Plus as an added bonus, it will never need to compute any
> unnecessary random numbers, thereby saving about 12 CPU
> cycles. :)

I doubt that is likely to be a problem. :)

> I don't really care much, but would lean toward leaving
> it the way I have it.  Do you feel strongly that I should
> change it?  Do you think [a-z] (islower()) would be even
> better?

No, the more random characters there are to chose from the better. I
guess that the table you've defined is plenty to chose from, so in
the absense of any hard numbers, I think your table-based approach
will be fine.

Swings and round-abouts, deck chairs on the Titanic...

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

end of thread, other threads:[~2011-03-03  5:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-18 21:21 [PATCH v3, 15/16] xfsprogs: metadump: use printable characters for obfuscated names Alex Elder
2011-02-24  8:45 ` Dave Chinner
2011-02-25 18:13   ` Alex Elder
2011-03-03  5:06     ` Dave Chinner

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