utag: report the return value of store_utags() to userspace

If store worker failed to store utag, report the failure to userspace so
that userspace can deal with it accordingly

Change-Id: I1ba9635b776fca1b27ab672a06df4a823e926684
Reviewed-on: https://gerrit.mot.com/1733628
SLTApproved: Slta Waiver
SME-Granted: SME Approvals Granted
Tested-by: Jira Key
Reviewed-by: Konstantin Makariev <kmakariev@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
jixj 2020-08-26 14:37:43 +08:00 • committed by Xiaojun Ji
commit ef8a1cb701

View file

@ -142,6 +142,7 @@ struct ctrl {
struct work_struct load_work;
struct work_struct store_work;
struct utag *head;
int store_work_result;
};
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0)
@ -1193,6 +1194,7 @@ void store_work_func(struct work_struct *work)
rc = store_utags(ctrl, ctrl->head);
if (rc)
pr_err("error storing utags partition\n");
ctrl->store_work_result = rc;
complete(&ctrl->store_comp);
}
@ -1349,6 +1351,8 @@ static ssize_t write_utag(struct file *file, const char __user *buffer,
queue_work(ctrl->store_queue, &ctrl->store_work);
wait_for_completion(&ctrl->store_comp);
if (ctrl->store_work_result)
count = ctrl->store_work_result;
free_tags_exit:
free_tags(tags);
free_temp_exit:
@ -1444,6 +1448,8 @@ static ssize_t delete_utag(struct file *file, const char __user *buffer,
/* Store changed partition */
queue_work(ctrl->store_queue, &ctrl->store_work);
wait_for_completion(&ctrl->store_comp);
if (ctrl->store_work_result)
count = ctrl->store_work_result;
rebuild_utags_directory(ctrl);
just_leave:
free_tags(tags);
@ -1637,6 +1643,8 @@ static ssize_t new_utag(struct file *file, const char __user *buffer,
/* Store changed partition */
queue_work(ctrl->store_queue, &ctrl->store_work);
wait_for_completion(&ctrl->store_comp);
if (ctrl->store_work_result)
ret = ctrl->store_work_result;
just_leave:
free_tags(tags);
mutex_unlock(&ctrl->access_lock);