diff options
Diffstat (limited to 'fs/fat/namei_vfat.c')
-rw-r--r-- | fs/fat/namei_vfat.c | 55 |
1 files changed, 35 insertions, 20 deletions
diff --git a/fs/fat/namei_vfat.c b/fs/fat/namei_vfat.c index b936703b8924..e3ffc5e12332 100644 --- a/fs/fat/namei_vfat.c +++ b/fs/fat/namei_vfat.c | |||
@@ -43,6 +43,9 @@ static int vfat_revalidate_shortname(struct dentry *dentry) | |||
43 | 43 | ||
44 | static int vfat_revalidate(struct dentry *dentry, struct nameidata *nd) | 44 | static int vfat_revalidate(struct dentry *dentry, struct nameidata *nd) |
45 | { | 45 | { |
46 | if (nd->flags & LOOKUP_RCU) | ||
47 | return -ECHILD; | ||
48 | |||
46 | /* This is not negative dentry. Always valid. */ | 49 | /* This is not negative dentry. Always valid. */ |
47 | if (dentry->d_inode) | 50 | if (dentry->d_inode) |
48 | return 1; | 51 | return 1; |
@@ -51,6 +54,9 @@ static int vfat_revalidate(struct dentry *dentry, struct nameidata *nd) | |||
51 | 54 | ||
52 | static int vfat_revalidate_ci(struct dentry *dentry, struct nameidata *nd) | 55 | static int vfat_revalidate_ci(struct dentry *dentry, struct nameidata *nd) |
53 | { | 56 | { |
57 | if (nd->flags & LOOKUP_RCU) | ||
58 | return -ECHILD; | ||
59 | |||
54 | /* | 60 | /* |
55 | * This is not negative dentry. Always valid. | 61 | * This is not negative dentry. Always valid. |
56 | * | 62 | * |
@@ -85,22 +91,26 @@ static int vfat_revalidate_ci(struct dentry *dentry, struct nameidata *nd) | |||
85 | } | 91 | } |
86 | 92 | ||
87 | /* returns the length of a struct qstr, ignoring trailing dots */ | 93 | /* returns the length of a struct qstr, ignoring trailing dots */ |
88 | static unsigned int vfat_striptail_len(struct qstr *qstr) | 94 | static unsigned int __vfat_striptail_len(unsigned int len, const char *name) |
89 | { | 95 | { |
90 | unsigned int len = qstr->len; | 96 | while (len && name[len - 1] == '.') |
91 | |||
92 | while (len && qstr->name[len - 1] == '.') | ||
93 | len--; | 97 | len--; |
94 | return len; | 98 | return len; |
95 | } | 99 | } |
96 | 100 | ||
101 | static unsigned int vfat_striptail_len(const struct qstr *qstr) | ||
102 | { | ||
103 | return __vfat_striptail_len(qstr->len, qstr->name); | ||
104 | } | ||
105 | |||
97 | /* | 106 | /* |
98 | * Compute the hash for the vfat name corresponding to the dentry. | 107 | * Compute the hash for the vfat name corresponding to the dentry. |
99 | * Note: if the name is invalid, we leave the hash code unchanged so | 108 | * Note: if the name is invalid, we leave the hash code unchanged so |
100 | * that the existing dentry can be used. The vfat fs routines will | 109 | * that the existing dentry can be used. The vfat fs routines will |
101 | * return ENOENT or EINVAL as appropriate. | 110 | * return ENOENT or EINVAL as appropriate. |
102 | */ | 111 | */ |
103 | static int vfat_hash(struct dentry *dentry, struct qstr *qstr) | 112 | static int vfat_hash(const struct dentry *dentry, const struct inode *inode, |
113 | struct qstr *qstr) | ||
104 | { | 114 | { |
105 | qstr->hash = full_name_hash(qstr->name, vfat_striptail_len(qstr)); | 115 | qstr->hash = full_name_hash(qstr->name, vfat_striptail_len(qstr)); |
106 | return 0; | 116 | return 0; |
@@ -112,9 +122,10 @@ static int vfat_hash(struct dentry *dentry, struct qstr *qstr) | |||
112 | * that the existing dentry can be used. The vfat fs routines will | 122 | * that the existing dentry can be used. The vfat fs routines will |
113 | * return ENOENT or EINVAL as appropriate. | 123 | * return ENOENT or EINVAL as appropriate. |
114 | */ | 124 | */ |
115 | static int vfat_hashi(struct dentry *dentry, struct qstr *qstr) | 125 | static int vfat_hashi(const struct dentry *dentry, const struct inode *inode, |
126 | struct qstr *qstr) | ||
116 | { | 127 | { |
117 | struct nls_table *t = MSDOS_SB(dentry->d_inode->i_sb)->nls_io; | 128 | struct nls_table *t = MSDOS_SB(dentry->d_sb)->nls_io; |
118 | const unsigned char *name; | 129 | const unsigned char *name; |
119 | unsigned int len; | 130 | unsigned int len; |
120 | unsigned long hash; | 131 | unsigned long hash; |
@@ -133,16 +144,18 @@ static int vfat_hashi(struct dentry *dentry, struct qstr *qstr) | |||
133 | /* | 144 | /* |
134 | * Case insensitive compare of two vfat names. | 145 | * Case insensitive compare of two vfat names. |
135 | */ | 146 | */ |
136 | static int vfat_cmpi(struct dentry *dentry, struct qstr *a, struct qstr *b) | 147 | static int vfat_cmpi(const struct dentry *parent, const struct inode *pinode, |
148 | const struct dentry *dentry, const struct inode *inode, | ||
149 | unsigned int len, const char *str, const struct qstr *name) | ||
137 | { | 150 | { |
138 | struct nls_table *t = MSDOS_SB(dentry->d_inode->i_sb)->nls_io; | 151 | struct nls_table *t = MSDOS_SB(parent->d_sb)->nls_io; |
139 | unsigned int alen, blen; | 152 | unsigned int alen, blen; |
140 | 153 | ||
141 | /* A filename cannot end in '.' or we treat it like it has none */ | 154 | /* A filename cannot end in '.' or we treat it like it has none */ |
142 | alen = vfat_striptail_len(a); | 155 | alen = vfat_striptail_len(name); |
143 | blen = vfat_striptail_len(b); | 156 | blen = __vfat_striptail_len(len, str); |
144 | if (alen == blen) { | 157 | if (alen == blen) { |
145 | if (nls_strnicmp(t, a->name, b->name, alen) == 0) | 158 | if (nls_strnicmp(t, name->name, str, alen) == 0) |
146 | return 0; | 159 | return 0; |
147 | } | 160 | } |
148 | return 1; | 161 | return 1; |
@@ -151,15 +164,17 @@ static int vfat_cmpi(struct dentry *dentry, struct qstr *a, struct qstr *b) | |||
151 | /* | 164 | /* |
152 | * Case sensitive compare of two vfat names. | 165 | * Case sensitive compare of two vfat names. |
153 | */ | 166 | */ |
154 | static int vfat_cmp(struct dentry *dentry, struct qstr *a, struct qstr *b) | 167 | static int vfat_cmp(const struct dentry *parent, const struct inode *pinode, |
168 | const struct dentry *dentry, const struct inode *inode, | ||
169 | unsigned int len, const char *str, const struct qstr *name) | ||
155 | { | 170 | { |
156 | unsigned int alen, blen; | 171 | unsigned int alen, blen; |
157 | 172 | ||
158 | /* A filename cannot end in '.' or we treat it like it has none */ | 173 | /* A filename cannot end in '.' or we treat it like it has none */ |
159 | alen = vfat_striptail_len(a); | 174 | alen = vfat_striptail_len(name); |
160 | blen = vfat_striptail_len(b); | 175 | blen = __vfat_striptail_len(len, str); |
161 | if (alen == blen) { | 176 | if (alen == blen) { |
162 | if (strncmp(a->name, b->name, alen) == 0) | 177 | if (strncmp(name->name, str, alen) == 0) |
163 | return 0; | 178 | return 0; |
164 | } | 179 | } |
165 | return 1; | 180 | return 1; |
@@ -757,11 +772,11 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry, | |||
757 | 772 | ||
758 | out: | 773 | out: |
759 | unlock_super(sb); | 774 | unlock_super(sb); |
760 | dentry->d_op = sb->s_root->d_op; | 775 | d_set_d_op(dentry, sb->s_root->d_op); |
761 | dentry->d_time = dentry->d_parent->d_inode->i_version; | 776 | dentry->d_time = dentry->d_parent->d_inode->i_version; |
762 | dentry = d_splice_alias(inode, dentry); | 777 | dentry = d_splice_alias(inode, dentry); |
763 | if (dentry) { | 778 | if (dentry) { |
764 | dentry->d_op = sb->s_root->d_op; | 779 | d_set_d_op(dentry, sb->s_root->d_op); |
765 | dentry->d_time = dentry->d_parent->d_inode->i_version; | 780 | dentry->d_time = dentry->d_parent->d_inode->i_version; |
766 | } | 781 | } |
767 | return dentry; | 782 | return dentry; |
@@ -1063,9 +1078,9 @@ static int vfat_fill_super(struct super_block *sb, void *data, int silent) | |||
1063 | } | 1078 | } |
1064 | 1079 | ||
1065 | if (MSDOS_SB(sb)->options.name_check != 's') | 1080 | if (MSDOS_SB(sb)->options.name_check != 's') |
1066 | sb->s_root->d_op = &vfat_ci_dentry_ops; | 1081 | d_set_d_op(sb->s_root, &vfat_ci_dentry_ops); |
1067 | else | 1082 | else |
1068 | sb->s_root->d_op = &vfat_dentry_ops; | 1083 | d_set_d_op(sb->s_root, &vfat_dentry_ops); |
1069 | 1084 | ||
1070 | unlock_super(sb); | 1085 | unlock_super(sb); |
1071 | return 0; | 1086 | return 0; |