<FILE>utils</FILE>
mnt_fstype_is_netfs
mnt_fstype_is_pseudofs
-mnt_open_device
mnt_match_fstype
mnt_match_options
</SECTION>
int mnt_cache_read_tags(mnt_cache *cache, const char *devname)
{
int i, ntags = 0;
- int fd;
static blkid_probe pr;
const char *tags[] = { "LABEL", "UUID" };
DBG(DEBUG_CACHE,
printf("cache: reading tags for: %s\n", devname));
- fd = mnt_open_device(devname, O_RDONLY);
- if (fd < 0)
- return -1;
- pr = blkid_new_probe();
+ pr = blkid_new_probe_from_filename(devname);
if (!pr)
- goto error;
- if (blkid_probe_set_device(pr, fd, 0, 0))
- goto error;
+ return -1;
blkid_probe_enable_superblocks(pr, 1);
return ntags ? 0 : 1;
error:
blkid_free_probe(pr);
- close(fd);
return -1;
}
/* utils.c */
extern int mnt_fstype_is_netfs(const char *type);
extern int mnt_fstype_is_pseudofs(const char *type);
-extern int mnt_open_device(const char *devname, int flags);
extern int mnt_match_fstype(const char *type, const char *pattern);
extern int mnt_match_options(const char *optstr, const char *pattern);
mnt_new_optls;
mnt_new_tab;
mnt_new_tab_from_file;
- mnt_open_device;
mnt_optent_dup_value;
mnt_optent_get_flag;
mnt_optent_get_id;
return s;
}
-/**
- * mnt_open_device:
- * @devname: device path
- * @flags: open(2) flags
- *
- * Opens device like open(2), but waits for cdrom medium (if errno=ENOMEDIUM).
- *
- * Returns: file descriptor or -1 in case of error.
- */
-int mnt_open_device(const char *devname, int flags)
-{
- int retries = 0;
-
- do {
- int fd = open(devname, flags);
- if (fd >= 0)
- return fd;
- if (errno != ENOMEDIUM)
- break;
- if (retries >= CONFIG_CDROM_NOMEDIUM_RETRIES)
- break;
- ++retries;
- sleep(3);
- } while(1);
-
- return -1;
-}
-
/*
* Returns allocated string with username or NULL.
*/