OpenFAM Reference Implementation

openfam::fam::fam_change_permissions

Change permissions associated with a data item or region in FAM.

Synopsis

int fam_change_permissions(Fam_Descriptor *descriptor, mode_t accessPermissions);
int 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

Returns 0 on Success. Throws an exception on error.

Exceptions

ExceptionDescription
FAM_ERR_NOPERMCaller does not have access rights
FAM_ERR_NOTFOUNDthe data item name not found in FAM
FAM_ERR_GRPCthere is a communication error with memory server
FAM_ERR_RPC_CLIENT_NOTFOUNDMemory server initialization failure

Notes

None.

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("Successully changed permission from 0600 to 0400\n");
		
		// free allocated space in FAM
		myFam->fam_deallocate(descriptor);
		printf("Successully de-allocated 50 unnamed integer elements\n");
	} catch (Fam_Exception &e) {
		printf("fam API failed: %d: %s\n", e.fam_error(), e.fam_error_msg());
	}
	
	// ... Finalization code here
}