~ubuntu-branches/ubuntu/dapper/mdadm/dapper

« back to all changes in this revision

Viewing changes to mdadm.c

  • Committer: Package Import Robot
  • Author(s): Fabio M. Di Nitto
  • Date: 2005-11-28 07:35:36 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20051128073536-ph8pstb6ams9huk4
Tags: 1.12.0-1ubuntu1
Resyncronize with Debian.

Show diffs side-by-side

added added

removed removed

Lines of Context:
123
123
                        fputs(Version, stderr);
124
124
                        exit(0);
125
125
 
126
 
                case 'v': verbose = 1;
 
126
                case 'v': verbose++;
127
127
                        continue;
128
128
 
129
129
                case 'b': brief = 1;
466
466
                        continue;
467
467
 
468
468
                case O(BUILD,'f'): /* force honouring '-n 1' */
 
469
                case O(GROW,'f'): /* ditto */
469
470
                case O(CREATE,'f'): /* force honouring of device list */
470
471
                case O(ASSEMBLE,'f'): /* force assembly */
471
472
                case O(MISC,'f'): /* force zero */
479
480
                                        "Second value %s.\n", optarg);
480
481
                                exit(2);
481
482
                        }
482
 
                        if (parse_uuid(optarg, (int *)ident.uuid))
 
483
                        if (parse_uuid(optarg, ident.uuid))
483
484
                                ident.uuid_set = 1;
484
485
                        else {
485
486
                                fprintf(stderr,Name ": Bad uuid: %s\n", optarg);
720
721
                if (!rv && readonly < 0)
721
722
                        rv = Manage_ro(devlist->devname, mdfd, readonly);
722
723
                if (!rv && runstop)
723
 
                        rv = Manage_runstop(devlist->devname, mdfd, runstop);
 
724
                        rv = Manage_runstop(devlist->devname, mdfd, runstop, 0);
724
725
                break;
725
726
        case ASSEMBLE:
726
727
                if (devs_found == 1 && ident.uuid_set == 0 &&
777
778
                        } else
778
779
                                for (; array_list; array_list = array_list->next) {
779
780
                                        mdu_array_info_t array;
780
 
                                        mdfd = open_mddev(array_list->devname, array_list->autof);
 
781
                                        mdfd = open_mddev(array_list->devname, array_list->autof); 
781
782
                                        if (mdfd < 0) {
782
783
                                                rv |= 1;
783
784
                                                continue;
815
816
                                fprintf(stderr, Name ": No devices listed in %s\n", configfile?configfile:DefaultConfFile);
816
817
                                exit(1);
817
818
                        }
818
 
                        rv = Examine(devlist, scan?!verbose:brief, scan, SparcAdjust);
 
819
                        rv = Examine(devlist, scan?(verbose>1?0:verbose+1):brief, scan, SparcAdjust);
819
820
                } else {
820
821
                        if (devlist == NULL) {
821
 
                                if ((devmode == 'S' ||devmode=='D') && scan) {
822
 
                                        /* apply to all devices in /proc/mdstat */
 
822
                                if (devmode=='D' && scan) {
 
823
                                        /* apply --detail to all devices in /proc/mdstat */
823
824
                                        struct mdstat_ent *ms = mdstat_read(0);
824
825
                                        struct mdstat_ent *e;
825
 
                                        if (devmode == 'S') {
826
 
                                                /* reverse order so that arrays made of arrays are stopped properly */
827
 
                                                struct mdstat_ent *sm = NULL;
828
 
                                                while ((e=ms) != NULL) {
829
 
                                                        ms = e->next;
830
 
                                                        e->next = sm;
831
 
                                                        sm = e;
832
 
                                                }
833
 
                                                ms = sm;
834
 
                                        }
835
826
                                        for (e=ms ; e ; e=e->next) {
836
827
                                                char *name = get_md_name(e->devnum);
837
828
 
840
831
                                                                e->dev);
841
832
                                                        continue;
842
833
                                                }
843
 
                                                if (devmode == 'D')
844
 
                                                        rv |= Detail(name, !verbose, test);
845
 
                                                else if (devmode=='S') {
 
834
                                                rv |= Detail(name, verbose>1?0:verbose+1, test);
 
835
                                                put_md_name(name);
 
836
                                        }
 
837
                                } else  if (devmode == 'S' && scan) {
 
838
                                        /* apply --stop to all devices in /proc/mdstat */
 
839
                                        /* Due to possible stacking of devices, repeat until
 
840
                                         * nothing more can be stopped
 
841
                                         */
 
842
                                        int progress=1, err;
 
843
                                        int last = 0;
 
844
                                        do {
 
845
                                                struct mdstat_ent *ms = mdstat_read(0);
 
846
                                                struct mdstat_ent *e;
 
847
 
 
848
                                                if (!progress) last = 1;
 
849
                                                progress = 0; err = 0;
 
850
                                                for (e=ms ; e ; e=e->next) {
 
851
                                                        char *name = get_md_name(e->devnum);
 
852
 
 
853
                                                        if (!name) {
 
854
                                                                fprintf(stderr, Name ": cannot find device file for %s\n",
 
855
                                                                        e->dev);
 
856
                                                                continue;
 
857
                                                        }
846
858
                                                        mdfd = open_mddev(name, 0);
847
859
                                                        if (mdfd >= 0) {
848
 
                                                                rv |= Manage_runstop(name, mdfd, -1);
 
860
                                                                if (Manage_runstop(name, mdfd, -1, !last))
 
861
                                                                        err = 1;
 
862
                                                                else
 
863
                                                                        progress = 1;
849
864
                                                                close(mdfd);
850
865
                                                        }
 
866
 
 
867
                                                        put_md_name(name);
851
868
                                                }
852
 
                                                put_md_name(name);
853
 
                                        }
854
 
                                } else {                                                
 
869
                                        } while (!last && err);
 
870
                                } else {
855
871
                                        fprintf(stderr, Name ": No devices given.\n");
856
872
                                        exit(2);
857
873
                                }
859
875
                        for (dv=devlist ; dv; dv=dv->next) {
860
876
                                switch(dv->disposition) {
861
877
                                case 'D':
862
 
                                        rv |= Detail(dv->devname, brief, test); continue;
 
878
                                        rv |= Detail(dv->devname, brief?1+verbose:0, test); continue;
863
879
                                case 'K': /* Zero superblock */
864
880
                                        rv |= Kill(dv->devname, force); continue;
865
881
                                case 'Q':
869
885
                                if (mdfd>=0) {
870
886
                                        switch(dv->disposition) {
871
887
                                        case 'R':
872
 
                                                rv |= Manage_runstop(dv->devname, mdfd, 1); break;
 
888
                                                rv |= Manage_runstop(dv->devname, mdfd, 1, 0); break;
873
889
                                        case 'S':
874
 
                                                rv |= Manage_runstop(dv->devname, mdfd, -1); break;
 
890
                                                rv |= Manage_runstop(dv->devname, mdfd, -1, 0); break;
875
891
                                        case 'o':
876
892
                                                rv |= Manage_ro(dv->devname, mdfd, 1); break;
877
893
                                        case 'w':