如何使用C从用户空间获取驱动器标签在Linux中 [英] How to get drive label in Linux using C from userspace

查看:128
本文介绍了如何使用C从用户空间获取驱动器标签在Linux中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要获得在Linux中使用C / C ++(无D-BUS)特定设备的标签。问题是,我不能只打开设备并读取它的信息(分机它是非常容易得到来自设备标签),因为从/ 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.

推荐答案

我觉得在大部分发行,现在你有

I think in most distributions now you have

/dev/disk/by-label/

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

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

这篇关于如何使用C从用户空间获取驱动器标签在Linux中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆