diff options
Diffstat (limited to 'src/logicalfile/file.c')
-rw-r--r-- | src/logicalfile/file.c | 89 |
1 files changed, 6 insertions, 83 deletions
diff --git a/src/logicalfile/file.c b/src/logicalfile/file.c index ac68b6f..03c99da 100644 --- a/src/logicalfile/file.c +++ b/src/logicalfile/file.c @@ -29,40 +29,6 @@ const ConfigEntry *provider_config_defaults = (const ConfigEntry *)&(ConfigEntry const char *provider_name = "logicalfile"; -CMPIStatus lmi_check_required( - const CMPIBroker *b, - const CMPIContext *ctx, - const CMPIObjectPath *o) -{ - const char *prop; - - CMPIStatus st; - CMPIData data; - /* check computer system creation class name */ - data = CMGetKey(o, "CSCreationClassName", &st); - check_status(st); - if (CMIsNullValue(data)) { - CMReturnWithChars(b, CMPI_RC_ERR_FAILED, "CSCreationClassName is empty"); - } - prop = get_string_property_from_op(o, "CSCreationClassName"); - if (strcmp(prop, lmi_get_system_creation_class_name()) != 0) { - CMReturnWithChars(b, CMPI_RC_ERR_FAILED, "Wrong CSCreationClassName"); - } - - /* check fqdn */ - data = CMGetKey(o, "CSName", &st); - check_status(st); - if (CMIsNullValue(data)) { - CMReturnWithChars(b, CMPI_RC_ERR_FAILED, "CSName is empty"); - } - prop = get_string_property_from_op(o, "CSName"); - if (strcmp(prop, lmi_get_system_name()) != 0) { - CMReturnWithChars(b, CMPI_RC_ERR_FAILED, "Wrong CSName"); - } - - 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") : @@ -99,14 +65,14 @@ CMPIStatus get_fsinfo_from_stat(const CMPIBroker *b, const struct stat *sb, cons udev_ctx = udev_new(); if (!udev_ctx) { - return_with_status(b, &st, ERR_FAILED, "Could not create udev context"); + lmi_return_with_status(b, &st, ERR_FAILED, "Could not create udev context"); } 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 (!*fsname) { if (asprintf(fsname, "UUID=%s", dev_name) < 0) { - return_with_status(b, &st, ERR_FAILED, "asprintf failed"); + lmi_return_with_status(b, &st, ERR_FAILED, "asprintf failed"); } } if (!*fsclassname) { @@ -115,7 +81,7 @@ CMPIStatus get_fsinfo_from_stat(const CMPIBroker *b, const struct stat *sb, cons } else if ((dev_name = udev_device_get_property_value(udev_dev, "DEVNAME"))) { if (!*fsname) { if (asprintf(fsname, "DEVICE=%s", dev_name) < 0) { - return_with_status(b, &st, ERR_FAILED, "asprintf failed"); + lmi_return_with_status(b, &st, ERR_FAILED, "asprintf failed"); } } if (!*fsclassname) { @@ -124,7 +90,7 @@ CMPIStatus get_fsinfo_from_stat(const CMPIBroker *b, const struct stat *sb, cons } else { if (!*fsname) { if (asprintf(fsname, "PATH=%s", path) < 0) { - return_with_status(b, &st, ERR_FAILED, "asprintf failed"); + lmi_return_with_status(b, &st, ERR_FAILED, "asprintf failed"); } } if (!*fsclassname) { @@ -143,51 +109,12 @@ CMPIStatus get_fsinfo_from_path(const CMPIBroker *b, const char *path, char **fs struct stat sb; if (lstat(path, &sb) < 0) { - return_with_status(b, &st, ERR_FAILED, "lstat(2) failed"); + lmi_return_with_status(b, &st, ERR_FAILED, "lstat(2) failed"); } return get_fsinfo_from_stat(b, &sb, path, fsclassname, fsname); } -const char *get_string_property_from_op(const CMPIObjectPath *o, const char *prop) -{ - CMPIData d; - d = CMGetKey(o, prop, NULL); - return KChars(d.value.string); -} - -const char *get_string_property_from_instance(const CMPIInstance *i, const char *prop) -{ - CMPIData d; - d = CMGetProperty(i, prop, NULL); - return KChars(d.value.string); -} - -CMPIStatus check_assoc_class( - const CMPIBroker *cb, - const char *namespace, - const char *assocClass, - const char *class) -{ - CMPIObjectPath *o; - CMPIStatus st = {.rc = CMPI_RC_OK}; - - o = CMNewObjectPath(cb, namespace, class, &st); - if (!o) { - /* assume that status has been properly set */ - return st; - } else if (st.rc != CMPI_RC_OK) { - CMRelease(o); - return st; - } - if (assocClass && !CMClassPathIsA(cb, o, assocClass, &st)) { - CMRelease(o); - st.rc = RC_ERR_CLASS_CHECK_FAILED; - return st; - } - CMRelease(o); - return st; -} CMPIStatus stat_logicalfile_and_fill( const CMPIBroker *b, @@ -214,7 +141,7 @@ CMPIStatus stat_logicalfile_and_fill( fsname = (char *) KChars(lf->lf.datafile.FSName.value); fsclassname = (char *) KChars(lf->lf.datafile.FSCreationClassName.value); st = get_fsinfo_from_stat(b, &sb, path, &fsclassname, &fsname); - check_status(st); + lmi_check_status(st); switch(mode) { case S_IFREG: @@ -264,10 +191,6 @@ CMPIStatus stat_logicalfile_and_fill( return st; } -void _dump_objectpath(const CMPIObjectPath *o) -{ - printf("OP: %s\n", CMGetCharsPtr(o->ft->toString(o, NULL), NULL)); -} /* vi: set et: */ /* Local Variables: */ /* indent-tabs-mode: nil */ |