如何使用 C 从用户空间获取 Linux 中的驱动器标签

发布于 2024-09-30 17:42:31 字数 118 浏览 2 评论 0原文

我需要在 Linux 中使用 c/c++ (并且没有 d-bus)获取特定设备的标签。问题是我不能只打开设备并读取它的信息(对于 extN 来说,很容易从设备获取标签),因为从 /dev/xxx 读取需要 root 权限。

I need to get a label for specific device using c/c++ (and no d-bus) in linux. The problem is that i can't just open device and read it's information (for extN it is very easy to get label from device) because reading from /dev/xxx requires root privileges.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

相对绾红妆 2024-10-07 17:42:31

我认为现在大多数发行版中都

/dev/disk/by-label/

充满了指向真实设备的符号链接。

I think in most distributions now you have

/dev/disk/by-label/

which is filled with symlinks that point to the real device.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文