MCPcopy Create free account
hub / github.com/F-Stack/f-stack / zap_name_alloc

Function zap_name_alloc

freebsd/contrib/openzfs/module/zfs/zap_micro.c:173–230  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

171}
172
173zap_name_t *
174zap_name_alloc(zap_t *zap, const char *key, matchtype_t mt)
175{
176 zap_name_t *zn = kmem_alloc(sizeof (zap_name_t), KM_SLEEP);
177
178 zn->zn_zap = zap;
179 zn->zn_key_intlen = sizeof (*key);
180 zn->zn_key_orig = key;
181 zn->zn_key_orig_numints = strlen(zn->zn_key_orig) + 1;
182 zn->zn_matchtype = mt;
183 zn->zn_normflags = zap->zap_normflags;
184
185 /*
186 * If we're dealing with a case sensitive lookup on a mixed or
187 * insensitive fs, remove U8_TEXTPREP_TOUPPER or the lookup
188 * will fold case to all caps overriding the lookup request.
189 */
190 if (mt & MT_MATCH_CASE)
191 zn->zn_normflags &= ~U8_TEXTPREP_TOUPPER;
192
193 if (zap->zap_normflags) {
194 /*
195 * We *must* use zap_normflags because this normalization is
196 * what the hash is computed from.
197 */
198 if (zap_normalize(zap, key, zn->zn_normbuf,
199 zap->zap_normflags) != 0) {
200 zap_name_free(zn);
201 return (NULL);
202 }
203 zn->zn_key_norm = zn->zn_normbuf;
204 zn->zn_key_norm_numints = strlen(zn->zn_key_norm) + 1;
205 } else {
206 if (mt != 0) {
207 zap_name_free(zn);
208 return (NULL);
209 }
210 zn->zn_key_norm = zn->zn_key_orig;
211 zn->zn_key_norm_numints = zn->zn_key_orig_numints;
212 }
213
214 zn->zn_hash = zap_hash(zn);
215
216 if (zap->zap_normflags != zn->zn_normflags) {
217 /*
218 * We *must* use zn_normflags because this normalization is
219 * what the matching is based on. (Not the hash!)
220 */
221 if (zap_normalize(zap, key, zn->zn_normbuf,
222 zn->zn_normflags) != 0) {
223 zap_name_free(zn);
224 return (NULL);
225 }
226 zn->zn_key_norm_numints = strlen(zn->zn_key_norm) + 1;
227 }
228
229 return (zn);
230}

Callers 10

mzap_openFunction · 0.85
mzap_upgradeFunction · 0.85
zap_lookup_implFunction · 0.85
zap_prefetchFunction · 0.85
zap_lengthFunction · 0.85
zap_add_implFunction · 0.85
zap_updateFunction · 0.85
zap_remove_implFunction · 0.85

Calls 3

zap_normalizeFunction · 0.85
zap_name_freeFunction · 0.85
zap_hashFunction · 0.85

Tested by

no test coverage detected