sysfs_change_owner(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… sysfs_change_owner β€” the kernel API manual, but make it cute

okay bestie, welcome to the Kernel API Manual ✨ this one's a little function with big main-character energy: sysfs_change_owner. It literally changes who owns stuff. slay.


✨ NAME ✨

sysfs_change_owner β€” change owner of the given object πŸ’–


πŸ¦‹ SYNOPSIS πŸ¦‹

int sysfs_change_owner (struct kobject *kobj , kuid_t kuid , kgid_t kgid );

that's the whole signature, no cap. three args, one int back. 🫢


πŸŽ€ ARGUMENTS πŸŽ€

  • kobj β€” object. yeah. that's it. the object. the main character of this whole page πŸ‘‘
  • kuid β€” new owner's kuid πŸ’œ
  • kgid β€” new owner's kgid πŸ’œ

🌸 DESCRIPTION 🌸

So here's the vibe: sysfs_change_owner changes the owner of the default directory, files, groups, and attributes of kobj to kuid/kgid. iconic behaviour, honestly.

and like, the way it does this is mirroring how the sysfs entries for a kobject get added by driver core. in summary (and I'm quoting the vibe here, not adding anything), sysfs_change_owner takes care of:

  • the default directory entry for kobj
  • the default attributes associated with the ktype of kobj
  • the default attributes associated with the ktype of kobj β€” and yes bestie, it's listed twice in the source, so we're listing it twice. we don't gatekeep, we don't edit. ✨

ngl though, this is the important part: additional properties not added by driver core have to be changed by the driver or subsystem which created them. so if you made it yourself, you're changing it yourself. periodt. πŸ’…

and this whole thing is similar to how driver/subsystem specific entries are removed β€” same energy, matching set. 🧚

πŸ“ Returns 0 on success or error code on failure. no in-between, no "sort of worked", it's 0 or it's a whole error code, that's the deal.

πŸ”₯ SEE ALSO πŸ”₯

go off, related functions β€” kernel file ./fs/sysfs/file.c and the whole friend group:


okay that's the whole page, you ate it up πŸ’– mwah. this little icon was served up from ./fs/sysfs, dated October 2026 β€” remember her πŸŽ€βœ¨πŸŒ·

πŸ“¦ where this page comes from