Changeset 8fab3f6 in mainline
- Timestamp:
- 2019-08-17T13:50:05Z (5 years ago)
- Children:
- 31ef7c1
- Parents:
- 504d103
- git-author:
- Michal Koutný <xm.koutny+hos@…> (2015-12-04 17:21:21)
- git-committer:
- Matthieu Riolo <matthieu.riolo@…> (2019-08-17 13:50:05)
- Location:
- uspace
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/sysctl/main.c
r504d103 r8fab3f6 97 97 } 98 98 99 static int start(int argc, char *argv[]) 100 { 101 unit_handle_t handle; 102 char *unit_name = argv[1]; 103 104 int rc = sysman_unit_handle(unit_name, &handle); 105 if (rc != EOK) { 106 printf("Cannot obtain handle for unit '%s' (%s).\n", 107 unit_name, str_error(rc)); 108 return rc; 109 } 110 111 rc = sysman_unit_start(handle, IPC_FLAG_BLOCKING); 112 if (rc != EOK) { 113 printf("Error when starting unit '%s' error (%s).\n", 114 unit_name, str_error(rc)); 115 return rc; 116 } 117 118 return 0; 119 } 120 99 121 static int stop(int argc, char *argv[]) 100 122 { … … 111 133 rc = sysman_unit_stop(handle, IPC_FLAG_BLOCKING); 112 134 if (rc != EOK) { 113 printf("Error when stopping unit '%s' handle(%s).\n",135 printf("Error when stopping unit '%s' error (%s).\n", 114 136 unit_name, str_error(rc)); 115 137 return rc; … … 121 143 command_t commands[] = { 122 144 { "list-units", 0, &list_units }, 145 { "start", 1, &start }, 123 146 { "stop", 1, &stop }, 124 147 { 0 } … … 127 150 static void print_syntax(void) 128 151 { 129 printf("syntax:\n"); 130 printf("\t%s\n", NAME); 131 // TODO update as functionality grows 152 printf("%s commands:\n", NAME); 153 for (command_t *it = commands; it->name != NULL; ++it) { 154 printf("\t%s", it->name); 155 for (int i = 0; i < it->args; ++i) { 156 printf(" <arg%i>", i + 1); 157 } 158 printf("\n"); 159 } 132 160 } 133 161 -
uspace/lib/c/include/ipc/sysman.h
r504d103 r8fab3f6 46 46 SYSMAN_CTL_UNIT_HANDLE, 47 47 SYSMAN_CTL_UNIT_START_BY_NAME, 48 SYSMAN_CTL_UNIT_START, 48 49 SYSMAN_CTL_UNIT_STOP, 49 50 SYSMAN_CTL_GET_UNITS, -
uspace/lib/sysman/include/sysman/ctl.h
r504d103 r8fab3f6 36 36 37 37 int sysman_unit_start_by_name(const char *, int); 38 int sysman_unit_start(unit_handle_t, int); 38 39 int sysman_unit_stop(unit_handle_t, int); 39 40 -
uspace/lib/sysman/src/ctl.c
r504d103 r8fab3f6 78 78 79 79 async_wait_for(req, &rc); 80 return rc; 81 } 82 83 int sysman_unit_start(unit_handle_t handle, int flags) 84 { 85 async_exch_t *exch = sysman_exchange_begin(SYSMAN_PORT_CTL); 86 87 int rc = async_req_2_0(exch, SYSMAN_CTL_UNIT_START, handle, flags); 88 sysman_exchange_end(exch); 89 80 90 return rc; 81 91 } -
uspace/srv/sysman/connection_ctl.c
r504d103 r8fab3f6 138 138 } 139 139 140 static void sysman_unit_stop(ipc_callid_t iid, ipc_call_t *icall) 140 static void sysman_unit_operation(ipc_callid_t iid, ipc_call_t *icall, 141 unit_state_t state) 141 142 { 142 143 sysarg_t retval; … … 144 145 unit_handle_t handle = IPC_GET_ARG1(*icall); 145 146 int flags = IPC_GET_ARG2(*icall); 146 sysman_log(LVL_DEBUG2, "%s(%i, %x )", __func__, handle, flags);147 sysman_log(LVL_DEBUG2, "%s(%i, %x, %i)", __func__, handle, flags, state); 147 148 148 149 unit_t *unit = repo_find_unit_by_handle(handle); … … 153 154 154 155 if (!(flags & IPC_FLAG_BLOCKING)) { 155 retval = sysman_run_job(unit, STATE_STOPPED, NULL, NULL);156 retval = sysman_run_job(unit, state, NULL, NULL); 156 157 goto answer; 157 158 } … … 162 163 goto answer; 163 164 } 164 retval = sysman_run_job(unit, STATE_STOPPED, &answer_callback,165 retval = sysman_run_job(unit, state, &answer_callback, 165 166 iid_ptr); 166 167 if (retval != EOK) { … … 173 174 answer: 174 175 async_answer_0(iid, retval); 176 } 177 178 static void sysman_unit_start(ipc_callid_t iid, ipc_call_t *icall) 179 { 180 sysman_unit_operation(iid, icall, STATE_STARTED); 181 } 182 183 static void sysman_unit_stop(ipc_callid_t iid, ipc_call_t *icall) 184 { 185 sysman_unit_operation(iid, icall, STATE_STOPPED); 175 186 } 176 187 … … 289 300 sysman_unit_start_by_name(callid, &call); 290 301 break; 302 case SYSMAN_CTL_UNIT_START: 303 sysman_unit_start(callid, &call); 304 break; 291 305 case SYSMAN_CTL_UNIT_STOP: 292 306 sysman_unit_stop(callid, &call);
Note:
See TracChangeset
for help on using the changeset viewer.