nvme_get_log_smart(2)
π nvme_get_log_smart β bestie edition π
okay so this is a page from the libnvme API manual, and it's about nvme_get_log_smart(2), aka the lil function that goes and grabs the SMART log off your NVMe device. pull up a chair, we're doing this β¨
πΈ NAME πΈ
nvme_get_log_smart β retrieve nvme smart log π©Ίβ¨ like, it's literally the health check but for your drive, no cap.
π SYNOPSIS π
int nvme_get_log_smart (int fd , __u32 nsid , bool rae , struct
nvme_smart_log *smart_log );
she takes four things and gives you back an int. that's the whole vibe.
π¦ ARGUMENTS π¦
fdβ the file descriptor of the nvme device π this is your main character, your entry point, the one who knocks.nsidβ optional namespace identifier π«Ά optional!! she's not mandatory, she's a choice.raeβ retain asynchronous events π you're telling it whether to hold onto those async events or not.smart_logβ user address to store the smart log π this is where the tea gets poured. hand it a place to put the results and it will fill it.
π DESCRIPTION π
so this log page is giving SMART and general health information π©Ίπ the info it hands you is over the life of the controller and β important β it's retained across power cycles. so even if you yeet the power, that history stays. iconic behavior honestly.
to request the controller log page, the namespace identifier you specify is FFFFFFFFh β that's the magic one, the "give me the whole controller" move, iykyk.
the controller may also support requesting the log page on a per namespace basis β whether it does is indicated by bit 0 of the LPA field in the Identify Controller data structure π so like. check that bit before you assume, bestie.
π RETURN π
what you get back is the nvme command status if a response was received (see enum nvme_status_field) π«Ά
or, and this is the not-fun one, -1 with errno set otherwise π so if you see -1, go check errno, that's where the actual drama is.
lowkey a whole vibe: this function is just "hey controller, how are you feeling" and the controller replies in a struct. we love a healthy drive. we do NOT love a -1. periodt.
and that's the page, babe π brought to you by libnvme API manual, nvme_get_log_smart, dated July 2026 π stay healthy, keep your FFFFFFFFh close, and always close your file descriptors πβ¨
π¦ where this page comes from
- ubuntu stonking: libnvme-dev 1.16.2-1build1 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms