Lines Matching +full:slot +full:- +full:size

1 // SPDX-License-Identifier: GPL-2.0
14 * For further information, see "Documentation/block/cmdline-partition.rst"
30 sector_t size; member
51 return -ENOMEM; in parse_subpart()
53 if (*partdef == '-') { in parse_subpart()
54 new_subpart->size = (sector_t)(~0ULL); in parse_subpart()
57 new_subpart->size = (sector_t)memparse(partdef, &partdef); in parse_subpart()
58 if (new_subpart->size < (sector_t)PAGE_SIZE) { in parse_subpart()
59 pr_warn("cmdline partition size is invalid."); in parse_subpart()
60 ret = -EINVAL; in parse_subpart()
67 new_subpart->from = (sector_t)memparse(partdef, &partdef); in parse_subpart()
69 new_subpart->from = (sector_t)(~0ULL); in parse_subpart()
78 ret = -EINVAL; in parse_subpart()
82 strscpy(new_subpart->name, next, sizeof(new_subpart->name)); in parse_subpart()
84 new_subpart->name[0] = '\0'; in parse_subpart()
86 new_subpart->flags = 0; in parse_subpart()
89 new_subpart->flags |= PF_RDONLY; in parse_subpart()
94 new_subpart->flags |= PF_POWERUP_LOCK; in parse_subpart()
109 while (parts->subpart) { in free_subpart()
110 subpart = parts->subpart; in free_subpart()
111 parts->subpart = subpart->next_subpart; in free_subpart()
118 int ret = -EINVAL; in parse_parts()
127 return -ENOMEM; in parse_parts()
135 strscpy(newparts->name, next, sizeof(newparts->name)); in parse_parts()
136 newparts->nr_subparts = 0; in parse_parts()
138 next_subpart = &newparts->subpart; in parse_parts()
145 newparts->nr_subparts++; in parse_parts()
146 next_subpart = &(*next_subpart)->next_subpart; in parse_parts()
149 if (!newparts->subpart) { in parse_parts()
151 ret = -EINVAL; in parse_parts()
169 next_parts = (*parts)->next_parts; in cmdline_parts_free()
189 return -ENOMEM; in cmdline_parts_parse()
198 next_parts = &(*next_parts)->next_parts; in cmdline_parts_parse()
203 ret = -EINVAL; in cmdline_parts_parse()
220 while (parts && strncmp(bdev, parts->name, sizeof(parts->name))) in cmdline_parts_find()
221 parts = parts->next_parts; in cmdline_parts_find()
228 static int add_part(int slot, struct cmdline_subpart *subpart, in add_part() argument
232 char tmp[sizeof(info->volname) + 4]; in add_part()
234 if (slot >= state->limit) in add_part()
237 put_partition(state, slot, subpart->from >> 9, in add_part()
238 subpart->size >> 9); in add_part()
240 if (subpart->flags & PF_RDONLY) in add_part()
241 state->parts[slot].flags |= ADDPART_FLAG_READONLY; in add_part()
243 info = &state->parts[slot].info; in add_part()
245 strscpy(info->volname, subpart->name, sizeof(info->volname)); in add_part()
247 snprintf(tmp, sizeof(tmp), "(%s)", info->volname); in add_part()
248 strlcat(state->pp_buf, tmp, PAGE_SIZE); in add_part()
250 state->parts[slot].has_info = true; in add_part()
260 int slot = 1; in cmdline_parts_set() local
262 for (subpart = parts->subpart; subpart; in cmdline_parts_set()
263 subpart = subpart->next_subpart, slot++) { in cmdline_parts_set()
264 if (subpart->from == (sector_t)(~0ULL)) in cmdline_parts_set()
265 subpart->from = from; in cmdline_parts_set()
267 from = subpart->from; in cmdline_parts_set()
272 if (subpart->size > (disk_size - from)) in cmdline_parts_set()
273 subpart->size = disk_size - from; in cmdline_parts_set()
275 from += subpart->size; in cmdline_parts_set()
277 if (add_part(slot, subpart, state)) in cmdline_parts_set()
281 return slot; in cmdline_parts_set()
291 static bool has_overlaps(sector_t from, sector_t size, in has_overlaps() argument
294 sector_t end = from + size; in has_overlaps()
318 static void cmdline_parts_verifier(int slot, struct parsed_partitions *state) in cmdline_parts_verifier() argument
323 for (; slot < state->limit && state->parts[slot].has_info; slot++) { in cmdline_parts_verifier()
324 for (i = slot+1; i < state->limit && state->parts[i].has_info; in cmdline_parts_verifier()
326 if (has_overlaps(state->parts[slot].from, in cmdline_parts_verifier()
327 state->parts[slot].size, in cmdline_parts_verifier()
328 state->parts[i].from, in cmdline_parts_verifier()
329 state->parts[i].size)) { in cmdline_parts_verifier()
336 state->parts[slot].info.volname, in cmdline_parts_verifier()
337 (u64)state->parts[slot].from << 9, in cmdline_parts_verifier()
338 (u64)state->parts[slot].size << 9, in cmdline_parts_verifier()
339 state->parts[i].info.volname, in cmdline_parts_verifier()
340 (u64)state->parts[i].from << 9, in cmdline_parts_verifier()
341 (u64)state->parts[i].size << 9); in cmdline_parts_verifier()
350 * -1 if unable to read the partition table
365 return -1; in cmdline_partition()
373 parts = cmdline_parts_find(bdev_parts, state->disk->disk_name); in cmdline_partition()
377 disk_size = get_capacity(state->disk) << 9; in cmdline_partition()
382 strlcat(state->pp_buf, "\n", PAGE_SIZE); in cmdline_partition()