| Summary: | [patch] atacontrol(8): atacontrol depends on executable in /usr | ||||||
|---|---|---|---|---|---|---|---|
| Product: | Base System | Reporter: | Stef Walter <stef> | ||||
| Component: | bin | Assignee: | Antoine Brodin <antoine> | ||||
| Status: | Closed FIXED | ||||||
| Severity: | Affects Only Me | ||||||
| Priority: | Normal | ||||||
| Version: | 6.3-RELEASE | ||||||
| Hardware: | Any | ||||||
| OS: | Any | ||||||
| Attachments: |
|
||||||
|
Description
Stef Walter
2008-07-16 16:40:01 UTC
Better fix: use /bin/csh and the built-in nice. Kris On Wed, Jul 16, 2008, Kris Kennaway wrote:
> Better fix: use /bin/csh and the built-in nice.
Better yet, given that it's a C program that invokes
/usr/bin/nice -n 20 /bin/dd if=/dev/ar%d of=/dev/null bs=1m &
via system(3), would be to use nice(3). Actually, the whole thing
is sort of dubious: What if my libraries are corrupted and I'm trying
to use /rescue/atacontrol to fix things, but it gives an error because
it's hardwired to use /bin/dd instead of /rescue/dd? A simple
while (!eof) read(); loop should suffice.
David Schultz wrote:
> On Wed, Jul 16, 2008, Kris Kennaway wrote:
>> Better fix: use /bin/csh and the built-in nice.
>
> Better yet, given that it's a C program that invokes
> /usr/bin/nice -n 20 /bin/dd if=/dev/ar%d of=/dev/null bs=1m &
> via system(3), would be to use nice(3). Actually, the whole thing
> is sort of dubious: What if my libraries are corrupted and I'm trying
> to use /rescue/atacontrol to fix things, but it gives an error because
> it's hardwired to use /bin/dd instead of /rescue/dd? A simple
> while (!eof) read(); loop should suffice.
>
>
You make a good point, sir :)
Kris
Could you try the attached patch ? Cheers, Antoine State Changed From-To: open->feedback I asked the submitter to test a patch. Responsible Changed From-To: freebsd-bugs->antoine Take. Yes, I can confirm this works as expected. I setup a test machine and tested this on an IHC7 based Intel Matrix RAID. ar0: 476940MB <Intel MatrixRAID RAID1> status: READY ar0: disk0 READY (master) using ad4 at ata2-master ar0: disk1 READY (mirror) using ad6 at ata3-master Nice. Thanks! antoine 2008-08-06 18:08:02 UTC
FreeBSD src repository
Modified files:
sbin/atacontrol atacontrol.c
Log:
SVN rev 181349 on 2008-08-06 18:08:02Z by antoine
Make atacontrol(8) rebuild work when /usr is not mounted or from /rescue
PR: bin/125680
MFC after: 1 month
Tested by: Stef Walter
Revision Changes Path
1.49 +25 -6 src/sbin/atacontrol/atacontrol.c
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
State Changed From-To: feedback->patched Patched in head. Author: antoine Date: Sun Jan 25 19:35:23 2009 New Revision: 187697 URL: http://svn.freebsd.org/changeset/base/187697 Log: MFC r181349 to stable/7: Make atacontrol(8) rebuild work when /usr is not mounted or from /rescue PR: bin/125680 MFC after: 1 month Tested by: Stef Walter Modified: stable/7/sbin/atacontrol/ (props changed) stable/7/sbin/atacontrol/atacontrol.c Modified: stable/7/sbin/atacontrol/atacontrol.c ============================================================================== --- stable/7/sbin/atacontrol/atacontrol.c Sun Jan 25 19:25:41 2009 (r187696) +++ stable/7/sbin/atacontrol/atacontrol.c Sun Jan 25 19:35:23 2009 (r187697) @@ -37,6 +37,7 @@ #include <stdlib.h> #include <string.h> #include <sysexits.h> +#include <unistd.h> static const char * mode2str(int mode) @@ -517,12 +518,30 @@ main(int argc, char **argv) if (ioctl(fd, IOCATARAIDREBUILD, &array) < 0) warn("ioctl(IOCATARAIDREBUILD)"); else { - char buffer[128]; - sprintf(buffer, "/usr/bin/nice -n 20 /bin/dd " - "if=/dev/ar%d of=/dev/null bs=1m &", - array); - if (system(buffer)) - warn("background dd"); + char device[64]; + char *buffer; + ssize_t len; + int arfd; + + if (daemon(0, 1) == -1) + err(1, "daemon"); + nice(20); + snprintf(device, sizeof(device), "/dev/ar%d", + array); + if ((arfd = open(device, O_RDONLY)) == -1) + err(1, "open %s", device); + if ((buffer = malloc(1024 * 1024)) == NULL) + err(1, "malloc"); + while ((len = read(arfd, buffer, 1024 * 1024)) > 0) + ; + if (len == -1) + err(1, "read"); + else + fprintf(stderr, + "atacontrol: ar%d rebuild completed\n", + array); + free(buffer); + close(arfd); } exit(EX_OK); } _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org" State Changed From-To: patched->closed Close: fix committed in head and stable/7. |