FreeBSD/bin/ls/print.c
/*
 * Add a + after the standard rwxrwxrwx mode if the file has an
 * ACL. strmode() reserves space at the end of the string.
 */
Add a + after the standard rwxrwxrwx mode if the file has an
ACL. strmode() reserves space at the end of the string.
Add a + after the standard rwxrwxrwx mode if the file has an ACL . strmode () reserves space at the end of the string .
static void
aclmode(char *buf, const FTSENT *p)
{
	char name[MAXPATHLEN + 1];
	int ret, trivial;
	static dev_t previous_dev = NODEV;
	static int supports_acls = -1;
	static int type = ACL_TYPE_ACCESS;
	acl_t facl;
	if (S_ISCHR(p->fts_statp->st_mode) || S_ISBLK(p->fts_statp->st_mode) ||
	    S_ISWHT(p->fts_statp->st_mode))
		return;
	if (previous_dev == p->fts_statp->st_dev && supports_acls == 0)
		return;
	if (p->fts_level == FTS_ROOTLEVEL)
		snprintf(name, sizeof(name), "%s", p->fts_name);
	else
		snprintf(name, sizeof(name), "%s/%s",
		    p->fts_parent->fts_accpath, p->fts_name);
	if (previous_dev != p->fts_statp->st_dev) {
		previous_dev = p->fts_statp->st_dev;
		supports_acls = 0;
		ret = lpathconf(name, _PC_ACL_NFS4);
		if (ret > 0) {
			type = ACL_TYPE_NFS4;
			supports_acls = 1;
		} else if (ret < 0 && errno != EINVAL) {
			xo_warn("%s", name);
			return;
		}
		if (supports_acls == 0) {
			ret = lpathconf(name, _PC_ACL_EXTENDED);
			if (ret > 0) {
				type = ACL_TYPE_ACCESS;
				supports_acls = 1;
			} else if (ret < 0 && errno != EINVAL) {
				xo_warn("%s", name);
				return;
			}
		}
	}
	if (supports_acls == 0)
		return;
	facl = acl_get_link_np(name, type);
	if (facl == NULL) {
		xo_warn("%s", name);
		return;
	}
	if (acl_is_trivial_np(facl, &trivial)) {
		acl_free(facl);
		xo_warn("%s", name);
		return;
	}
	if (!trivial)
		buf[10] = '+';
	acl_free(facl);
}
static void aclmode ( char * buf , const FTSENT * p ) { char name [ MAXPATHLEN + 1 ] ; int ret , trivial ; static dev_t previous_dev = NODEV ; static int supports_acls = -1 ; static int type = ACL_TYPE_ACCESS ; acl_t facl ; if ( S_ISCHR ( p -> fts_statp -> st_mode ) || S_ISBLK ( p -> fts_statp -> st_mode ) || S_ISWHT ( p -> fts_statp -> st_mode ) ) return ; if ( previous_dev == p -> fts_statp -> st_dev && supports_acls == 0 ) return ; if ( p -> fts_level == FTS_ROOTLEVEL ) snprintf ( name , sizeof ( name ) , " " , p -> fts_name ) ; else snprintf ( name , sizeof ( name ) , " " , p -> fts_parent -> fts_accpath , p -> fts_name ) ; if ( previous_dev != p -> fts_statp -> st_dev ) { previous_dev = p -> fts_statp -> st_dev ; supports_acls = 0 ; ret = lpathconf ( name , _PC_ACL_NFS4 ) ; if ( ret > 0 ) { type = ACL_TYPE_NFS4 ; supports_acls = 1 ; } else if ( ret < 0 && errno != EINVAL ) { xo_warn ( " " , name ) ; return ; } if ( supports_acls == 0 ) { ret = lpathconf ( name , _PC_ACL_EXTENDED ) ; if ( ret > 0 ) { type = ACL_TYPE_ACCESS ; supports_acls = 1 ; } else if ( ret < 0 && errno != EINVAL ) { xo_warn ( " " , name ) ; return ; } } } if ( supports_acls == 0 ) return ; facl = acl_get_link_np ( name , type ) ; if ( facl == NULL ) { xo_warn ( " " , name ) ; return ; } if ( acl_is_trivial_np ( facl , & trivial ) ) { acl_free ( facl ) ; xo_warn ( " " , name ) ; return ; } if ( ! trivial ) buf [ 10 ] = ' ' ; acl_free ( facl ) ; }
Add a + after the standard rwxrwxrwx mode if the file has an
 ACL.
Add a + after the standard rwxrwxrwx mode if the file has an ACL .
/*
	 * XXX: ACLs are not supported on whiteouts and device files
	 * residing on UFS.
	 */