public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 10/12] xfsprogs: use printable characters for obfuscated filenames
@ 2010-12-30 20:42 Alex Elder
  0 siblings, 0 replies; only message in thread
From: Alex Elder @ 2010-12-30 20:42 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 filenames to printable characters
rather than every permitted 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.

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

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

Index: b/db/metadump.c
===================================================================
--- a/db/metadump.c
+++ b/db/metadump.c
@@ -377,12 +377,11 @@ clear_nametable(void)
 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] only message in thread

only message in thread, other threads:[~2010-12-30 20:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-30 20:42 [PATCH 10/12] xfsprogs: use printable characters for obfuscated filenames Alex Elder

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