Mirror of git://git.busybox.net/busybox with our patches on top
Source
/* vi: set sw=4 ts=4: */
/*
* devname.c - get a dev by its device inode name
*
* Copyright (C) Andries Brouwer
* Copyright (C) 1999, 2000, 2001, 2002, 2003 Theodore Ts'o
* Copyright (C) 2001 Andreas Dilger
*
* %Begin-Header%
* This file may be redistributed under the terms of the
* GNU Lesser General Public License.
* %End-Header%
*/
/*
* Find a dev struct in the cache by device name, if available.
*
* If there is no entry with the specified device name, and the create
* flag is set, then create an empty device entry.
*/
blkid_dev blkid_get_dev(blkid_cache cache, const char *devname, int flags)
{
blkid_dev dev = NULL, tmp;
struct list_head *p;
if (!cache || !devname)
return NULL;
list_for_each(p, &cache->bic_devs) {
tmp = list_entry(p, struct blkid_struct_dev, bid_devs);
if (strcmp(tmp->bid_name, devname))
continue;
DBG(DEBUG_DEVNAME,
printf("found devname %s in cache\n", tmp->bid_name));
dev = tmp;
break;
}
if (!dev && (flags & BLKID_DEV_CREATE)) {
dev = blkid_new_dev();