Trusted Solaris Developer's Guide

Get File CMW Label

You can get a file CMW label and perform operations on it as a unit, or extract the SL portion and perform independent operations on the SL portion.

This example gets the file CMW label and extracts the sensitivity label portion. The fgetcmwlabel(2) and lgetcmwlabel(2) routines are used the same way, but operate on a file descriptor or symbolic link.

#include <tsol/label.h>

main()
{
	int retval, length = 0;
	bclabel_t fileCMWlabel;
 bslabel_t fsenslabel;
	char *string = (char *)0;

/* Get file CMW label */
	retval = getcmwlabel("/export/home/zelda/afile", &fileCMWlabel);

/* Get sensitivity label portion */
	getcsl(&fsenslabel, &fileCMWlabel);

/* Translate fileCMWlabel to text and print */
	retval = bcltos(&fileCMWlabel, &string, length, LONG_CLASSIFICATION);
	printf("File CMW label = %s\n", string);
}

File CMW label = [CONFIDENTIAL]