^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Parse command line, get partition information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Written by Cai Zhiyong <caizhiyong@huawei.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/cmdline-parser.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) static int parse_subpart(struct cmdline_subpart **subpart, char *partdef)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) struct cmdline_subpart *new_subpart;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) *subpart = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) new_subpart = kzalloc(sizeof(struct cmdline_subpart), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) if (!new_subpart)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) if (*partdef == '-') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) new_subpart->size = (sector_t)(~0ULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) partdef++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) new_subpart->size = (sector_t)memparse(partdef, &partdef);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) if (new_subpart->size < (sector_t)PAGE_SIZE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) pr_warn("cmdline partition size is invalid.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) goto fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) if (*partdef == '@') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) partdef++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) new_subpart->from = (sector_t)memparse(partdef, &partdef);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) new_subpart->from = (sector_t)(~0ULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) if (*partdef == '(') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) int length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) char *next = strchr(++partdef, ')');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) if (!next) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) pr_warn("cmdline partition format is invalid.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) goto fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) length = min_t(int, next - partdef,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) sizeof(new_subpart->name) - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) strncpy(new_subpart->name, partdef, length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) new_subpart->name[length] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) partdef = ++next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) new_subpart->name[0] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) new_subpart->flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) if (!strncmp(partdef, "ro", 2)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) new_subpart->flags |= PF_RDONLY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) partdef += 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) if (!strncmp(partdef, "lk", 2)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) new_subpart->flags |= PF_POWERUP_LOCK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) partdef += 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) *subpart = new_subpart;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) fail:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) kfree(new_subpart);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) static void free_subpart(struct cmdline_parts *parts)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) struct cmdline_subpart *subpart;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) while (parts->subpart) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) subpart = parts->subpart;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) parts->subpart = subpart->next_subpart;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) kfree(subpart);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) static int parse_parts(struct cmdline_parts **parts, const char *bdevdef)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) int ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) char *next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) int length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) struct cmdline_subpart **next_subpart;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) struct cmdline_parts *newparts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) char buf[BDEVNAME_SIZE + 32 + 4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) *parts = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) newparts = kzalloc(sizeof(struct cmdline_parts), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) if (!newparts)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) next = strchr(bdevdef, ':');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) if (!next) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) pr_warn("cmdline partition has no block device.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) goto fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) length = min_t(int, next - bdevdef, sizeof(newparts->name) - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) strncpy(newparts->name, bdevdef, length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) newparts->name[length] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) newparts->nr_subparts = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) next_subpart = &newparts->subpart;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) while (next && *(++next)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) bdevdef = next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) next = strchr(bdevdef, ',');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) length = (!next) ? (sizeof(buf) - 1) :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) min_t(int, next - bdevdef, sizeof(buf) - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) strncpy(buf, bdevdef, length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) buf[length] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) ret = parse_subpart(next_subpart, buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) goto fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) newparts->nr_subparts++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) next_subpart = &(*next_subpart)->next_subpart;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) if (!newparts->subpart) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) pr_warn("cmdline partition has no valid partition.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) goto fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) *parts = newparts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) fail:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) free_subpart(newparts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) kfree(newparts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) void cmdline_parts_free(struct cmdline_parts **parts)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) struct cmdline_parts *next_parts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) while (*parts) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) next_parts = (*parts)->next_parts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) free_subpart(*parts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) kfree(*parts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) *parts = next_parts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) EXPORT_SYMBOL(cmdline_parts_free);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) int cmdline_parts_parse(struct cmdline_parts **parts, const char *cmdline)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) char *buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) char *pbuf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) char *next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) struct cmdline_parts **next_parts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) *parts = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) next = pbuf = buf = kstrdup(cmdline, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) if (!buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) next_parts = parts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) while (next && *pbuf) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) next = strchr(pbuf, ';');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) if (next)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) *next = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) ret = parse_parts(next_parts, pbuf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) goto fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) if (next)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) pbuf = ++next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) next_parts = &(*next_parts)->next_parts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) if (!*parts) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) pr_warn("cmdline partition has no valid partition.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) goto fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) done:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) kfree(buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) fail:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) cmdline_parts_free(parts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) goto done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) EXPORT_SYMBOL(cmdline_parts_parse);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) struct cmdline_parts *cmdline_parts_find(struct cmdline_parts *parts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) const char *bdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) while (parts && strncmp(bdev, parts->name, sizeof(parts->name)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) parts = parts->next_parts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) return parts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) EXPORT_SYMBOL(cmdline_parts_find);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) * add_part()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) * 0 success.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) * 1 can not add so many partitions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) int cmdline_parts_set(struct cmdline_parts *parts, sector_t disk_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) int slot,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) int (*add_part)(int, struct cmdline_subpart *, void *),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) void *param)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) sector_t from = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) struct cmdline_subpart *subpart;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) for (subpart = parts->subpart; subpart;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) subpart = subpart->next_subpart, slot++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) if (subpart->from == (sector_t)(~0ULL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) subpart->from = from;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) from = subpart->from;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) if (from >= disk_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) if (subpart->size > (disk_size - from))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) subpart->size = disk_size - from;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) from += subpart->size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) if (add_part(slot, subpart, param))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) return slot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) EXPORT_SYMBOL(cmdline_parts_set);