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

Function cache_fplookup_skip_slashes

freebsd/kern/vfs_cache.c:5341–5375  ·  view source on GitHub ↗

* Skip spurious slashes in a pathname (e.g., "foo///bar") and retry. * * Lockless lookup tries to elide checking for spurious slashes and should they * be present is guaranteed to fail to find an entry. In this case the caller * must check if the name starts with a slash and call this routine. It is * going to fast forward across the spurious slashes and set the state up for * retry. */

Source from the content-addressed store, hash-verified

5339 * retry.
5340 */
5341static int __noinline
5342cache_fplookup_skip_slashes(struct cache_fpl *fpl)
5343{
5344 struct nameidata *ndp;
5345 struct componentname *cnp;
5346
5347 ndp = fpl->ndp;
5348 cnp = fpl->cnp;
5349
5350 MPASS(*(cnp->cn_nameptr) == '/');
5351 do {
5352 cnp->cn_nameptr++;
5353 cache_fpl_pathlen_dec(fpl);
5354 } while (*(cnp->cn_nameptr) == '/');
5355
5356 /*
5357 * Go back to one slash so that cache_fplookup_parse_advance has
5358 * something to skip.
5359 */
5360 cnp->cn_nameptr--;
5361 cache_fpl_pathlen_inc(fpl);
5362
5363 /*
5364 * cache_fplookup_parse_advance starts from ndp->ni_next
5365 */
5366 ndp->ni_next = cnp->cn_nameptr;
5367
5368 /*
5369 * See cache_fplookup_dot.
5370 */
5371 fpl->tvp = fpl->dvp;
5372 fpl->tvp_seqc = fpl->dvp_seqc;
5373
5374 return (0);
5375}
5376
5377/*
5378 * Handle trailing slashes (e.g., "foo/").

Callers 1

cache_fplookup_noentryFunction · 0.85

Calls 2

cache_fpl_pathlen_decFunction · 0.85
cache_fpl_pathlen_incFunction · 0.85

Tested by

no test coverage detected