if (!sysfs)
return -BLKID_ERR_SYSFS;
+ DBG(DEVNAME, ul_debug(" probe /sys/block"));
+
/* scan /sys/block */
while ((dev = xreaddir(sysfs))) {
DIR *dir = NULL;
/*
* Read the device data for all available block devices in the system.
*/
-static int probe_all(blkid_cache cache, int only_if_new)
+static int probe_all(blkid_cache cache, int only_if_new, int update_interval)
{
+ int rc;
+
if (!cache)
return -BLKID_ERR_PARAM;
if (cache->bic_flags & BLKID_BIC_FL_PROBED &&
- time(NULL) - cache->bic_time < BLKID_PROBE_INTERVAL)
+ time(NULL) - cache->bic_time < BLKID_PROBE_INTERVAL) {
+ DBG(PROBE, ul_debug("don't re-probe [delay < %d]", BLKID_PROBE_INTERVAL));
return 0;
+ }
blkid_read_cache(cache);
#ifdef VG_DIR
#endif
ubi_probe_all(cache, only_if_new);
- sysfs_probe_all(cache, only_if_new, 0);
+ rc = sysfs_probe_all(cache, only_if_new, 0);
+
+ /* Don't mark the change as "probed" if /sys not avalable */
+ if (update_interval && rc == 0) {
+ cache->bic_time = time(NULL);
+ cache->bic_flags |= BLKID_BIC_FL_PROBED;
+ }
blkid_flush_cache(cache);
return 0;
int ret;
DBG(PROBE, ul_debug("Begin blkid_probe_all()"));
- ret = probe_all(cache, 0);
- if (ret == 0) {
- cache->bic_time = time(NULL);
- cache->bic_flags |= BLKID_BIC_FL_PROBED;
- }
+ ret = probe_all(cache, 0, 1);
DBG(PROBE, ul_debug("End blkid_probe_all() [rc=%d]", ret));
return ret;
}
int ret;
DBG(PROBE, ul_debug("Begin blkid_probe_all_new()"));
- ret = probe_all(cache, 1);
+ ret = probe_all(cache, 1, 0);
DBG(PROBE, ul_debug("End blkid_probe_all_new() [rc=%d]", ret));
return ret;
}
blkid_dev dev;
int pri;
struct list_head *p;
- int probe_new = 0;
+ int probe_new = 0, probe_all = 0;
if (!cache || !type || !value)
return NULL;
blkid_read_cache(cache);
- DBG(TAG, ul_debug("looking for %s=%s in cache", type, value));
+ DBG(TAG, ul_debug("looking for tag %s=%s in cache", type, value));
try_again:
pri = -1;
goto try_again;
}
- if (!dev && !(cache->bic_flags & BLKID_BIC_FL_PROBED)) {
+ if (!dev && !probe_all
+ && !(cache->bic_flags & BLKID_BIC_FL_PROBED)) {
if (blkid_probe_all(cache) < 0)
return NULL;
+ probe_all++;
goto try_again;
}
return dev;