Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/lib/blockdev.c.in
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,8 @@ gboolean bd_init (BDPluginSpec **require_plugins, BDUtilsLogFunc log_func, GErro
}

if (!load_plugins (require_plugins, FALSE, &num_loaded)) {
g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_PLUGINS_FAILED,
"Failed to load plugins");
g_set_error_literal (error, BD_INIT_ERROR, BD_INIT_ERROR_PLUGINS_FAILED,
"Failed to load plugins");
success = FALSE;
}

Expand Down Expand Up @@ -518,8 +518,8 @@ gboolean bd_ensure_init (BDPluginSpec **require_plugins, BDUtilsLogFunc log_func
}

if (!load_plugins (require_plugins, FALSE, &num_loaded)) {
g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_PLUGINS_FAILED,
"Failed to load plugins");
g_set_error_literal (error, BD_INIT_ERROR, BD_INIT_ERROR_PLUGINS_FAILED,
"Failed to load plugins");
success = FALSE;
}

Expand Down Expand Up @@ -622,8 +622,8 @@ gboolean bd_reinit (BDPluginSpec **require_plugins, gboolean reload, BDUtilsLogF
}

if (!load_plugins (require_plugins, reload, &num_loaded)) {
g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_PLUGINS_FAILED,
"Failed to load plugins");
g_set_error_literal (error, BD_INIT_ERROR, BD_INIT_ERROR_PLUGINS_FAILED,
"Failed to load plugins");
success = FALSE;
} else
if (require_plugins && (*require_plugins == NULL) && reload)
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/btrfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ gboolean bd_btrfs_create_volume (const gchar **devices, const gchar *label, cons
return FALSE;

if (!devices || (g_strv_length ((gchar **) devices) < 1)) {
g_set_error (error, BD_BTRFS_ERROR, BD_BTRFS_ERROR_DEVICE, "No devices given");
g_set_error_literal (error, BD_BTRFS_ERROR, BD_BTRFS_ERROR_DEVICE, "No devices given");
return FALSE;
}

Expand Down Expand Up @@ -480,7 +480,7 @@ guint64 bd_btrfs_get_default_subvolume_id (const gchar *mountpoint, GError **err

success = g_regex_match (regex, output, 0, &match_info);
if (!success) {
g_set_error (error, BD_BTRFS_ERROR, BD_BTRFS_ERROR_PARSE, "Failed to parse subvolume's ID");
g_set_error_literal (error, BD_BTRFS_ERROR, BD_BTRFS_ERROR_PARSE, "Failed to parse subvolume's ID");
g_regex_unref (regex);
g_match_info_free (match_info);
g_free (output);
Expand Down Expand Up @@ -619,7 +619,7 @@ BDBtrfsDeviceInfo** bd_btrfs_list_devices (const gchar *device, GError **error)
g_regex_unref (regex);

if (dev_infos->len == 0) {
g_set_error (error, BD_BTRFS_ERROR, BD_BTRFS_ERROR_PARSE, "Failed to parse information about devices");
g_set_error_literal (error, BD_BTRFS_ERROR, BD_BTRFS_ERROR_PARSE, "Failed to parse information about devices");
g_ptr_array_free (dev_infos, TRUE);
return NULL;
}
Expand Down Expand Up @@ -712,7 +712,7 @@ BDBtrfsSubvolumeInfo** bd_btrfs_list_subvolumes (const gchar *mountpoint, gboole
g_regex_unref (regex);

if (subvol_infos->len == 0) {
g_set_error (error, BD_BTRFS_ERROR, BD_BTRFS_ERROR_PARSE, "Failed to parse information about subvolumes");
g_set_error_literal (error, BD_BTRFS_ERROR, BD_BTRFS_ERROR_PARSE, "Failed to parse information about subvolumes");
g_ptr_array_free (subvol_infos, TRUE);
return NULL;
}
Expand Down
253 changes: 128 additions & 125 deletions src/plugins/crypto.c

Large diffs are not rendered by default.

40 changes: 20 additions & 20 deletions src/plugins/dm.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,14 @@ gchar* bd_dm_name_from_node (const gchar *dm_node, GError **error) {
g_autofree gchar *sys_path = g_strdup_printf ("/sys/class/block/%s/dm/name", dm_node);

if (!dm_node || strlen (dm_node) == 0) {
g_set_error (error, BD_DM_ERROR, BD_DM_ERROR_DEVICE_NOEXIST,
"No DM node specified");
g_set_error_literal (error, BD_DM_ERROR, BD_DM_ERROR_DEVICE_NOEXIST,
"No DM node specified");
return NULL;
}

if (access (sys_path, R_OK) != 0) {
g_set_error (error, BD_DM_ERROR, BD_DM_ERROR_SYS,
"Failed to access dm node's parameters under /sys");
g_set_error_literal (error, BD_DM_ERROR, BD_DM_ERROR_SYS,
"Failed to access dm node's parameters under /sys");
return NULL;
}

Expand Down Expand Up @@ -215,8 +215,8 @@ gchar* bd_dm_node_from_name (const gchar *map_name, GError **error) {
g_autofree gchar *dev_mapper_path = g_strdup_printf ("/dev/mapper/%s", map_name);

if (!map_name || strlen (map_name) == 0) {
g_set_error (error, BD_DM_ERROR, BD_DM_ERROR_DEVICE_NOEXIST,
"No DM name specified");
g_set_error_literal (error, BD_DM_ERROR, BD_DM_ERROR_DEVICE_NOEXIST,
"No DM name specified");
return NULL;
}

Expand Down Expand Up @@ -246,28 +246,28 @@ gchar* bd_dm_get_subsystem_from_name (const gchar *device_name, GError **error)

task = dm_task_create (DM_DEVICE_INFO);
if (!task) {
g_set_error (error, BD_DM_ERROR, BD_DM_ERROR_TASK,
"Failed to create DM task");
g_set_error_literal (error, BD_DM_ERROR, BD_DM_ERROR_TASK,
"Failed to create DM task");
return NULL;
}

if (!dm_task_set_name (task, device_name)) {
g_set_error (error, BD_DM_ERROR, BD_DM_ERROR_TASK,
"Failed to set device name for DM task");
g_set_error_literal (error, BD_DM_ERROR, BD_DM_ERROR_TASK,
"Failed to set device name for DM task");
dm_task_destroy (task);
return NULL;
}

if (!dm_task_run (task)) {
g_set_error (error, BD_DM_ERROR, BD_DM_ERROR_TASK,
"Failed to run DM task");
g_set_error_literal (error, BD_DM_ERROR, BD_DM_ERROR_TASK,
"Failed to run DM task");
dm_task_destroy (task);
return NULL;
}

if (!dm_task_get_info (task, &info)) {
g_set_error (error, BD_DM_ERROR, BD_DM_ERROR_TASK,
"Failed to get info from DM task");
g_set_error_literal (error, BD_DM_ERROR, BD_DM_ERROR_TASK,
"Failed to get info from DM task");
dm_task_destroy (task);
return NULL;
}
Expand Down Expand Up @@ -317,15 +317,15 @@ gboolean bd_dm_map_exists (const gchar *map_name, gboolean live_only, gboolean a
gboolean ret = FALSE;

if (geteuid () != 0) {
g_set_error (error, BD_DM_ERROR, BD_DM_ERROR_NOT_ROOT,
"Not running as root, cannot query DM maps");
g_set_error_literal (error, BD_DM_ERROR, BD_DM_ERROR_NOT_ROOT,
"Not running as root, cannot query DM maps");
return FALSE;
}

task_list = dm_task_create (DM_DEVICE_LIST);
if (!task_list) {
g_set_error (error, BD_DM_ERROR, BD_DM_ERROR_TASK,
"Failed to create DM task");
g_set_error_literal (error, BD_DM_ERROR, BD_DM_ERROR_TASK,
"Failed to create DM task");
return FALSE;
}

Expand All @@ -348,8 +348,8 @@ gboolean bd_dm_map_exists (const gchar *map_name, gboolean live_only, gboolean a
/* get device info */
task_info = dm_task_create (DM_DEVICE_INFO);
if (!task_info) {
g_set_error (error, BD_DM_ERROR, BD_DM_ERROR_TASK,
"Failed to create DM task");
g_set_error_literal (error, BD_DM_ERROR, BD_DM_ERROR_TASK,
"Failed to create DM task");
break;
}

Expand Down
4 changes: 2 additions & 2 deletions src/plugins/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ gboolean bd_fs_is_tech_avail (BDFSTech tech, guint64 mode, GError **error) {
return TRUE;

if (tech > BD_FS_LAST_FS) {
g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_TECH_UNAVAIL, "Unknown technology");
g_set_error_literal (error, BD_FS_ERROR, BD_FS_ERROR_TECH_UNAVAIL, "Unknown technology");
return FALSE;
}

Expand Down Expand Up @@ -120,7 +120,7 @@ gboolean bd_fs_is_tech_avail (BDFSTech tech, guint64 mode, GError **error) {
default:
/* this should never be reached (see the comparison with LAST_FS
above), but better safe than sorry */
g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_TECH_UNAVAIL, "Unknown technology");
g_set_error_literal (error, BD_FS_ERROR, BD_FS_ERROR_TECH_UNAVAIL, "Unknown technology");
return FALSE;
}
}
16 changes: 8 additions & 8 deletions src/plugins/fs/btrfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,14 +238,14 @@ gboolean bd_fs_btrfs_set_label (const gchar *mpoint, const gchar *label, GError
*/
gboolean bd_fs_btrfs_check_label (const gchar *label, GError **error) {
if (strlen (label) > 256) {
g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_LABEL_INVALID,
"Label for btrfs filesystem must be at most 256 characters long.");
g_set_error_literal (error, BD_FS_ERROR, BD_FS_ERROR_LABEL_INVALID,
"Label for btrfs filesystem must be at most 256 characters long.");
return FALSE;
}

if (strchr (label, '\n') != NULL) {
g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_LABEL_INVALID,
"Label for btrfs filesystem cannot contain new lines.");
g_set_error_literal (error, BD_FS_ERROR, BD_FS_ERROR_LABEL_INVALID,
"Label for btrfs filesystem cannot contain new lines.");
return FALSE;
}

Expand Down Expand Up @@ -351,8 +351,8 @@ BDFSBtrfsInfo* bd_fs_btrfs_get_info (const gchar *mpoint, GError **error) {

success = g_regex_match (regex, output, 0, &match_info);
if (!success) {
g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_PARSE,
"Failed to parse btrfs filesystem information");
g_set_error_literal (error, BD_FS_ERROR, BD_FS_ERROR_PARSE,
"Failed to parse btrfs filesystem information");
g_regex_unref (regex);
g_match_info_free (match_info);
return NULL;
Expand Down Expand Up @@ -401,8 +401,8 @@ BDFSBtrfsInfo* bd_fs_btrfs_get_info (const gchar *mpoint, GError **error) {
/* 114032640 bytes (108.75MiB) */
scanned = sscanf (output, " %" G_GUINT64_FORMAT " bytes", &min_size);
if (scanned != 1) {
g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_PARSE,
"Failed to parse btrfs filesystem min size.");
g_set_error_literal (error, BD_FS_ERROR, BD_FS_ERROR_PARSE,
"Failed to parse btrfs filesystem min size.");
bd_fs_btrfs_info_free (ret);
return NULL;
}
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/fs/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,16 @@ check_uuid (const gchar *uuid, GError **error) {
uuid_t uu;

if (!g_str_is_ascii (uuid)) {
g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_UUID_INVALID,
"Provided UUID is not a valid RFC-4122 UUID.");
g_set_error_literal (error, BD_FS_ERROR, BD_FS_ERROR_UUID_INVALID,
"Provided UUID is not a valid RFC-4122 UUID.");
return FALSE;
}

lowercase = g_ascii_strdown (uuid, -1);
ret = uuid_parse (lowercase, uu);
if (ret < 0){
g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_UUID_INVALID,
"Provided UUID is not a valid RFC-4122 UUID.");
g_set_error_literal (error, BD_FS_ERROR, BD_FS_ERROR_UUID_INVALID,
"Provided UUID is not a valid RFC-4122 UUID.");
return FALSE;
}

Expand Down
24 changes: 12 additions & 12 deletions src/plugins/fs/exfat.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ bd_fs_exfat_is_tech_avail (BDFSTech tech G_GNUC_UNUSED, guint64 mode, GError **e
guint i = 0;

if (mode & BD_FS_TECH_MODE_RESIZE) {
g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_TECH_UNAVAIL,
"exFAT currently doesn't support resizing.");
g_set_error_literal (error, BD_FS_ERROR, BD_FS_ERROR_TECH_UNAVAIL,
"exFAT currently doesn't support resizing.");
return FALSE;
}

Expand Down Expand Up @@ -259,14 +259,14 @@ gboolean bd_fs_exfat_check_label (const gchar *label, GError **error) {
}

if (!str) {
g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_LABEL_INVALID,
"Label for exFAT filesystem must be a valid UTF-8 string.");
g_set_error_literal (error, BD_FS_ERROR, BD_FS_ERROR_LABEL_INVALID,
"Label for exFAT filesystem must be a valid UTF-8 string.");
return FALSE;
}

if (bytes_written > 22) {
g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_LABEL_INVALID,
"Label for exFAT filesystem is too long.");
g_set_error_literal (error, BD_FS_ERROR, BD_FS_ERROR_LABEL_INVALID,
"Label for exFAT filesystem is too long.");
return FALSE;
}

Expand Down Expand Up @@ -349,15 +349,15 @@ gboolean bd_fs_exfat_check_uuid (const gchar *uuid, GError **error) {

vol_id = g_ascii_strtoull (new_uuid, &endptr, 16);
if ((vol_id == 0 && endptr == new_uuid) || (endptr && *endptr)) {
g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_UUID_INVALID,
"UUID for exFAT filesystem must be a hexadecimal number.");
g_set_error_literal (error, BD_FS_ERROR, BD_FS_ERROR_UUID_INVALID,
"UUID for exFAT filesystem must be a hexadecimal number.");
g_free (new_uuid);
return FALSE;
}

if (vol_id > G_MAXUINT32) {
g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_UUID_INVALID,
"UUID for exFAT filesystem must fit into 32 bits.");
g_set_error_literal (error, BD_FS_ERROR, BD_FS_ERROR_UUID_INVALID,
"UUID for exFAT filesystem must fit into 32 bits.");
g_free (new_uuid);
return FALSE;
}
Expand Down Expand Up @@ -432,8 +432,8 @@ BDFSExfatInfo* bd_fs_exfat_get_info (const gchar *device, GError **error) {
g_strfreev (lines);

if (ret->sector_size == 0 || ret->sector_count == 0 || ret->cluster_count == 0) {
g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_FAIL,
"Failed to to parse exFAT info.");
g_set_error_literal (error, BD_FS_ERROR, BD_FS_ERROR_FAIL,
"Failed to parse exFAT info.");
bd_fs_exfat_info_free (ret);
return NULL;
}
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/fs/ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -558,8 +558,8 @@ gboolean bd_fs_ext4_set_label (const gchar *device, const gchar *label, GError *
*/
gboolean bd_fs_ext2_check_label (const gchar *label, GError **error) {
if (strlen (label) > 16) {
g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_LABEL_INVALID,
"Label for ext filesystem must be at most 16 characters long.");
g_set_error_literal (error, BD_FS_ERROR, BD_FS_ERROR_LABEL_INVALID,
"Label for ext filesystem must be at most 16 characters long.");
return FALSE;
}

Expand Down Expand Up @@ -735,7 +735,7 @@ static BDFSExtInfo* ext_get_info (const gchar *device, GError **error) {
unix_io_manager,
&fs);
if (retval) {
g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_FAIL, "Failed to open ext4 file system");
g_set_error_literal (error, BD_FS_ERROR, BD_FS_ERROR_FAIL, "Failed to open ext4 file system");
return NULL;
}

Expand Down
20 changes: 10 additions & 10 deletions src/plugins/fs/f2fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,14 @@ bd_fs_f2fs_is_tech_avail (BDFSTech tech G_GNUC_UNUSED, guint64 mode, GError **er
guint i = 0;

if (mode & BD_FS_TECH_MODE_SET_LABEL) {
g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_TECH_UNAVAIL,
"F2FS doesn't support setting label for an existing device.");
g_set_error_literal (error, BD_FS_ERROR, BD_FS_ERROR_TECH_UNAVAIL,
"F2FS doesn't support setting label for an existing device.");
return FALSE;
}

if (mode & BD_FS_TECH_MODE_SET_UUID) {
g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_TECH_UNAVAIL,
"F2FS doesn't support setting UUID for an existing device.");
g_set_error_literal (error, BD_FS_ERROR, BD_FS_ERROR_TECH_UNAVAIL,
"F2FS doesn't support setting UUID for an existing device.");
return FALSE;
}

Expand Down Expand Up @@ -323,7 +323,7 @@ BDFSF2FSInfo* bd_fs_f2fs_get_info (const gchar *device, GError **error) {
while (line_p && *line_p && !g_str_has_prefix (*line_p, "Info: total FS sectors"))
line_p++;
if (!line_p || !(*line_p)) {
g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_PARSE, "Failed to parse F2FS file system information");
g_set_error_literal (error, BD_FS_ERROR, BD_FS_ERROR_PARSE, "Failed to parse F2FS file system information");
g_strfreev (lines);
bd_fs_f2fs_info_free (ret);
return NULL;
Expand All @@ -338,7 +338,7 @@ BDFSF2FSInfo* bd_fs_f2fs_get_info (const gchar *device, GError **error) {
while (line_p && *line_p && !g_str_has_prefix (*line_p, "Info: superblock features"))
line_p++;
if (!line_p || !(*line_p)) {
g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_PARSE, "Failed to parse F2FS file system information");
g_set_error_literal (error, BD_FS_ERROR, BD_FS_ERROR_PARSE, "Failed to parse F2FS file system information");
g_strfreev (lines);
bd_fs_f2fs_info_free (ret);
return NULL;
Expand Down Expand Up @@ -395,8 +395,8 @@ gboolean bd_fs_f2fs_resize (const gchar *device, guint64 new_size, gboolean safe

if (new_size != 0 && new_size < info->sector_count && !safe) {
/* resize.f2fs prints error and returns 0 in this case */
g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_INVAL,
"F2FS filesystem doesn't support shrinking without using the 'safe' option");
g_set_error_literal (error, BD_FS_ERROR, BD_FS_ERROR_INVAL,
"F2FS filesystem doesn't support shrinking without using the 'safe' option");
bd_fs_f2fs_info_free (info);
return FALSE;
}
Expand Down Expand Up @@ -435,8 +435,8 @@ gboolean bd_fs_f2fs_check_label (const gchar *label, GError **error) {

len = strlen (label);
if (len > 512) {
g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_LABEL_INVALID,
"Label for F2FS filesystem must be at most 512 characters long.");
g_set_error_literal (error, BD_FS_ERROR, BD_FS_ERROR_LABEL_INVALID,
"Label for F2FS filesystem must be at most 512 characters long.");
return FALSE;
}

Expand Down
Loading