

# This is for acquire. If a process acquire the lock, it is the obligation to clean the folder
# Only reserve $name.fslock.X and $name.fslock.$pid

# TODO: optimized this.
___x_cmd_fslock_cleanup___reserve_x_and_pid(){
    local name="$1"
    local pid="$2"

    x fsiter "$___X_CMD_FSLOCK_ROOT" |  (
        ___x_cmd_inner_cd "$___X_CMD_FSLOCK_ROOT"
        local arg=""
        local i; while read -r i; do
            [ "${i#"$name".fslock}" != "$i" ] || continue
            if [ "$i" != "$name.fslock.x-cmd.$pid" ] && [ "$i" != "$name.fslock.x-cmd.X" ]; then
                arg="\"$i\""
            fi
            eval "___x_cmd_cmds_rm -f $arg"  2>/dev/null
        done
    )
}
