OpenFAM Reference Implementation

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

NameDescription
descriptorDescriptor associated with the data item or region.
accessPermissionsNew access permissions to be associated with the item.

Return Values

None. Throws Fam_Exception on error.

Fam error numbers

ErrorDescription
FAM_ERR_NOPERMCaller does not have access rights
FAM_ERR_NOTFOUNDData item name not found in FAM
FAM_ERR_RPCCommunication error from grpc layer.
FAM_ERR_RPC_CLIENT_NOTFOUNDRPC service not available.
FAM_ERR_METADATAMetadata service error.
FAM_ERR_MEMORYMemory service error.
FAM_ERR_RESOURCEResource 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
}