• Paolo 'Blaisorblade' Giarrusso's avatar
    [PATCH] uml: fix not_dead_yet when directory is in bad state · 912ad922
    Paolo 'Blaisorblade' Giarrusso authored
    The bug occurred to me when a UML left an empty ~/.uml/Sarge-norm folder -
    when trying to reuse not_dead_yet() failed one of its check.  The comment
    says that's ok and means that we can take the directory, but while normally
    not_dead_yet() removes it and returns 0 (i.e.  go on, use this), on failure
    it returns 0 but forgets to remove it.  The fix is to remove it anytime
    we're going to return 0.
    
    But since "not_dead_yet" didn't make the interface so clear, causing this
    bug, and I couldn't find a convenient name for the mix of things it did, I
    split it into two parts:
    
    is_umdir_used()      -	returns a boolean, contains all checks of not_dead_yet()
    umdir_take_if_dead   -	tries to remove the dir unless it's used - returns
    			whether it removed it, that is we now own it.
    
    With this changes the control flow is IMHO a bit clearer and needs less
    comment for control flow.
    Signed-off-by: default avatarPaolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
    Cc: Jeff Dike <jdike@addtoit.com>
    Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
    912ad922
umid.c 7.16 KB