From: Alex Elder <aelder@sgi.com>
To: xfs@oss.sgi.com
Subject: [PATCH 01/12] xfsprogs: some things aren't all that special
Date: Thu, 30 Dec 2010 14:39:59 -0600 [thread overview]
Message-ID: <1293741599.2294.342.camel@doink> (raw)
Move the check for short file names out of is_special_dirent() and
into generate_obfuscated_name(). That way the check is more
directly associated with the algorithm that requires it.
Similarly, move the check for inode == 0, since that case has to do
with storing extended attributes (not files) in the name table.
As a result, is_special_dirent() is really only focused on whether a
given file is in the lost+found directory.
Rename is_special_dirent() to reflect its more specific purpose.
And use a cast to elminate a compile warning in calls to
libxfs_da_hashname().
Signed-off-by: Alex Elder <aelder@sgi.com>
---
db/metadump.c | 51 +++++++++++++++++++++++++++++----------------------
1 file changed, 29 insertions(+), 22 deletions(-)
Index: b/db/metadump.c
===================================================================
--- a/db/metadump.c
+++ b/db/metadump.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007 Silicon Graphics, Inc.
+ * Copyright (c) 2007,2010 SGI
* All Rights Reserved.
*
* This program is free software; you can redistribute it and/or
@@ -377,8 +377,15 @@ random_filename_char(void)
return c;
}
+/*
+ * We won't obfuscate "lost+found" nor any inodes within it.
+ *
+ * Record the "lost+found" directory's inode number when it's found.
+ * While processing that directory, any file whose name matches
+ * its inode number is left as-is (no obfuscation).
+ */
static int
-is_special_dirent(
+in_lost_found(
xfs_ino_t ino,
int namelen,
uchar_t *name)
@@ -387,22 +394,8 @@ is_special_dirent(
char s[32];
int slen;
- /*
- * due to the XFS name hashing algorithm, we cannot obfuscate
- * names with 4 chars or less.
- */
- if (namelen <= 4)
- return 1;
-
- if (ino == 0)
- return 0;
-
- /*
- * don't obfuscate lost+found nor any inodes within lost+found with
- * the inode number
- */
- if (cur_ino == mp->m_sb.sb_rootino && namelen == 10 &&
- memcmp(name, "lost+found", 10) == 0) {
+ if (!orphanage_ino && cur_ino == mp->m_sb.sb_rootino &&
+ namelen == 10 && !memcmp(name, "lost+found", 10)) {
orphanage_ino = ino;
return 1;
}
@@ -410,7 +403,8 @@ is_special_dirent(
return 0;
slen = sprintf(s, "%lld", (long long)ino);
- return (slen == namelen && memcmp(name, s, namelen) == 0);
+
+ return slen == namelen && !memcmp(name, s, namelen);
}
static void
@@ -426,10 +420,23 @@ generate_obfuscated_name(
xfs_dahash_t newhash;
uchar_t newname[NAME_MAX];
- if (is_special_dirent(ino, namelen, name))
+ /*
+ * Our obfuscation algorithm requires at least 5-character
+ * names, so don't bother if the name is too short.
+ */
+ if (namelen < 5)
+ return;
+
+ /*
+ * We don't obfuscate "lost+found" or any of the files
+ * therein. When the name table is used for extended
+ * attributes, the inode number provided is 0, in which
+ * case we don't need to make this check.
+ */
+ if (ino && in_lost_found(ino, namelen, name))
return;
- hash = libxfs_da_hashname(name, namelen);
+ hash = libxfs_da_hashname((char *) name, namelen);
/* create a random name with the same hash value */
@@ -468,7 +475,7 @@ generate_obfuscated_name(
break;
}
- ASSERT(libxfs_da_hashname(newname, namelen) == hash);
+ ASSERT(libxfs_da_hashname((char *) newname, namelen) == hash);
for (p = nametable[hash % NAME_TABLE_SIZE]; p; p = p->next) {
if (p->hash == hash && p->namelen == namelen &&
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next reply other threads:[~2010-12-30 20:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-30 20:39 Alex Elder [this message]
2011-01-10 20:11 ` [PATCH 01/12] xfsprogs: some things aren't all that special Christoph Hellwig
2011-01-10 20:22 ` Alex Elder
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1293741599.2294.342.camel@doink \
--to=aelder@sgi.com \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox