~ubuntu-branches/ubuntu/edgy/e2fsprogs/edgy-updates

« back to all changes in this revision

Viewing changes to doc/libblkid.txt

  • Committer: Bazaar Package Importer
  • Author(s): Tollef Fog Heen
  • Date: 2005-08-23 10:42:10 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20050823104210-t15igvmgrkzea0dq
Tags: 1.38-2ubuntu1
* Merge with Debian.  (Ubuntu #13757)
* Remove tests/f_bad_disconnected_inode/image.gz to be able to build the
  package.  This will (hopefully) be in the next upstream version and is
  just used for testing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
        }
36
36
 
37
37
The cache parameter is optional; if it is NULL, then the blkid library
38
 
will load the default blkid.tab cache file, and the release the cache
 
38
will load the default blkid.tab cache file, and then release the cache
39
39
before function call returns.  The return value is an allocated string
40
40
which holds the resulting device name (if it is found).  If the value
41
41
is NULL, then attribute_name is parsed as if it were
49
49
"LABEL", and value of "root", if that is more convenient.
50
50
 
51
51
Another common usage is to retrieve the value of a specific attribute
52
 
for a particular device.  This can be used to used to determine the
53
 
filesystem type, or label, or uuid for a particular device:
 
52
for a particular device.  This can be used to determine the filesystem
 
53
type, or label, or uuid for a particular device:
54
54
 
55
55
        if ((value = blkid_get_tag_value(cache, attribute_name, devname))) {
56
56
                /* do something with value */
57
57
                string_free(value);
58
58
        }
59
59
 
60
 
If a program need to call multiple blkid functions, then passing in a
 
60
If a program needs to call multiple blkid functions, then passing in a
61
61
cache value of NULL is not recommended, since the /etc/blkid.tab file
62
 
will be repeatedly parsed over and over again, with a memory allocated
 
62
will be repeatedly parsed over and over again, with memory allocated
63
63
and deallocated.  To initialize the blkid cache, blkid_get_cache()
64
64
function is used:
65
65
 
70
70
filename of the blkid cache file (where the default is
71
71
/etc/blkid.tab).  Normally, programs should just pass in NULL.
72
72
 
73
 
If you have called blkid_get_cache(), you need to clean up by saving
74
 
the cache (assuming you have write access to the cache, this happens
75
 
automatically if you didn't load it directly), and freeing it (this
76
 
will also free all associated devices/tags):
77
 
 
78
 
        blkid_put_cache(cache);
79
 
 
 
73
If you have called blkid_get_cache(), you should call blkid_put_cache()
 
74
when you are done using the blkid library functions.  This will save the
 
75
cache to the blkid.tab file, if you have write access to the file.  It
 
76
will also free all associated devices and tags:
 
77
 
 
78
        blkid_put_cache(cache);