Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

block: partitions: Replace pp_buf with struct seq_buf

In preparation for removing the strlcat API[1], replace the char *pp_buf
with a struct seq_buf, which tracks the current write position and
remaining space internally. This allows for:

- Direct use of seq_buf_printf() in place of snprintf()+strlcat()
pairs, eliminating local tmp buffers throughout.
- Adjacent strlcat() calls that build strings piece-by-piece
(e.g., strlcat("["); strlcat(name); strlcat("]")) to be collapsed
into single seq_buf_printf() calls.
- Simpler call sites: seq_buf_puts() takes only the buffer and string,
with no need to pass PAGE_SIZE at every call.

The backing buffer allocation is unchanged (__get_free_page), and the
output path uses seq_buf_str() to NUL-terminate before passing to
printk().

Link: https://github.com/KSPP/linux/issues/370 [1]
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Josh Law <objecting@objecting.org>
Signed-off-by: Kees Cook <kees@kernel.org>
Reviewed-by: Josh Law <objecting@objecting.org>
Link: https://patch.msgid.link/20260321004840.work.670-kees@kernel.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Kees Cook and committed by
Jens Axboe
c2d466b9 7b6d3255

+106 -157
+14 -18
block/partitions/acorn.c
··· 40 40 (le32_to_cpu(dr->disc_size) >> 9); 41 41 42 42 if (name) { 43 - strlcat(state->pp_buf, " [", PAGE_SIZE); 44 - strlcat(state->pp_buf, name, PAGE_SIZE); 45 - strlcat(state->pp_buf, "]", PAGE_SIZE); 43 + seq_buf_printf(&state->pp_buf, " [%s]", name); 46 44 } 47 45 put_partition(state, slot, first_sector, nr_sects); 48 46 return dr; ··· 76 78 if (!rr) 77 79 return -1; 78 80 79 - strlcat(state->pp_buf, " [RISCiX]", PAGE_SIZE); 81 + seq_buf_puts(&state->pp_buf, " [RISCiX]"); 80 82 81 83 82 84 if (rr->magic == RISCIX_MAGIC) { 83 85 unsigned long size = nr_sects > 2 ? 2 : nr_sects; 84 86 int part; 85 87 86 - strlcat(state->pp_buf, " <", PAGE_SIZE); 88 + seq_buf_puts(&state->pp_buf, " <"); 87 89 88 90 put_partition(state, slot++, first_sect, size); 89 91 for (part = 0; part < 8; part++) { ··· 92 94 put_partition(state, slot++, 93 95 le32_to_cpu(rr->part[part].start), 94 96 le32_to_cpu(rr->part[part].length)); 95 - strlcat(state->pp_buf, "(", PAGE_SIZE); 96 - strlcat(state->pp_buf, rr->part[part].name, PAGE_SIZE); 97 - strlcat(state->pp_buf, ")", PAGE_SIZE); 97 + seq_buf_printf(&state->pp_buf, "(%s)", rr->part[part].name); 98 98 } 99 99 } 100 100 101 - strlcat(state->pp_buf, " >\n", PAGE_SIZE); 101 + seq_buf_puts(&state->pp_buf, " >\n"); 102 102 } else { 103 103 put_partition(state, slot++, first_sect, nr_sects); 104 104 } ··· 126 130 struct linux_part *linuxp; 127 131 unsigned long size = nr_sects > 2 ? 2 : nr_sects; 128 132 129 - strlcat(state->pp_buf, " [Linux]", PAGE_SIZE); 133 + seq_buf_puts(&state->pp_buf, " [Linux]"); 130 134 131 135 put_partition(state, slot++, first_sect, size); 132 136 ··· 134 138 if (!linuxp) 135 139 return -1; 136 140 137 - strlcat(state->pp_buf, " <", PAGE_SIZE); 141 + seq_buf_puts(&state->pp_buf, " <"); 138 142 while (linuxp->magic == cpu_to_le32(LINUX_NATIVE_MAGIC) || 139 143 linuxp->magic == cpu_to_le32(LINUX_SWAP_MAGIC)) { 140 144 if (slot == state->limit) ··· 144 148 le32_to_cpu(linuxp->nr_sects)); 145 149 linuxp ++; 146 150 } 147 - strlcat(state->pp_buf, " >", PAGE_SIZE); 151 + seq_buf_puts(&state->pp_buf, " >"); 148 152 149 153 put_dev_sector(sect); 150 154 return slot; ··· 289 293 break; 290 294 } 291 295 } 292 - strlcat(state->pp_buf, "\n", PAGE_SIZE); 296 + seq_buf_puts(&state->pp_buf, "\n"); 293 297 return 1; 294 298 } 295 299 #endif ··· 362 366 return 0; 363 367 } 364 368 365 - strlcat(state->pp_buf, " [ICS]", PAGE_SIZE); 369 + seq_buf_puts(&state->pp_buf, " [ICS]"); 366 370 367 371 for (slot = 1, p = (const struct ics_part *)data; p->size; p++) { 368 372 u32 start = le32_to_cpu(p->start); ··· 396 400 } 397 401 398 402 put_dev_sector(sect); 399 - strlcat(state->pp_buf, "\n", PAGE_SIZE); 403 + seq_buf_puts(&state->pp_buf, "\n"); 400 404 return 1; 401 405 } 402 406 #endif ··· 456 460 return 0; 457 461 } 458 462 459 - strlcat(state->pp_buf, " [POWERTEC]", PAGE_SIZE); 463 + seq_buf_puts(&state->pp_buf, " [POWERTEC]"); 460 464 461 465 for (i = 0, p = (const struct ptec_part *)data; i < 12; i++, p++) { 462 466 u32 start = le32_to_cpu(p->start); ··· 467 471 } 468 472 469 473 put_dev_sector(sect); 470 - strlcat(state->pp_buf, "\n", PAGE_SIZE); 474 + seq_buf_puts(&state->pp_buf, "\n"); 471 475 return 1; 472 476 } 473 477 #endif ··· 538 542 539 543 size = get_capacity(state->disk); 540 544 put_partition(state, slot++, start, size - start); 541 - strlcat(state->pp_buf, "\n", PAGE_SIZE); 545 + seq_buf_puts(&state->pp_buf, "\n"); 542 546 } 543 547 544 548 return i ? 1 : 0;
+8 -13
block/partitions/aix.c
··· 173 173 if (d) { 174 174 struct lvm_rec *p = (struct lvm_rec *)d; 175 175 u16 lvm_version = be16_to_cpu(p->version); 176 - char tmp[64]; 177 176 178 177 if (lvm_version == 1) { 179 178 int pp_size_log2 = be16_to_cpu(p->pp_size); 180 179 181 180 pp_bytes_size = 1 << pp_size_log2; 182 181 pp_blocks_size = pp_bytes_size / 512; 183 - snprintf(tmp, sizeof(tmp), 184 - " AIX LVM header version %u found\n", 185 - lvm_version); 182 + seq_buf_printf(&state->pp_buf, 183 + " AIX LVM header version %u found\n", 184 + lvm_version); 186 185 vgda_len = be32_to_cpu(p->vgda_len); 187 186 vgda_sector = be32_to_cpu(p->vgda_psn[0]); 188 187 } else { 189 - snprintf(tmp, sizeof(tmp), 190 - " unsupported AIX LVM version %d found\n", 191 - lvm_version); 188 + seq_buf_printf(&state->pp_buf, 189 + " unsupported AIX LVM version %d found\n", 190 + lvm_version); 192 191 } 193 - strlcat(state->pp_buf, tmp, PAGE_SIZE); 194 192 put_dev_sector(sect); 195 193 } 196 194 if (vgda_sector && (d = read_part_sector(state, vgda_sector, &sect))) { ··· 249 251 continue; 250 252 } 251 253 if (lp_ix == lvip[lv_ix].pps_per_lv) { 252 - char tmp[70]; 253 - 254 254 put_partition(state, lv_ix + 1, 255 255 (i + 1 - lp_ix) * pp_blocks_size + psn_part1, 256 256 lvip[lv_ix].pps_per_lv * pp_blocks_size); 257 - snprintf(tmp, sizeof(tmp), " <%s>\n", 258 - n[lv_ix].name); 259 - strlcat(state->pp_buf, tmp, PAGE_SIZE); 257 + seq_buf_printf(&state->pp_buf, " <%s>\n", 258 + n[lv_ix].name); 260 259 lvip[lv_ix].lv_is_contiguous = 1; 261 260 ret = 1; 262 261 next_lp_ix = 1;
+15 -20
block/partitions/amiga.c
··· 81 81 /* blksize is blocks per 512 byte standard block */ 82 82 blksize = be32_to_cpu( rdb->rdb_BlockBytes ) / 512; 83 83 84 - { 85 - char tmp[7 + 10 + 1 + 1]; 86 - 87 - /* Be more informative */ 88 - snprintf(tmp, sizeof(tmp), " RDSK (%d)", blksize * 512); 89 - strlcat(state->pp_buf, tmp, PAGE_SIZE); 90 - } 84 + /* Be more informative */ 85 + seq_buf_printf(&state->pp_buf, " RDSK (%d)", blksize * 512); 91 86 blk = be32_to_cpu(rdb->rdb_PartitionList); 92 87 put_dev_sector(sect); 93 88 for (part = 1; (s32) blk>0 && part<=16; part++, put_dev_sector(sect)) { ··· 174 179 { 175 180 /* Be even more informative to aid mounting */ 176 181 char dostype[4]; 177 - char tmp[42]; 178 182 179 183 __be32 *dt = (__be32 *)dostype; 180 184 *dt = pb->pb_Environment[16]; 181 185 if (dostype[3] < ' ') 182 - snprintf(tmp, sizeof(tmp), " (%c%c%c^%c)", 183 - dostype[0], dostype[1], 184 - dostype[2], dostype[3] + '@' ); 186 + seq_buf_printf(&state->pp_buf, 187 + " (%c%c%c^%c)", 188 + dostype[0], dostype[1], 189 + dostype[2], 190 + dostype[3] + '@'); 185 191 else 186 - snprintf(tmp, sizeof(tmp), " (%c%c%c%c)", 187 - dostype[0], dostype[1], 188 - dostype[2], dostype[3]); 189 - strlcat(state->pp_buf, tmp, PAGE_SIZE); 190 - snprintf(tmp, sizeof(tmp), "(res %d spb %d)", 191 - be32_to_cpu(pb->pb_Environment[6]), 192 - be32_to_cpu(pb->pb_Environment[4])); 193 - strlcat(state->pp_buf, tmp, PAGE_SIZE); 192 + seq_buf_printf(&state->pp_buf, 193 + " (%c%c%c%c)", 194 + dostype[0], dostype[1], 195 + dostype[2], dostype[3]); 196 + seq_buf_printf(&state->pp_buf, "(res %d spb %d)", 197 + be32_to_cpu(pb->pb_Environment[6]), 198 + be32_to_cpu(pb->pb_Environment[4])); 194 199 } 195 200 res = 1; 196 201 } 197 - strlcat(state->pp_buf, "\n", PAGE_SIZE); 202 + seq_buf_puts(&state->pp_buf, "\n"); 198 203 199 204 rdb_done: 200 205 return res;
+6 -6
block/partitions/atari.c
··· 70 70 } 71 71 72 72 pi = &rs->part[0]; 73 - strlcat(state->pp_buf, " AHDI", PAGE_SIZE); 73 + seq_buf_puts(&state->pp_buf, " AHDI"); 74 74 for (slot = 1; pi < &rs->part[4] && slot < state->limit; slot++, pi++) { 75 75 struct rootsector *xrs; 76 76 Sector sect2; ··· 89 89 #ifdef ICD_PARTS 90 90 part_fmt = 1; 91 91 #endif 92 - strlcat(state->pp_buf, " XGM<", PAGE_SIZE); 92 + seq_buf_puts(&state->pp_buf, " XGM<"); 93 93 partsect = extensect = be32_to_cpu(pi->st); 94 94 while (1) { 95 95 xrs = read_part_sector(state, partsect, &sect2); ··· 128 128 break; 129 129 } 130 130 } 131 - strlcat(state->pp_buf, " >", PAGE_SIZE); 131 + seq_buf_puts(&state->pp_buf, " >"); 132 132 } 133 133 #ifdef ICD_PARTS 134 134 if ( part_fmt!=1 ) { /* no extended partitions -> test ICD-format */ 135 135 pi = &rs->icdpart[0]; 136 136 /* sanity check: no ICD format if first partition invalid */ 137 137 if (OK_id(pi->id)) { 138 - strlcat(state->pp_buf, " ICD<", PAGE_SIZE); 138 + seq_buf_puts(&state->pp_buf, " ICD<"); 139 139 for (; pi < &rs->icdpart[8] && slot < state->limit; slot++, pi++) { 140 140 /* accept only GEM,BGM,RAW,LNX,SWP partitions */ 141 141 if (!((pi->flg & 1) && OK_id(pi->id))) ··· 144 144 be32_to_cpu(pi->st), 145 145 be32_to_cpu(pi->siz)); 146 146 } 147 - strlcat(state->pp_buf, " >", PAGE_SIZE); 147 + seq_buf_puts(&state->pp_buf, " >"); 148 148 } 149 149 } 150 150 #endif 151 151 put_dev_sector(sect); 152 152 153 - strlcat(state->pp_buf, "\n", PAGE_SIZE); 153 + seq_buf_puts(&state->pp_buf, "\n"); 154 154 155 155 return 1; 156 156 }
+3 -5
block/partitions/check.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 */ 2 2 #include <linux/pagemap.h> 3 3 #include <linux/blkdev.h> 4 + #include <linux/seq_buf.h> 4 5 #include "../blk.h" 5 6 6 7 /* ··· 21 20 int next; 22 21 int limit; 23 22 bool access_beyond_eod; 24 - char *pp_buf; 23 + struct seq_buf pp_buf; 25 24 }; 26 25 27 26 typedef struct { ··· 38 37 put_partition(struct parsed_partitions *p, int n, sector_t from, sector_t size) 39 38 { 40 39 if (n < p->limit) { 41 - char tmp[1 + BDEVNAME_SIZE + 10 + 1]; 42 - 43 40 p->parts[n].from = from; 44 41 p->parts[n].size = size; 45 - snprintf(tmp, sizeof(tmp), " %s%d", p->name, n); 46 - strlcat(p->pp_buf, tmp, PAGE_SIZE); 42 + seq_buf_printf(&p->pp_buf, " %s%d", p->name, n); 47 43 } 48 44 } 49 45
+2 -4
block/partitions/cmdline.c
··· 229 229 struct parsed_partitions *state) 230 230 { 231 231 struct partition_meta_info *info; 232 - char tmp[sizeof(info->volname) + 4]; 233 232 234 233 if (slot >= state->limit) 235 234 return 1; ··· 243 244 244 245 strscpy(info->volname, subpart->name, sizeof(info->volname)); 245 246 246 - snprintf(tmp, sizeof(tmp), "(%s)", info->volname); 247 - strlcat(state->pp_buf, tmp, PAGE_SIZE); 247 + seq_buf_printf(&state->pp_buf, "(%s)", info->volname); 248 248 249 249 state->parts[slot].has_info = true; 250 250 ··· 377 379 cmdline_parts_set(parts, disk_size, state); 378 380 cmdline_parts_verifier(1, state); 379 381 380 - strlcat(state->pp_buf, "\n", PAGE_SIZE); 382 + seq_buf_puts(&state->pp_buf, "\n"); 381 383 382 384 return 1; 383 385 }
+10 -10
block/partitions/core.c
··· 123 123 state = allocate_partitions(hd); 124 124 if (!state) 125 125 return NULL; 126 - state->pp_buf = (char *)__get_free_page(GFP_KERNEL); 127 - if (!state->pp_buf) { 126 + state->pp_buf.buffer = (char *)__get_free_page(GFP_KERNEL); 127 + if (!state->pp_buf.buffer) { 128 128 free_partitions(state); 129 129 return NULL; 130 130 } 131 - state->pp_buf[0] = '\0'; 131 + seq_buf_init(&state->pp_buf, state->pp_buf.buffer, PAGE_SIZE); 132 132 133 133 state->disk = hd; 134 134 strscpy(state->name, hd->disk_name); 135 - snprintf(state->pp_buf, PAGE_SIZE, " %s:", state->name); 135 + seq_buf_printf(&state->pp_buf, " %s:", state->name); 136 136 if (isdigit(state->name[strlen(state->name)-1])) 137 137 sprintf(state->name, "p"); 138 138 ··· 151 151 152 152 } 153 153 if (res > 0) { 154 - printk(KERN_INFO "%s", state->pp_buf); 154 + printk(KERN_INFO "%s", seq_buf_str(&state->pp_buf)); 155 155 156 - free_page((unsigned long)state->pp_buf); 156 + free_page((unsigned long)state->pp_buf.buffer); 157 157 return state; 158 158 } 159 159 if (state->access_beyond_eod) ··· 164 164 if (err) 165 165 res = err; 166 166 if (res) { 167 - strlcat(state->pp_buf, 168 - " unable to read partition table\n", PAGE_SIZE); 169 - printk(KERN_INFO "%s", state->pp_buf); 167 + seq_buf_puts(&state->pp_buf, 168 + " unable to read partition table\n"); 169 + printk(KERN_INFO "%s", seq_buf_str(&state->pp_buf)); 170 170 } 171 171 172 - free_page((unsigned long)state->pp_buf); 172 + free_page((unsigned long)state->pp_buf.buffer); 173 173 free_partitions(state); 174 174 return ERR_PTR(res); 175 175 }
+1 -1
block/partitions/efi.c
··· 751 751 } 752 752 kfree(ptes); 753 753 kfree(gpt); 754 - strlcat(state->pp_buf, "\n", PAGE_SIZE); 754 + seq_buf_puts(&state->pp_buf, "\n"); 755 755 return 1; 756 756 }
+10 -17
block/partitions/ibm.c
··· 173 173 { 174 174 sector_t blk; 175 175 int counter; 176 - char tmp[64]; 177 176 Sector sect; 178 177 unsigned char *data; 179 178 loff_t offset, size; 180 179 struct vtoc_format1_label f1; 181 180 int secperblk; 182 181 183 - snprintf(tmp, sizeof(tmp), "VOL1/%8s:", name); 184 - strlcat(state->pp_buf, tmp, PAGE_SIZE); 182 + seq_buf_printf(&state->pp_buf, "VOL1/%8s:", name); 185 183 /* 186 184 * get start of VTOC from the disk label and then search for format1 187 185 * and format8 labels ··· 217 219 blk++; 218 220 data = read_part_sector(state, blk * secperblk, &sect); 219 221 } 220 - strlcat(state->pp_buf, "\n", PAGE_SIZE); 222 + seq_buf_puts(&state->pp_buf, "\n"); 221 223 222 224 if (!data) 223 225 return -1; ··· 235 237 dasd_information2_t *info) 236 238 { 237 239 loff_t offset, geo_size, size; 238 - char tmp[64]; 239 240 int secperblk; 240 241 241 - snprintf(tmp, sizeof(tmp), "LNX1/%8s:", name); 242 - strlcat(state->pp_buf, tmp, PAGE_SIZE); 242 + seq_buf_printf(&state->pp_buf, "LNX1/%8s:", name); 243 243 secperblk = blocksize >> 9; 244 244 if (label->lnx.ldl_version == 0xf2) { 245 245 size = label->lnx.formatted_blocks * secperblk; ··· 254 258 size = nr_sectors; 255 259 if (size != geo_size) { 256 260 if (!info) { 257 - strlcat(state->pp_buf, "\n", PAGE_SIZE); 261 + seq_buf_puts(&state->pp_buf, "\n"); 258 262 return 1; 259 263 } 260 264 if (!strcmp(info->type, "ECKD")) ··· 266 270 /* first and only partition starts in the first block after the label */ 267 271 offset = labelsect + secperblk; 268 272 put_partition(state, 1, offset, size - offset); 269 - strlcat(state->pp_buf, "\n", PAGE_SIZE); 273 + seq_buf_puts(&state->pp_buf, "\n"); 270 274 return 1; 271 275 } 272 276 ··· 278 282 sector_t labelsect) 279 283 { 280 284 loff_t offset, size; 281 - char tmp[64]; 282 285 int secperblk; 283 286 284 287 /* ··· 286 291 blocksize = label->cms.block_size; 287 292 secperblk = blocksize >> 9; 288 293 if (label->cms.disk_offset != 0) { 289 - snprintf(tmp, sizeof(tmp), "CMS1/%8s(MDSK):", name); 290 - strlcat(state->pp_buf, tmp, PAGE_SIZE); 294 + seq_buf_printf(&state->pp_buf, "CMS1/%8s(MDSK):", name); 291 295 /* disk is reserved minidisk */ 292 296 offset = label->cms.disk_offset * secperblk; 293 297 size = (label->cms.block_count - 1) * secperblk; 294 298 } else { 295 - snprintf(tmp, sizeof(tmp), "CMS1/%8s:", name); 296 - strlcat(state->pp_buf, tmp, PAGE_SIZE); 299 + seq_buf_printf(&state->pp_buf, "CMS1/%8s:", name); 297 300 /* 298 301 * Special case for FBA devices: 299 302 * If an FBA device is CMS formatted with blocksize > 512 byte ··· 307 314 } 308 315 309 316 put_partition(state, 1, offset, size-offset); 310 - strlcat(state->pp_buf, "\n", PAGE_SIZE); 317 + seq_buf_puts(&state->pp_buf, "\n"); 311 318 return 1; 312 319 } 313 320 ··· 384 391 */ 385 392 res = 1; 386 393 if (info->format == DASD_FORMAT_LDL) { 387 - strlcat(state->pp_buf, "(nonl)", PAGE_SIZE); 394 + seq_buf_puts(&state->pp_buf, "(nonl)"); 388 395 size = nr_sectors; 389 396 offset = (info->label_block + 1) * (blocksize >> 9); 390 397 put_partition(state, 1, offset, size-offset); 391 - strlcat(state->pp_buf, "\n", PAGE_SIZE); 398 + seq_buf_puts(&state->pp_buf, "\n"); 392 399 } 393 400 } else 394 401 res = 0;
+1 -1
block/partitions/karma.c
··· 53 53 } 54 54 slot++; 55 55 } 56 - strlcat(state->pp_buf, "\n", PAGE_SIZE); 56 + seq_buf_puts(&state->pp_buf, "\n"); 57 57 put_dev_sector(sect); 58 58 return 1; 59 59 }
+2 -2
block/partitions/ldm.c
··· 582 582 return false; 583 583 } 584 584 585 - strlcat(pp->pp_buf, " [LDM]", PAGE_SIZE); 585 + seq_buf_puts(&pp->pp_buf, " [LDM]"); 586 586 587 587 /* Create the data partitions */ 588 588 list_for_each (item, &ldb->v_part) { ··· 597 597 part_num++; 598 598 } 599 599 600 - strlcat(pp->pp_buf, "\n", PAGE_SIZE); 600 + seq_buf_puts(&pp->pp_buf, "\n"); 601 601 return true; 602 602 } 603 603
+2 -2
block/partitions/mac.c
··· 86 86 if (blocks_in_map >= state->limit) 87 87 blocks_in_map = state->limit - 1; 88 88 89 - strlcat(state->pp_buf, " [mac]", PAGE_SIZE); 89 + seq_buf_puts(&state->pp_buf, " [mac]"); 90 90 for (slot = 1; slot <= blocks_in_map; ++slot) { 91 91 int pos = slot * secsize; 92 92 put_dev_sector(sect); ··· 152 152 #endif 153 153 154 154 put_dev_sector(sect); 155 - strlcat(state->pp_buf, "\n", PAGE_SIZE); 155 + seq_buf_puts(&state->pp_buf, "\n"); 156 156 return 1; 157 157 }
+23 -44
block/partitions/msdos.c
··· 263 263 put_dev_sector(sect); 264 264 return; 265 265 } 266 - { 267 - char tmp[1 + BDEVNAME_SIZE + 10 + 11 + 1]; 268 - 269 - snprintf(tmp, sizeof(tmp), " %s%d: <solaris:", state->name, origin); 270 - strlcat(state->pp_buf, tmp, PAGE_SIZE); 271 - } 266 + seq_buf_printf(&state->pp_buf, " %s%d: <solaris:", state->name, origin); 272 267 if (le32_to_cpu(v->v_version) != 1) { 273 - char tmp[64]; 274 - 275 - snprintf(tmp, sizeof(tmp), " cannot handle version %d vtoc>\n", 276 - le32_to_cpu(v->v_version)); 277 - strlcat(state->pp_buf, tmp, PAGE_SIZE); 268 + seq_buf_printf(&state->pp_buf, 269 + " cannot handle version %d vtoc>\n", 270 + le32_to_cpu(v->v_version)); 278 271 put_dev_sector(sect); 279 272 return; 280 273 } ··· 275 282 max_nparts = le16_to_cpu(v->v_nparts) > 8 ? SOLARIS_X86_NUMSLICE : 8; 276 283 for (i = 0; i < max_nparts && state->next < state->limit; i++) { 277 284 struct solaris_x86_slice *s = &v->v_slice[i]; 278 - char tmp[3 + 10 + 1 + 1]; 279 285 280 286 if (s->s_size == 0) 281 287 continue; 282 - snprintf(tmp, sizeof(tmp), " [s%d]", i); 283 - strlcat(state->pp_buf, tmp, PAGE_SIZE); 288 + seq_buf_printf(&state->pp_buf, " [s%d]", i); 284 289 /* solaris partitions are relative to current MS-DOS 285 290 * one; must add the offset of the current partition */ 286 291 put_partition(state, state->next++, ··· 286 295 le32_to_cpu(s->s_size)); 287 296 } 288 297 put_dev_sector(sect); 289 - strlcat(state->pp_buf, " >\n", PAGE_SIZE); 298 + seq_buf_puts(&state->pp_buf, " >\n"); 290 299 #endif 291 300 } 292 301 ··· 350 359 Sector sect; 351 360 struct bsd_disklabel *l; 352 361 struct bsd_partition *p; 353 - char tmp[64]; 354 362 355 363 l = read_part_sector(state, offset + 1, &sect); 356 364 if (!l) ··· 359 369 return; 360 370 } 361 371 362 - snprintf(tmp, sizeof(tmp), " %s%d: <%s:", state->name, origin, flavour); 363 - strlcat(state->pp_buf, tmp, PAGE_SIZE); 372 + seq_buf_printf(&state->pp_buf, " %s%d: <%s:", state->name, origin, flavour); 364 373 365 374 if (le16_to_cpu(l->d_npartitions) < max_partitions) 366 375 max_partitions = le16_to_cpu(l->d_npartitions); ··· 380 391 /* full parent partition, we have it already */ 381 392 continue; 382 393 if (offset > bsd_start || offset+size < bsd_start+bsd_size) { 383 - strlcat(state->pp_buf, "bad subpartition - ignored\n", PAGE_SIZE); 394 + seq_buf_puts(&state->pp_buf, "bad subpartition - ignored\n"); 384 395 continue; 385 396 } 386 397 put_partition(state, state->next++, bsd_start, bsd_size); 387 398 } 388 399 put_dev_sector(sect); 389 - if (le16_to_cpu(l->d_npartitions) > max_partitions) { 390 - snprintf(tmp, sizeof(tmp), " (ignored %d more)", 391 - le16_to_cpu(l->d_npartitions) - max_partitions); 392 - strlcat(state->pp_buf, tmp, PAGE_SIZE); 393 - } 394 - strlcat(state->pp_buf, " >\n", PAGE_SIZE); 400 + if (le16_to_cpu(l->d_npartitions) > max_partitions) 401 + seq_buf_printf(&state->pp_buf, " (ignored %d more)", 402 + le16_to_cpu(l->d_npartitions) - max_partitions); 403 + seq_buf_puts(&state->pp_buf, " >\n"); 395 404 } 396 405 #endif 397 406 ··· 483 496 put_dev_sector(sect); 484 497 return; 485 498 } 486 - { 487 - char tmp[1 + BDEVNAME_SIZE + 10 + 12 + 1]; 488 - 489 - snprintf(tmp, sizeof(tmp), " %s%d: <unixware:", state->name, origin); 490 - strlcat(state->pp_buf, tmp, PAGE_SIZE); 491 - } 499 + seq_buf_printf(&state->pp_buf, " %s%d: <unixware:", state->name, origin); 492 500 p = &l->vtoc.v_slice[1]; 493 501 /* I omit the 0th slice as it is the same as whole disk. */ 494 502 while (p - &l->vtoc.v_slice[0] < UNIXWARE_NUMSLICE) { ··· 497 515 p++; 498 516 } 499 517 put_dev_sector(sect); 500 - strlcat(state->pp_buf, " >\n", PAGE_SIZE); 518 + seq_buf_puts(&state->pp_buf, " >\n"); 501 519 #endif 502 520 } 503 521 ··· 528 546 * the normal boot sector. */ 529 547 if (msdos_magic_present(data + 510) && 530 548 p->sys_ind == MINIX_PARTITION) { /* subpartition table present */ 531 - char tmp[1 + BDEVNAME_SIZE + 10 + 9 + 1]; 532 - 533 - snprintf(tmp, sizeof(tmp), " %s%d: <minix:", state->name, origin); 534 - strlcat(state->pp_buf, tmp, PAGE_SIZE); 549 + seq_buf_printf(&state->pp_buf, " %s%d: <minix:", state->name, origin); 535 550 for (i = 0; i < MINIX_NR_SUBPARTITIONS; i++, p++) { 536 551 if (state->next == state->limit) 537 552 break; ··· 537 558 put_partition(state, state->next++, 538 559 start_sect(p), nr_sects(p)); 539 560 } 540 - strlcat(state->pp_buf, " >\n", PAGE_SIZE); 561 + seq_buf_puts(&state->pp_buf, " >\n"); 541 562 } 542 563 put_dev_sector(sect); 543 564 #endif /* CONFIG_MINIX_SUBPARTITION */ ··· 581 602 #ifdef CONFIG_AIX_PARTITION 582 603 return aix_partition(state); 583 604 #else 584 - strlcat(state->pp_buf, " [AIX]", PAGE_SIZE); 605 + seq_buf_puts(&state->pp_buf, " [AIX]"); 585 606 return 0; 586 607 #endif 587 608 } ··· 608 629 fb = (struct fat_boot_sector *) data; 609 630 if (slot == 1 && fb->reserved && fb->fats 610 631 && fat_valid_media(fb->media)) { 611 - strlcat(state->pp_buf, "\n", PAGE_SIZE); 632 + seq_buf_puts(&state->pp_buf, "\n"); 612 633 put_dev_sector(sect); 613 634 return 1; 614 635 } else { ··· 657 678 n = min(size, max(sector_size, n)); 658 679 put_partition(state, slot, start, n); 659 680 660 - strlcat(state->pp_buf, " <", PAGE_SIZE); 681 + seq_buf_puts(&state->pp_buf, " <"); 661 682 parse_extended(state, start, size, disksig); 662 - strlcat(state->pp_buf, " >", PAGE_SIZE); 683 + seq_buf_puts(&state->pp_buf, " >"); 663 684 continue; 664 685 } 665 686 put_partition(state, slot, start, size); ··· 667 688 if (p->sys_ind == LINUX_RAID_PARTITION) 668 689 state->parts[slot].flags = ADDPART_FLAG_RAID; 669 690 if (p->sys_ind == DM6_PARTITION) 670 - strlcat(state->pp_buf, "[DM]", PAGE_SIZE); 691 + seq_buf_puts(&state->pp_buf, "[DM]"); 671 692 if (p->sys_ind == EZD_PARTITION) 672 - strlcat(state->pp_buf, "[EZD]", PAGE_SIZE); 693 + seq_buf_puts(&state->pp_buf, "[EZD]"); 673 694 } 674 695 675 - strlcat(state->pp_buf, "\n", PAGE_SIZE); 696 + seq_buf_puts(&state->pp_buf, "\n"); 676 697 677 698 /* second pass - output for each on a separate line */ 678 699 p = (struct msdos_partition *) (0x1be + data);
+2 -4
block/partitions/of.c
··· 36 36 struct device_node *np) 37 37 { 38 38 struct partition_meta_info *info; 39 - char tmp[sizeof(info->volname) + 4]; 40 39 const char *partname; 41 40 int len; 42 41 ··· 62 63 partname = of_get_property(np, "name", &len); 63 64 strscpy(info->volname, partname, sizeof(info->volname)); 64 65 65 - snprintf(tmp, sizeof(tmp), "(%s)", info->volname); 66 - strlcat(state->pp_buf, tmp, PAGE_SIZE); 66 + seq_buf_printf(&state->pp_buf, "(%s)", info->volname); 67 67 } 68 68 69 69 int of_partition(struct parsed_partitions *state) ··· 102 104 slot++; 103 105 } 104 106 105 - strlcat(state->pp_buf, "\n", PAGE_SIZE); 107 + seq_buf_puts(&state->pp_buf, "\n"); 106 108 107 109 return 1; 108 110 }
+1 -1
block/partitions/osf.c
··· 81 81 le32_to_cpu(partition->p_size)); 82 82 slot++; 83 83 } 84 - strlcat(state->pp_buf, "\n", PAGE_SIZE); 84 + seq_buf_puts(&state->pp_buf, "\n"); 85 85 put_dev_sector(sect); 86 86 return 1; 87 87 }
+1 -1
block/partitions/sgi.c
··· 79 79 } 80 80 slot++; 81 81 } 82 - strlcat(state->pp_buf, "\n", PAGE_SIZE); 82 + seq_buf_puts(&state->pp_buf, "\n"); 83 83 put_dev_sector(sect); 84 84 return 1; 85 85 }
+1 -1
block/partitions/sun.c
··· 121 121 } 122 122 slot++; 123 123 } 124 - strlcat(state->pp_buf, "\n", PAGE_SIZE); 124 + seq_buf_puts(&state->pp_buf, "\n"); 125 125 put_dev_sector(sect); 126 126 return 1; 127 127 }
+3 -6
block/partitions/sysv68.c
··· 54 54 unsigned char *data; 55 55 struct dkblk0 *b; 56 56 struct slice *slice; 57 - char tmp[64]; 58 57 59 58 data = read_part_sector(state, 0, &sect); 60 59 if (!data) ··· 73 74 return -1; 74 75 75 76 slices -= 1; /* last slice is the whole disk */ 76 - snprintf(tmp, sizeof(tmp), "sysV68: %s(s%u)", state->name, slices); 77 - strlcat(state->pp_buf, tmp, PAGE_SIZE); 77 + seq_buf_printf(&state->pp_buf, "sysV68: %s(s%u)", state->name, slices); 78 78 slice = (struct slice *)data; 79 79 for (i = 0; i < slices; i++, slice++) { 80 80 if (slot == state->limit) ··· 82 84 put_partition(state, slot, 83 85 be32_to_cpu(slice->blkoff), 84 86 be32_to_cpu(slice->nblocks)); 85 - snprintf(tmp, sizeof(tmp), "(s%u)", i); 86 - strlcat(state->pp_buf, tmp, PAGE_SIZE); 87 + seq_buf_printf(&state->pp_buf, "(s%u)", i); 87 88 } 88 89 slot++; 89 90 } 90 - strlcat(state->pp_buf, "\n", PAGE_SIZE); 91 + seq_buf_puts(&state->pp_buf, "\n"); 91 92 put_dev_sector(sect); 92 93 return 1; 93 94 }
+1 -1
block/partitions/ultrix.c
··· 39 39 label->pt_part[i].pi_blkoff, 40 40 label->pt_part[i].pi_nblocks); 41 41 put_dev_sector(sect); 42 - strlcat(state->pp_buf, "\n", PAGE_SIZE); 42 + seq_buf_puts(&state->pp_buf, "\n"); 43 43 return 1; 44 44 } else { 45 45 put_dev_sector(sect);