bitmap_parselist(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… bitmap_parselist(9) β€” the kernel API manual, bestie edition πŸŽ€

okay so we're doing bitmap_parselist today, from the Kernel API Manual, and honestly? she's iconic. this is the function that takes a cute little ASCII list and turns it into a bitmap. let's get into it ✨


🌸 NAME 🌸

bitmap_parselist β€” convert list format ASCII string to bitmap

like, string goes in, bitmap comes out. that's the whole vibe. πŸ’–


πŸ¦‹ SYNOPSIS πŸ¦‹

int bitmap_parselist (const char *buf , unsigned long *maskp , int
nmaskbits );

three args, no cap. she takes buf, maskp, and nmaskbits and returns an int. periodt. πŸ‘‘


πŸ’œ ARGUMENTS πŸ’œ

  • buf β€” read the user string from this buffer, bestie. it must be terminated with a \n or 0. do not skip this, i'm literally begging πŸ₯Ί
  • maskp β€” write the resulting mask right here, this is where the good stuff goes ✨
  • nmaskbits β€” the number of bits in the mask that are gonna get written. so like, the size of the whole situation πŸ’…

πŸŽ€ DESCRIPTION πŸŽ€

so the input format is a comma-separated list of decimal numbers and ranges. consecutively set bits get shown as two hyphen-separated decimal numbers β€” the smallest and the largest bit numbers set in the range. simple, slay πŸ“

optionally, each range can be postfixed to say "hey, only parts of this range should be set." the range will be divided into groups of a specific size, and from each group only a defined amount of bits gets used. the syntax is, drumroll please:

range:used_size/group_size

and here are the error values, aka the moments where she says "no ❀️":

  • `-EINVAL`: wrong region format πŸ™ˆ
  • `-EINVAL`: invalid character in string 😭
  • `-ERANGE`: bit number specified is too large for the mask πŸ’€
  • `-EOVERFLOW`: integer overflow in the input parameters πŸ”₯

⭐ EXAMPLE ⭐

0-1023:2/256 ==> 0,1,256,257,512,513,768,769

look at her go. genuinely obsessed 🫢

also!! the value N can be used as a dynamically substituted token for the maximum allowed value β€” that's (nmaskbits - 1), iykyk. but keep in mind that it is dynamic, so if system changes cause the bitmap width to change (like, say, more cores showing up in a CPU list), then any ranges using N will change too. she's flexible like that 🌈


πŸ’« RETURN πŸ’«

0 on success, -errno on invalid input strings. the error values are the ones listed above, in DESCRIPTION, where they live 🧚


πŸ” SEE ALSO πŸ”

go read the whole friend group, they're all main characters πŸ’–


ngl, the error bullet list technically lives inside DESCRIPTION in this page but it's describing the RETURN values β€” that's just how the original rolls, don't come for me πŸ™ˆ

and that's the page, bestie!! brought to you by ./lib, October 2026 edition of bitmap_parselist(9) β€” she ate and left no crumbs πŸŽ€βœ¨πŸ’…

πŸ“¦ where this page comes from