openfam::fam::fam_change_permissions
Change permissions associated with a data item or region in FAM.
Synopsis
void fam_change_permissions(Fam_Descriptor *descriptor, mode_t
accessPermissions);
void
fam_change_permissions(Fam_Region_Descriptor *descriptor, mode_t
accessPermissions);
Description
This method changes read/write permissions for a data item or region.
Input Arguments
| Name | Description |
|---|---|
| descriptor | Descriptor associated with the data item or region. |
| accessPermissions | New access permissions to be associated with the item. |
Return Values
None. Throws Fam_Exception on error.
Fam error numbers
| Error | Description |
|---|---|
| FAM_ERR_NOPERM | Caller does not have access rights |
| FAM_ERR_NOTFOUND | Data item name not found in FAM |
| FAM_ERR_RPC | Communication error from grpc layer. |
| FAM_ERR_RPC_CLIENT_NOTFOUND | RPC service not available. |
| FAM_ERR_METADATA | Metadata service error. |
| FAM_ERR_MEMORY | Memory service error. |
| FAM_ERR_RESOURCE | Resource not available. |
Notes
Permissions are checked on first descriptor use in a running program. Changed permissions are only applied the next time the program is run, not immediately on next access.
Example
#include <string.h>
#include <fam/fam.h>
#include <fam/fam_exception.h>
using namespace std;
using namespace openfam;
int main(void) {
fam *myFam = new fam();
// ... Initialization code here
try {
Fam_Region_Descriptor *region = myFam->fam_lookup_region("myRegion");
// create 50 element named integer array in FAM with 0600
// (read/write by owner) permissions in myRegion
Fam_Descriptor *descriptor = myFam->fam_allocate("myItem", 50*sizeof(int), 0600, region);
printf("Successfully allocated 50 unnamed integer elements\n");
// initialize the allocated space here with meaningful values
// make the item read-only (0400) to prevent further change by
// subsequent programs
myFam->fam_change_permissions(descriptor, 0400);
printf("Successfully changed permission from 0600 to 0400\n");
} catch (Fam_Exception &e) {
printf("fam API failed: %d: %s\n", e.fam_error(), e.fam_error_msg());
}
// ... Finalization code here
}