lkml.org 
[lkml]   [2006]   [Jun]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[Suspend2][ 05/21] [Suspend2] Receive a message from the userui.
    Date
    Receive a message from the userspace user interface.

    Signed-off-by: Nigel Cunningham <nigel@suspend2.net>

    kernel/power/ui.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++
    1 files changed, 58 insertions(+), 0 deletions(-)

    diff --git a/kernel/power/ui.c b/kernel/power/ui.c
    index 365c033..48719de 100644
    --- a/kernel/power/ui.c
    +++ b/kernel/power/ui.c
    @@ -118,3 +118,61 @@ void request_abort_suspend(void)
    }
    }

    +static int userui_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
    +{
    + int type;
    + int *data;
    +
    + type = nlh->nlmsg_type;
    +
    + /* A control message: ignore them */
    + if (type < NETLINK_MSG_BASE)
    + return 0;
    +
    + /* Unknown message: reply with EINVAL */
    + if (type >= USERUI_MSG_MAX)
    + return -EINVAL;
    +
    + /* All operations require privileges, even GET */
    + if (security_netlink_recv(skb))
    + return -EPERM;
    +
    + /* Only allow one task to receive NOFREEZE privileges */
    + if (type == NETLINK_MSG_NOFREEZE_ME && ui_helper_data.pid != -1)
    + return -EBUSY;
    +
    + data = (int*)NLMSG_DATA(nlh);
    +
    + switch (type) {
    + case USERUI_MSG_ABORT:
    + request_abort_suspend();
    + break;
    + case USERUI_MSG_GET_STATE:
    + suspend_send_netlink_message(&ui_helper_data,
    + USERUI_MSG_GET_STATE, &suspend_action,
    + sizeof(suspend_action));
    + break;
    + case USERUI_MSG_GET_DEBUG_STATE:
    + suspend_send_netlink_message(&ui_helper_data,
    + USERUI_MSG_GET_DEBUG_STATE,
    + &suspend_debug_state,
    + sizeof(suspend_debug_state));
    + break;
    + case USERUI_MSG_SET_STATE:
    + if (nlh->nlmsg_len < NLMSG_LENGTH(sizeof(int)))
    + return -EINVAL;
    + ui_nl_set_state(*data);
    + break;
    + case USERUI_MSG_SET_DEBUG_STATE:
    + if (nlh->nlmsg_len < NLMSG_LENGTH(sizeof(int)))
    + return -EINVAL;
    + suspend_debug_state = (*data);
    + break;
    + case USERUI_MSG_SPACE:
    + wake_up_interruptible(&userui_wait_for_key);
    + break;
    + }
    +
    + return 1;
    +}
    +
    --
    Nigel Cunningham nigel at suspend2 dot net
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2006-06-27 06:53    [W:0.021 / U:1.984 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site