|
From: Dave H. <hel...@us...> - 2012-11-13 20:08:25
|
Update of /cvsroot/sblim/cmpi-fsvol
In directory vz-cvs-3.sog:/tmp/cvs-serv9351
Modified Files:
ChangeLog NEWS OSBase_CommonFsvol.c
Log Message:
Fixed 3574777: Mounted file systems show as disabled
Index: NEWS
===================================================================
RCS file: /cvsroot/sblim/cmpi-fsvol/NEWS,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- NEWS 27 Jun 2011 03:26:14 -0000 1.17
+++ NEWS 13 Nov 2012 20:08:23 -0000 1.18
@@ -2,6 +2,7 @@
================
Bugs:
+- 3574777 Mounted file systems show as disabled
Features:
- 3325700 support ext4 file systems
Index: OSBase_CommonFsvol.c
===================================================================
RCS file: /cvsroot/sblim/cmpi-fsvol/OSBase_CommonFsvol.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- OSBase_CommonFsvol.c 2 Jun 2009 19:42:24 -0000 1.10
+++ OSBase_CommonFsvol.c 13 Nov 2012 20:08:23 -0000 1.11
@@ -1,7 +1,7 @@
/*
* OSBase_CommonFsvol.c
*
- * (C) Copyright IBM Corp. 2002, 2009
+ * (C) Copyright IBM Corp. 2002, 2012
*
* THIS FILE IS PROVIDED UNDER THE TERMS OF THE ECLIPSE PUBLIC LICENSE
* ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE
@@ -12,6 +12,8 @@
*
* Author: Heidi Neumann <hei...@de...>
* Contributors: Marcin Gozdalik <go...@go...>
+ * Henning Sackewitz (shenningz)
+ * Dave Heller <hel...@us...>
*
* Description:
* This shared library provides resource access functionality for the class
@@ -21,6 +23,7 @@
/* ---------------------------------------------------------------------------*/
+#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -175,7 +178,7 @@
FILE * mtab = NULL ;
char * buf = NULL ;
- _OSBASE_TRACE(4,("--- _cpy_fs_data() called"));
+ _OSBASE_TRACE(3,("--- _cpy_fs_data() called"));
mer = calloc (1,sizeof (struct mntent));
@@ -214,7 +217,7 @@
mer->mnt_opts = calloc (1, strlen(me->mnt_opts)+1 );
strcpy( mer->mnt_opts, me->mnt_opts);
- _OSBASE_TRACE(4,("--- _cpy_fs_data() exited"));
+ _OSBASE_TRACE(3,("--- _cpy_fs_data() exited"));
return mer;
}
@@ -240,9 +243,8 @@
free(sptr);
}
-
/* ---------------------------------------------------------------------------*/
-// get mount status of a certain file system
+// get mount status of a certain file system (from mount command)
/* ---------------------------------------------------------------------------*/
/*
@@ -250,13 +252,13 @@
* 1 ... mounted
*/
-unsigned char fs_mount_status( char * fsname ) {
+unsigned char fs_mount_status_internal( char * fsname ) {
char * cmd = NULL;
char ** hdout = NULL;
unsigned char vrc = 0;
int rc = 0;
- _OSBASE_TRACE(4,("--- fs_mount_status() called"));
+ _OSBASE_TRACE(3,("--- fs_mount_status_internal() called for %s",fsname));
cmd = calloc (1, (14+strlen(fsname)));
strcpy( cmd, "mount | grep ");
@@ -271,7 +273,65 @@
if(cmd) free(cmd);
freeresultbuf(hdout);
- _OSBASE_TRACE(4,("--- fs_mount_status() exited : %s %i",fsname,vrc));
+ _OSBASE_TRACE(3,("--- fs_mount_status_internal() exited : %s %i",fsname,vrc));
+ return vrc;
+}
+
+/* ---------------------------------------------------------------------------*/
+// get mount status of a certain file system
+/* ---------------------------------------------------------------------------*/
+
+/*
+ * 0 ... not mounted
+ * 1 ... mounted
+ */
+
+unsigned char fs_mount_status( char * fsname ) {
+ unsigned char vrc = 0;
+ const char * uuid = "UUID=";
+ const char * label = "LABEL=";
+ char * str = NULL;
+ char pathname_uuid[255] = "/dev/disk/by-uuid/";
+ char pathname_label[255] = "/dev/disk/by-label/";
+ char * findname = NULL;
+ char * realname = NULL;
+
+ _OSBASE_TRACE(3,("--- fs_mount_status() called for %s",fsname));
+
+ if (!(vrc = fs_mount_status_internal(fsname))) {
+ /* in fstab, some distros use UUIDs, LABELs or device links that don't show
+ * up in mount */
+ if ((str = strstr(fsname, uuid)) != NULL) {
+ str = str + strlen(uuid);
+ strcat(pathname_uuid, str);
+ findname = pathname_uuid;
+ _OSBASE_TRACE(4,("--- fs_mount_status() %s is %s",fsname,pathname_uuid));
+ }
+ else if ((str = strstr(fsname, label)) != NULL) {
+ str = str + strlen(label);
+ strcat(pathname_label, str);
+ findname = pathname_label;
+ _OSBASE_TRACE(4,("--- fs_mount_status() %s is %s",fsname,pathname_label));
+ }
+ else { // fsname is some other symlink or device name
+ findname = fsname;
+ }
+ if (!(vrc = fs_mount_status_internal(findname))) {
+ realname = realpath(findname, NULL); // uses malloc
+ if (realname != NULL) {
+ _OSBASE_TRACE(4,("--- fs_mount_status() %s is really %s",findname,
+ realname));
+ vrc = fs_mount_status_internal(realname);
+ free(realname);
+ }
+ else {
+ _OSBASE_TRACE(1,("--- fs_mount_status() cannot find %s (%s)",findname,
+ strerror(errno)));
+ // TODO: should return some error here instead of reporting not mounted
+ }
+ }
+ }
+ _OSBASE_TRACE(3,("--- fs_mount_status() exited : %s %i",fsname,vrc));
return vrc;
}
@@ -286,7 +346,7 @@
unsigned char vrc = 0;
int rc = 0;
- _OSBASE_TRACE(4,("--- fs_default_mount_status() called"));
+ _OSBASE_TRACE(3,("--- fs_default_mount_status() called for %s",fsname));
cmd = calloc (1, (23+strlen(fsname)));
strcpy( cmd, "cat /etc/fstab | grep ");
@@ -302,7 +362,7 @@
if(cmd) free(cmd);
freeresultbuf(hdout);
- _OSBASE_TRACE(4,("--- fs_default_mount_status() exited : %s %i",fsname,vrc));
+ _OSBASE_TRACE(3,("--- fs_default_mount_status() exited : %s %i",fsname,vrc));
return vrc;
}
Index: ChangeLog
===================================================================
RCS file: /cvsroot/sblim/cmpi-fsvol/ChangeLog,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- ChangeLog 18 May 2011 02:40:43 -0000 1.15
+++ ChangeLog 13 Nov 2012 20:08:23 -0000 1.16
@@ -1,3 +1,10 @@
+2012-11-13 Dave Heller <hel...@us...>
+
+ * NEWS, OSBase_CommonFsvol.c:
+
+ Fixed 3574777: Mounted file systems show as disabled
+ (contribution by Henning Sackewitz :) ... thx
+
2011-05-17 Tyrel Datwyler <ty...@us...>
* NEWS, OSBase_BlockStorageStatisticalData.c:
|