From: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
To: Linus Torvalds <torvalds@osdl.org>, Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 3/13] FAT: IS_BADCHAR/IS_REPLACECHR/IS_SKIPCHAR cleanup
Date: Tue, 18 Jan 2005 02:41:05 +0900 [thread overview]
Message-ID: <87hdlgoswe.fsf_-_@devron.myhome.or.jp> (raw)
In-Reply-To: <87llasosxu.fsf@devron.myhome.or.jp> (OGAWA Hirofumi's message of "Tue, 18 Jan 2005 02:40:13 +0900")
From Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
---
fs/vfat/namei.c | 49 +++++++++++++++++++++----------------------------
1 files changed, 21 insertions(+), 28 deletions(-)
diff -puN fs/vfat/namei.c~fat_check-chars-cleanup fs/vfat/namei.c
--- linux-2.6.10/fs/vfat/namei.c~fat_check-chars-cleanup 2005-01-08 09:07:50.000000000 +0900
+++ linux-2.6.10-hirofumi/fs/vfat/namei.c 2005-01-08 09:07:50.000000000 +0900
@@ -158,33 +158,26 @@ static int vfat_cmp(struct dentry *dentr
/* Characters that are undesirable in an MS-DOS file name */
-static wchar_t bad_chars[] = {
- /* `*' `?' `<' `>' `|' `"' `:' `/' */
- 0x002A, 0x003F, 0x003C, 0x003E, 0x007C, 0x0022, 0x003A, 0x002F,
- /* `\' */
- 0x005C, 0,
-};
-#define IS_BADCHAR(uni) (vfat_unistrchr(bad_chars, (uni)) != NULL)
-
-static wchar_t replace_chars[] = {
- /* `[' `]' `;' `,' `+' `=' */
- 0x005B, 0x005D, 0x003B, 0x002C, 0x002B, 0x003D, 0,
-};
-#define IS_REPLACECHAR(uni) (vfat_unistrchr(replace_chars, (uni)) != NULL)
+static inline wchar_t vfat_bad_char(wchar_t w)
+{
+ return (w < 0x0020)
+ || (w == 0x002A) /* * */ || (w == 0x003F) /* ? */
+ || (w == 0x003C) /* < */ || (w == 0x003E) /* > */
+ || (w == 0x007C) /* | */ || (w == 0x0022) /* " */
+ || (w == 0x003A) /* : */ || (w == 0x002F) /* / */
+ || (w == 0x005C);/* \ */
+}
-static wchar_t skip_chars[] = {
- /* `.' ` ' */
- 0x002E, 0x0020, 0,
-};
-#define IS_SKIPCHAR(uni) \
- ((wchar_t)(uni) == skip_chars[0] || (wchar_t)(uni) == skip_chars[1])
+static inline wchar_t vfat_replace_char(wchar_t w)
+{
+ return (w == 0x005B) /* [ */ || (w == 0x005D) /* ] */
+ || (w == 0x003B) /* ; */ || (w == 0x002C) /* , */
+ || (w == 0x002B) /* + */ || (w == 0x003D);/* = */
+}
-static inline wchar_t *vfat_unistrchr(const wchar_t *s, const wchar_t c)
+static wchar_t vfat_skip_char(wchar_t w)
{
- for(; *s != c; ++s)
- if (*s == 0)
- return NULL;
- return (wchar_t *) s;
+ return (w == 0x002E) /* . */ || (w == 0x0020);/* <space> */
}
static inline int vfat_is_used_badchars(const wchar_t *s, int len)
@@ -192,7 +185,7 @@ static inline int vfat_is_used_badchars(
int i;
for (i = 0; i < len; i++)
- if (s[i] < 0x0020 || IS_BADCHAR(s[i]))
+ if (vfat_bad_char(s[i]))
return -EINVAL;
return 0;
}
@@ -291,11 +284,11 @@ static inline int to_shortname_char(stru
{
int len;
- if (IS_SKIPCHAR(*src)) {
+ if (vfat_skip_char(*src)) {
info->valid = 0;
return 0;
}
- if (IS_REPLACECHAR(*src)) {
+ if (vfat_replace_char(*src)) {
info->valid = 0;
buf[0] = '_';
return 1;
@@ -375,7 +368,7 @@ static int vfat_create_shortname(struct
*/
name_start = &uname[0];
while (name_start < ext_start) {
- if (!IS_SKIPCHAR(*name_start))
+ if (!vfat_skip_char(*name_start))
break;
name_start++;
}
_
next prev parent reply other threads:[~2005-01-17 17:44 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-17 17:39 [PATCH 1/13] FAT: kill fatfs_syms.c OGAWA Hirofumi
2005-01-17 17:40 ` [PATCH 2/13] FAT: merge msdos_fs_{i,sb}.h into msdos_fs.h OGAWA Hirofumi
2005-01-17 17:41 ` OGAWA Hirofumi [this message]
2005-01-17 17:42 ` [PATCH 4/13] FAT: Return better error codes from vfat_valid_longname() OGAWA Hirofumi
2005-01-17 17:42 ` [PATCH 5/13] FAT: Manually inline shortname_info_to_lcase() OGAWA Hirofumi
2005-01-17 17:44 ` [PATCH 6/13] FAT: use vprintk instead of snprintf with static buffer OGAWA Hirofumi
2005-01-17 17:44 ` [PATCH 7/13] FAT: kill unnecessary kmap() OGAWA Hirofumi
2005-01-17 17:47 ` [PATCH 8/13] FAT: fs/fat/cache.c: make __fat_access static OGAWA Hirofumi
2005-01-17 17:48 ` [PATCH 9/13] FAT: Lindent fs/msdos/namei.c OGAWA Hirofumi
2005-01-17 17:49 ` [PATCH 10/13] FAT: Lindent fs/vfat/namei.c OGAWA Hirofumi
2005-01-17 17:50 ` [PATCH 11/13] FAT: fs/fat/* cleanup OGAWA Hirofumi
2005-01-17 17:52 ` [PATCH 12/13] FAT: reserved clusters cleanup OGAWA Hirofumi
2005-01-17 17:54 ` [PATCH 13/13] FAT: show current nls config even if it's default OGAWA Hirofumi
2005-01-17 19:12 ` [PATCH 10/13] FAT: Lindent fs/vfat/namei.c Sytse Wielinga
2005-01-18 1:06 ` OGAWA Hirofumi
2005-01-18 2:03 ` [PATCH 4/13] FAT: Return better error codes from vfat_valid_longname() Rogério Brito
2005-01-18 2:29 ` OGAWA Hirofumi
2005-01-18 2:57 ` Rogério Brito
2005-01-17 18:33 ` [PATCH 3/13] FAT: IS_BADCHAR/IS_REPLACECHR/IS_SKIPCHAR cleanup Al Viro
2005-01-18 1:04 ` OGAWA Hirofumi
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=87hdlgoswe.fsf_-_@devron.myhome.or.jp \
--to=hirofumi@mail.parknet.co.jp \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@osdl.org \
/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
Powered by JetHome