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
| Name | Type | Dir | Description |
|---|---|---|---|
| path | const char | - | |
| alist | struct attrlist | - | |
| attributeBuffer | void | - | |
| bufferSize | size_t | - | |
| options | u_long | - |
Version history
| XNU tag | macOS | # |
|---|---|---|
| xnu-1456.1.26 | macOS 10.6 Snow Leopard | 220 |
| xnu-1486.2.11 | — | 220 |
| xnu-1504.15.3 | — | 220 |
| xnu-1504.3.12 | — | 220 |
| xnu-1504.7.4 | — | 220 |
| xnu-1504.9.17 | — | 220 |
| xnu-1504.9.26 | — | 220 |
| xnu-1504.9.37 | — | 220 |
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