Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
messaging.c File Reference
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/user_namespace.h>
#include <linux/nsproxy.h>
#include "ecryptfs_kernel.h"

Go to the source code of this file.

Macros

#define ecryptfs_current_euid_hash(uid)   hash_long((unsigned long)from_kuid(&init_user_ns, current_euid()), ecryptfs_hash_bits)
 

Functions

void ecryptfs_msg_ctx_alloc_to_free (struct ecryptfs_msg_ctx *msg_ctx)
 
int ecryptfs_find_daemon_by_euid (struct ecryptfs_daemon **daemon)
 
int ecryptfs_spawn_daemon (struct ecryptfs_daemon **daemon, struct file *file)
 
int ecryptfs_exorcise_daemon (struct ecryptfs_daemon *daemon)
 
int ecryptfs_process_response (struct ecryptfs_daemon *daemon, struct ecryptfs_message *msg, u32 seq)
 
int ecryptfs_send_message (char *data, int data_len, struct ecryptfs_msg_ctx **msg_ctx)
 
int ecryptfs_wait_for_response (struct ecryptfs_msg_ctx *msg_ctx, struct ecryptfs_message **msg)
 
int __init ecryptfs_init_messaging (void)
 
void ecryptfs_release_messaging (void)
 

Variables

struct mutex ecryptfs_daemon_hash_mux
 

Macro Definition Documentation

#define ecryptfs_current_euid_hash (   uid)    hash_long((unsigned long)from_kuid(&init_user_ns, current_euid()), ecryptfs_hash_bits)

Definition at line 35 of file messaging.c.

Function Documentation

int ecryptfs_exorcise_daemon ( struct ecryptfs_daemon daemon)

ecryptfs_exorcise_daemon - Destroy the daemon struct

Must be called ceremoniously while in possession of ecryptfs_daemon_hash_mux and the daemon's own mux.

Definition at line 173 of file messaging.c.

int ecryptfs_find_daemon_by_euid ( struct ecryptfs_daemon **  daemon)

ecryptfs_find_daemon_by_euid : If return value is zero, points to the desired daemon pointer

Must be called with ecryptfs_daemon_hash_mux held.

Search the hash list for the current effective user id.

Returns zero if the user id exists in the list; non-zero otherwise.

Definition at line 116 of file messaging.c.

int __init ecryptfs_init_messaging ( void  )

Definition at line 371 of file messaging.c.

void ecryptfs_msg_ctx_alloc_to_free ( struct ecryptfs_msg_ctx msg_ctx)

ecryptfs_msg_ctx_alloc_to_free : The context to move from the alloc list to the free list

Must be called with ecryptfs_msg_ctx_lists_mux held.

Definition at line 97 of file messaging.c.

int ecryptfs_process_response ( struct ecryptfs_daemon daemon,
struct ecryptfs_message msg,
u32  seq 
)

ecryptfs_process_reponse : The ecryptfs message received; the caller should sanity check msg->data_len and free the memory : The sequence number of the message; must match the sequence number for the existing message context waiting for this response

Processes a response message after sending an operation request to userspace. Some other process is awaiting this response. Before sending out its first communications, the other process allocated a msg_ctx from the ecryptfs_msg_ctx_arr at a particular index. The response message contains this index so that we can copy over the response message into the msg_ctx that the process holds a reference to. The other process is going to wake up, check to see that msg_ctx->state == ECRYPTFS_MSG_CTX_STATE_DONE, and then proceed to read off and process the response message. Returns zero upon delivery to desired context element; non-zero upon delivery failure or error.

Returns zero on success; non-zero otherwise

Definition at line 222 of file messaging.c.

void ecryptfs_release_messaging ( void  )

Definition at line 432 of file messaging.c.

int ecryptfs_send_message ( char data,
int  data_len,
struct ecryptfs_msg_ctx **  msg_ctx 
)

ecryptfs_send_message : The data to send : The length of data : The message context allocated for the send

Grabs ecryptfs_daemon_hash_mux.

Returns zero on success; non-zero otherwise

Definition at line 321 of file messaging.c.

int ecryptfs_spawn_daemon ( struct ecryptfs_daemon **  daemon,
struct file file 
)

Definition at line 145 of file messaging.c.

int ecryptfs_wait_for_response ( struct ecryptfs_msg_ctx msg_ctx,
struct ecryptfs_message **  msg 
)

ecryptfs_wait_for_response : The context that was assigned when sending a message : The incoming message from userspace; not set if rc != 0

Sleeps until awaken by ecryptfs_receive_message or until the amount of time exceeds ecryptfs_message_wait_timeout. If zero is returned, msg will point to a valid message from userspace; a non-zero value is returned upon failure to receive a message or an error occurs. Callee must free on success.

Definition at line 344 of file messaging.c.

Variable Documentation

struct mutex ecryptfs_daemon_hash_mux

Definition at line 33 of file messaging.c.