int efup_mount(const char *mount_point) { volume_t *volumep; int result; if (mount_point != NULL) { volumep = volume_list_lookup_by_mount_point(&volumes, mount_point); if (volumep != NULL) { result = mount(volume_get_spec(volumep), mount_point, volume_get_fs_type(volumep), 0, NULL); if (result == -1) result = errno; } else result = ENOENT; } else result = EINVAL; return result; }
int format(const char *vol) { const char *fsType, *dev; volume_t *volume; int result; /* Lookup the specified volume. */ volume = volume_list_lookup_by_mount_point(&volumes, vol); if (volume != NULL) { /* Check mounted volumes. */ result = volume_list_check_mounted(&volumes); if (result == 0) { /* Is the volume mounted? */ if (volume_get_mounted(volume)) { result = EBUSY; } else { /* Get file-system type. */ fsType = volume_get_fs_type(volume); /* Check if supported. */ if ((strcmp(fsType, "ext2")) && (strcmp(fsType, "ext3")) && (strcmp(fsType, "ext4"))) { result = ENOSYS; } } } } else result = ENOENT; /* Volume may be formatted? */ if (result == 0) { dev = volume_get_spec(volume); if (strcmp(fsType, "ext2") == 0) result = format_ext2(dev); if (strcmp(fsType, "ext3") == 0) result = format_ext3(dev); if (strcmp(fsType, "ext4") == 0) result = format_ext4(dev); } return result; }