[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[monit-dev] [monit] r313 committed - fix solaris device file support in
From: |
monit |
Subject: |
[monit-dev] [monit] r313 committed - fix solaris device file support in check filesystem path |
Date: |
Sat, 18 Dec 2010 15:18:24 +0000 |
Revision: 313
Author: address@hidden
Date: Sat Dec 18 07:17:09 2010
Log: fix solaris device file support in check filesystem path
http://code.google.com/p/monit/source/detail?r=313
Modified:
/trunk/CHANGES.txt
/trunk/device/device_common.c
/trunk/device/sysdep_SOLARIS.c
=======================================
--- /trunk/CHANGES.txt Fri Dec 17 16:35:24 2010
+++ /trunk/CHANGES.txt Sat Dec 18 07:17:09 2010
@@ -11,7 +11,7 @@
BUGFIXES:
-* FreeBSD, NetBSD, OpenBSD, MacOSX filesystem check fix:
+* FreeBSD, NetBSD, OpenBSD, MacOSX, Solaris filesystem check fix:
If block/character device was used in the check path instead
of mountpoint, monit reported usage of wrong filesystem.
=======================================
--- /trunk/device/device_common.c Fri Dec 17 16:35:24 2010
+++ /trunk/device/device_common.c Sat Dec 18 07:17:09 2010
@@ -88,7 +88,6 @@
* @return NULL in the case of failure otherwise filesystem path
*/
char *device_path(Info_T inf, char *object) {
-
struct stat buf;
ASSERT(inf);
@@ -100,21 +99,15 @@
}
if(S_ISREG(buf.st_mode) || S_ISDIR(buf.st_mode)) {
-
- inf->mntpath[sizeof(inf->mntpath) - 1] = 0;
- return strncpy(inf->mntpath, object, sizeof(inf->mntpath) - 1);
-
+ snprintf(inf->mntpath, sizeof(inf->mntpath), "%s", object);
+ return inf->mntpath;
} else if(S_ISBLK(buf.st_mode) || S_ISCHR(buf.st_mode)) {
-
return device_mountpoint_sysdep(inf, object);
-
}
- LogError("%s: Not file, directory or block special device: '%s'",
- prog, object);
+ LogError("%s: Not file, directory or block special device: '%s'", prog,
object);
return NULL;
-
}
@@ -128,18 +121,15 @@
* @return TRUE if informations were succesfully read otherwise
FALSE
*/
int filesystem_usage(Info_T inf, char *object) {
-
ASSERT(inf);
ASSERT(object);
- if(!device_path(inf, object)) {
+ if(!device_path(inf, object))
return FALSE;
- }
/* save the previous filesystem flags */
inf->_flags= inf->flags;
return filesystem_usage_sysdep(inf);
-
}
=======================================
--- /trunk/device/sysdep_SOLARIS.c Fri Jan 8 03:20:43 2010
+++ /trunk/device/sysdep_SOLARIS.c Sat Dec 18 07:17:09 2010
@@ -76,36 +76,28 @@
* @return NULL in the case of failure otherwise mountpoint
*/
char *device_mountpoint_sysdep(Info_T inf, char *blockdev) {
-
struct mnttab mnt;
FILE *mntfd;
ASSERT(inf);
ASSERT(blockdev);
-
- if((mntfd= fopen("/etc/mnttab", "r")) == NULL) {
+ if ((mntfd= fopen("/etc/mnttab", "r")) == NULL) {
LogError("%s: Cannot open /etc/mnttab file\n", prog);
return NULL;
}
- /* First match is significant */
- while(getmntent(mntfd, &mnt) == 0) {
-
- if(IS(blockdev, mnt.mnt_special)) {
-
- fclose(mntfd);
- inf->mntpath[sizeof(inf->mntpath) - 1] = 0;
- return strncpy(inf->mntpath, mnt.mnt_mountp, sizeof(inf->mntpath) -
1);
-
- }
-
+ while (getmntent(mntfd, &mnt) == 0) {
+ char real_mnt_special[PATH_MAX+1];
+ if (realpath(mnt.mnt_special, real_mnt_special) &&
IS(real_mnt_special, blockdev)) {
+ fclose(mntfd);
+ snprintf(inf->mntpath, sizeof(inf->mntpath), "%s", mnt.mnt_mountp);
+ return inf->mntpath;
+ }
}
fclose(mntfd);
-
return NULL;
-
}
@@ -114,17 +106,15 @@
* given information structure.
*
* @param inf Information structure where resulting data will be stored
- * @return TRUE if informations were succesfully read otherwise
FALSE
+ * @return TRUE if informations were succesfully read otherwise FALSE
*/
int filesystem_usage_sysdep(Info_T inf) {
-
struct statvfs usage;
ASSERT(inf);
- if(statvfs(inf->mntpath, &usage) != 0) {
- LogError("%s: Error getting usage statistics for filesystem '%s'
-- %s\n",
- prog, inf->mntpath, STRERROR);
+ if (statvfs(inf->mntpath, &usage) != 0) {
+ LogError("%s: Error getting usage statistics for filesystem '%s'
-- %s\n", prog, inf->mntpath, STRERROR);
return FALSE;
}
@@ -137,6 +127,5 @@
inf->flags= usage.f_flag;
return TRUE;
-
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [monit-dev] [monit] r313 committed - fix solaris device file support in check filesystem path,
monit <=