Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试在不需要 root 访问权限的情况下获取 linux 上的硬盘序列号。这可以通过此源在 Windows 上实现。本质上,它执行DeviceIoControlwith IOCTL_STORAGE_QUERY_PROPERTY。ioctl 版本是多少?
DeviceIoControl
IOCTL_STORAGE_QUERY_PROPERTY
您可以询问 udev,而无需 root 权限。试试这个命令并注意 ID_SERIAL 行:
/sbin/udevadm info --query=property --name /dev/sda
以编程方式,您将使用 libudev。