Updated on 2026-08-03 GMT+08:00

Listing Parallel File Systems (SDK for C)

If you have any questions during development, post them on the Issues page of GitHub.

You can call the list_bucket_obs API to list all parallel file systems under the current account. The results are returned in lexicographical order by the names of the parallel file systems.

Restrictions

  • To list parallel file systems, you must have the obs:bucket:ListAllMyBuckets permission. IAM is recommended for granting permissions. For details, see IAM Custom Policies.
  • The mapping between OBS regions and endpoints must comply with what is listed in Regions and Endpoints.

Method

1
2
void list_bucket_obs(const obs_options *options, obs_list_service_obs_handler *handler, 
                   void *callback_data);

Request Parameters

Table 1 List of request parameters

Parameter

Type

Mandatory (Yes/No)

Description

options

const obs_options *

Yes

The context of the requested bucket. Refer to Configuring option (SDK for C) to set the AK, SK, endpoint, bucket, timeout, and temporary credentials through obs_options.

handler

obs_list_service_obs_handler *

Yes

A callback structure where all members are pointers to callback functions, used to set the callback functions that handle response data. You can set a callback function to copy the response data from the server to your custom callback_data.

callback_data

void *

No

Custom callback data.

Sample Code

This example lists parallel file systems.

static void test_list_bucket_obs()
{ 
    // Create and initialize options, including the access domain name (host_name), access keys (access_key_id and access_key_secret), bucket name (bucket_name), and bucket storage class (storage_class).
    obs_options options;
    init_obs_options(&options);
    // Enter the endpoint corresponding to the bucket for host_name. CN-Hong Kong is used here as an example. Replace it with the one currently in use.
    options.bucket_options.host_name = "obs.ap-southeast-1.myhuaweicloud.com";
    options.bucket_options.bucket_name = "<Your bucketname>";

    // Hard-coded or plaintext AK/SK are risky. For security purposes, encrypt your AK/SK and store them in the configuration file or environment variables. In this example, the AK/SK are stored in environment variables for identity authentication. Before running this example, configure environment variables ACCESS_KEY_ID and SECRET_ACCESS_KEY.
    // Obtain an AK/SK pair on the management console. For details, see https://support.huaweicloud.com/intl/en-us/usermanual-ca/ca_01_0003.html.
    options.bucket_options.access_key = getenv("ACCESS_KEY_ID");
    options.bucket_options.secret_access_key = getenv("SECRET_ACCESS_KEY");

    list_service_data data;
    memset_s(&data, sizeof(list_service_data), 0, sizeof(list_service_data));
    // Customize response callback function.
    obs_list_service_obs_handler listHandler =
    { 
        {NULL,
        &list_bucket_complete_callback },
        &listServiceObsCallback
    };
    // List parallel file systems.
    list_bucket_obs(&options,&listHandler,&data);
    if (data.ret_status == OBS_STATUS_OK) 
    {
        printf("list bucket successfully. \n");
    }
    else
    {
        printf("list bucket failed(%s).\n", obs_get_status_name(data.ret_status));
    }
}