static bool disk_is_partitioned_by_kernel(struct udev_device *dev)
{
DIR *dp;
+ struct dirent entry;
struct dirent *dir;
const char *syspath;
bool ret = false;
}
/* TODO compare devname and d_name */
- while ((dir = readdir(dp))) {
+ while (readdir_r(dp, &entry, &dir) == 0 && dir != NULL) {
if (!fnmatch(MMC_PARTITION_PATH, dir->d_name, 0) ||
!fnmatch(SCSI_PARTITION_PATH, dir->d_name, 0)) {
ret = true;
#define FS_EXT4_NAME "ext4"
-static const char *check_smack_arg[] = {
- "/usr/bin/mmc-smack-label",
- NULL, NULL,
-};
-
-static const char *ext4_arg[] = {
- "/sbin/mkfs.ext4",
- NULL, NULL,
-};
-
-static const char *ext4_check_arg[] = {
- "/sbin/fsck.ext4",
- "-f", "-y", NULL, NULL,
-};
-
-static struct fs_check ext4_info = {
- FS_TYPE_EXT4,
- "ext4",
- 0x438,
- 2,
- {0x53, 0xef},
-};
-
static bool ext4_match(const char *devpath)
{
+ struct fs_check ext4_info = {
+ FS_TYPE_EXT4,
+ "ext4",
+ 0x438,
+ 2,
+ {0x53, 0xef},
+ };
char buf[4];
int fd, r;
static int ext4_check(const char *devpath)
{
+ const char *ext4_check_arg[] = {
+ "/sbin/fsck.ext4",
+ "-f", "-y", NULL, NULL,
+ };
int argc;
+
argc = ARRAY_SIZE(ext4_check_arg);
ext4_check_arg[argc - 2] = devpath;
return run_child(argc, ext4_check_arg);
static int mmc_check_smack(const char *mount_point)
{
+ const char *check_smack_arg[] = {
+ "/usr/bin/mmc-smack-label",
+ NULL, NULL,
+ };
char buf[NAME_MAX] = {0,};
int argc;
int ret;
static int ext4_format(const char *devpath)
{
+ const char *ext4_arg[] = {
+ "/sbin/mkfs.ext4",
+ NULL, NULL,
+ };
int argc;
+
argc = ARRAY_SIZE(ext4_arg);
ext4_arg[argc - 2] = devpath;
return run_child(argc, ext4_arg);
int print_open_files(const char *mount_point)
{
DIR *dp;
- struct dirent *dentry;
+ struct dirent entry;
+ struct dirent *dir;
DIR *dp_child;
- struct dirent *dentry_child;
+ struct dirent *dir_child;
int pid = -1, fd;
int ret;
}
while (1) {
- dentry = readdir(dp);
- if (dentry == NULL)
+ ret = readdir_r(dp, &entry, &dir);
+ if (dir == NULL)
+ break;
+ if (ret != 0)
break;
- if (!isdigit(dentry->d_name[0]))
+ if (!isdigit(dir->d_name[0]))
continue;
- pid = atoi(dentry->d_name);
+ pid = atoi(dir->d_name);
snprintf(buf, PATH_MAX, "/proc/%d/cmdline", pid);
fd = open(buf, O_RDONLY);
if (!dp_child)
continue;
while (1) {
- dentry_child = readdir(dp_child);
- if (dentry_child == NULL)
+ ret = readdir_r(dp, &entry, &dir_child);
+ if (dir_child == NULL)
+ break;
+ if (ret != 0)
break;
- snprintf(check_path, PATH_MAX, "%s/%s", buf, dentry_child->d_name);
+ snprintf(check_path, PATH_MAX, "%s/%s", buf, dir_child->d_name);
if (readlink(check_path, buf2, PATH_MAX) < 0)
continue;
storaged_module_interface *plugin;
struct storaged_module *module;
DIR *dp;
- struct dirent *dentry;
+ struct dirent entry;
+ struct dirent *dir;
int ret;
char path[256];
return ret;
}
- while ((dentry = readdir(dp))) {
- if (dentry->d_type != DT_REG)
+ while (readdir_r(dp, &entry, &dir) == 0 && dir != NULL) {
+ if (dir->d_type != DT_REG)
continue;
- snprintf(path, sizeof(path), "%s/%s", PLUGIN_PATH, dentry->d_name);
+ snprintf(path, sizeof(path), "%s/%s", PLUGIN_PATH, dir->d_name);
ret = storaged_open_module(path, &plugin);
if (ret < 0) {
_E("Failed to open module (%s: %d)", path, ret);
module = calloc(1, sizeof(struct storaged_module));
module->plugin = plugin;
module->name = strdup(plugin->name);
- module->so_name = strdup(dentry->d_name);
+ module->so_name = strdup(dir->d_name);
module_list = g_list_append(module_list, module);
struct dbus_method_handle_s *item;
struct dbus_handle_s *h = handle;
struct dbus_method_handle_s *mh = method_handle;
+ bool found = false;
if (!h || !h->conn)
return;
l = g_list_next(l), item = NULL) {
if (item == mh) {
h->method_handle_list = g_list_remove(h->method_handle_list, item);
+ found = true;
break;
}
}
- if (!item)
+ if (!found)
return;
dbus_connection_unregister_object_path(h->conn, item->path);
return -ECOMM;
}
- pdata = calloc(1, sizeof(struct pending_call_data));
- if (!pdata) {
- _E("malloc error : %s-%s", interface, method);
- return -ENOMEM;
- }
-
- pdata->func = cb;
- pdata->data = data;
-
msg = dbus_message_new_method_call(dest, path, interface, method);
if (!msg) {
_E("dbus_message_new_method_call(%s:%s-%s)",