Functorise over a grant sharing/exporting interface

Signed-off-by: David Scott <dave.scott@eu.citrix.com>