mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-17 13:50:06 +01:00
Prepare tools_detect_signatures for new filter type.
This commit is contained in:
committed by
Milan Broz
parent
83ef36bd59
commit
8c350b65a3
@@ -206,7 +206,7 @@ static int action_open_plain(void)
|
|||||||
/* Skip blkid scan when activating plain device with offset */
|
/* Skip blkid scan when activating plain device with offset */
|
||||||
if (!ARG_UINT64(OPT_OFFSET_ID)) {
|
if (!ARG_UINT64(OPT_OFFSET_ID)) {
|
||||||
/* Print all present signatures in read-only mode */
|
/* Print all present signatures in read-only mode */
|
||||||
r = tools_detect_signatures(action_argv[0], 0, &signatures, ARG_SET(OPT_BATCH_MODE_ID));
|
r = tools_detect_signatures(action_argv[0], PRB_FILTER_NONE, &signatures, ARG_SET(OPT_BATCH_MODE_ID));
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@@ -1156,7 +1156,7 @@ static int action_luksRepair(void)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = tools_detect_signatures(action_argv[0], 1, NULL, ARG_SET(OPT_BATCH_MODE_ID));
|
r = tools_detect_signatures(action_argv[0], PRB_FILTER_LUKS, NULL, ARG_SET(OPT_BATCH_MODE_ID));
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
@@ -1340,7 +1340,7 @@ int luksFormat(struct crypt_device **r_cd, char **r_password, size_t *r_password
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Print all present signatures in read-only mode */
|
/* Print all present signatures in read-only mode */
|
||||||
r = tools_detect_signatures(header_device, 0, &signatures, ARG_SET(OPT_BATCH_MODE_ID));
|
r = tools_detect_signatures(header_device, PRB_FILTER_NONE, &signatures, ARG_SET(OPT_BATCH_MODE_ID));
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
|||||||
@@ -110,7 +110,12 @@ int tools_write_mk(const char *file, const char *key, int keysize);
|
|||||||
int tools_read_json_file(const char *file, char **json, size_t *json_size, bool batch_mode);
|
int tools_read_json_file(const char *file, char **json, size_t *json_size, bool batch_mode);
|
||||||
int tools_write_json_file(const char *file, const char *json);
|
int tools_write_json_file(const char *file, const char *json);
|
||||||
|
|
||||||
int tools_detect_signatures(const char *device, int ignore_luks, size_t *count, bool batch_mode);
|
typedef enum {
|
||||||
|
PRB_FILTER_NONE = 0,
|
||||||
|
PRB_FILTER_LUKS
|
||||||
|
} tools_probe_filter_info;
|
||||||
|
|
||||||
|
int tools_detect_signatures(const char *device, tools_probe_filter_info filter, size_t *count, bool batch_mode);
|
||||||
int tools_wipe_all_signatures(const char *path);
|
int tools_wipe_all_signatures(const char *path);
|
||||||
|
|
||||||
int tools_lookup_crypt_device(struct crypt_device *cd, const char *type,
|
int tools_lookup_crypt_device(struct crypt_device *cd, const char *type,
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ static int action_format(void)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = tools_detect_signatures(action_argv[0], 0, &signatures, ARG_SET(OPT_BATCH_MODE_ID));
|
r = tools_detect_signatures(action_argv[0], PRB_FILTER_NONE, &signatures, ARG_SET(OPT_BATCH_MODE_ID));
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
|||||||
@@ -197,7 +197,8 @@ static void report_superblock(const char *value, const char *device, bool batch_
|
|||||||
log_std(_("WARNING: Device %s already contains a '%s' superblock signature.\n"), device, value);
|
log_std(_("WARNING: Device %s already contains a '%s' superblock signature.\n"), device, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
int tools_detect_signatures(const char *device, int ignore_luks, size_t *count, bool batch_mode)
|
int tools_detect_signatures(const char *device, tools_probe_filter_info filter,
|
||||||
|
size_t *count,bool batch_mode)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
size_t tmp_count;
|
size_t tmp_count;
|
||||||
@@ -221,7 +222,7 @@ int tools_detect_signatures(const char *device, int ignore_luks, size_t *count,
|
|||||||
|
|
||||||
blk_set_chains_for_full_print(h);
|
blk_set_chains_for_full_print(h);
|
||||||
|
|
||||||
if (ignore_luks && blk_superblocks_filter_luks(h)) {
|
if (filter == PRB_FILTER_LUKS && blk_superblocks_filter_luks(h)) {
|
||||||
r = -EINVAL;
|
r = -EINVAL;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user