Skip to content
  • Linus Torvalds's avatar
    fs/proc: simplify and clarify get_mm_cmdline() function · 5ab82718
    Linus Torvalds authored
    We have some very odd semantics for reading the command line through
    /proc, because we allow people to rewrite their own command line pretty
    much at will, and things get positively funky when you extend your
    command line past the point that used to be the end of the command line,
    and is now in the environment variable area.
    
    But our weird semantics doesn't mean that we should write weird and
    complex code to handle them.
    
    So re-write get_mm_cmdline() to be much simpler, and much more explicit
    about what it is actually doing and why.  And avoid the extra check for
    "is there a NUL character at the end of the command line where I expect
    one to be", by simply making the NUL character handling be part of the
    normal "once you hit the end of the command line, stop at the first NUL
    character" logic.
    
    It's quite possible that we should stop the crazy "walk into
    environment" entirely, but happily it's not really the usual case.
    
    NOTE! We tried to really simplify and limit our odd cmdline parsing some
    time ago, but people complained.  See commit c2c0bb44
    
     ("proc: fix
    PAGE_SIZE limit of /proc/$PID/cmdline") for details about why we have
    this complexity.
    
    Cc: Tejun Heo <tj@kernel.org>
    Cc: Alexey Dobriyan <adobriyan@gmail.com>
    Cc: Jarod Wilson <jarod@redhat.com>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    5ab82718