USTORE(9)
β¨ USTORE β storing data in userspace, but make it safe π
okay so bestie, welcome to USTORE(9) from the Kernel Developer's Manual π this is one of those pages you're gonna want to bookmark, because if you're writing kernel code and you need to poke a single little value into userspace memory, this whole family of functions is literally your girl. no cap.
πΈ NAME πΈ
ustore, ustore_8, ustore_16, ustore_32, ustore_64, ustore_char, ustore_short, ustore_int, ustore_long, ustore_ptr β store data in user-space π
π¦ SYNOPSIS π¦
first things first, you gotta pull in the header:
#include <sys/systm.h>
and then here's the whole squad, all of them returning int:
int
ustore_8(const uint8_t *uaddr, uint8_t val);
int
ustore_16(const uint16_t *uaddr, uint16_t val);
int
ustore_32(const uint32_t *uaddr, uint32_t val);
int
ustore_64(const uint64_t *uaddr, uint64_t val);
int
ustore_char(const unsigned char *uaddr, unsigned char val);
int
ustore_short(const unsigned short *uaddr, unsigned short val);
int
ustore_int(const unsigned int *uaddr, unsigned int val);
int
ustore_long(const unsigned long *uaddr, unsigned long val);
int
ustore_ptr(const void **uaddr, void *val);
like, pick your size, pick your vibe, they're all right there β¨
π DESCRIPTION π
okay so the ustore functions are the way you store a value into single memory cells in user-space. that's the whole thing. in every single one of these, the value val gets stored in the user-space memory location that uaddr points at π«Ά
and here's a lil detail you do not wanna miss: ustore_64 is only available on systems employing the βLP64β memory model. how do you check if you're on one of those? test for the presence of the _LP64 C preprocessor macro, bestie. iykyk π₯
π RETURN VALUES π
the ustore functions return 0 on success and an error number on failure. that's it, that's the vibe check π
π SEE ALSO π
π fr fr, don't skip the_LP64check if you're reaching forustore_64β it's not available on every system, and that's just facts.
and that's the whole page, bestie! π this one's from the Debian folks, dated March 18, 2019 β iconic, honestly. go forth and store your data safely, you main character π§π
π¦ where this page comes from
- nixpkgs unstable: netbsd-source 11.0
- Copyright (c) 2019 The NetBSD Foundation, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms