Skip to content
BSD syscall#220

svc · unix #220

getattrlist

Reads a selected set of file attributes in a single syscall using a packed attrlist (macOS-specific).

Prototype

int getattrlist(const char *path, struct attrlist *alist, void *attributeBuffer, size_t bufferSize, u_long options);

Returns: int

Arguments

NameTypeDirDescription
pathconst char-
aliststruct attrlist-
attributeBuffervoid-
bufferSizesize_t-
optionsu_long-

Version history

XNU tagmacOS#
xnu-1456.1.26macOS 10.6 Snow Leopard220
xnu-1486.2.11220
xnu-1504.15.3220
xnu-1504.3.12220
xnu-1504.7.4220
xnu-1504.9.17220
xnu-1504.9.26220
xnu-1504.9.37220

Examples

C — read common attributes

struct attrlist al = {0};
al.bitmapcount = ATTR_BIT_MAP_COUNT;
al.commonattr = ATTR_CMN_NAME | ATTR_CMN_MODTIME;
char buf[1024];
getattrlist(path, &al, buf, sizeof buf, 0);

Notes

Far more efficient than multiple stat/xattr calls when many attributes are needed. Supports common, volume, dir, file and forkattr groups. Many APFS-specific attributes (clone status, sealed state, dataless detection) are only accessible through this API.

Detection

syscall::getattrlist:entry in DTrace; the attrlist struct can be decoded from arg1.

Related APIs

fgetattrlistsetattrlistgetattrlistatgetattrlistbulkstat