mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 02:49:02 -04:00
Use a more precise error detection when running external programs
This commit is contained in:
parent
f974a8378b
commit
88aa107596
2 changed files with 21 additions and 2 deletions
|
|
@ -696,9 +696,21 @@ static int devsmart(dev_t device, uint64_t* smart, char* serial)
|
|||
}
|
||||
|
||||
ret = pclose(f);
|
||||
if (!WIFEXITED(ret) || WEXITSTATUS(ret) != 0) {
|
||||
if (!WIFEXITED(ret)) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Failed to run smartctrl -a on device '%u:%u' (from pclose).\n", major(device), minor(device));
|
||||
fprintf(stderr, "Failed to run smartctrl -a on device '%u:%u' (not exited).\n", major(device), minor(device));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (WEXITSTATUS(ret) == 127) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Failed to run smartctrl -a on device '%u:%u' (from sh).\n", major(device), minor(device));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (WEXITSTATUS(ret) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Failed to run smartctrl -a on device '%u:%u' with return code %d.\n", major(device), minor(device), WEXITSTATUS(ret));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -724,6 +736,12 @@ static int devdown(dev_t device)
|
|||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (!WIFEXITED(ret)) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Failed to run hdparm -y on device '%u:%u' (not exited).\n", major(device), minor(device));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (WEXITSTATUS(ret) == 127) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Failed to run hdparm -y on device '%u:%u' (from sh).\n", major(device), minor(device));
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ AC_HEADER_ASSERT
|
|||
AC_HEADER_STDC
|
||||
AC_HEADER_DIRENT
|
||||
AC_HEADER_TIME
|
||||
AC_HEADER_SYS_WAIT
|
||||
AC_CHECK_HEADERS([fcntl.h stddef.h stdint.h stdlib.h string.h limits.h])
|
||||
AC_CHECK_HEADERS([unistd.h getopt.h fnmatch.h io.h inttypes.h byteswap.h])
|
||||
AC_CHECK_HEADERS([pthread.h math.h])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue