summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Synacek <jsynacek@redhat.com>2013-12-17 10:27:15 +0100
committerJan Synacek <jsynacek@redhat.com>2013-12-17 11:11:03 +0100
commit67ae76aecfac0b04f22bea07b87bd7a8ce04a711 (patch)
tree55da46583bc833564ff8a27625dff80565342e9e
parent9a3adaf677fe49c016774c98e016140055c36afb (diff)
downloadopenlmi-providers-67ae76aecfac0b04f22bea07b87bd7a8ce04a711.tar.gz
openlmi-providers-67ae76aecfac0b04f22bea07b87bd7a8ce04a711.tar.xz
openlmi-providers-67ae76aecfac0b04f22bea07b87bd7a8ce04a711.zip
logicalfile: correctly fill FSCreationClassName and FSName
Files residing on nodevice or remote filesystems now correctly set these properties. FSCreationClassName is set to "LMI_TransientFileSystem" and FSName is set to "PATH=<path to file>". This behavior is consistent with how storage providers set those properties. To check for filesystem, the provider uses udev and checks for ID_FS_UUID_ENC and DEVNAME fields. If these are not found, filesystem is then considered nodevice or remote. Additional test for files on transient filesystems has been added.
-rw-r--r--src/logicalfile/LMI_DirectoryContainsFileProvider.c23
-rw-r--r--src/logicalfile/LMI_FileIdentityProvider.c18
-rw-r--r--src/logicalfile/LMI_RootDirectoryProvider.c15
-rw-r--r--src/logicalfile/LMI_UnixFileProvider.c5
-rw-r--r--src/logicalfile/file.c29
-rw-r--r--src/logicalfile/file.h15
-rw-r--r--src/logicalfile/test/test_basic.py31
7 files changed, 87 insertions, 49 deletions
diff --git a/src/logicalfile/LMI_DirectoryContainsFileProvider.c b/src/logicalfile/LMI_DirectoryContainsFileProvider.c
index a631ec1..6e1ddc5 100644
--- a/src/logicalfile/LMI_DirectoryContainsFileProvider.c
+++ b/src/logicalfile/LMI_DirectoryContainsFileProvider.c
@@ -63,6 +63,7 @@ static CMPIStatus dir_file_objectpaths(
char rpath[BUFLEN + 1]; /* \0 */
char fileclass[BUFLEN];
char *fsname;
+ char *fsclassname;
if (strcmp(de->d_name, "..") == 0) {
/* to get the parent directory, if either role or result role is
@@ -100,7 +101,7 @@ static CMPIStatus dir_file_objectpaths(
} else if (st.rc != CMPI_RC_OK) {
goto done;
}
- st = get_fsname_from_stat(_cb, &sb, &fsname);
+ st = get_fsinfo_from_stat(_cb, &sb, rpath, &fsclassname, &fsname);
if (st.rc != CMPI_RC_OK) {
goto done;
}
@@ -108,7 +109,7 @@ static CMPIStatus dir_file_objectpaths(
CIM_LogicalFileRef cim_lfr;
CIM_LogicalFileRef_Init(&cim_lfr, _cb, namespace);
- fill_logicalfile(CIM_LogicalFileRef, &cim_lfr, rpath, fsname, fileclass);
+ fill_logicalfile(CIM_LogicalFileRef, &cim_lfr, rpath, fsclassname, fsname, fileclass);
o = CIM_LogicalFileRef_ToObjectPath(&cim_lfr, &st);
CMSetClassName(o, fileclass);
@@ -217,14 +218,15 @@ static CMPIStatus associators(
char *aux = strdup(path);
char *dir = dirname(aux);
char *fsname;
+ char *fsclassname;
- st = get_fsname_from_path(_cb, path, &fsname);
+ st = get_fsinfo_from_path(_cb, path, &fsclassname, &fsname);
if (st.rc != CMPI_RC_OK) {
free(aux);
return st;
}
- fill_logicalfile(CIM_DirectoryRef, &lmi_dr, dir, fsname, LMI_UnixDirectory_ClassName);
+ fill_logicalfile(CIM_DirectoryRef, &lmi_dr, dir, fsclassname, fsname, LMI_UnixDirectory_ClassName);
o = CIM_DirectoryRef_ToObjectPath(&lmi_dr, &st);
CMSetClassName(o, LMI_UnixDirectory_ClassName);
@@ -258,6 +260,7 @@ static CMPIStatus references(
const char *ns = KNameSpace(cop);
const char *path;
char *fsname;
+ char *fsclassname;
char ccname[BUFLEN];
/* GroupComponent */
@@ -291,10 +294,10 @@ static CMPIStatus references(
path = get_string_property_from_op(cop, "Name");
if (!path)
CMReturnWithChars(_cb, CMPI_RC_ERR_NOT_FOUND, "Cannot find Name property in provided LMI_UnixDirectory");
- st = get_fsname_from_path(_cb, path, &fsname);
+ st = get_fsinfo_from_path(_cb, path, &fsclassname, &fsname);
check_status(st);
/* got GroupComponent - DirectoryRef */
- fill_logicalfile(CIM_DirectoryRef, &lmi_dr, path, fsname, LMI_UnixDirectory_ClassName);
+ fill_logicalfile(CIM_DirectoryRef, &lmi_dr, path, fsclassname, fsname, LMI_UnixDirectory_ClassName);
o = CIM_DirectoryRef_ToObjectPath(&lmi_dr, &st);
CMSetClassName(o, LMI_UnixDirectory_ClassName);
LMI_DirectoryContainsFile_SetObjectPath_GroupComponent(&lmi_dcf, o);
@@ -326,14 +329,14 @@ static CMPIStatus references(
if (!path)
CMReturnWithChars(_cb, CMPI_RC_ERR_NOT_FOUND, "Cannot find Name property in provided CIM_LogicalFile");
get_class_from_path(path, ccname);
- st = get_fsname_from_path(_cb, path, &fsname);
+ st = get_fsinfo_from_path(_cb, path, &fsclassname, &fsname);
check_status(st);
/* got PartComponent - LogicalFileRef */
if (group == 1) {
CMReturn(CMPI_RC_OK);
}
- fill_logicalfile(CIM_LogicalFileRef, &lmi_lfr, path, fsname, ccname);
+ fill_logicalfile(CIM_LogicalFileRef, &lmi_lfr, path, fsclassname, fsname, ccname);
o = CIM_LogicalFileRef_ToObjectPath(&lmi_lfr, &st);
CMSetClassName(o, ccname);
LMI_DirectoryContainsFile_SetObjectPath_PartComponent(&lmi_dcf, o);
@@ -341,13 +344,13 @@ static CMPIStatus references(
/* GroupComponent */
char *aux = strdup(path);
char *dir = dirname(aux);
- st = get_fsname_from_path(_cb, dir, &fsname);
+ st = get_fsinfo_from_path(_cb, dir, &fsclassname, &fsname);
if (st.rc != CMPI_RC_OK) {
free(aux);
return st;
}
- fill_logicalfile(CIM_DirectoryRef, &lmi_dr, dir, fsname, LMI_UnixDirectory_ClassName);
+ fill_logicalfile(CIM_DirectoryRef, &lmi_dr, dir, fsclassname, fsname, LMI_UnixDirectory_ClassName);
o = CIM_DirectoryRef_ToObjectPath(&lmi_dr, &st);
CMSetClassName(o, LMI_UnixDirectory_ClassName);
LMI_DirectoryContainsFile_SetObjectPath_GroupComponent(&lmi_dcf, o);
diff --git a/src/logicalfile/LMI_FileIdentityProvider.c b/src/logicalfile/LMI_FileIdentityProvider.c
index 514f5c3..90c5cbe 100644
--- a/src/logicalfile/LMI_FileIdentityProvider.c
+++ b/src/logicalfile/LMI_FileIdentityProvider.c
@@ -46,6 +46,7 @@ static CMPIStatus associators(
const char *path;
char fileclass[BUFLEN];
char *fsname;
+ char *fsclassname;
st = check_assoc_class(_cb, ns, assocClass, LMI_FileIdentity_ClassName);
check_class_check_status(st);
@@ -57,7 +58,7 @@ static CMPIStatus associators(
path = get_string_property_from_op(cop, "LFName");
get_class_from_path(path, fileclass);
- st = get_fsname_from_path(_cb, path, &fsname);
+ st = get_fsinfo_from_path(_cb, path, &fsclassname, &fsname);
check_status(st);
st = check_assoc_class(_cb, ns, resultClass, fileclass);
@@ -71,7 +72,7 @@ static CMPIStatus associators(
CIM_LogicalFileRef cim_lfr;
CIM_LogicalFileRef_Init(&cim_lfr, _cb, ns);
- fill_logicalfile(CIM_LogicalFileRef, &cim_lfr, path, fsname, fileclass);
+ fill_logicalfile(CIM_LogicalFileRef, &cim_lfr, path, fsclassname, fsname, fileclass);
o = CIM_LogicalFileRef_ToObjectPath(&cim_lfr, &st);
CMSetClassName(o, fileclass);
} else if (CMClassPathIsA(_cb, cop, CIM_LogicalFile_ClassName, &st)) {
@@ -91,7 +92,7 @@ static CMPIStatus associators(
}
get_class_from_path(path, fileclass);
- st = get_fsname_from_path(_cb, path, &fsname);
+ st = get_fsinfo_from_path(_cb, path, &fsclassname, &fsname);
check_status(st);
LMI_UnixFile lmi_uf;
@@ -99,7 +100,7 @@ static CMPIStatus associators(
LMI_UnixFile_Set_LFName(&lmi_uf, path);
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_FSCreationClassName(&lmi_uf, fsclassname);
LMI_UnixFile_Set_FSName(&lmi_uf, fsname);
LMI_UnixFile_Set_LFCreationClassName(&lmi_uf, fileclass);
o = LMI_UnixFile_ToObjectPath(&lmi_uf, &st);
@@ -136,6 +137,7 @@ static CMPIStatus references(
const char *path;
char fileclass[BUFLEN];
char *fsname;
+ char *fsclassname;
st = check_assoc_class(_cb, ns, assocClass, LMI_FileIdentity_ClassName);
check_class_check_status(st);
@@ -153,7 +155,7 @@ static CMPIStatus references(
path = get_string_property_from_op(cop, "LFName");
get_class_from_path(path, fileclass);
- st = get_fsname_from_path(_cb, path, &fsname);
+ st = get_fsinfo_from_path(_cb, path, &fsclassname, &fsname);
check_status(st);
if (role && strcmp(role, SAME_ELEMENT) != 0) {
@@ -163,7 +165,7 @@ static CMPIStatus references(
/* SystemElement */
CIM_LogicalFileRef lmi_lfr;
CIM_LogicalFileRef_Init(&lmi_lfr, _cb, ns);
- fill_logicalfile(CIM_LogicalFileRef, &lmi_lfr, path, fsname, fileclass);
+ fill_logicalfile(CIM_LogicalFileRef, &lmi_lfr, path, fsclassname, fsname, fileclass);
o = CIM_LogicalFileRef_ToObjectPath(&lmi_lfr, &st);
CMSetClassName(o, fileclass);
@@ -182,7 +184,7 @@ static CMPIStatus references(
}
path = get_string_property_from_op(cop, "Name");
get_class_from_path(path, fileclass);
- st = get_fsname_from_path(_cb, path, &fsname);
+ st = get_fsinfo_from_path(_cb, path, &fsclassname, &fsname);
check_status(st);
/* SameElement */
@@ -191,7 +193,7 @@ static CMPIStatus references(
LMI_UnixFile_Set_LFName(&lmi_uf, path);
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_FSCreationClassName(&lmi_uf, fsclassname);
LMI_UnixFile_Set_FSName(&lmi_uf, fsname);
LMI_UnixFile_Set_LFCreationClassName(&lmi_uf, fileclass);
o = LMI_UnixFile_ToObjectPath(&lmi_uf, &st);
diff --git a/src/logicalfile/LMI_RootDirectoryProvider.c b/src/logicalfile/LMI_RootDirectoryProvider.c
index 0afb39c..b8f442a 100644
--- a/src/logicalfile/LMI_RootDirectoryProvider.c
+++ b/src/logicalfile/LMI_RootDirectoryProvider.c
@@ -43,12 +43,13 @@ static CMPIStatus associators(
const char *comp_ccname = get_system_creation_class_name();
const char *path = get_string_property_from_op(cop, "Name");
char *fsname;
+ char *fsclassname;
const char *systemname = lmi_get_system_creation_class_name();
st = check_assoc_class(_cb, ns, assocClass, LMI_RootDirectory_ClassName);
check_class_check_status(st);
- st = get_fsname_from_path(_cb, "/", &fsname);
+ st = get_fsinfo_from_path(_cb, "/", &fsclassname, &fsname);
check_status(st);
if (CMClassPathIsA(_cb, cop, LMI_UnixDirectory_ClassName, &st)) {
@@ -85,7 +86,7 @@ static CMPIStatus associators(
LMI_UnixDirectory lmi_ud;
LMI_UnixDirectory_Init(&lmi_ud, _cb, ns);
- fill_logicalfile(LMI_UnixDirectory, &lmi_ud, "/", fsname, LMI_UnixDirectory_ClassName);
+ fill_logicalfile(LMI_UnixDirectory, &lmi_ud, "/", fsclassname, fsname, LMI_UnixDirectory_ClassName);
o = LMI_UnixDirectory_ToObjectPath(&lmi_ud, &st);
if (names) {
CMReturnObjectPath(cr, o);
@@ -127,7 +128,8 @@ static CMPIStatus references(
check_class_check_status(st);
char *fsname;
- st = get_fsname_from_path(_cb, "/", &fsname);
+ char *fsclassname;
+ st = get_fsinfo_from_path(_cb, "/", &fsclassname, &fsname);
check_status(st);
LMI_RootDirectory_Init(&lmi_rd, _cb, ns);
@@ -156,7 +158,7 @@ static CMPIStatus references(
LMI_UnixDirectory lmi_ud;
LMI_UnixDirectory_Init(&lmi_ud, _cb, ns);
- fill_logicalfile(LMI_UnixDirectory, &lmi_ud, "/", fsname, LMI_UnixDirectory_ClassName);
+ fill_logicalfile(LMI_UnixDirectory, &lmi_ud, "/", fsclassname, fsname, LMI_UnixDirectory_ClassName);
o = LMI_UnixDirectory_ToObjectPath(&lmi_ud, &st);
LMI_RootDirectory_SetObjectPath_PartComponent(&lmi_rd, o);
} else {
@@ -209,6 +211,7 @@ static CMPIStatus LMI_RootDirectoryEnumInstances(
CMPIObjectPath *o;
CMPIStatus st;
char *fsname;
+ char *fsclassname;
const char *ns = KNameSpace(cop);
LMI_RootDirectory lmi_rd;
@@ -218,9 +221,9 @@ static CMPIStatus LMI_RootDirectoryEnumInstances(
LMI_UnixDirectory lmi_ud;
LMI_UnixDirectory_Init(&lmi_ud, _cb, ns);
- st = get_fsname_from_path(_cb, "/", &fsname);
+ st = get_fsinfo_from_path(_cb, "/", &fsclassname, &fsname);
check_status(st);
- fill_logicalfile(LMI_UnixDirectory, &lmi_ud, "/", fsname, LMI_UnixDirectory_ClassName);
+ fill_logicalfile(LMI_UnixDirectory, &lmi_ud, "/", fsclassname, fsname, LMI_UnixDirectory_ClassName);
o = LMI_UnixDirectory_ToObjectPath(&lmi_ud, NULL);
LMI_RootDirectory_SetObjectPath_PartComponent(&lmi_rd, o);
diff --git a/src/logicalfile/LMI_UnixFileProvider.c b/src/logicalfile/LMI_UnixFileProvider.c
index fbe467c..165eb82 100644
--- a/src/logicalfile/LMI_UnixFileProvider.c
+++ b/src/logicalfile/LMI_UnixFileProvider.c
@@ -120,6 +120,7 @@ static CMPIStatus LMI_UnixFileGetInstance(
char aux[BUFLEN];
const char *path;
char *fsname;
+ char *fsclassname;
st = lmi_check_required(_cb, cc, cop);
if (st.rc != CMPI_RC_OK) {
@@ -134,9 +135,9 @@ static CMPIStatus LMI_UnixFileGetInstance(
CMReturnWithChars(_cb, CMPI_RC_ERR_NOT_FOUND, aux);
}
/* set ignored stuff */
- LMI_UnixFile_Set_FSCreationClassName(&lmi_file, FSCREATIONCLASSNAME);
- st = get_fsname_from_stat(_cb, &sb, &fsname);
+ st = get_fsinfo_from_stat(_cb, &sb, path, &fsclassname, &fsname);
check_status(st);
+ LMI_UnixFile_Set_FSCreationClassName(&lmi_file, fsclassname);
LMI_UnixFile_Set_FSName(&lmi_file, fsname);
free(fsname);
get_class_from_stat(&sb, aux);
diff --git a/src/logicalfile/file.c b/src/logicalfile/file.c
index 6297f02..4d66b2f 100644
--- a/src/logicalfile/file.c
+++ b/src/logicalfile/file.c
@@ -83,7 +83,8 @@ int get_class_from_path(const char *path, char *fileclass)
return rc;
}
-CMPIStatus get_fsname_from_stat(const CMPIBroker *b, const struct stat *sb, char **fname)
+CMPIStatus get_fsinfo_from_stat(const CMPIBroker *b, const struct stat *sb, const char *path,
+ char **fsclassname, char **fsname)
{
struct udev *udev_ctx;
struct udev_device *udev_dev;
@@ -97,17 +98,20 @@ CMPIStatus get_fsname_from_stat(const CMPIBroker *b, const struct stat *sb, char
udev_dev = udev_device_new_from_devnum(udev_ctx, 'b', sb->st_dev);
if ((dev_name = udev_device_get_property_value(udev_dev, "ID_FS_UUID_ENC"))) {
- if (asprintf(fname, "UUID=%s", dev_name) < 0) {
+ if (asprintf(fsname, "UUID=%s", dev_name) < 0) {
return_with_status(b, &st, ERR_FAILED, "asprintf failed");
}
+ *fsclassname = FSCREATIONCLASSNAME_LOCAL;
} else if ((dev_name = udev_device_get_property_value(udev_dev, "DEVNAME"))) {
- if (asprintf(fname, "DEVICE=%s", dev_name) < 0) {
+ if (asprintf(fsname, "DEVICE=%s", dev_name) < 0) {
return_with_status(b, &st, ERR_FAILED, "asprintf failed");
}
+ *fsclassname = FSCREATIONCLASSNAME_LOCAL;
} else {
- if (asprintf(fname, "Unknown") < 0) {
+ if (asprintf(fsname, "PATH=%s", path) < 0) {
return_with_status(b, &st, ERR_FAILED, "asprintf failed");
}
+ *fsclassname = FSCREATIONCLASSNAME_TRANSIENT;
}
udev_device_unref(udev_dev);
udev_unref(udev_ctx);
@@ -115,7 +119,7 @@ CMPIStatus get_fsname_from_stat(const CMPIBroker *b, const struct stat *sb, char
return st;
}
-CMPIStatus get_fsname_from_path(const CMPIBroker *b, const char *path, char **fsname)
+CMPIStatus get_fsinfo_from_path(const CMPIBroker *b, const char *path, char **fsclassname, char **fsname)
{
CMPIStatus st = {.rc = CMPI_RC_OK};
struct stat sb;
@@ -124,7 +128,7 @@ CMPIStatus get_fsname_from_path(const CMPIBroker *b, const char *path, char **fs
return_with_status(b, &st, ERR_FAILED, "lstat(2) failed");
}
- return get_fsname_from_stat(b, &sb, fsname);
+ return get_fsinfo_from_stat(b, &sb, path, fsclassname, fsname);
}
const char *get_string_property_from_op(const CMPIObjectPath *o, const char *prop)
@@ -169,6 +173,7 @@ CMPIStatus stat_logicalfile_and_fill(
struct stat sb;
char buf[BUFLEN];
char *fsname = NULL;
+ char *fsclassname = NULL;
const char *path = KChars(lf->lf.datafile.Name.value);
CMPIStatus st = {.rc = CMPI_RC_OK};
@@ -179,17 +184,17 @@ CMPIStatus stat_logicalfile_and_fill(
get_class_from_stat(&sb, buf);
- st = get_fsname_from_stat(b, &sb, &fsname);
+ st = get_fsinfo_from_stat(b, &sb, path, &fsclassname, &fsname);
check_status(st);
switch(mode) {
case S_IFREG:
- fill_basic(b, DataFile, &lf->lf.datafile, buf, fsname, sb);
+ fill_basic(b, DataFile, &lf->lf.datafile, buf, fsclassname, fsname, sb);
break;
case S_IFCHR:
/* FALLTHROUGH */
case S_IFBLK:
- fill_basic(b, UnixDeviceFile, &lf->lf.unixdevicefile, buf, fsname, sb);
+ fill_basic(b, UnixDeviceFile, &lf->lf.unixdevicefile, buf, fsclassname, fsname, sb);
/* device-specific stuff */
char tmp[21];
sprintf(tmp, "%lu", sb.st_rdev);
@@ -205,13 +210,13 @@ CMPIStatus stat_logicalfile_and_fill(
}
break;
case S_IFDIR:
- fill_basic(b, UnixDirectory, &lf->lf.unixdirectory, buf, fsname, sb);
+ fill_basic(b, UnixDirectory, &lf->lf.unixdirectory, buf, fsclassname, fsname, sb);
break;
case S_IFIFO:
- fill_basic(b, FIFOPipeFile, &lf->lf.fifopipefile, buf, fsname, sb);
+ fill_basic(b, FIFOPipeFile, &lf->lf.fifopipefile, buf, fsclassname, fsname, sb);
break;
case S_IFLNK:
- fill_basic(b, SymbolicLink, &lf->lf.symboliclink, buf, fsname, sb);
+ fill_basic(b, SymbolicLink, &lf->lf.symboliclink, buf, fsclassname, fsname, sb);
/* symlink-specific stuff */
char rpath[PATH_MAX];
const char *path;
diff --git a/src/logicalfile/file.h b/src/logicalfile/file.h
index 09c428a..a95cb46 100644
--- a/src/logicalfile/file.h
+++ b/src/logicalfile/file.h
@@ -48,7 +48,8 @@
const ConfigEntry *provider_config_defaults;
const char *provider_name;
-#define FSCREATIONCLASSNAME "LMI_LocalFileSystem"
+#define FSCREATIONCLASSNAME_LOCAL "LMI_LocalFileSystem"
+#define FSCREATIONCLASSNAME_TRANSIENT "LMI_TransientFileSystem"
#define GROUP_COMPONENT "GroupComponent"
#define PART_COMPONENT "PartComponent"
#define SAME_ELEMENT "SameElement"
@@ -77,17 +78,17 @@ const char *provider_name;
)
#define stoms(t) ((t)*1000000)
-#define fill_logicalfile(type, obj, name, fsname, creation_class) \
+#define fill_logicalfile(type, obj, name, fsclassname, fsname, creation_class) \
type##_Set_Name((obj), (name)); \
type##_Set_CSCreationClassName((obj), get_system_creation_class_name()); \
type##_Set_CSName((obj), get_system_name()); \
- type##_Set_FSCreationClassName((obj), FSCREATIONCLASSNAME); \
+ type##_Set_FSCreationClassName((obj), fsclassname); \
type##_Set_FSName((obj), (fsname)); \
type##_Set_CreationClassName((obj), (creation_class));
-#define fill_basic(b, cmpitype, lmi_file, creation_class_name, fsname, sb) \
+#define fill_basic(b, cmpitype, lmi_file, creation_class_name, fsclassname, fsname, sb) \
LMI_##cmpitype##_Set_CreationClassName(lmi_file, creation_class_name); \
- LMI_##cmpitype##_Set_FSCreationClassName(lmi_file, FSCREATIONCLASSNAME); \
+ LMI_##cmpitype##_Set_FSCreationClassName(lmi_file, fsclassname); \
LMI_##cmpitype##_Set_FSName(lmi_file, fsname); \
LMI_##cmpitype##_Set_Readable(lmi_file, sb_isreadable(sb)); \
LMI_##cmpitype##_Set_Writeable(lmi_file, sb_iswriteable(sb)); \
@@ -125,8 +126,8 @@ typedef struct {
CMPIStatus lmi_check_required(const CMPIBroker *, const CMPIContext *, const CMPIObjectPath *);
void get_class_from_stat(const struct stat *, char *);
int get_class_from_path(const char *, char *);
-CMPIStatus get_fsname_from_stat(const CMPIBroker *, const struct stat *, char **);
-CMPIStatus get_fsname_from_path(const CMPIBroker *, const char *, char **);
+CMPIStatus get_fsinfo_from_stat(const CMPIBroker *, const struct stat *, const char *, char **, char **);
+CMPIStatus get_fsinfo_from_path(const CMPIBroker *, const char *, char **, char **);
const char *get_string_property_from_op(const CMPIObjectPath *, const char *);
CMPIStatus check_assoc_class(const CMPIBroker *, const char *, const char *, const char *);
CMPIStatus stat_logicalfile_and_fill(const CMPIBroker *, logicalfile_t *, mode_t, const char *);
diff --git a/src/logicalfile/test/test_basic.py b/src/logicalfile/test/test_basic.py
index d813f1a..26f525a 100644
--- a/src/logicalfile/test/test_basic.py
+++ b/src/logicalfile/test/test_basic.py
@@ -67,6 +67,13 @@ class TestLogicalFile(LogicalFileTestBase):
'class': 'LMI_UnixDirectory',
'props': {}}}
+ self.transient_file = {'path' : self.testdir + "/transient",
+ 'class' : 'LMI_UnixDirectory',
+ 'props' : {'FSCreationClassName' : 'LMI_TransientFileSystem',
+ 'FSName' : 'PATH=' + self.testdir + "/transient"}}
+
+ self.num_files = len(self.files.keys()) + 1
+
self.cop = pywbem.CIMInstanceName(classname='LMI_UnixDirectory',
namespace='root/cimv2',
keybindings={
@@ -121,8 +128,12 @@ class TestLogicalFile(LogicalFileTestBase):
bldev = self.files['bldev']
bldev_device = os.makedev(bldev['props']['DeviceMajor'], bldev['props']['DeviceMinor'])
os.mknod(bldev['path'], 0666 | stat.S_IFBLK, bldev_device)
+ transient_file = self.transient_file['path']
+ os.mkdir(transient_file)
+ subprocess.call(['mount', '-t', 'tmpfs', 'tmpfs', transient_file, '-o', 'size=1M'])
def _cleanup(self):
+ subprocess.call(['umount', self.transient_file['path']])
shutil.rmtree(self.testdir)
def test_lmi_directorycontainsfile(self):
@@ -130,7 +141,7 @@ class TestLogicalFile(LogicalFileTestBase):
### Associators and AssociatorNames
for assoc_method in [self.wbemconnection.Associators, self.wbemconnection.AssociatorNames]:
assocs = assoc_method(self.cop, AssocClass=assoc_class)
- self.assertEquals(len(assocs), len(self.files.keys()))
+ self.assertEquals(len(assocs), self.num_files)
for k, f in self.files.iteritems():
# test that the files are actually there and have the correct class name
match = filter(lambda a: a['Name'] == f['path'], assocs)
@@ -186,7 +197,7 @@ class TestLogicalFile(LogicalFileTestBase):
### References and ReferenceNames
for assoc_method in [self.wbemconnection.References, self.wbemconnection.ReferenceNames]:
assocs = assoc_method(self.cop, ResultClass='LMI_DirectoryContainsFile')
- self.assertEquals(len(assocs), len(self.files.keys()))
+ self.assertEquals(len(assocs), self.num_files)
for k, f in self.files.iteritems():
# test that the files are actually there and have the correct class name
match = filter(lambda a: a['PartComponent']['Name'] == f['path'], assocs)
@@ -216,7 +227,7 @@ class TestLogicalFile(LogicalFileTestBase):
assoc_class = 'LMI_FileIdentity'
for assoc_method in [self.wbemconnection.Associators, self.wbemconnection.AssociatorNames]:
assocs = assoc_method(self.cop, AssocClass='LMI_DirectoryContainsFile')
- self.assertEquals(len(assocs), len(self.files.keys()))
+ self.assertEquals(len(assocs), self.num_files)
for k, f in self.files.iteritems():
match = filter(lambda a: a['Name'] == f['path'], assocs)
self.assertEquals(len(match), 1)
@@ -289,7 +300,7 @@ class TestLogicalFile(LogicalFileTestBase):
### References and ReferenceNames
for assoc_method in [self.wbemconnection.References, self.wbemconnection.ReferenceNames]:
assocs = assoc_method(self.cop, ResultClass='LMI_DirectoryContainsFile')
- self.assertEquals(len(assocs), len(self.files.keys()))
+ self.assertEquals(len(assocs), self.num_files)
for k, f in self.files.iteritems():
match = filter(lambda a: a['PartComponent']['Name'] == f['path'], assocs)
self.assertEquals(len(match), 1)
@@ -483,5 +494,17 @@ class TestLogicalFile(LogicalFileTestBase):
def test_logicalfile_missing_or_wrong_properties(self):
self._test_missing_or_wrong_properties(False)
+ def test_transient_file(self):
+ cop = self.cop.copy()
+ cop['Name'] = self.transient_file['path']
+
+ try:
+ inst = self.wbemconnection.GetInstance(cop)
+ except pywbem.CIMError as pe:
+ self.fail(pe[1])
+
+ self.assertEquals(inst['FSCreationClassName'], 'LMI_TransientFileSystem')
+ self.assertEquals(inst['FSName'], 'PATH=' + cop['Name'])
+
if __name__ == '__main__':
unittest.main()