~ubuntu-branches/ubuntu/utopic/mdadm/utopic

« back to all changes in this revision

Viewing changes to mdmon.c

  • Committer: Package Import Robot
  • Author(s): Dmitrijs Ledkovs
  • Date: 2012-06-15 15:31:59 UTC
  • mfrom: (1.1.30 sid)
  • Revision ID: package-import@ubuntu.com-20120615153159-9lp7jykbq7vua4bo
Tags: 3.2.5-1ubuntu1
* Merge from Debian testing. (LP: #920324)  Remaining changes:
  - Call checks in local-premount to avoid race condition with udev
    and opening a degraded array.
  - d/initramfs/mdadm-functions: Record in /run when boot-degraded 
    question has been asked so that it is only asked once
  - pass --test to mdadm to enable result codes for degraded arrays. 
  - debian/control: we need udev and util-linux in the right version. We
    also remove the build dependency from quilt and docbook-to-man as both
    are not used in Ubuntus mdadm.
  - debian/initramfs/hook: kept the Ubuntus version for handling the absence
    of active raid arrays in <initramfs>/etc/mdadm/mdadm.conf
  - debian/initramfs/script.local-top.DEBIAN, debian/mdadm-startall,
    debian/mdadm.raid.DEBIAN: removed. udev does its job now instead.
  - debian/mdadm-startall.sgml, debian/mdadm-startall.8: documentation of
    unused startall script
  - debian/mdadm.config, debian/mdadm.postinst - let udev do the handling
    instead. Resolved merge conflict by keeping Ubuntu's version.
  - debian/mdadm.postinst, debian/mdadm.config, initramfs/init-premount:
    boot-degraded enablement; maintain udev starting of RAID devices;
    init-premount hook script for the initramfs, to provide information at
    boot
  - debian/mkconf.in is the older mkconf. Kept the Ubuntu version.
  - debian/rules: Kept Ubuntus version for installing apport hooks, not
    installing un-used startall script.
  - debian/install-rc, check.d/_numbers, check.d/root_on_raid: Ubuntu partman
    installer changes
  - debian/presubj: Dropped this unused bug reporting file. Instead use
    source_mdadm.py act as an apport hook for bug handling.
  - d/p/debian-changes-3.1.4-1+8efb9d1ubuntu4: mdadm udev rule
    incrementally adds mdadm member when detected. Starting such an
    array in degraded mode is possible by mdadm -IRs. Using mdadm
    -ARs without stopping the array first does nothing when no
    mdarray-unassociated device is available. Using mdadm -IRs to
    start a previously partially assembled array through incremental
    mode. Keeping the mdadm -ARs for assembling arrays which were for
    some reason not assembled through incremental mode (i.e through
    mdadm's udev rule).

* Additional Ubuntu changes:
    - debian/initramfs/local-premount: add call wait_for_udev to wait a
    little longer for RAID devices to appear (LP: #942106)

* Dropped Ubuntu changes:
  - Build udeb with -O2 on ppc64, working around a link error. Builds
    fine without it on debian.
  - rename debian/mdadm.vol_id.udev to debian/mdadm.mdadm-blkid.udev so
    that the rules file ends up with a more reasonable name. debian/rules
    changes for adding ubuntu's udev rule corresponding to mdadm. As we
    are now using 'upstream' udev rules see 3.2.3-2ubuntu2.

* Changes to Ubuntu changes:
  - debian/source_mdadm.py: make apport hook python 2 and 3 compatible
    (LP: #1013171).

* New upstream release closes this bugs:
  - mdadm --detail --scan segfaults during update-initramfs (LP: #969384)

Show diffs side-by-side

added added

removed removed

Lines of Context:
265
265
 
266
266
void usage(void)
267
267
{
268
 
        fprintf(stderr, "Usage: mdmon [--all] [--takeover] CONTAINER\n");
 
268
        fprintf(stderr,
 
269
"Usage: mdmon [options] CONTAINER\n"
 
270
"\n"
 
271
"Options are:\n"
 
272
"  --help        -h   : This message\n"
 
273
"  --all              : All devices\n"
 
274
"  --takeover    -t   : Takeover container\n"
 
275
"  --offroot          : Set first character of argv[0] to @ to indicate the\n"
 
276
"                       application was launched from initrd/initramfs and\n"
 
277
"                       should not be shutdown by systemd as part of the\n"
 
278
"                       regular shutdown process.\n"
 
279
);
269
280
        exit(2);
270
281
}
271
282
 
277
288
        int devnum;
278
289
        char *devname;
279
290
        int status = 0;
280
 
        int arg;
 
291
        int opt;
281
292
        int all = 0;
282
293
        int takeover = 0;
 
294
        static struct option options[] = {
 
295
                {"all", 0, NULL, 'a'},
 
296
                {"takeover", 0, NULL, 't'},
 
297
                {"help", 0, NULL, 'h'},
 
298
                {"offroot", 0, NULL, OffRootOpt},
 
299
                {NULL, 0, NULL, 0}
 
300
        };
283
301
 
284
 
        for (arg = 1; arg < argc; arg++) {
285
 
                if (strncmp(argv[arg], "--all",5) == 0 ||
286
 
                    strcmp(argv[arg], "/proc/mdstat") == 0) {
287
 
                        container_name = argv[arg];
 
302
        while ((opt = getopt_long(argc, argv, "th", options, NULL)) != -1) {
 
303
                switch (opt) {
 
304
                case 'a':
 
305
                        container_name = argv[optind-1];
288
306
                        all = 1;
289
 
                } else if (strcmp(argv[arg], "--takeover") == 0)
 
307
                        break;
 
308
                case 't':
 
309
                        container_name = optarg;
290
310
                        takeover = 1;
291
 
                else if (container_name == NULL)
292
 
                        container_name = argv[arg];
293
 
                else
 
311
                        break;
 
312
                case OffRootOpt:
 
313
                        argv[0][0] = '@';
 
314
                        break;
 
315
                case 'h':
 
316
                default:
294
317
                        usage();
295
 
        }
 
318
                        break;
 
319
                }
 
320
        }
 
321
 
 
322
        if (all == 0 && container_name == NULL) {
 
323
                if (argv[optind])
 
324
                        container_name = argv[optind];
 
325
        }
 
326
 
296
327
        if (container_name == NULL)
297
328
                usage();
298
329
 
 
330
        if (argc - optind > 1)
 
331
                usage();
 
332
 
 
333
        if (strcmp(container_name, "/proc/mdstat") == 0)
 
334
                all = 1;
 
335
 
299
336
        if (all) {
300
337
                struct mdstat_ent *mdstat, *e;
301
338
                int container_len = strlen(container_name);