summaryrefslogtreecommitdiffstats
path: root/src/logicalfile/LMI_DirectoryContainsFileProvider.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_DirectoryContainsFileProvider.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_DirectoryContainsFileProvider.c')
-rw-r--r--src/logicalfile/LMI_DirectoryContainsFileProvider.c33
1 files changed, 28 insertions, 5 deletions
diff --git a/src/logicalfile/LMI_DirectoryContainsFileProvider.c b/src/logicalfile/LMI_DirectoryContainsFileProvider.c
index d7dda12..339c486 100644
--- a/src/logicalfile/LMI_DirectoryContainsFileProvider.c
+++ b/src/logicalfile/LMI_DirectoryContainsFileProvider.c
@@ -56,6 +56,7 @@ static CMPIStatus dir_file_objectpaths(
char rpath[BUFLEN];
char fileclass[BUFLEN];
char *aux = strdup(path);
+ char *fsname;
if (!strcmp(de->d_name, "..")) {
strncpy(rpath, dirname(aux), BUFLEN);
@@ -72,15 +73,19 @@ static CMPIStatus dir_file_objectpaths(
CMReturnWithChars(_cb, CMPI_RC_ERR_NOT_FOUND, err);
} else {
get_class_from_stat(&sb, fileclass);
+ if (get_fsname_from_stat(&sb, &fsname) < 0) {
+ CMReturnWithChars(_cb, CMPI_RC_ERR_FAILED, "Can't get filesystem name");
+ }
}
CIM_LogicalFileRef cim_lfr;
CIM_LogicalFileRef_Init(&cim_lfr, _cb, namespace);
- fill_logicalfile(CIM_LogicalFileRef, &cim_lfr, rpath, fileclass);
+ fill_logicalfile(CIM_LogicalFileRef, &cim_lfr, rpath, fsname, fileclass);
o = CIM_LogicalFileRef_ToObjectPath(&cim_lfr, &st);
CMSetClassName(o, fileclass);
ops[i++] = o;
+ free(fsname);
}
*count = i;
CMReturn(CMPI_RC_OK);
@@ -163,7 +168,12 @@ static CMPIStatus associators(
CIM_DirectoryRef lmi_dr;
CIM_DirectoryRef_Init(&lmi_dr, _cb, ns);
char *aux = strdup(path);
- fill_logicalfile(CIM_DirectoryRef, &lmi_dr, dirname(aux), LMI_UnixDirectory_ClassName);
+ char *dir = dirname(aux);
+ char *fsname;
+ if (get_fsname_from_path(dir, &fsname) < 0) {
+ CMReturnWithChars(_cb, CMPI_RC_ERR_FAILED, "Can't get filesystem name");
+ }
+ fill_logicalfile(CIM_DirectoryRef, &lmi_dr, dir, fsname, LMI_UnixDirectory_ClassName);
o = CIM_DirectoryRef_ToObjectPath(&lmi_dr, &st);
CMSetClassName(o, LMI_UnixDirectory_ClassName);
@@ -174,6 +184,7 @@ static CMPIStatus associators(
CMReturnInstance(cr, ci);
}
free(aux);
+ free(fsname);
}
CMReturn(CMPI_RC_OK);
}
@@ -219,10 +230,14 @@ static CMPIStatus references(
const char *ccname = KChars(cd.value.string);
pathd = CMGetKey(cop, "Name", &st);
const char *path = KChars(pathd.value.string);
+ char *fsname;
+ if (get_fsname_from_path(path, &fsname) < 0) {
+ CMReturnWithChars(_cb, CMPI_RC_ERR_FAILED, "Can't get filesystem name");
+ }
if (!strcmp(ccname, LMI_UnixDirectory_ClassName)) {
/* got GroupComponent - DirectoryRef */
- fill_logicalfile(CIM_DirectoryRef, &lmi_dr, path, LMI_UnixDirectory_ClassName);
+ fill_logicalfile(CIM_DirectoryRef, &lmi_dr, path, fsname, LMI_UnixDirectory_ClassName);
o = CIM_DirectoryRef_ToObjectPath(&lmi_dr, &st);
CMSetClassName(o, LMI_UnixDirectory_ClassName);
LMI_DirectoryContainsFile_SetObjectPath_GroupComponent(&lmi_dcf, o);
@@ -249,14 +264,20 @@ static CMPIStatus references(
}
} else {
/* got PartComponent - LogicalFileRef */
- 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, ccname);
LMI_DirectoryContainsFile_SetObjectPath_PartComponent(&lmi_dcf, o);
/* GroupComponent */
char *aux = strdup(path);
- fill_logicalfile(CIM_DirectoryRef, &lmi_dr, dirname(aux), LMI_UnixDirectory_ClassName);
+ char *dir = dirname(aux);
+ char *fsname;
+ if (get_fsname_from_path(dir, &fsname) < 0) {
+ CMReturnWithChars(_cb, CMPI_RC_ERR_FAILED, "Can't get filesystem name");
+ }
+
+ fill_logicalfile(CIM_DirectoryRef, &lmi_dr, dir, fsname, LMI_UnixDirectory_ClassName);
o = CIM_DirectoryRef_ToObjectPath(&lmi_dr, &st);
CMSetClassName(o, LMI_UnixDirectory_ClassName);
LMI_DirectoryContainsFile_SetObjectPath_GroupComponent(&lmi_dcf, o);
@@ -268,7 +289,9 @@ static CMPIStatus references(
CMReturnInstance(cr, ci);
}
free(aux);
+ free(fsname);
}
+ free(fsname);
CMReturn(CMPI_RC_OK);
}