Loading include/norns/norns.h +14 −34 Original line number Diff line number Diff line Loading @@ -56,40 +56,17 @@ typedef struct { norns_resource_t t_dst; /* destination resource */ } norns_iotask_t; #if 0 // deprecated #define NORNS_IOTD_INIT(type, src, dst) \ { \ .io_taskid = 0, \ .io_optype = (type), \ .io_src = src, \ .io_dst = dst \ } #endif /* Task types */ //enum { // NORNS_COPY = 00000000, // NORNS_MOVE = 00000001, // NORNS_LOCAL = 00000010, // NORNS_REMOTE = 00000020 //}; #define NORNS_IOTASK_COPY 0x1 #define NORNS_IOTASK_MOVE 0x2 /* I/O task status descriptor */ struct norns_iotst { int ni_status; /* current status */ }; /* Status codes */ enum { NORNS_WAITING, NORNS_INPROGRESS, NORNS_COMPLETE }; typedef struct { norns_status_t st_status; /* task current status */ norns_error_t st_error; /* task return value */ size_t st_pending; /* bytes pending in task */ size_t st_total; /* total bytes in task */ } norns_stat_t; /**************************************************************************/ /* Client API */ Loading @@ -114,20 +91,23 @@ norns_iotask_t NORNS_IOTASK(norns_op_t operation, norns_resource_t src, /* Submit an asynchronous I/O task */ norns_error_t norns_submit(norns_iotask_t* task) __THROW; /* wait for the completion of the task associated to task */ int norns_wait(norns_iotask_t* task) __THROW; /* wait for the completion of the I/O task associated to 'task' */ norns_error_t norns_wait(norns_iotask_t* task) __THROW; /* Try to cancel an asynchronous I/O task associated with task */ ssize_t norns_cancel(norns_iotask_t* task) __THROW; /* Check the status of a submitted I/O task */ norns_error_t norns_status(norns_iotask_t* task, norns_stat_t* stats) __THROW; /* Retrieve return status associated with task */ ssize_t norns_return(norns_iotask_t* task, struct norns_iotst* statp) __THROW; ssize_t norns_return(norns_iotask_t* task, norns_stat_t* stats) __THROW; /* Retrieve current status associated with task (if task is NULL, retrieve status for all running tasks) */ ssize_t norns_progress(norns_iotask_t* task, struct norns_iotst* statp) __THROW; //ssize_t norns_progress(norns_iotask_t* task, struct norns_iotst* statp) __THROW; /* Retrieve error status associated with task */ int norns_error(norns_iotask_t* task) __THROW; //int norns_error(norns_iotask_t* task) __THROW; /* Check if the urd daemon is running */ int norns_ping() __THROW; Loading include/norns/norns_error.h +34 −18 Original line number Diff line number Diff line Loading @@ -33,8 +33,6 @@ extern "C" { #endif typedef int norns_error_t; #define NORNS_ERRMAX 512 /** Error codes */ Loading @@ -43,17 +41,35 @@ typedef int norns_error_t; #define NORNS_EBADARGS -2 #define NORNS_EBADREQUEST -3 #define NORNS_ENOMEM -4 /* errors about communication */ #define NORNS_ECONNFAILED -5 #define NORNS_ERPCSENDFAILED -6 #define NORNS_ERPCRECVFAILED -7 #define NORNS_EJOBEXISTS -8 #define NORNS_ENOSUCHJOB -9 #define NORNS_EPROCESSEXISTS -10 #define NORNS_ENOSUCHPROCESS -11 #define NORNS_EBACKENDEXISTS -12 #define NORNS_ENOSUCHBACKEND -13 #define NORNS_ENOTSUPPORTED -64 /* errors about jobs */ #define NORNS_EJOBEXISTS -10 #define NORNS_ENOSUCHJOB -11 /* errors about processes */ #define NORNS_EPROCESSEXISTS -20 #define NORNS_ENOSUCHPROCESS -21 /* errors about backends */ #define NORNS_EBACKENDEXISTS -30 #define NORNS_ENOSUCHBACKEND -31 /* errors about tasks */ #define NORNS_ETASKEXISTS -40 #define NORNS_ENOSUCHTASK -41 /* task status */ #define NORNS_EPENDING -100 #define NORNS_EINPROGRESS -101 #define NORNS_EFINISHED -102 /* misc errors */ #define NORNS_ENOTSUPPORTED -200 #ifdef __cplusplus } Loading include/norns/norns_resources.h +3 −8 Original line number Diff line number Diff line Loading @@ -84,13 +84,9 @@ typedef struct { norns_flags_t r_flags; /* resource type and flags */ const char* r_nsid; /* namespace id */ union { norns_memory_region_t __r_buffer; norns_posix_path_t __r_posix_path; } __r_data; #define r_buffer __r_data.__r_buffer #define r_posix_path __r_data.__r_posix_path norns_memory_region_t r_buffer; norns_posix_path_t r_posix_path; }; } norns_resource_t; norns_resource_t NORNS_MEMORY_REGION(const char* nsid, void* addr, size_t size); Loading @@ -98,7 +94,6 @@ norns_resource_t NORNS_LOCAL_PATH(const char* nsid, const char* path); norns_resource_t NORNS_REMOTE_PATH(const char* nsid, const char* host, const char* path); norns_resource_t NORNS_SHARED_PATH(const char* nsid, const char* path); #ifdef __cplusplus } #endif Loading include/norns/norns_types.h +3 −0 Original line number Diff line number Diff line Loading @@ -28,5 +28,8 @@ typedef uint32_t norns_tid_t; typedef uint32_t norns_op_t; typedef uint32_t norns_flags_t; typedef int32_t norns_status_t; typedef int32_t norns_error_t; #endif /* __NORNS_TYPES_H__ */ lib/daemon-communication.c +41 −17 Original line number Diff line number Diff line Loading @@ -58,18 +58,42 @@ send_submit_request(norns_iotask_t* task) { return NORNS_EBADARGS; } if((res = send_request(NORNS_SUBMIT_IOTASK, &resp, task)) if((res = send_request(NORNS_IOTASK_SUBMIT, &resp, task)) != NORNS_SUCCESS) { return res; } if(resp.r_type != NORNS_SUBMIT_IOTASK) { if(resp.r_type != NORNS_IOTASK_SUBMIT) { return NORNS_ESNAFU; } task->t_id = resp.r_taskid; return resp.r_status; return resp.r_error_code; } norns_error_t send_status_request(norns_iotask_t* task, norns_stat_t* stats) { int res; norns_response_t resp; if(task->t_id == 0) { return NORNS_EBADARGS; } if((res = send_request(NORNS_IOTASK_STATUS, &resp, task)) != NORNS_SUCCESS) { return res; } if(resp.r_type != NORNS_IOTASK_STATUS) { return NORNS_ESNAFU; } stats->st_status = resp.r_status; return resp.r_error_code; } norns_error_t Loading @@ -86,7 +110,7 @@ send_ping_request() { return NORNS_ESNAFU; } return resp.r_status; return resp.r_error_code; } norns_error_t Loading @@ -105,7 +129,7 @@ send_job_request(norns_rpc_type_t type, struct norns_cred* auth, return NORNS_ESNAFU; } return resp.r_status; return resp.r_error_code; } Loading @@ -125,7 +149,7 @@ send_process_request(norns_rpc_type_t type, struct norns_cred* auth, return NORNS_ESNAFU; } return resp.r_status; return resp.r_error_code; } norns_error_t Loading @@ -144,7 +168,7 @@ send_backend_request(norns_rpc_type_t type, struct norns_cred* auth, return NORNS_ESNAFU; } return resp.r_status; return resp.r_error_code; } static int Loading @@ -159,7 +183,8 @@ send_request(norns_rpc_type_t type, norns_response_t* resp, ...) { // fetch args and pack them into a buffer switch(type) { case NORNS_SUBMIT_IOTASK: case NORNS_IOTASK_SUBMIT: case NORNS_IOTASK_STATUS: { const norns_iotask_t* task = va_arg(ap, const norns_iotask_t*); Loading @@ -172,7 +197,6 @@ send_request(norns_rpc_type_t type, norns_response_t* resp, ...) { break; } case NORNS_PING: { if((res = pack_to_buffer(type, &req_buf)) != NORNS_SUCCESS) { Loading @@ -182,9 +206,9 @@ send_request(norns_rpc_type_t type, norns_response_t* resp, ...) { break; } case NORNS_REGISTER_JOB: case NORNS_UPDATE_JOB: case NORNS_UNREGISTER_JOB: case NORNS_JOB_REGISTER: case NORNS_JOB_UPDATE: case NORNS_JOB_UNREGISTER: { const struct norns_cred* auth = va_arg(ap, const struct norns_cred*); Loading @@ -201,8 +225,8 @@ send_request(norns_rpc_type_t type, norns_response_t* resp, ...) { break; } case NORNS_ADD_PROCESS: case NORNS_REMOVE_PROCESS: case NORNS_PROCESS_ADD: case NORNS_PROCESS_REMOVE: { const struct norns_cred* auth = va_arg(ap, const struct norns_cred*); Loading @@ -223,9 +247,9 @@ send_request(norns_rpc_type_t type, norns_response_t* resp, ...) { break; } case NORNS_REGISTER_BACKEND: case NORNS_UPDATE_BACKEND: case NORNS_UNREGISTER_BACKEND: case NORNS_BACKEND_REGISTER: case NORNS_BACKEND_UPDATE: case NORNS_BACKEND_UNREGISTER: { const struct norns_cred* auth = va_arg(ap, const struct norns_cred*); Loading Loading
include/norns/norns.h +14 −34 Original line number Diff line number Diff line Loading @@ -56,40 +56,17 @@ typedef struct { norns_resource_t t_dst; /* destination resource */ } norns_iotask_t; #if 0 // deprecated #define NORNS_IOTD_INIT(type, src, dst) \ { \ .io_taskid = 0, \ .io_optype = (type), \ .io_src = src, \ .io_dst = dst \ } #endif /* Task types */ //enum { // NORNS_COPY = 00000000, // NORNS_MOVE = 00000001, // NORNS_LOCAL = 00000010, // NORNS_REMOTE = 00000020 //}; #define NORNS_IOTASK_COPY 0x1 #define NORNS_IOTASK_MOVE 0x2 /* I/O task status descriptor */ struct norns_iotst { int ni_status; /* current status */ }; /* Status codes */ enum { NORNS_WAITING, NORNS_INPROGRESS, NORNS_COMPLETE }; typedef struct { norns_status_t st_status; /* task current status */ norns_error_t st_error; /* task return value */ size_t st_pending; /* bytes pending in task */ size_t st_total; /* total bytes in task */ } norns_stat_t; /**************************************************************************/ /* Client API */ Loading @@ -114,20 +91,23 @@ norns_iotask_t NORNS_IOTASK(norns_op_t operation, norns_resource_t src, /* Submit an asynchronous I/O task */ norns_error_t norns_submit(norns_iotask_t* task) __THROW; /* wait for the completion of the task associated to task */ int norns_wait(norns_iotask_t* task) __THROW; /* wait for the completion of the I/O task associated to 'task' */ norns_error_t norns_wait(norns_iotask_t* task) __THROW; /* Try to cancel an asynchronous I/O task associated with task */ ssize_t norns_cancel(norns_iotask_t* task) __THROW; /* Check the status of a submitted I/O task */ norns_error_t norns_status(norns_iotask_t* task, norns_stat_t* stats) __THROW; /* Retrieve return status associated with task */ ssize_t norns_return(norns_iotask_t* task, struct norns_iotst* statp) __THROW; ssize_t norns_return(norns_iotask_t* task, norns_stat_t* stats) __THROW; /* Retrieve current status associated with task (if task is NULL, retrieve status for all running tasks) */ ssize_t norns_progress(norns_iotask_t* task, struct norns_iotst* statp) __THROW; //ssize_t norns_progress(norns_iotask_t* task, struct norns_iotst* statp) __THROW; /* Retrieve error status associated with task */ int norns_error(norns_iotask_t* task) __THROW; //int norns_error(norns_iotask_t* task) __THROW; /* Check if the urd daemon is running */ int norns_ping() __THROW; Loading
include/norns/norns_error.h +34 −18 Original line number Diff line number Diff line Loading @@ -33,8 +33,6 @@ extern "C" { #endif typedef int norns_error_t; #define NORNS_ERRMAX 512 /** Error codes */ Loading @@ -43,17 +41,35 @@ typedef int norns_error_t; #define NORNS_EBADARGS -2 #define NORNS_EBADREQUEST -3 #define NORNS_ENOMEM -4 /* errors about communication */ #define NORNS_ECONNFAILED -5 #define NORNS_ERPCSENDFAILED -6 #define NORNS_ERPCRECVFAILED -7 #define NORNS_EJOBEXISTS -8 #define NORNS_ENOSUCHJOB -9 #define NORNS_EPROCESSEXISTS -10 #define NORNS_ENOSUCHPROCESS -11 #define NORNS_EBACKENDEXISTS -12 #define NORNS_ENOSUCHBACKEND -13 #define NORNS_ENOTSUPPORTED -64 /* errors about jobs */ #define NORNS_EJOBEXISTS -10 #define NORNS_ENOSUCHJOB -11 /* errors about processes */ #define NORNS_EPROCESSEXISTS -20 #define NORNS_ENOSUCHPROCESS -21 /* errors about backends */ #define NORNS_EBACKENDEXISTS -30 #define NORNS_ENOSUCHBACKEND -31 /* errors about tasks */ #define NORNS_ETASKEXISTS -40 #define NORNS_ENOSUCHTASK -41 /* task status */ #define NORNS_EPENDING -100 #define NORNS_EINPROGRESS -101 #define NORNS_EFINISHED -102 /* misc errors */ #define NORNS_ENOTSUPPORTED -200 #ifdef __cplusplus } Loading
include/norns/norns_resources.h +3 −8 Original line number Diff line number Diff line Loading @@ -84,13 +84,9 @@ typedef struct { norns_flags_t r_flags; /* resource type and flags */ const char* r_nsid; /* namespace id */ union { norns_memory_region_t __r_buffer; norns_posix_path_t __r_posix_path; } __r_data; #define r_buffer __r_data.__r_buffer #define r_posix_path __r_data.__r_posix_path norns_memory_region_t r_buffer; norns_posix_path_t r_posix_path; }; } norns_resource_t; norns_resource_t NORNS_MEMORY_REGION(const char* nsid, void* addr, size_t size); Loading @@ -98,7 +94,6 @@ norns_resource_t NORNS_LOCAL_PATH(const char* nsid, const char* path); norns_resource_t NORNS_REMOTE_PATH(const char* nsid, const char* host, const char* path); norns_resource_t NORNS_SHARED_PATH(const char* nsid, const char* path); #ifdef __cplusplus } #endif Loading
include/norns/norns_types.h +3 −0 Original line number Diff line number Diff line Loading @@ -28,5 +28,8 @@ typedef uint32_t norns_tid_t; typedef uint32_t norns_op_t; typedef uint32_t norns_flags_t; typedef int32_t norns_status_t; typedef int32_t norns_error_t; #endif /* __NORNS_TYPES_H__ */
lib/daemon-communication.c +41 −17 Original line number Diff line number Diff line Loading @@ -58,18 +58,42 @@ send_submit_request(norns_iotask_t* task) { return NORNS_EBADARGS; } if((res = send_request(NORNS_SUBMIT_IOTASK, &resp, task)) if((res = send_request(NORNS_IOTASK_SUBMIT, &resp, task)) != NORNS_SUCCESS) { return res; } if(resp.r_type != NORNS_SUBMIT_IOTASK) { if(resp.r_type != NORNS_IOTASK_SUBMIT) { return NORNS_ESNAFU; } task->t_id = resp.r_taskid; return resp.r_status; return resp.r_error_code; } norns_error_t send_status_request(norns_iotask_t* task, norns_stat_t* stats) { int res; norns_response_t resp; if(task->t_id == 0) { return NORNS_EBADARGS; } if((res = send_request(NORNS_IOTASK_STATUS, &resp, task)) != NORNS_SUCCESS) { return res; } if(resp.r_type != NORNS_IOTASK_STATUS) { return NORNS_ESNAFU; } stats->st_status = resp.r_status; return resp.r_error_code; } norns_error_t Loading @@ -86,7 +110,7 @@ send_ping_request() { return NORNS_ESNAFU; } return resp.r_status; return resp.r_error_code; } norns_error_t Loading @@ -105,7 +129,7 @@ send_job_request(norns_rpc_type_t type, struct norns_cred* auth, return NORNS_ESNAFU; } return resp.r_status; return resp.r_error_code; } Loading @@ -125,7 +149,7 @@ send_process_request(norns_rpc_type_t type, struct norns_cred* auth, return NORNS_ESNAFU; } return resp.r_status; return resp.r_error_code; } norns_error_t Loading @@ -144,7 +168,7 @@ send_backend_request(norns_rpc_type_t type, struct norns_cred* auth, return NORNS_ESNAFU; } return resp.r_status; return resp.r_error_code; } static int Loading @@ -159,7 +183,8 @@ send_request(norns_rpc_type_t type, norns_response_t* resp, ...) { // fetch args and pack them into a buffer switch(type) { case NORNS_SUBMIT_IOTASK: case NORNS_IOTASK_SUBMIT: case NORNS_IOTASK_STATUS: { const norns_iotask_t* task = va_arg(ap, const norns_iotask_t*); Loading @@ -172,7 +197,6 @@ send_request(norns_rpc_type_t type, norns_response_t* resp, ...) { break; } case NORNS_PING: { if((res = pack_to_buffer(type, &req_buf)) != NORNS_SUCCESS) { Loading @@ -182,9 +206,9 @@ send_request(norns_rpc_type_t type, norns_response_t* resp, ...) { break; } case NORNS_REGISTER_JOB: case NORNS_UPDATE_JOB: case NORNS_UNREGISTER_JOB: case NORNS_JOB_REGISTER: case NORNS_JOB_UPDATE: case NORNS_JOB_UNREGISTER: { const struct norns_cred* auth = va_arg(ap, const struct norns_cred*); Loading @@ -201,8 +225,8 @@ send_request(norns_rpc_type_t type, norns_response_t* resp, ...) { break; } case NORNS_ADD_PROCESS: case NORNS_REMOVE_PROCESS: case NORNS_PROCESS_ADD: case NORNS_PROCESS_REMOVE: { const struct norns_cred* auth = va_arg(ap, const struct norns_cred*); Loading @@ -223,9 +247,9 @@ send_request(norns_rpc_type_t type, norns_response_t* resp, ...) { break; } case NORNS_REGISTER_BACKEND: case NORNS_UPDATE_BACKEND: case NORNS_UNREGISTER_BACKEND: case NORNS_BACKEND_REGISTER: case NORNS_BACKEND_UPDATE: case NORNS_BACKEND_UNREGISTER: { const struct norns_cred* auth = va_arg(ap, const struct norns_cred*); Loading