/*
* linux/fs/hpfs/name.c
*
* Mikulas Patocka (mikulas@artax.karlin.mff.cuni.cz), 1998-1999
*
* operations with filenames
*/
#include "hpfs_fn.h"
static inline int not_allowed_char(unsigned char c)
{
return c<' ' || c=='"' || c=='*' || c=='/' || c==':' || c=='<' ||
c=='>' || c=='?' || c=='\\' || c=='|';
}
static inline int no_dos_char(unsigned char c)
{ /* Characters that are allowed in HPFS but not in DOS */
return c=='+' || c==',' || c==';' || c=='=' || c=='[' || c==']';
}
static inline unsigned char upcase(unsigned char *dir, unsigned char a)
{
if (a<128 || a==255) return a>='a' && a<='z' ? a - 0x20 : a;
if (!dir) return a;
return dir[a-128];
}
unsigned char hpfs_upcase(unsigned char *dir, unsigned char a)
{
return upcase(dir, a);
}
static inline unsigned char locase(unsigned char *dir, unsigned char a)
{
if (a<128 || a==255) return a>='A' && a<='Z' ? a + 0x20 : a;
if (!dir) return a;
return dir[a];
}
int hpfs_chk_name(const unsigned char *name, unsigned *len)
{
int i;
if (*len > 254) return -ENAMETOOLONG;
hpfs_adjust_length(name, len);
if (!*len) return -EINVAL;
for (i = 0; i < *len; i++) if (not_allowed_char(name[i])) return -EINVAL;
if (*len == 1) if (name[0] == '.') return -EINVAL;
if (*len == 2) if (name[0] == '.' && name[1] == '.') return -EINVAL;
return 0;
}
unsigned char *hpfs_translate_name(struct super_block *s, unsigned char *from,
unsigned len, int lc, int lng)
{
unsigned char *to;
int i;
if (hpfs_sb(s)->sb_chk >= 2) if (hpfs_is_name_long(from, len) != lng) {
pr_err("Long name flag mismatch - name ");
for (i = 0; i < len; i++)
pr_cont("%c", from[i]);
pr_cont(" misidentified as %s.\n", lng ? "short" : "long");
pr_err("It's nothing serious. It could happen because of bug in OS/2.\nSet checks=normal to disable this message.\n");
}
if (!lc) return from;
if (!(to = kmalloc(len, GFP_KERNEL))) {
pr_err("can't allocate memory for name conversion buffer\n");
return from;
}
for (i = 0; i < len; i++) to[i] = locase(hpfs_sb(s)->sb_cp_table,from[i]);
return to;
}
int hpfs_compare_names(struct super_block *s,
const unsigned char *n1, unsigned l1,
const unsigned char *n2, unsigned l2, int last)
{
unsigned l = l1 < l2 ? l1 : l2;
unsigned i;
if (last) return -1;
for (i = 0; i < l; i++) {
unsigned char c1 = upcase(hpfs_sb(s)->sb_cp_table,n1[i]);
unsigned char c2 = upcase(hpfs_sb(s)->sb_cp_table,n2[i]);
if (c1 < c2) return -1;
if (c1 > c2) return 1;
}
if (l1 < l2) return -1;
if (l1 > l2) return 1;
return 0;
}
int hpfs_is_name_long(const unsigned char *name, unsigned len)
{
int i,j;
for (i = 0; i < len && name[i] != '.'; i++)
if (no_dos_char(name[i])) return 1;
if (!i || i > 8) return 1;
if (i == len) return 0;
for (j = i + 1; j < len; j++)
if (name[j] == '.' || no_dos_char(name[i])) return 1;
return j - i > 4;
}
/* OS/2 clears dots and spaces at the end of file name, so we have to */
void hpfs_adjust_length(const unsigned char *name, unsigned *len)
{
if (!*len) return;
if (*len == 1 && name[0] == '.') return;
if (*len == 2 && name[0] == '.' && name[1] == '.') return;
while (*len && (name[*len - 1] == '.' || name[*len - 1] == ' '))
(*len)--;
}
Mode | Name | Size | |
-rw-r--r-- | alphascale,asm9260.h | 2695 | logplain |
-rw-r--r-- | at91.h | 751 | logplain |
-rw-r--r-- | ath79-clk.h | 479 | logplain |
-rw-r--r-- | axis,artpec6-clkctrl.h | 1112 | logplain |
-rw-r--r-- | bcm-cygnus.h | 3135 | logplain |
-rw-r--r-- | bcm-ns2.h | 2915 | logplain |
-rw-r--r-- | bcm-nsp.h | 2148 | logplain |
-rw-r--r-- | bcm21664.h | 1984 | logplain |
-rw-r--r-- | bcm281xx.h | 2456 | logplain |
-rw-r--r-- | bcm2835-aux.h | 635 | logplain |
-rw-r--r-- | bcm2835.h | 1962 | logplain |
-rw-r--r-- | berlin2.h | 1034 | logplain |
-rw-r--r-- | berlin2q.h | 695 | logplain |
-rw-r--r-- | clps711x-clock.h | 718 | logplain |
-rw-r--r-- | efm32-cmu.h | 1112 | logplain |
-rw-r--r-- | exynos-audss-clk.h | 597 | logplain |
-rw-r--r-- | exynos3250.h | 9083 | logplain |
-rw-r--r-- | exynos4.h | 8284 | logplain |
-rw-r--r-- | exynos4415.h | 9828 | logplain |
-rw-r--r-- | exynos5250.h | 4616 | logplain |
-rw-r--r-- | exynos5260-clk.h | 14876 | logplain |
-rw-r--r-- | exynos5410.h | 1689 | logplain |
-rw-r--r-- | exynos5420.h | 6857 | logplain |
-rw-r--r-- | exynos5433.h | 45372 | logplain |
-rw-r--r-- | exynos5440.h | 1141 | logplain |
-rw-r--r-- | exynos7-clk.h | 5281 | logplain |
-rw-r--r-- | gxbb-aoclkc.h | 2866 | logplain |
-rw-r--r-- | gxbb-clkc.h | 592 | logplain |
-rw-r--r-- | hi3516cv300-clock.h | 1668 | logplain |
-rw-r--r-- | hi3519-clock.h | 1328 | logplain |
-rw-r--r-- | hi3620-clock.h | 4496 | logplain |
-rw-r--r-- | hi6220-clock.h | 4508 | logplain |
-rw-r--r-- | hip04-clock.h | 1137 | logplain |
-rw-r--r-- | histb-clock.h | 2012 | logplain |
-rw-r--r-- | hix5hd2-clock.h | 2415 | logplain |
-rw-r--r-- | imx1-clock.h | 1055 | logplain |
-rw-r--r-- | imx21-clock.h | 2461 | logplain |
-rw-r--r-- | imx27-clock.h | 3494 | logplain |
-rw-r--r-- | imx5-clock.h | 7212 | logplain |
-rw-r--r-- | imx6qdl-clock.h | 9593 | logplain |
-rw-r--r-- | imx6sl-clock.h | 5849 | logplain |
-rw-r--r-- | imx6sx-clock.h | 9099 | logplain |
-rw-r--r-- | imx6ul-clock.h | 8203 | logplain |
-rw-r--r-- | imx7d-clock.h | 15974 | logplain |
-rw-r--r-- | jz4740-cgu.h | 1028 | logplain |
-rw-r--r-- | jz4780-cgu.h | 2470 | logplain |
-rw-r--r-- | lpc18xx-ccu.h | 2134 | logplain |
-rw-r--r-- | lpc18xx-cgu.h | 1142 | logplain |
-rw-r--r-- | lpc32xx-clock.h | 1633 | logplain |
-rw-r--r-- | lsi,axm5516-clks.h | 974 | logplain |
-rw-r--r-- | marvell,mmp2.h | 2022 | logplain |
-rw-r--r-- | marvell,pxa168.h | 1654 | logplain |
-rw-r--r-- | marvell,pxa1928.h | 1535 | logplain |
-rw-r--r-- | marvell,pxa910.h | 1598 | logplain |
-rw-r--r-- | maxim,max77620.h | 632 | logplain |
-rw-r--r-- | maxim,max77686.h | 648 | logplain |
-rw-r--r-- | maxim,max77802.h | 630 | logplain |
-rw-r--r-- | meson8b-clkc.h | 523 | logplain |
-rw-r--r-- | microchip,pic32-clock.h | 1150 | logplain |
-rw-r--r-- | mpc512x-clock.h | 2236 | logplain |
-rw-r--r-- | mt2701-clk.h | 13832 | logplain |
-rw-r--r-- | mt8135-clk.h | 5641 | logplain |
-rw-r--r-- | mt8173-clk.h | 9293 | logplain |
-rw-r--r-- | oxsemi,ox810se.h | 1002 | logplain |
-rw-r--r-- | oxsemi,ox820.h | 1203 | logplain |
-rw-r--r-- | pistachio-clk.h | 4863 | logplain |
-rw-r--r-- | pxa-clock.h | 1715 | logplain |
-rw-r--r-- | qcom,gcc-apq8084.h | 12872 | logplain |
-rw-r--r-- | qcom,gcc-ipq4019.h | 5423 | logplain |
-rw-r--r-- | qcom,gcc-ipq806x.h | 8574 | logplain |
-rw-r--r-- | qcom,gcc-mdm9615.h | 9497 | logplain |
-rw-r--r-- | qcom,gcc-msm8660.h | 7932 | logplain |
-rw-r--r-- | qcom,gcc-msm8916.h | 6190 | logplain |
-rw-r--r-- | qcom,gcc-msm8960.h | 9342 | logplain |
-rw-r--r-- | qcom,gcc-msm8974.h | 12340 | logplain |
-rw-r--r-- | qcom,gcc-msm8994.h | 4858 | logplain |
-rw-r--r-- | qcom,gcc-msm8996.h | 12575 | logplain |
-rw-r--r-- | qcom,lcc-ipq806x.h | 899 | logplain |
-rw-r--r-- | qcom,lcc-mdm9615.h | 1701 | logplain |
-rw-r--r-- | qcom,lcc-msm8960.h | 1616 | logplain |
-rw-r--r-- | qcom,mmcc-apq8084.h | 5722 | logplain |
-rw-r--r-- | qcom,mmcc-msm8960.h | 4109 | logplain |
-rw-r--r-- | qcom,mmcc-msm8974.h | 5223 | logplain |
-rw-r--r-- | qcom,mmcc-msm8996.h | 9403 | logplain |
-rw-r--r-- | qcom,rpmcc.h | 2101 | logplain |
-rw-r--r-- | r7s72100-clock.h | 1218 | logplain |
-rw-r--r-- | r8a73a4-clock.h | 1596 | logplain |
-rw-r--r-- | r8a7740-clock.h | 1992 | logplain |
-rw-r--r-- | r8a7743-cpg-mssr.h | 1269 | logplain |
-rw-r--r-- | r8a7745-cpg-mssr.h | 1298 | logplain |
-rw-r--r-- | r8a7778-clock.h | 1855 | logplain |
-rw-r--r-- | r8a7779-clock.h | 1647 | logplain |
-rw-r--r-- | r8a7790-clock.h | 4367 | logplain |
-rw-r--r-- | r8a7791-clock.h | 4388 | logplain |
-rw-r--r-- | r8a7792-clock.h | 2562 | logplain |
-rw-r--r-- | r8a7793-clock.h | 4561 | logplain |
-rw-r--r-- | r8a7794-clock.h | 3679 | logplain |
-rw-r--r-- | r8a7795-cpg-mssr.h | 1890 | logplain |
-rw-r--r-- | r8a7796-cpg-mssr.h | 2066 | logplain |
-rw-r--r-- | renesas-cpg-mssr.h | 542 | logplain |
-rw-r--r-- | rk1108-cru.h | 6605 | logplain |
-rw-r--r-- | rk3036-cru.h | 4584 | logplain |
-rw-r--r-- | rk3066a-cru.h | 1068 | logplain |
-rw-r--r-- | rk3188-cru-common.h | 6105 | logplain |
-rw-r--r-- | rk3188-cru.h | 1435 | logplain |