Beispiel #1
0
static int stat_blobstore (const char * conf_instances_path, const char * name, blobstore_meta * meta)
{
    bzero (meta, sizeof (blobstore_meta));
    char path [MAX_PATH]; 
    snprintf (path, sizeof (path), "%s/%s", conf_instances_path, name);

    // stat the file system and return those numbers even if blobstore does not exist
    if (statfs_path (path, &(meta->fs_bytes_size), &(meta->fs_bytes_available), &(meta->fs_id)) != OK) {
        return ERROR;
    }

    // get the size and params of the blobstore, if it exists
    blobstore * bs = blobstore_open (path, 
                                     0, // any size
                                     0, // no flags = do not create it
                                     BLOBSTORE_FORMAT_ANY, 
                                     BLOBSTORE_REVOCATION_ANY, 
                                     BLOBSTORE_SNAPSHOT_ANY);
    if (bs == NULL)
        return OK;
    blobstore_stat (bs, meta);
    blobstore_close (bs);
    
    return OK;
}
//!
//! Stats the blobstore (name) created under the given path.
//!
//! @param[in]  conf_instances_path path to where the instances information are stored
//! @param[in]  name name of the blobstore
//! @param[out] meta the blobstore metadata to retrieve
//!
//! @return EUCA_OK on success or the following error codes:
//!         \li EUCA_ACCESS_ERROR if we fail to access the requested blobstore
//!
//! @pre The conf_instance_path, name and meta fields must not be NULL.
//!
//! @post On success the meta fields have been updated
//!
static int stat_blobstore(const char *conf_instances_path, const char *name, blobstore_meta * meta)
{
    char path[EUCA_MAX_PATH] = "";
    blobstore *bs = NULL;

    bzero(meta, sizeof(blobstore_meta));
    snprintf(path, sizeof(path), "%s/%s", conf_instances_path, name);

    // stat the file system and return those numbers even if blobstore does not exist
    if (statfs_path(path, &(meta->fs_bytes_size), &(meta->fs_bytes_available), &(meta->fs_id)) != EUCA_OK) {
        return (EUCA_ACCESS_ERROR);
    }
    // get the size and params of the blobstore, if it exists (do not create)
    if ((bs = blobstore_open(path, 0, 0, BLOBSTORE_FORMAT_ANY, BLOBSTORE_REVOCATION_ANY, BLOBSTORE_SNAPSHOT_ANY)) == NULL)
        return (EUCA_OK);

    // stat and close our blobstore
    blobstore_stat(bs, meta);
    BLOBSTORE_CLOSE(bs);
    return (EUCA_OK);
}