Trusted Solaris Developer's Guide

Programming Interface Declarations

The following programming interfaces are available for getting information on MLDs and SLDs.

System Calls

System calls are available to get the SLD name, get MLD adornment, and get SLD or MLD file attribute information.

Get SLD Name

The getsldname(2) system call gets the SLD name for path_name at the specified slabel. Refer to the getsldname(2) man page. The fgetsldname(2) system call uses a file descriptor.

int getsldname(const char *path_name,
	const bslabel_t *slabel,
	char *name_buf,
	const int len);

int fgetsldname(const int fd,
	const bslabel_t *slabel_p,
	char *name_buf,
	const int len);

Get MLD Adornment

The getmldadorn(2) system call gets the fully adorned path name for path_name. The fgetmldadorn(2) system call uses a file descriptor. Refer to the getmldadorn(2) man page.

int getmldadorn(const char *path_name, char *adorn_buf[MLD_ADORN_MAX]);
int fgetmldadorn(const int fd, char adorn_buf[MLD_ADORN_MAX]);

Get Attribute Information for SLD or MLD

The mldstat(3TSOL) system call returns file attribute information on the MLD specified by path_name. The mldlstat(3TSOL) system call returns information on the MLD symbolic link.

int mldstat(const char *path_name, struct stat *stat_buf);
int mldlstat(const char *path_name, struct stat *stat_buf);

Get MLD Attribute Flags

These system calls are described in "Get and Set File System Security Attribute Flags" in Chapter 2, Getting Started. Also, refer to the getfattrflag(2) man page.

int mldgetfattrflag(const char *path, secflgs_t *flags);
int mldsetfattrflag(const char * path, secflgs_t which, secflgs_t flags);

Library Routines

Library routines are available to get the pathname of the current working directory and display a pathname with adornments.

Get Current Working Directory

This routine gets the fully adorned path name for the current working directory. Refer to the mldgetcwd(3TSOL) man page.

char* mldgetcwd(char *buf, size_t size);

Get Adorned Name

This routine gets the adorned name for the MLD specified in path_name. Refer to the adornfc(3TSOL) man page.

int adornfc(const char *path_name, char *adorned_name);

Find the Real Path Name

These routines take the path name supplied in path_name, expand all symbolic links, resolve dot references to the current directory and dot-dot references to the parent directory, remove extra slash characters, add the correct MLD and SLD adornments, and store the final result in resolved_path. The result is for the SLD at which the process is running, or at the specified SLD. Refer to the mldrealpath(3TSOL) man page.

char* mldrealpath(const char *path_name,
	char *resolved_path);

char *mldrealpathl(const char *path_name,
	char *resolved_path, const bslabel_t *senslabel);