• Christian Schoenebeck's avatar
    net/9p: add p9_msg_buf_size() · 1effdbf9
    Christian Schoenebeck authored
    This new function calculates a buffer size suitable for holding the
    intended 9p request or response. For rather small message types (which
    applies to almost all 9p message types actually) simply use hard coded
    values. For some variable-length and potentially large message types
    calculate a more precise value according to what data is actually
    transmitted to avoid unnecessarily huge buffers.
    
    So p9_msg_buf_size() divides the individual 9p message types into 3
    message size categories:
    
      - dynamically calculated message size (i.e. potentially large)
      - 8k hard coded message size
      - 4k hard coded message size
    
    As for the latter two hard coded message types: for most 9p message
    types it is pretty obvious whether they would always fit into 4k or
    8k. But for some of them it depends on the maximum directory entry
    name length allowed by OS and filesystem for determining into which
    of the two size categories they would fit into. Currently Linux
    supports directory entry names up to NAME_MAX (255), however when
    comparing the limitation of individual filesystems, ReiserFS
    theoretically supports up to slightly below 4k long names. So in
    order to make this code more future proof, and as revisiting it
    later on is a bit tedious and has the potential to miss out details,
    the decision [1] was made to take 4k as basis as for max. name length.
    
    Link: https://lkml.kernel.org/r/bd6be891cf67e867688e8c8796d06408bfafa0d9.1657920926.git.linux_oss@crudebyte.com
    Link: https://lore.kernel.org/all/5564296.oo812IJUPE@silver/ [1]
    Signed-off-by: default avatarChristian Schoenebeck <linux_oss@crudebyte.com>
    Signed-off-by: default avatarDominique Martinet <asmadeus@codewreck.org>
    1effdbf9
protocol.h 755 Bytes