11 static inline int not_allowed_char(
unsigned char c)
13 return c<
' ' || c==
'"' || c==
'*' || c==
'/' || c==
':' || c==
'<' ||
14 c==
'>' || c==
'?' || c==
'\\' || c==
'|';
17 static inline int no_dos_char(
unsigned char c)
19 return c==
'+' || c==
',' || c==
';' || c==
'=' || c==
'[' || c==
']';
22 static inline unsigned char upcase(
unsigned char *dir,
unsigned char a)
24 if (a<128 || a==255)
return a>=
'a' && a<=
'z' ? a - 0x20 :
a;
29 unsigned char hpfs_upcase(
unsigned char *dir,
unsigned char a)
31 return upcase(dir, a);
34 static inline unsigned char locase(
unsigned char *dir,
unsigned char a)
36 if (a<128 || a==255)
return a>=
'A' && a<=
'Z' ? a + 0x20 :
a;
47 for (i = 0; i < *len; i++)
if (not_allowed_char(name[i]))
return -
EINVAL;
48 if (*len == 1)
if (name[0] ==
'.')
return -
EINVAL;
49 if (*len == 2)
if (name[0] ==
'.' && name[1] ==
'.')
return -
EINVAL;
54 unsigned len,
int lc,
int lng)
59 printk(
"HPFS: Long name flag mismatch - name ");
60 for (i=0; i<len; i++)
printk(
"%c", from[i]);
61 printk(
" misidentified as %s.\n", lng ?
"short" :
"long");
62 printk(
"HPFS: It's nothing serious. It could happen because of bug in OS/2.\nHPFS: Set checks=normal to disable this message.\n");
66 printk(
"HPFS: can't allocate memory for name conversion buffer\n");
69 for (i = 0; i < len; i++) to[i] = locase(hpfs_sb(s)->
sb_cp_table,from[i]);
74 const unsigned char *n1,
unsigned l1,
75 const unsigned char *n2,
unsigned l2,
int last)
77 unsigned l = l1 < l2 ? l1 :
l2;
80 for (i = 0; i <
l; i++) {
81 unsigned char c1 = upcase(hpfs_sb(s)->
sb_cp_table,n1[i]);
82 unsigned char c2 = upcase(hpfs_sb(s)->
sb_cp_table,n2[i]);
83 if (c1 < c2)
return -1;
84 if (c1 > c2)
return 1;
86 if (l1 < l2)
return -1;
87 if (l1 > l2)
return 1;
94 for (i = 0; i < len && name[
i] !=
'.'; i++)
95 if (no_dos_char(name[i]))
return 1;
96 if (!i || i > 8)
return 1;
97 if (i == len)
return 0;
98 for (j = i + 1; j < len; j++)
99 if (name[j] ==
'.' || no_dos_char(name[i]))
return 1;
108 if (*len == 1 && name[0] ==
'.')
return;
109 if (*len == 2 && name[0] ==
'.' && name[1] ==
'.')
return;
110 while (*len && (name[*len - 1] ==
'.' || name[*len - 1] ==
' '))