summaryrefslogtreecommitdiff
path: root/fs/cachefiles/Makefile
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2021-11-17 18:48:06 +0300
committerDavid Howells <dhowells@redhat.com>2022-01-07 16:42:16 +0300
commit5d439467b802f5c6393b20d57662500dfb177c8f (patch)
treeed356351e8e25095ef79610b904314d5774b814a /fs/cachefiles/Makefile
parentdf98e87f2091774c377ddfaedfe64bd90ed4bdca (diff)
downloadlinux-5d439467b802f5c6393b20d57662500dfb177c8f.tar.xz
cachefiles: Implement key to filename encoding
Implement a function to encode a binary cookie key as something that can be used as a filename. Four options are considered: (1) All printable chars with no '/' characters. Prepend a 'D' to indicate the encoding but otherwise use as-is. (2) Appears to be an array of __be32. Encode as 'S' plus a list of hex-encoded 32-bit ints separated by commas. If a number is 0, it is rendered as "" instead of "0". (3) Appears to be an array of __le32. Encoded as (2) but with a 'T' encoding prefix. (4) Encoded as base64 with an 'E' prefix plus a second char indicating how much padding is involved. A non-standard base64 encoding is used because '/' cannot be used in the encoded form. If (1) is not possible, whichever of (2), (3) or (4) produces the shortest string is selected (hex-encoding a number may be less dense than base64 encoding it). Note that the prefix characters have to be selected from the set [DEIJST@] lest cachefilesd remove the files because it recognise the name. Changes ======= ver #2: - Fix a short allocation that didn't allow for a string terminator[1] Signed-off-by: David Howells <dhowells@redhat.com> Reviewed-by: Jeff Layton <jlayton@kernel.org> cc: linux-cachefs@redhat.com Link: https://lore.kernel.org/r/bcefb8f2-576a-b3fc-cc29-89808ebfd7c1@linux.alibaba.com/ [1] Link: https://lore.kernel.org/r/163819640393.215744.15212364106412961104.stgit@warthog.procyon.org.uk/ # v1 Link: https://lore.kernel.org/r/163906940529.143852.17352132319136117053.stgit@warthog.procyon.org.uk/ # v2 Link: https://lore.kernel.org/r/163967149827.1823006.6088580775428487961.stgit@warthog.procyon.org.uk/ # v3 Link: https://lore.kernel.org/r/164021549223.640689.14762875188193982341.stgit@warthog.procyon.org.uk/ # v4
Diffstat (limited to 'fs/cachefiles/Makefile')
-rw-r--r--fs/cachefiles/Makefile1
1 files changed, 1 insertions, 0 deletions
diff --git a/fs/cachefiles/Makefile b/fs/cachefiles/Makefile
index d67210ece9cd..6f025940a65c 100644
--- a/fs/cachefiles/Makefile
+++ b/fs/cachefiles/Makefile
@@ -7,6 +7,7 @@ cachefiles-y := \
cache.o \
daemon.o \
interface.o \
+ key.o \
main.o \
namei.o \
security.o \