summaryrefslogtreecommitdiffstats
path: root/src/logicalfile/file.c
diff options
context:
space:
mode:
authorJan Synacek <jsynacek@redhat.com>2013-02-14 15:23:51 +0100
committerJan Synacek <jsynacek@redhat.com>2013-02-14 16:00:03 +0100
commit01a81cf733f25bbe8d988e557672b539e9fc3c1b (patch)
tree2f09d5b4b5178f5137eacdea306acaf6aa0ffb04 /src/logicalfile/file.c
parentf9800113caf680157b86a7d7e072fb163985e52f (diff)
downloadopenlmi-providers-01a81cf733f25bbe8d988e557672b539e9fc3c1b.tar.gz
openlmi-providers-01a81cf733f25bbe8d988e557672b539e9fc3c1b.tar.xz
openlmi-providers-01a81cf733f25bbe8d988e557672b539e9fc3c1b.zip
LogicalFile: fix FileIdentity
LMI_FileIdentity.Associators() was not behaving correctly -- it was returning the object itself instead of the other one. Also, LMI_FileIdentity.References() has been updated.
Diffstat (limited to 'src/logicalfile/file.c')
-rw-r--r--src/logicalfile/file.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/logicalfile/file.c b/src/logicalfile/file.c
index a9a13a6..6c482f0 100644
--- a/src/logicalfile/file.c
+++ b/src/logicalfile/file.c
@@ -69,6 +69,32 @@ CMPIStatus lmi_check_required(
CMReturn(CMPI_RC_OK);
}
+void get_class_from_stat(const struct stat *sb, char *fileclass) {
+ (S_ISREG(sb->st_mode)) ? strcpy(fileclass, "LMI_DataFile") :
+ (S_ISDIR(sb->st_mode)) ? strcpy(fileclass, "LMI_UnixDirectory") :
+ (S_ISCHR(sb->st_mode)) ? strcpy(fileclass, "LMI_UnixDeviceFile") :
+ (S_ISBLK(sb->st_mode)) ? strcpy(fileclass, "LMI_UnixDeviceFile") :
+ (S_ISLNK(sb->st_mode)) ? strcpy(fileclass, "LMI_SymbolicLink") :
+ (S_ISFIFO(sb->st_mode)) ? strcpy(fileclass, "LMI_FIFOPipeFile") :
+ (S_ISSOCK(sb->st_mode)) ? strcpy(fileclass, "LMI_UnixSocket") :
+ strcpy(fileclass, "Unknown");
+ assert(strcmp(fileclass, "Unknown") != 0);
+}
+
+int get_class_from_path(const char *path, char *fileclass)
+{
+ int rc = 0;
+ struct stat sb;
+
+ if (lstat(path, &sb) < 0) {
+ rc = 1;
+ } else {
+ get_class_from_stat(&sb, fileclass);
+ }
+
+ return rc;
+}
+
void _dump_objectpath(const CMPIObjectPath *o)
{
printf("OP: %s\n", CMGetCharsPtr(o->ft->toString(o, NULL), NULL));