Changeset 26a6ed4 in mainline
- Timestamp:
- 2018-03-11T07:35:05Z (7 years ago)
- Children:
- bbf38ad
- Parents:
- 813fc8c
- git-author:
- Jakub Jermar <jakub@…> (2018-03-10 18:18:12)
- git-committer:
- Jakub Jermar <jakub@…> (2018-03-11 07:35:05)
- Location:
- kernel/generic
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/ipc/ipcrsc.h
r813fc8c r26a6ed4 40 40 #include <cap/cap.h> 41 41 42 extern errno_t phone_alloc(task_t *, cap_handle_t*);42 extern errno_t phone_alloc(task_t *, bool, cap_handle_t *, kobject_t **); 43 43 extern bool phone_connect(cap_handle_t, answerbox_t *); 44 44 extern void phone_dealloc(cap_handle_t); -
kernel/generic/src/ipc/ipcrsc.c
r813fc8c r26a6ed4 150 150 /** Allocate new phone in the specified task. 151 151 * 152 * @param task Task for which to allocate a new phone. 153 * 154 * @param[out] out_handle New phone capability handle. 152 * @param[in] task Task for which to allocate a new phone. 153 * @param[in] publish If true, the new capability will be published. 154 * @param[out] phandle New phone capability handle. 155 * @param[out] kobject New phone kobject. 155 156 * 156 157 * @return An error code if a new capability cannot be allocated. 157 158 */ 158 errno_t phone_alloc(task_t *task, cap_handle_t *out_handle) 159 errno_t phone_alloc(task_t *task, bool publish, cap_handle_t *phandle, 160 kobject_t **kobject) 159 161 { 160 162 cap_handle_t handle; … … 166 168 return ENOMEM; 167 169 } 168 kobject_t *kobj ect= malloc(sizeof(kobject_t), FRAME_ATOMIC);169 if (!kobj ect) {170 kobject_t *kobj = malloc(sizeof(kobject_t), FRAME_ATOMIC); 171 if (!kobj) { 170 172 cap_free(TASK, handle); 171 173 slab_free(phone_cache, phone); … … 176 178 phone->state = IPC_PHONE_CONNECTING; 177 179 178 kobject_initialize(kobj ect, KOBJECT_TYPE_PHONE, phone,180 kobject_initialize(kobj, KOBJECT_TYPE_PHONE, phone, 179 181 &phone_kobject_ops); 180 phone->kobject = kobject; 181 182 cap_publish(task, handle, kobject); 183 184 *out_handle = handle; 182 phone->kobject = kobj; 183 184 if (publish) 185 cap_publish(task, handle, kobj); 186 187 *phandle = handle; 188 if (kobject) 189 *kobject = kobj; 185 190 } 186 191 return rc; -
kernel/generic/src/ipc/kbox.c
r813fc8c r26a6ed4 253 253 /* Allocate a new phone. */ 254 254 cap_handle_t phone_handle; 255 errno_t rc = phone_alloc(TASK, &phone_handle);255 errno_t rc = phone_alloc(TASK, true, &phone_handle, NULL); 256 256 if (rc != EOK) { 257 257 mutex_unlock(&task->kb.cleanup_lock); -
kernel/generic/src/ipc/ops/conctmeto.c
r813fc8c r26a6ed4 42 42 static errno_t request_preprocess(call_t *call, phone_t *phone) 43 43 { 44 /* 45 * Create the new phone and capability, but don't publish them yet. 46 * That will be done once the phone is connected. 47 */ 44 48 cap_handle_t phone_handle; 45 errno_t rc = phone_alloc(TASK, &phone_handle); 49 kobject_t *phone_obj; 50 errno_t rc = phone_alloc(TASK, false, &phone_handle, &phone_obj); 46 51 if (rc != EOK) { 47 52 call->priv = -1; 48 53 return rc; 49 }50 51 /*52 * The capability is now published, but the phone is not connected yet.53 * The user cannot use it to send anything over it, in fact the54 * userspace can only unpublish and free the capability at this point.55 *56 * We now proceed to test the capability is still there. We don't care57 * if the user destroyed the old one and recreated a new published one58 * of the same type under the same handle.59 *60 * If the capability is in place we temporarily unpublish it to make61 * sure the user cannot fiddle with it while we are connecting.62 */63 64 kobject_t *phone_obj = cap_unpublish(TASK, phone_handle,65 KOBJECT_TYPE_PHONE);66 if (!phone_obj) {67 /*68 * Another thread of the same task can destroy the new69 * capability before we manage to get a reference from it.70 */71 call->priv = -1;72 return ENOENT;73 54 } 74 55 -
kernel/generic/src/ipc/ops/concttome.c
r813fc8c r26a6ed4 43 43 { 44 44 cap_handle_t phone_handle; 45 errno_t rc = phone_alloc(TASK, &phone_handle);45 errno_t rc = phone_alloc(TASK, true, &phone_handle, NULL); 46 46 IPC_SET_ARG5(call->data, (rc == EOK) ? phone_handle : -1); 47 47 return 0; -
kernel/generic/src/proc/task.c
r813fc8c r26a6ed4 246 246 (container_check(ipc_box_0->task->container, task->container))) { 247 247 cap_handle_t phone_handle; 248 errno_t rc = phone_alloc(task, &phone_handle);248 errno_t rc = phone_alloc(task, true, &phone_handle, NULL); 249 249 if (rc != EOK) { 250 250 task->as = NULL;
Note:
See TracChangeset
for help on using the changeset viewer.