common: change fscanf to fgets
[platform/core/system/libstorage.git] / src / storage-external.c
index b5654f2..42ea2e8 100755 (executable)
@@ -359,6 +359,7 @@ int storage_ext_get_root(int storage_id, char *path, size_t len)
        FILE *fp;
        storage_ext_device *dev;
        char file_name[PATH_LEN];
+       char *tmp;
        int ret = 0;
 
        if (storage_id < 0)
@@ -377,14 +378,14 @@ int storage_ext_get_root(int storage_id, char *path, size_t len)
                        goto out;
                }
 
-               ret = fscanf(fp, "%s", path);
-               if (ret <= 0) {
+               tmp = fgets(path, len, fp);
+               fclose(fp);
+               if (!tmp) {
                        ret = -ENODEV;
                        _D("Failed to get path");
-                       fclose(fp);
                        goto out;
                }
-               fclose(fp);
+
        } else {
                dev = calloc(1, sizeof(storage_ext_device));
                if (!dev) {