|
Lines 37-42
Link Here
|
| 37 |
#include <stdlib.h> |
37 |
#include <stdlib.h> |
| 38 |
#include <string.h> |
38 |
#include <string.h> |
| 39 |
#include <sysexits.h> |
39 |
#include <sysexits.h> |
|
|
40 |
#include <unistd.h> |
| 40 |
|
41 |
|
| 41 |
static const char * |
42 |
static const char * |
| 42 |
mode2str(int mode) |
43 |
mode2str(int mode) |
|
Lines 517-528
Link Here
|
| 517 |
if (ioctl(fd, IOCATARAIDREBUILD, &array) < 0) |
518 |
if (ioctl(fd, IOCATARAIDREBUILD, &array) < 0) |
| 518 |
warn("ioctl(IOCATARAIDREBUILD)"); |
519 |
warn("ioctl(IOCATARAIDREBUILD)"); |
| 519 |
else { |
520 |
else { |
| 520 |
char buffer[128]; |
521 |
char device[64]; |
| 521 |
sprintf(buffer, "/usr/bin/nice -n 20 /bin/dd " |
522 |
char *buffer; |
| 522 |
"if=/dev/ar%d of=/dev/null bs=1m &", |
523 |
int arfd; |
| 523 |
array); |
524 |
|
| 524 |
if (system(buffer)) |
525 |
switch (fork()) { |
| 525 |
warn("background dd"); |
526 |
case -1: |
|
|
527 |
err(1, "fork"); |
| 528 |
case 0: |
| 529 |
nice(20); |
| 530 |
snprintf(device, sizeof(device), "/dev/ar%d", |
| 531 |
array); |
| 532 |
if ((arfd = open(device, O_RDONLY)) == -1) |
| 533 |
err(1, "open %s", device); |
| 534 |
if ((buffer = malloc(1024 * 1024)) == NULL) |
| 535 |
err(1, "malloc"); |
| 536 |
while (read(arfd, buffer, 1024 * 1024) > 0) |
| 537 |
; |
| 538 |
free(buffer); |
| 539 |
close(arfd); |
| 540 |
break; |
| 541 |
default: |
| 542 |
break; |
| 543 |
} |
| 526 |
} |
544 |
} |
| 527 |
exit(EX_OK); |
545 |
exit(EX_OK); |
| 528 |
} |
546 |
} |