Changeset View
Changeset View
Standalone View
Standalone View
ksysguardd/Linux/softraid.c
Show First 20 Lines • Show All 494 Lines • ▼ Show 20 Line(s) | 485 | for(;;) { | |||
---|---|---|---|---|---|
495 | current_word_length=0; | 495 | current_word_length=0; | ||
496 | while( mdstatBufP[0] != '\0' && mdstatBufP[0] != '\n' && mdstatBufP[0] != ' ' && mdstatBufP[0] != '\t') { | 496 | while( mdstatBufP[0] != '\0' && mdstatBufP[0] != '\n' && mdstatBufP[0] != ' ' && mdstatBufP[0] != '\t') { | ||
497 | /*find the end of the word. We do this now so that we know the length of the word*/ | 497 | /*find the end of the word. We do this now so that we know the length of the word*/ | ||
498 | mdstatBufP++; | 498 | mdstatBufP++; | ||
499 | current_word_length++; | 499 | current_word_length++; | ||
500 | } | 500 | } | ||
501 | 501 | | |||
502 | char *eq; | 502 | char *eq; | ||
503 | int in_devs = 0; | | |||
504 | int temp_int =0; | 503 | int temp_int =0; | ||
505 | 504 | | |||
506 | | ||||
507 | if (strncmp(current_word, "active", sizeof("active")-1)==0) | 505 | if (strncmp(current_word, "active", sizeof("active")-1)==0) | ||
508 | MyArray->ArrayActive = true; | 506 | MyArray->ArrayActive = true; | ||
509 | else if (strncmp(current_word, "inactive", sizeof("inactive")-1)==0) | 507 | else if (strncmp(current_word, "inactive", sizeof("inactive")-1)==0) | ||
510 | MyArray->ArrayActive = false; | 508 | MyArray->ArrayActive = false; | ||
511 | else if (MyArray->ArrayActive && MyArray->level == NULL && current_word[0] != '(' && current_word[0] != ':' /*readonly*/) { | 509 | else if (MyArray->ArrayActive && MyArray->level == NULL && current_word[0] != '(' && current_word[0] != ':' /*readonly*/) { | ||
512 | MyArray->level = strndup(current_word, current_word_length); | 510 | MyArray->level = strndup(current_word, current_word_length); | ||
513 | in_devs = 1; | | |||
514 | | ||||
515 | } else if (sscanf(current_word, "%d blocks ", &temp_int) == 1 ) { | 511 | } else if (sscanf(current_word, "%d blocks ", &temp_int) == 1 ) { | ||
516 | MyArray->NumBlocks = temp_int; /* We have to do it via a temp_int variable otherwise we'll end up with nonsence if it's not found */ | 512 | MyArray->NumBlocks = temp_int; /* We have to do it via a temp_int variable otherwise we'll end up with nonsence if it's not found */ | ||
517 | } else if (in_devs && strncmp(current_word, "blocks", sizeof("blocks")-1)==0) | | |||
518 | in_devs = 0; | | |||
519 | #ifdef __GNUC__ | | |||
520 | #warning in_devs cannot be != 0!! (CID 3228) | | |||
521 | #endif | | |||
522 | else if (in_devs && strncmp(current_word, "md", 2)==0) { | | |||
523 | /* This has an md device as a component. Maybe we should note this or something*/ | | |||
524 | } else if(sscanf(current_word, "%[^[ ][%d]%[^ ]", buffer, &harddisk_index, status) >= 2) { | 513 | } else if(sscanf(current_word, "%[^[ ][%d]%[^ ]", buffer, &harddisk_index, status) >= 2) { | ||
525 | /*Each device in the raid has an index. We can find the total number of devices in the raid by | 514 | /*Each device in the raid has an index. We can find the total number of devices in the raid by | ||
526 | simply finding the device with the highest index + 1. */ | 515 | simply finding the device with the highest index + 1. */ | ||
527 | if(harddisk_index >= MyArray->TotalDevices) MyArray->TotalDevices = harddisk_index+1; | 516 | if(harddisk_index >= MyArray->TotalDevices) MyArray->TotalDevices = harddisk_index+1; | ||
528 | Disks *new_disk = malloc(sizeof(Disks)); | 517 | Disks *new_disk = malloc(sizeof(Disks)); | ||
529 | new_disk->name = strdup(buffer); | 518 | new_disk->name = strdup(buffer); | ||
530 | new_disk->index = harddisk_index; | 519 | new_disk->index = harddisk_index; | ||
531 | 520 | | |||
▲ Show 20 Lines • Show All 95 Lines • Show Last 20 Lines |