libblkid - a library to handle device identification and token extraction
Basic usage is as follows - there are two normal usage patterns:
For cases where a program wants information about multiple devices, or
expects to be doing multiple token searches, the program should
directly initialize cache file via (second parameter is cache
filename, NULL = default):
blkid_cache cache = NULL;
if (blkid_get_cache(&cache, NULL) < 0)
/* error reading the cache file, not really fatal */
Note that if no cache file exists, an empty cache struct is still
allocated. Usage of libblkid functions will use the cache to avoid
needless device scans.
The model of the blkid cache is that each device has a number of
attributes that can be associated with it. Currently the attributes
which are supported (and set) by blkid are:
TYPE filesystem type
UUID filesystem uuid
LABEL filesystem label
How to use libblkid? Normally, you either want to find a device with
a specific NAME=value token, or you want to output token(s) from a
device. To find a device that matches a following attribute, you
simply call the blkid_get_devname() function:
if ((devname = blkid_get_devname(cache, attribute_name, value))) {
/* do something with devname */
string_free(devname);
}
The cache parameter is optional; if it is NULL, then the blkid library
will load the default blkid.tab cache file, and then release the cache
before function call returns. The return value is an allocated string
which holds the resulting device name (if it is found). If the value
is NULL, then attribute_name is parsed as if it were
"<attribute_name>=<value>"; if it cannot be so parsed, then the
original attribute_name is returned in a copied allocated string.
This is a convenience to allow user programs to want to translate user
input, whether it is of the form: "/dev/hda1", "LABEL=root",
"UUID=082D-26E3", and get back a device name that it can use.
Alternatively, of course, the programmer can pass an attribute name of
"LABEL", and value of "root", if that is more convenient.
Another common usage is to retrieve the value of a specific attribute
for a particular device. This can be used to determine the filesystem
type, or label, or uuid for a particular device:
if ((value = blkid_get_tag_value(cache, attribute_name, devname))) {
/* do something with value */
string_free(value);
}
If a program needs to call multiple blkid functions, then passing in a
cache value of NULL is not recommended, since the /etc/blkid.tab file
will be repeatedly parsed over and over again, with memory allocated
and deallocated. To initialize the blkid cache, blkid_get_cache()
function is used:
if (blkid_get_cache(&cache, NULL) < 0)
goto errout;
The second parameter of blkid_get_cache (if non-zero) is the alternate
filename of the blkid cache file (where the default is
/etc/blkid.tab). Normally, programs should just pass in NULL.
If you have called blkid_get_cache(), you should call blkid_put_cache()
when you are done using the blkid library functions. This will save the
cache to the blkid.tab file, if you have write access to the file. It
will also free all associated devices and tags:
blkid_put_cache(cache);
没有合适的资源?快使用搜索试试~ 我知道了~
e2fsprogs-1.41.6.tar.gz
4星 · 超过85%的资源 需积分: 13 20 下载量 29 浏览量
2009-06-24
17:14:24
上传
评论
收藏 4.22MB GZ 举报
温馨提示
共1079个文件
c:273个
1:95个
h:93个
e2fsprogs-1.41.6.tar.gz,仅 Solaris8 需要安装,Solaris9 已自带此uuid 头文件和库文
资源推荐
资源详情
资源评论
收起资源包目录
e2fsprogs-1.41.6.tar.gz (1079个子文件)
expect.1 63KB
expect.1 33KB
expect.1 31KB
expect.1 7KB
expect.1 4KB
expect.1 4KB
expect.1 4KB
expect.1 4KB
expect.1 4KB
expect.1 2KB
expect.1 2KB
compile_et.1 2KB
expect.1 2KB
expect.1 2KB
expect.1 2KB
expect.1 2KB
expect.1 2KB
expect.1 2KB
expect.1 2KB
expect.1 1KB
expect.1 1KB
expect.1 1KB
expect.1 1KB
expect.1 1KB
expect.1 1KB
expect.1 1KB
expect.1 1KB
expect.1 1KB
expect.1 1KB
expect.1 1KB
expect.1 1KB
expect.1 1KB
expect.1 1KB
expect.1 1KB
mk_cmds.1 1KB
expect.1 1KB
expect.1 1KB
expect.1 1KB
expect-nohtree.1 1015B
expect.1 985B
expect.1 974B
expect.1 970B
expect.1 967B
expect.1 949B
expect.1 931B
expect.1 924B
expect.1 923B
expect.1 883B
expect.1 864B
expect.1 860B
expect.1 859B
expect.1 824B
expect.1 817B
expect.1 778B
expect.1 762B
expect.1 761B
expect.1 753B
expect.1 707B
expect.1 693B
expect.1 661B
expect.1 658B
expect.1 648B
expect.1 646B
expect.1 623B
expect.1 612B
expect.1 604B
expect.1 587B
expect.1 555B
expect.1 553B
expect.1 549B
expect.1 548B
expect.1 534B
expect.1 493B
expect.1 476B
expect.1 473B
expect.1 450B
expect.1 405B
expect.1 404B
expect.1 403B
expect.1 398B
expect.1 396B
expect.1 389B
expect.1 382B
expect.1 379B
expect.1 377B
expect.1 370B
expect.1 330B
expect.1 314B
expect.1 289B
expect.1 289B
expect.1 282B
expect.1 280B
expect.1 280B
expect.1 280B
expect.1 276B
expect.2 782B
expect.2 289B
expect.2 289B
expect.2 289B
expect.2 288B
共 1079 条
- 1
- 2
- 3
- 4
- 5
- 6
- 11
资源评论
- shawzy2013-10-14好久才来回复,是可用的
wytianjiao
- 粉丝: 1
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功