356
361
static NihTimer *boredom_timer = NULL;
364
* device_ready_timer:
366
* Having waited over ROOTDELAY seconds for certain devices to get ready,
367
* exit mountall and trigger the upstart jobs for bringing up the device
370
NihTimer *device_ready_timer = NULL;
1178
1201
nih_info (_("%s is %s"), MOUNT_NAME (mnt), "local");
1205
nih_info (_("%s is %s"), MOUNT_NAME (mnt), "local with timeout");
1181
1209
case TAG_REMOTE:
1182
1210
nih_info (_("%s is %s"), MOUNT_NAME (mnt), "remote");
1254
1288
if ((dep->tag == TAG_LOCAL)
1255
1289
&& (mnt->tag != TAG_REMOTE))
1256
1290
mnt->tag = TAG_LOCAL;
1291
if ((dep->tag == TAG_TIMEOUT)
1292
&& (mnt->tag != TAG_REMOTE))
1293
mnt->tag = TAG_LOCAL;
1257
1294
if (dep->tag == TAG_REMOTE)
1258
1295
mnt->tag = TAG_REMOTE;
1316
if ((tag == TAG_VIRTUAL)
1317
&& (mnt->tag == TAG_TIMEOUT)) {
1318
nih_debug ("%s is not virtual, inherited local (with timeout)",
1279
1323
if ((tag == TAG_LOCAL)
1280
1324
&& (mnt->tag == TAG_REMOTE)) {
1281
1325
nih_debug ("%s is not local, inherited remote",
1282
1326
MOUNT_NAME (mnt));
1329
if ((tag == TAG_TIMEOUT)
1330
&& (mnt->tag == TAG_REMOTE)) {
1331
nih_debug ("%s is not local (with timeout), inherited remote",
1285
1335
/* Set the tag, then if it's one we'd normally inherit, set it on
1286
1336
* any mount point that depends on this one.
1288
1338
mnt->tag = tag;
1340
/* TAG_TIMEOUT is TAG_LOCAL with a timeout. timeout cannot be
1341
* inherited but local could be */
1342
if(tag == TAG_TIMEOUT)
1290
1345
if ((tag == TAG_LOCAL)
1291
1346
|| (tag == TAG_REMOTE)) {
1292
1347
NIH_LIST_FOREACH (mounts, iter) {
1386
1441
case TAG_LOCAL:
1387
1442
num_local_mounted++;
1445
num_local_mounted++;
1446
num_timeout_mounted++;
1447
if (num_timeout_mounted == num_timeout) {
1448
nih_message(_("\n %s finished! "), "local_timeout");
1449
/* Stop the timeout waiting for device to get ready"
1451
if (device_ready_timer) {
1452
nih_free (device_ready_timer);
1453
device_ready_timer = NULL;
1389
1457
case TAG_REMOTE:
1390
1458
num_remote_mounted++;
1598
is_device_ready(void * data, NihTimer *timer)
1600
device_ready_timer = NULL;
1601
NIH_LIST_FOREACH (mounts, iter) {
1602
Mount *mnt = (Mount *)iter;
1606
if (mnt->tag != TAG_TIMEOUT)
1608
/* If udev was not able to identify the expected device within
1609
* ROOTDELAY time, something is wrong */
1612
&& (! is_remote (mnt))
1613
&& ((! strncmp (mnt->device, "/dev/", 5))
1614
|| (! strncmp (mnt->device, "UUID=", 5))
1615
|| (! strncmp (mnt->device, "LABEL=", 6))))
1617
nih_message("%s device not ready in ROOTDELAY sec", MOUNT_NAME (mnt));
1618
emit_event("device-not-ready", mnt);
1627
void activate_timer()
1629
NIH_LIST_FOREACH (mounts, iter) {
1630
Mount *mnt = (Mount *)iter;
1634
if (mnt->tag != TAG_TIMEOUT)
1636
/* If there's an underlying device that udev is going to deal with,
1637
* and it's not a virtual or remote filesystem, we wait for the udev
1638
* watcher to mark it ready within ROOTDELAY time.
1642
&& (! is_remote (mnt))
1643
&& ((! strncmp (mnt->device, "/dev/", 5))
1644
|| (! strncmp (mnt->device, "UUID=", 5))
1645
|| (! strncmp (mnt->device, "LABEL=", 6))))
1647
nih_message(_("Shall wait for device: %s for %d seconds, starting timer"), MOUNT_NAME (mnt), dev_wait_time);
1649
dev_wait_time = ROOTDELAY;
1650
device_ready_timer = NIH_MUST (nih_timer_add_timeout (NULL,
1651
dev_wait_time, is_device_ready, NULL));
1526
1661
try_mounts (void)
1843
1978
opts = cut_options (NULL, mnt, "showthrough", "optional",
1844
"bootwait", "nobootwait",
1979
"bootwait", "nobootwait", "timeout",
1846
1981
if (mnt->mounted && (! fake)) {
3334
int set_dev_wait_time(NihOption *option, const char *arg)
3337
dev_wait_time = strtol(arg, &end_ptr, 10);
3339
if(dev_wait_time <= 0) {
3340
nih_error(_("\n Legal values of dev-wait-time lie between 1sec to 2147483647 sec"));
3343
else if ((dev_wait_time == LONG_MIN) || (dev_wait_time == LONG_MAX)) {
3344
nih_error(_("\n Legal values of dev-wait-time lie between 1sec to 2147483647 sec"));
3347
else if (*end_ptr != '\0') {
3348
nih_error(_("\n Legal values of dev-wait-time lie between 1sec to 2147483647 sec"));
3212
3366
NULL, NULL, &fsck_fix, NULL },
3213
3367
{ 0, "no-events", N_("Do not emit events after mounting filesystems"),
3214
3368
NULL, NULL, &no_events, NULL },
3369
{ 0, "dev-wait-time", N_("In case of (bootwait,timeout): specify the time to wait for device to be detected"),
3370
NULL, N_("value in seconds (Default is 30 seconds, Legal value between 1second to 2147483647 seconds)"), &dev_wait_time, set_dev_wait_time},
3216
3371
NIH_OPTION_LAST
3397
3552
/* See what's already mounted */
3398
3553
mark_mounted ();
3554
/* Activate the timer for a fs that is local, unmounted and waits for
3555
* a device to be ready, before it can be mounted onto it. Timer on
3556
* only for fs not marked with a "nobootwait=1" */
3400
3559
/* See what we can mount straight away, and then schedule the same
3401
3560
* function to be run each time through the main loop.