summaryrefslogtreecommitdiffstats
path: root/src/logicalfile/LMI_FileIdentityProvider.c
diff options
context:
space:
mode:
authorJan Synacek <jsynacek@redhat.com>2013-07-02 13:47:00 +0200
committerJan Synacek <jsynacek@redhat.com>2013-07-02 14:57:03 +0200
commiteb40a7a4be8c04b527fb712106c345b770babe36 (patch)
tree6de5c6250e39142aaed2e123bfd64c0f85a4aa06 /src/logicalfile/LMI_FileIdentityProvider.c
parent7dc3232a1e2206e99272cb1dad2c8c71c11e42b3 (diff)
downloadopenlmi-providers-eb40a7a4be8c04b527fb712106c345b770babe36.tar.gz
openlmi-providers-eb40a7a4be8c04b527fb712106c345b770babe36.tar.xz
openlmi-providers-eb40a7a4be8c04b527fb712106c345b770babe36.zip
LogicalFile: use udev to fill info about the filesystem
Diffstat (limited to 'src/logicalfile/LMI_FileIdentityProvider.c')
-rw-r--r--src/logicalfile/LMI_FileIdentityProvider.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/src/logicalfile/LMI_FileIdentityProvider.c b/src/logicalfile/LMI_FileIdentityProvider.c
index 86f3b7f..cf81504 100644
--- a/src/logicalfile/LMI_FileIdentityProvider.c
+++ b/src/logicalfile/LMI_FileIdentityProvider.c
@@ -67,6 +67,8 @@ static CMPIStatus associators(
const char *ns = KNameSpace(cop);
CMPIData pathd;
CMPIData cd;
+ char fileclass[BUFLEN];
+ char *fsname;
/* allow only LMI_UnixFile and classes derived from CIM_LogicalFile */
if (!check_valid_classes(cop)) {
@@ -85,8 +87,10 @@ static CMPIStatus associators(
cd = CMGetKey(cop, "LFCreationClassName", &st);
const char *path = KChars(pathd.value.string);
const char *ccname = KChars(cd.value.string);
- char fileclass[BUFLEN];
get_class_from_path(path, fileclass);
+ if (get_fsname_from_path(path, &fsname) < 0) {
+ CMReturnWithChars(_cb, CMPI_RC_ERR_FAILED, "Can't get filesystem name");
+ }
/* TODO is this error necessary? */
if (strcmp(fileclass, ccname)) {
@@ -96,7 +100,7 @@ static CMPIStatus associators(
CIM_LogicalFileRef cim_lfr;
CIM_LogicalFileRef_Init(&cim_lfr, _cb, ns);
- fill_logicalfile(CIM_LogicalFileRef, &cim_lfr, path, ccname);
+ fill_logicalfile(CIM_LogicalFileRef, &cim_lfr, path, fsname, ccname);
o = CIM_LogicalFileRef_ToObjectPath(&cim_lfr, &st);
CMSetClassName(o, fileclass);
} else {
@@ -110,8 +114,10 @@ static CMPIStatus associators(
pathd = CMGetKey(cop, "Name", &st);
cd = CMGetKey(cop, "CreationClassName", &st);
const char *path = KChars(pathd.value.string);
- char fileclass[BUFLEN];
get_class_from_path(path, fileclass);
+ if (get_fsname_from_path(path, &fsname) < 0) {
+ CMReturnWithChars(_cb, CMPI_RC_ERR_FAILED, "Can't get filesystem name");
+ }
LMI_UnixFile lmi_uf;
LMI_UnixFile_Init(&lmi_uf, _cb, ns);
@@ -119,7 +125,7 @@ static CMPIStatus associators(
LMI_UnixFile_Set_CSCreationClassName(&lmi_uf, get_system_creation_class_name());
LMI_UnixFile_Set_CSName(&lmi_uf, get_system_name());
LMI_UnixFile_Set_FSCreationClassName(&lmi_uf, FSCREATIONCLASSNAME);
- LMI_UnixFile_Set_FSName(&lmi_uf, FSNAME);
+ LMI_UnixFile_Set_FSName(&lmi_uf, fsname);
LMI_UnixFile_Set_LFCreationClassName(&lmi_uf, fileclass);
o = LMI_UnixFile_ToObjectPath(&lmi_uf, &st);
}
@@ -130,6 +136,7 @@ static CMPIStatus associators(
ci = _cb->bft->getInstance(_cb, cc, o, properties, &st);
res = CMReturnInstance(cr, ci);
}
+ free(fsname);
return res;
}
@@ -150,6 +157,8 @@ static CMPIStatus references(
const char *ns = KNameSpace(cop);
CMPIInstance *ci;
CMPIObjectPath *o;
+ char fileclass[BUFLEN];
+ char *fsname;
/*
* allow only LMI_UnixFile and classes derived from CIM_LogicalFile
@@ -176,8 +185,10 @@ static CMPIStatus references(
cd = CMGetKey(cop, "LFCreationClassName", &st);
const char *path = KChars(pathd.value.string);
const char *ccname = KChars(cd.value.string);
- char fileclass[BUFLEN];
get_class_from_path(path, fileclass);
+ if (get_fsname_from_path(path, &fsname) < 0) {
+ CMReturnWithChars(_cb, CMPI_RC_ERR_FAILED, "Can't get filesystem name");
+ }
/* TODO is this error necessary? */
if (strcmp(fileclass, ccname)) {
@@ -188,7 +199,7 @@ static CMPIStatus references(
/* SystemElement */
CIM_LogicalFileRef lmi_lfr;
CIM_LogicalFileRef_Init(&lmi_lfr, _cb, ns);
- fill_logicalfile(CIM_LogicalFileRef, &lmi_lfr, path, ccname);
+ fill_logicalfile(CIM_LogicalFileRef, &lmi_lfr, path, fsname, ccname);
o = CIM_LogicalFileRef_ToObjectPath(&lmi_lfr, &st);
CMSetClassName(o, fileclass);
LMI_FileIdentity_SetObjectPath_SystemElement(&lmi_fi, o);
@@ -205,6 +216,9 @@ static CMPIStatus references(
cd = CMGetKey(cop, "CreationClassName", &st);
const char *path = KChars(pathd.value.string);
const char *ccname = KChars(cd.value.string);
+ if (get_fsname_from_path(path, &fsname) < 0) {
+ CMReturnWithChars(_cb, CMPI_RC_ERR_FAILED, "Can't get filesystem name");
+ }
/* SameElement */
LMI_UnixFile lmi_uf;
@@ -213,7 +227,7 @@ static CMPIStatus references(
LMI_UnixFile_Set_CSCreationClassName(&lmi_uf, get_system_creation_class_name());
LMI_UnixFile_Set_CSName(&lmi_uf, get_system_name());
LMI_UnixFile_Set_FSCreationClassName(&lmi_uf, FSCREATIONCLASSNAME);
- LMI_UnixFile_Set_FSName(&lmi_uf, FSNAME);
+ LMI_UnixFile_Set_FSName(&lmi_uf, fsname);
LMI_UnixFile_Set_LFCreationClassName(&lmi_uf, ccname);
o = LMI_UnixFile_ToObjectPath(&lmi_uf, &st);
LMI_FileIdentity_SetObjectPath_SameElement(&lmi_fi, o);
@@ -226,6 +240,7 @@ static CMPIStatus references(
ci = LMI_FileIdentity_ToInstance(&lmi_fi, &st);
res = CMReturnInstance(cr, ci);
}
+ free(fsname);
return res;
}