mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-13 20:00:08 +01:00
Remove helper get_first_data_offset completely.
This commit is contained in:
committed by
Milan Broz
parent
203fe0f4bf
commit
361fb22954
@@ -21,34 +21,6 @@
|
|||||||
|
|
||||||
#include "luks2_internal.h"
|
#include "luks2_internal.h"
|
||||||
|
|
||||||
/* use only on already validated 'segments' object */
|
|
||||||
static uint64_t get_first_data_offset(json_object *jobj_segs, const char *type)
|
|
||||||
{
|
|
||||||
json_object *jobj_offset, *jobj_type;
|
|
||||||
uint64_t tmp, min = UINT64_MAX;
|
|
||||||
|
|
||||||
json_object_object_foreach(jobj_segs, key, val) {
|
|
||||||
UNUSED(key);
|
|
||||||
|
|
||||||
if (type) {
|
|
||||||
json_object_object_get_ex(val, "type", &jobj_type);
|
|
||||||
if (strcmp(type, json_object_get_string(jobj_type)))
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
json_object_object_get_ex(val, "offset", &jobj_offset);
|
|
||||||
tmp = json_object_get_uint64(jobj_offset);
|
|
||||||
|
|
||||||
if (!tmp)
|
|
||||||
return tmp;
|
|
||||||
|
|
||||||
if (tmp < min)
|
|
||||||
min = tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
return min;
|
|
||||||
}
|
|
||||||
|
|
||||||
json_object *json_get_segments_jobj(json_object *hdr_jobj)
|
json_object *json_get_segments_jobj(json_object *hdr_jobj)
|
||||||
{
|
{
|
||||||
json_object *jobj_segments;
|
json_object *jobj_segments;
|
||||||
@@ -59,11 +31,27 @@ json_object *json_get_segments_jobj(json_object *hdr_jobj)
|
|||||||
return jobj_segments;
|
return jobj_segments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* use only on already validated 'segments' object */
|
||||||
uint64_t json_segments_get_minimal_offset(json_object *jobj_segments, unsigned blockwise)
|
uint64_t json_segments_get_minimal_offset(json_object *jobj_segments, unsigned blockwise)
|
||||||
{
|
{
|
||||||
|
uint64_t tmp, min = blockwise ? UINT64_MAX >> SECTOR_SHIFT : UINT64_MAX;
|
||||||
|
|
||||||
if (!jobj_segments)
|
if (!jobj_segments)
|
||||||
return 0;
|
return 0;
|
||||||
return blockwise ? get_first_data_offset(jobj_segments, NULL) >> SECTOR_SHIFT : get_first_data_offset(jobj_segments, NULL);
|
|
||||||
|
json_object_object_foreach(jobj_segments, key, val) {
|
||||||
|
UNUSED(key);
|
||||||
|
|
||||||
|
tmp = json_segment_get_offset(val, blockwise);
|
||||||
|
|
||||||
|
if (!tmp)
|
||||||
|
return tmp;
|
||||||
|
|
||||||
|
if (tmp < min)
|
||||||
|
min = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
return min;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t json_segment_get_offset(json_object *jobj_segment, unsigned blockwise)
|
uint64_t json_segment_get_offset(json_object *jobj_segment, unsigned blockwise)
|
||||||
|
|||||||
Reference in New Issue
Block a user