return fp;
}
+int print_open_files(const char *mount_point)
+{
+ DIR *dp;
+ struct dirent entry;
+ struct dirent *dentry;
+
+ DIR *dp_child;
+ struct dirent entry_child;
+ struct dirent *dentry_child;
+
+ int pid = -1, fd;
+ int ret;
+ char buf[PATH_MAX];
+ char buf2[PATH_MAX];
+
+ char cmdline[PATH_MAX];
+ char check_path[PATH_MAX];
+
+ int len = strlen(mount_point);
+
+ dp = opendir("/proc");
+ if (!dp) {
+ _E("FAIL: open /proc");
+ return -1;
+ }
+
+ while (1) {
+ ret = readdir_r(dp, &entry, &dentry);
+ if (ret != 0 || dentry == NULL)
+ break;
+
+ if (!isdigit(dentry->d_name[0]))
+ continue;
+
+ pid = atoi(dentry->d_name);
+ snprintf(buf, PATH_MAX, "/proc/%d/cmdline", pid);
+
+ fd = open(buf, O_RDONLY);
+ if (fd < 0)
+ continue;
+ ret = read(fd, cmdline, PATH_MAX);
+ close(fd);
+
+ if (ret < 0 || ret >= PATH_MAX)
+ continue;
+ cmdline[ret] = '\0';
+
+ snprintf(buf, PATH_MAX, "/proc/%d/fd", pid);
+ dp_child = opendir(buf);
+ if (!dp_child)
+ continue;
+ while (1){
+ ret = readdir_r(dp_child, &entry_child, &dentry_child);
+ if (ret != 0 || dentry_child == NULL)
+ break;
+
+ snprintf(check_path, PATH_MAX, "%s/%s",buf, dentry_child->d_name);
+
+ if(readlink(check_path, buf2, PATH_MAX) < 0)
+ continue;
+
+ if(strncmp(buf2, mount_point, len) == 0)
+ _D("Process %s : Opened files - %s", cmdline, buf2);
+ }
+ closedir(dp_child);
+ }
+
+ closedir(dp);
+ return 0;
+}
+
int get_exec_pid(const char *execpath)
{
DIR *dp;