~ubuntu-branches/ubuntu/intrepid/multipath-tools/intrepid-proposed

« back to all changes in this revision

Viewing changes to libmultipath/dict.c

  • Committer: Bazaar Package Importer
  • Author(s): Soren Hansen
  • Date: 2007-12-13 03:03:31 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20071213030331-bp0r75kwexi0o33m
Tags: 0.4.8-5ubuntu1
* Merge from debian unstable, remaining changes:
  - DebianMaintainerField.
  - Suggest sg3-utils, Conflict with sg-utils.
  - Replace multipath-tools-boot init script with udev rules in
    kpartx.rules.
  - Add /sbin/hsg80_start.
  - Move udev rules to priority 95, and drop call to dmsetup_env.
  - Add devices as they appear
  - Fix preinst script to modprobe dm-multipath. This will make sure
    that multipathd will be able to start.
  - Fix init script not to die on stop if multipathd is not running.
  - Add prerm script to not fail when upgrading from a broken version of
    multipathd.
  - Set umask in multipathd.
  - Handle udev rules priority change in preinst.

Show diffs side-by-side

added added

removed removed

Lines of Context:
201
201
}
202
202
 
203
203
static int
 
204
def_pg_timeout_handler(vector strvec)
 
205
{
 
206
        int pg_timeout;
 
207
        char * buff;
 
208
 
 
209
        buff = set_value(strvec);
 
210
 
 
211
        if (!buff)
 
212
                return 1;
 
213
 
 
214
        if (strlen(buff) == 4 && !strcmp(buff, "none"))
 
215
                conf->pg_timeout = -PGTIMEOUT_NONE;
 
216
        else if (sscanf(buff, "%d", &pg_timeout) == 1 && pg_timeout >= 0) {
 
217
                if (pg_timeout == 0)
 
218
                        conf->pg_timeout = -PGTIMEOUT_NONE;
 
219
                else
 
220
                        conf->pg_timeout = pg_timeout;
 
221
        }
 
222
        else
 
223
                conf->pg_timeout = PGTIMEOUT_UNDEF;
 
224
 
 
225
        FREE(buff);
 
226
        return 0;
 
227
}
 
228
 
 
229
static int
204
230
names_handler(vector strvec)
205
231
{
206
232
        char * buff;
238
264
}
239
265
 
240
266
static int
 
267
blacklist_exceptions_handler(vector strvec)
 
268
{
 
269
        conf->elist_devnode = vector_alloc();
 
270
        conf->elist_wwid = vector_alloc();
 
271
        conf->elist_device = vector_alloc();
 
272
 
 
273
        if (!conf->elist_devnode || !conf->elist_wwid || !conf->elist_device)
 
274
                return 1;
 
275
 
 
276
        return 0;
 
277
}
 
278
 
 
279
static int
241
280
ble_devnode_handler(vector strvec)
242
281
{
243
282
        char * buff;
247
286
        if (!buff)
248
287
                return 1;
249
288
 
250
 
        return store_ble(conf->blist_devnode, buff);
 
289
        return store_ble(conf->blist_devnode, buff, ORIGIN_CONFIG);
 
290
}
 
291
 
 
292
static int
 
293
ble_except_devnode_handler(vector strvec)
 
294
{
 
295
        char * buff;
 
296
 
 
297
        buff = set_value(strvec);
 
298
 
 
299
        if (!buff)
 
300
                return 1;
 
301
 
 
302
        return store_ble(conf->elist_devnode, buff, ORIGIN_CONFIG);
251
303
}
252
304
 
253
305
static int
260
312
        if (!buff)
261
313
                return 1;
262
314
 
263
 
        return store_ble(conf->blist_wwid, buff);
 
315
        return store_ble(conf->blist_wwid, buff, ORIGIN_CONFIG);
 
316
}
 
317
 
 
318
static int
 
319
ble_except_wwid_handler(vector strvec)
 
320
{
 
321
        char * buff;
 
322
 
 
323
        buff = set_value(strvec);
 
324
 
 
325
        if (!buff)
 
326
                return 1;
 
327
 
 
328
        return store_ble(conf->elist_wwid, buff, ORIGIN_CONFIG);
264
329
}
265
330
 
266
331
static int
270
335
}
271
336
 
272
337
static int
 
338
ble_except_device_handler(vector strvec)
 
339
{
 
340
        return alloc_ble_device(conf->elist_device);
 
341
}
 
342
 
 
343
static int
273
344
ble_vendor_handler(vector strvec)
274
345
{
275
346
        char * buff;
279
350
        if (!buff)
280
351
                return 1;
281
352
 
282
 
        return set_ble_device(conf->blist_device, buff, NULL);
 
353
        return set_ble_device(conf->blist_device, buff, NULL, ORIGIN_CONFIG);
 
354
}
 
355
 
 
356
static int
 
357
ble_except_vendor_handler(vector strvec)
 
358
{
 
359
        char * buff;
 
360
 
 
361
        buff = set_value(strvec);
 
362
 
 
363
        if (!buff)
 
364
                return 1;
 
365
 
 
366
        return set_ble_device(conf->elist_device, buff, NULL, ORIGIN_CONFIG);
283
367
}
284
368
 
285
369
static int
292
376
        if (!buff)
293
377
                return 1;
294
378
 
295
 
        return set_ble_device(conf->blist_device, NULL, buff);
 
379
        return set_ble_device(conf->blist_device, NULL, buff, ORIGIN_CONFIG);
 
380
}
 
381
 
 
382
static int
 
383
ble_except_product_handler(vector strvec)
 
384
{
 
385
        char * buff;
 
386
 
 
387
        buff = set_value(strvec);
 
388
 
 
389
        if (!buff)
 
390
                return 1;
 
391
 
 
392
        return set_ble_device(conf->elist_device, NULL, buff, ORIGIN_CONFIG);
296
393
}
297
394
 
298
395
/*
585
682
        return 0;
586
683
}
587
684
 
 
685
static int
 
686
hw_pg_timeout_handler(vector strvec)
 
687
{
 
688
        int pg_timeout;
 
689
        struct hwentry *hwe = VECTOR_LAST_SLOT(conf->hwtable);
 
690
        char *buff;
 
691
 
 
692
        if (!hwe)
 
693
                return 1;
 
694
 
 
695
        buff = set_value(strvec);
 
696
 
 
697
        if (!buff)
 
698
                return 1;
 
699
 
 
700
        if (strlen(buff) == 4 && !strcmp(buff, "none"))
 
701
                hwe->pg_timeout = -PGTIMEOUT_NONE;
 
702
        else if (sscanf(buff, "%d", &pg_timeout) == 1 && pg_timeout >= 0) {
 
703
                if (pg_timeout == 0)
 
704
                        hwe->pg_timeout = -PGTIMEOUT_NONE;
 
705
                else
 
706
                        hwe->pg_timeout = pg_timeout;
 
707
        }
 
708
        else
 
709
                hwe->pg_timeout = PGTIMEOUT_UNDEF;
 
710
 
 
711
        FREE(buff);
 
712
        return 0;
 
713
}
 
714
 
588
715
/*
589
716
 * multipaths block handlers
590
717
 */
777
904
        return 0;
778
905
}
779
906
 
 
907
static int
 
908
mp_pg_timeout_handler(vector strvec)
 
909
{
 
910
        int pg_timeout;
 
911
        struct mpentry *mpe = VECTOR_LAST_SLOT(conf->mptable);
 
912
        char *buff;
 
913
 
 
914
        if (!mpe)
 
915
                return 1;
 
916
 
 
917
        buff = set_value(strvec);
 
918
 
 
919
        if (!buff)
 
920
                return 1;
 
921
        if (strlen(buff) == 4 && !strcmp(buff, "none"))
 
922
                mpe->pg_timeout = -PGTIMEOUT_NONE;
 
923
        else if (sscanf(buff, "%d", &pg_timeout) == 1 && pg_timeout >= 0) {
 
924
                if (pg_timeout == 0)
 
925
                        mpe->pg_timeout = -PGTIMEOUT_NONE;
 
926
                else
 
927
                        mpe->pg_timeout = pg_timeout;
 
928
        }
 
929
        else
 
930
                mpe->pg_timeout = PGTIMEOUT_UNDEF;
 
931
 
 
932
        FREE(buff);
 
933
        return 0;
 
934
}
 
935
 
780
936
/*
781
937
 * config file keywords printing
782
938
 */
896
1052
}
897
1053
 
898
1054
static int
 
1055
snprint_mp_pg_timeout (char * buff, int len, void * data)
 
1056
{
 
1057
        struct mpentry * mpe = (struct mpentry *)data;
 
1058
 
 
1059
        switch (mpe->pg_timeout) {
 
1060
        case PGTIMEOUT_UNDEF:
 
1061
                break;
 
1062
        case -PGTIMEOUT_NONE:
 
1063
                return snprintf(buff, len, "none");
 
1064
        default:
 
1065
                return snprintf(buff, len, "%i", mpe->pg_timeout);
 
1066
        }
 
1067
        return 0;
 
1068
}
 
1069
 
 
1070
static int
899
1071
snprint_hw_vendor (char * buff, int len, void * data)
900
1072
{
901
1073
        struct hwentry * hwe = (struct hwentry *)data;
1097
1269
}
1098
1270
 
1099
1271
static int
 
1272
snprint_hw_pg_timeout (char * buff, int len, void * data)
 
1273
{
 
1274
        struct hwentry * hwe = (struct hwentry *)data;
 
1275
 
 
1276
        if (!hwe->pg_timeout)
 
1277
                return 0;
 
1278
        if (hwe->pg_timeout == conf->pg_timeout)
 
1279
                return 0;
 
1280
 
 
1281
        switch (hwe->pg_timeout) {
 
1282
        case PGTIMEOUT_UNDEF:
 
1283
                break;
 
1284
        case -PGTIMEOUT_NONE:
 
1285
                return snprintf(buff, len, "none");
 
1286
        default:
 
1287
                return snprintf(buff, len, "%i", hwe->pg_timeout);
 
1288
        }
 
1289
        return 0;
 
1290
}
 
1291
 
 
1292
static int
1100
1293
snprint_hw_path_checker (char * buff, int len, void * data)
1101
1294
{
1102
1295
        struct hwentry * hwe = (struct hwentry *)data;
1268
1461
}
1269
1462
 
1270
1463
static int
 
1464
snprint_def_pg_timeout (char * buff, int len, void * data)
 
1465
{
 
1466
        if (conf->pg_timeout == DEFAULT_PGTIMEOUT)
 
1467
                return 0;
 
1468
 
 
1469
        switch (conf->pg_timeout) {
 
1470
        case PGTIMEOUT_UNDEF:
 
1471
                break;
 
1472
        case -PGTIMEOUT_NONE:
 
1473
                return snprintf(buff, len, "none");
 
1474
        default:
 
1475
                return snprintf(buff, len, "%i", conf->pg_timeout);
 
1476
        }
 
1477
        return 0;
 
1478
}
 
1479
 
 
1480
static int
1271
1481
snprint_def_user_friendly_names (char * buff, int len, void * data)
1272
1482
{
1273
1483
        if (conf->user_friendly_names == DEFAULT_USER_FRIENDLY_NAMES)
1320
1530
        install_keyword("rr_min_io", &def_minio_handler, &snprint_def_rr_min_io);
1321
1531
        install_keyword("rr_weight", &def_weight_handler, &snprint_def_rr_weight);
1322
1532
        install_keyword("no_path_retry", &def_no_path_retry_handler, &snprint_def_no_path_retry);
 
1533
        install_keyword("pg_timeout", &def_pg_timeout_handler, &snprint_def_pg_timeout);
1323
1534
        install_keyword("user_friendly_names", &names_handler, &snprint_def_user_friendly_names);
1324
1535
        __deprecated install_keyword("default_selector", &def_selector_handler, NULL);
1325
1536
        __deprecated install_keyword("default_path_grouping_policy", &def_pgpolicy_handler, NULL);
1336
1547
        install_keyword("vendor", &ble_vendor_handler, &snprint_bled_vendor);
1337
1548
        install_keyword("product", &ble_product_handler, &snprint_bled_product);
1338
1549
        install_sublevel_end();
 
1550
        install_keyword_root("blacklist_exceptions", &blacklist_exceptions_handler);
 
1551
        install_keyword("devnode", &ble_except_devnode_handler, &snprint_ble_simple);
 
1552
        install_keyword("wwid", &ble_except_wwid_handler, &snprint_ble_simple);
 
1553
        install_keyword("device", &ble_except_device_handler, NULL);
 
1554
        install_sublevel();
 
1555
        install_keyword("vendor", &ble_except_vendor_handler, &snprint_bled_vendor);
 
1556
        install_keyword("product", &ble_except_product_handler, &snprint_bled_product);
 
1557
        install_sublevel_end();
1339
1558
 
1340
1559
#if 0
1341
1560
        __deprecated install_keyword_root("devnode_blacklist", &blacklist_handler);
1365
1584
        install_keyword("rr_weight", &hw_weight_handler, &snprint_hw_rr_weight);
1366
1585
        install_keyword("no_path_retry", &hw_no_path_retry_handler, &snprint_hw_no_path_retry);
1367
1586
        install_keyword("rr_min_io", &hw_minio_handler, &snprint_hw_rr_min_io);
 
1587
        install_keyword("pg_timeout", &hw_pg_timeout_handler, &snprint_hw_pg_timeout);
1368
1588
        install_sublevel_end();
1369
1589
 
1370
1590
        install_keyword_root("multipaths", &multipaths_handler);
1378
1598
        install_keyword("rr_weight", &mp_weight_handler, &snprint_mp_rr_weight);
1379
1599
        install_keyword("no_path_retry", &mp_no_path_retry_handler, &snprint_mp_no_path_retry);
1380
1600
        install_keyword("rr_min_io", &mp_minio_handler, &snprint_mp_rr_min_io);
 
1601
        install_keyword("pg_timeout", &mp_pg_timeout_handler, &snprint_mp_pg_timeout);
1381
1602
        install_sublevel_end();
1382
1603
}