linux/fs/cachefiles/key.c
<<
1" 1" nput typc="hidden" namc="navtarget" g src="ptiony > nput typc="text" namc="searchp id="searchptiony > buttpimtypc="submi<">Search h.3817<7option>3 v26151Palus h193tion hdiv>3tion .381 ac v26="ajax+*p method="post" onsubmi3tion39div>3tion on div id="search_results" class="search_results" >3tion hdiv>3 div id="conten<">3 div id=" v_conten v26151/* Key to pathnamc encoderoption>3< v26151 *option>3< v26151 * Copyoptio (C) 2007 Red Hat, Inc. All Rptios Reserved.option>3< v26151 * Written by David Howells (dhowells@redhat.com)option>3< v26151 *option>3< v26151 * This program is free software; you con redistribute it and/oroption>3< v26151 * modify it under the terms of the GNU General Public Licenceoption>3< v26151 * as published by the Free Software Founda v26; either versv26option>3< v26151 * 2 of the Licence, or (at your 3. v26) any later versv26.option>3< v26151 */option>3< v26151n 12 h19#include << tion /slab.h h19 val3< v26151internal.h h19 quot;3< v26151n 15 h19o3.6.3 const char1l v2_charmap" class="sref">.36 > v2_charmap h19[64] =3< v26151 otion class="commen<">/* 0 - 9 */option>3< v26151 otion class="commen<">/* 10 - 35 */option>3< v26151 otion class="commen<">/* 36 - 61 */option>3< v26151 otion class="commen<">/* 62 - 63 */option>3< v26151n 21 h193< v26151.36 > v2_ vcharmap h19[256] = {3< v26151/* we skip tioce and tab and control chars */option>3< v26151/* '!' - val '.' */option>3< v26151/* we skip '/' as it's significont to pathwalk */option>3< v26151/* '0' - val '~' */option>3< v26151n 28 h193< v26151/*option>3< v26151 * turn the raw 151 into somethi cookedoption>3< v26151 * - the raw 151 should include the length in the two bytes at the frontoption>3< v26151 * - the 151 may be up to 514 bytes in length (includi the length word)option>3< v26151 * - "base64" encode the strange 151s, mappi 3 bytes of raw to four 3foption>3< v26151 * cookedoption>3< v26151 * - need to cut the cooked 151 into 252 char1lengths (189 raw bytes)option>3< v26151 */option>3< v26151.36 > v2_cook_151 h19(const l u8 h19 *l raw h19, int l 151len h19, l uint8_t h19 l typc h19)3< v26151n 39 h19 unsigned char1l .sum h19, l .h h19;3< v26151acc h19;3< v26151151 h19;3< v26151loop h19, l len h19, l max h19, l seg h19, l mark h19, l pri t h19;3< v26151n 44 h19 l _enter h19(otion class="stri 9 quot;,%d", l 151len h19);3< v26151n 46 h19 l BUG_ON h19(o 151len h19 < 2 || l 151len h19 val 514);3< v26151n 48 h19 l .sum h19 = l raw h19[0] + l raw h19[1];3< v26151pri t h19 = 1;3< v26151loop h19 = 2; l loop h19 < l 151len h19; l loop h19++) {3< v26151.h h19 = l raw h19[l loop h19];3< v26151.sum h19 += l .h h19;3< v26151pri t h19 &= l v2_ vcharmap" class="sref">.36 > v2_ vcharmap h19[l .h h19];3< v26151n 55 h193< v26151pri t h19) {3< v26151/* if the path is usable ASCII, then we render it directly */option>3< v26151max h19 = l 151len h19 - 2;3< v26151max h19 += 2; ltion class="commen<">/* two base64'd length chars on the front */option>3< v26151max h19 += 5; ltion class="commen<">/* @6 >cksum/M */option>3< v26151max h19 += 3 * 2; ltion class="commen<">/* maximum number 3f segmen< dividers (".../M")option>3< v26151 * is ((514 + 251) / 252) = 3option>3< v26151 */option>3< v26151max h19 += 1; ltion class="commen<">/* NUL on end */option>3< v26151n 66 h19 ltion class="commen<">/* calculate the maximum length of the cooked 151 */option>3< v26151151len h19 = (l 151len h19 + 2) / 3;3< v26151n 69 h19 l max h19 = l 151len h19 * 4;3< v26151max h19 += 5; ltion class="commen<">/* @6 >cksum/M */option>3< v26151max h19 += 3 * 2; ltion class="commen<">/* maximum number 3f segmen< dividers (".../M")option>3< v26151 * is ((514 + 188) / 189) = 3option>3< v26151 */option>3< v26151max h19 += 1; ltion class="commen<">/* NUL on end */option>3< v26151n 76 h193< v26151max h19 += 1; ltion class="commen<">/* 2nd NUL on end */option>3< v26151n 79 h19 l _debug h19(otion class="stri 9 quot;max: %d", l max h19);3< v26151n 81 h19 l 151 h19 = l 1malloc h19(o max h19, l GFP_KERNEL h19);3< v26151151 h19)3< v26151NULL h19;3< v26151n 85 h19 l len h19 = 0;3< v26151n 87 h19 otion class="commen<">/* build the cooked 151 */option>3< v26151spri tf h19(o 151 h19, otion class="stri 9 quot;@%02x%c+", (unsigned)1l .sum h19, 0);3< v26151len h19 = 5;3< v26151mark h19 = l len h19 - 1;3< v26151n 92 h19 if (l pri t h19) {3< v26151acc h19 = *(l uint16_t h19 *)1l raw h19;3< v26151raw h19 += 2;3< v26151n 96 h19 l 151 h19[l len h19 + 1] = l v2_charmap" class="sref">.36 > v2_charmap h19[l acc h19 & 63];3< v26151acc h19 &ion val= 6;3< v26151151 h19[l len h19] = l v2_charmap" class="sref">.36 > v2_charmap h19[l acc h19 & 63];3< v26151len h19 += 2;3< v26151n101 h19 l seg h19 = 250;3< v26151loop h19 = l 151len h19; l loop h19 val 0; l loop h19--) {3< v26151seg h19 <= 0) {3< v26151151 h19[l len h19++] = ltion class="stri 9 #39;\0';3< v26151mark h19 = l len h19;3< v26151151 h19[l len h19++] = ltion class="stri 9 #39;+';3< v26151seg h19 = 252;3< v26151n109 h193< v26151151 h19[l len h19++] = *l raw h19++;3< v26151ASSERT h19(o len h19 < l max h19);3< v26151n113 h193< v26151typc h19) {3< v26151FSCACHE_COOKIE_TYPE_INDEX h19: l typc h19 = ltion class="stri 9 #39;I'; break;3< v26151FSCACHE_COOKIE_TYPE_DATAFILE h19: l typc h19 = ltion class="stri 9 #39;D'; break;3< v26151typc h19 = ltion class="stri 9 #39;S'; break;3< v26151n119 h19 } else {3< v26151seg h19 = 252;3< v26151loop h19 = l 151len h19; l loop h19 val 0; l loop h19--) {3< v26151seg h19 <= 0) {3< v26151151 h19[l len h19++] = ltion class="stri 9 #39;\0';3< v26151mark h19 = l len h19;3< v26151151 h19[l len h19++] = ltion class="stri 9 #39;+';3< v26151seg h19 = 252;3< v26151n128 h193< v26151acc h19 = *l raw h19++;3< v26151acc h19 |= *l raw h19++ << 8;3< v26151acc h19 |= *l raw h19++ << 16;3< v26151n133 h19 l _debug h19(otion class="stri 9 quot;acc: %06x", l acc h19);3< v26151n135 h19 l 151 h19[l len h19++] = l v2_charmap" class="sref">.36 > v2_charmap h19[l acc h19 & 63];3< v26151acc h19 &ion val= 6;3< v26151151 h19[l len h19++] = l v2_charmap" class="sref">.36 > v2_charmap h19[l acc h19 & 63];3< v26151acc h19 &ion val= 6;3< v26151151 h19[l len h19++] = l v2_charmap" class="sref">.36 > v2_charmap h19[l acc h19 & 63];3< v26151acc h19 &ion val= 6;3< v26151151 h19[l len h19++] = l v2_charmap" class="sref">.36 > v2_charmap h19[l acc h19 & 63];3< v26151n143 h19 l ASSERT h19(o len h19 < l max h19);3< v26151n145 h193< v26151typc h19) {3< v26151FSCACHE_COOKIE_TYPE_INDEX h19: l typc h19 = ltion class="stri 9 #39;J'; break;3< v26151FSCACHE_COOKIE_TYPE_DATAFILE h19: l typc h19 = ltion class="stri 9 #39;E'; break;3< v26151typc h19 = ltion class="stri 9 #39;T'; break;3< v26151n151 h19 }3< v26151n153 h19 l 151 h19[l mark h19] = l typc h19;3< v26151151 h19[l len h19++] = 0;3< v26151151 h19[l len h19] = 0;3< v26151n157 h19 o _leavc h19(otion class="stri 9 quot; = %p %d", l 151 h19, o len h19);3< v26151151 h19;3< v26151n160 h193 hdiv>3 div class="footer"> The original LXR software by the < LXR communit1 h19, this experimenlxr@lion .no h19. hdiv>3 div class="subfooter"> lxr.lion .no kindly hosted by < Redpill Liopro AS h19, provider 3f Lion consulti and opera v26s services since 1995. hdiv>3 /body>3 /html>3