FreeBSD/sys/kern/subr_acl_posix1e.c
/*
 * For the purposes of filesystems maintaining the _OBJ entries in an inode
 * with a mode_t field, this routine converts a mode_t entry to an
 * acl_perm_t.
 */
For the purposes of filesystems maintaining the _OBJ entries in an inode
with a mode_t field, this routine converts a mode_t entry to an
acl_perm_t.
For the purposes of filesystems maintaining the _OBJ entries in an inode with a mode_t field this routine converts a mode_t entry to an acl_perm_t .
acl_perm_t
acl_posix1e_mode_to_perm(acl_tag_t tag, mode_t mode)
{
	acl_perm_t	perm = 0;
	switch(tag) {
	case ACL_USER_OBJ:
		if (mode & S_IXUSR)
			perm |= ACL_EXECUTE;
		if (mode & S_IRUSR)
			perm |= ACL_READ;
		if (mode & S_IWUSR)
			perm |= ACL_WRITE;
		return (perm);
	case ACL_GROUP_OBJ:
		if (mode & S_IXGRP)
			perm |= ACL_EXECUTE;
		if (mode & S_IRGRP)
			perm |= ACL_READ;
		if (mode & S_IWGRP)
			perm |= ACL_WRITE;
		return (perm);
	case ACL_OTHER:
		if (mode & S_IXOTH)
			perm |= ACL_EXECUTE;
		if (mode & S_IROTH)
			perm |= ACL_READ;
		if (mode & S_IWOTH)
			perm |= ACL_WRITE;
		return (perm);
	default:
		printf("acl_posix1e_mode_to_perm: invalid tag (%d)\n", tag);
		return (0);
	}
}
acl_perm_t acl_posix1e_mode_to_perm ( acl_tag_t tag , mode_t mode ) { acl_perm_t perm = 0 ; switch ( tag ) { case ACL_USER_OBJ : if ( mode & S_IXUSR ) perm |= ACL_EXECUTE ; if ( mode & S_IRUSR ) perm |= ACL_READ ; if ( mode & S_IWUSR ) perm |= ACL_WRITE ; return ( perm ) ; case ACL_GROUP_OBJ : if ( mode & S_IXGRP ) perm |= ACL_EXECUTE ; if ( mode & S_IRGRP ) perm |= ACL_READ ; if ( mode & S_IWGRP ) perm |= ACL_WRITE ; return ( perm ) ; case ACL_OTHER : if ( mode & S_IXOTH ) perm |= ACL_EXECUTE ; if ( mode & S_IROTH ) perm |= ACL_READ ; if ( mode & S_IWOTH ) perm |= ACL_WRITE ; return ( perm ) ; default : printf ( " \n " , tag ) ; return ( 0 ) ; } }
For the purposes of filesystems maintaining the _OBJ entries in an inode
 with a mode_t field, this routine converts a mode_t entry to an
 acl_perm_t.
For the purposes of filesystems maintaining the _OBJ entries in an inode with a mode_t field this routine converts a mode_t entry to an acl_perm_t .