+ if (ret_val < 0)
+ return STORAGE_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+
+ return STORAGE_ERROR_NONE;
+}
+//LCOV_EXCL_STOP
+
+//LCOV_EXCL_START Internal API
+API int storage_is_mounted_opt_usr(storage_part_mount_e *mounted)
+{
+ blkid_cache cache = NULL;
+ blkid_dev_iterate iter;
+ blkid_dev dev;
+ int ret_val;
+ bool found = false;
+ char *user_label = syscommon_is_container()? CONTAINER_USER_PARTITION: USER_PARTITION;
+
+ if (!mounted)
+ return STORAGE_ERROR_INVALID_PARAMETER;
+
+ _D("Find user partition label: %s", user_label);
+ ret_val = blkid_get_cache(&cache, NULL);
+ if (ret_val < 0) {
+ _E("Failed to get cache"); //LCOV_EXCL_LINE
+ *mounted = STORAGE_PART_ERROR; //LCOV_EXCL_LINE
+ return STORAGE_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
+
+ ret_val = blkid_probe_all(cache);
+ if (ret_val < 0) {
+ _E("Failed to probe all block devices"); //LCOV_EXCL_LINE
+ *mounted = STORAGE_PART_ERROR; //LCOV_EXCL_LINE
+ return STORAGE_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
+
+ iter = blkid_dev_iterate_begin(cache);
+ if (!iter) {
+ _E("Failed to get iterate"); //LCOV_EXCL_LINE
+ *mounted = STORAGE_PART_ERROR; //LCOV_EXCL_LINE
+ return STORAGE_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+ }
+
+ ret_val = blkid_dev_set_search(iter, "LABEL", user_label);
+ if (blkid_dev_next(iter, &dev) == 0) {
+ dev = blkid_verify(cache, dev);
+ if (dev) {
+ found = true;
+ _D("Partition for user data is found(LABEL=%s)", user_label);
+ }
+ }
+ blkid_dev_iterate_end(iter);
+
+ if (!found) {
+ iter = blkid_dev_iterate_begin(cache);
+ if (!iter) {
+ _E("Failed to get iterate"); //LCOV_EXCL_LINE
+ *mounted = STORAGE_PART_ERROR; //LCOV_EXCL_LINE
+ return STORAGE_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+ }
+
+ ret_val = blkid_dev_set_search(iter, "PARTLABEL", user_label);
+ if (blkid_dev_next(iter, &dev) == 0) {
+ dev = blkid_verify(cache, dev);
+ if (dev) {
+ found = true;
+ _D("Partition for user data is found(PARTLABEL=%s)", user_label);
+ }
+ }
+ blkid_dev_iterate_end(iter);
+ }
+
+ blkid_put_cache(cache);
+
+ if (found) {
+ ret_val = mount_check(tzplatform_getenv(TZ_SYS_USER));
+ if (ret_val)
+ *mounted = STORAGE_PART_MOUNTED;
+ else
+ *mounted = STORAGE_PART_NOT_MOUNTED;
+ } else
+ *mounted = STORAGE_PART_NOT_SUPPORTED;