---
name: "fsgetpath"
section: "2"
platform: "macos"
package: "xnu"
version: "12377.121.6"
release: "macOS 26.5"
platforms: ["macos"]
url: "https://new.carta.tech/fsgetpath"
---

# fsgetpath(2)

get the path associated with filesystem node identifier (inode number/link id/object id)

## NAME

**fsgetpath** – get the path associated with filesystem node identifier (inode number/link id/object id)

## SYNOPSIS

**#include \<sys/attr.h\>**

**#include \<sys/fsgetpath.h\>**

*ssize\_t*\

**fsgetpath**(*char \* restrict\_buf*, *size\_t buflen*, *fsid\_t \* fsid*, *uint64\_t obj\_id*);

## DESCRIPTION

The **fsgetpath**() function  returns the path in a caller provided buffer *restrict\_buf* of length indicated by *buflen* associated with a filesystem object identified by *fsid* and *obj\_id.* *fsid* is a pointer to a structure which identifies a filesystem to which the object belongs. It is obtained by the value returned for ATTR\_CMN\_FSID in a previous call to [getattrlist(2)](/getattrlist/2.md) or the *f\_fsid* field of the *statfs* structure returned by [statfs(2)](/statfs/2.md). *obj\_id* can be any one of of a object identifier i.e. ATTR\_CMN\_FILEID returned by [getattrlist(2)](/getattrlist/2.md) or *st\_ino* field of the *stat* structure returned by [stat(2)](/stat/2.md) or a link id returned in ATTR\_CMNEXT\_LINKID by a previous call to [getattrlist(2)](/getattrlist/2.md). Using a linkid will result in a more accurate path in case the filesystem object is a hard link. If a inode number is passed and the object is a hard link, any one of the multiple paths to that filesystem object may be returned.

## RETURN VALUES

Upon successful completion, **fsgetpath**() returns the length of the path including the null terminator. Otherwise, a value of -1 is returned and errno is set to indicate the error.

## COMPATIBILITY

Not all volumes support **fsgetpath**(). A volume can be tested for **fsgetpath**() support by using [getattrlist(2)](/getattrlist/2.md) to get the volume capabilities attribute ATTR\_VOL\_CAPABILITIES, and then testing the VOL\_CAP\_FMT\_PATH\_FROM\_ID flag.

## ERRORS

The **fsgetpath**() function will fail if:

- \[EACCES\]

  Read permissions are denied on any component of the pathname.

- \[ENOTSUP\]

  The underlying filesystem does not support this call.

- \[EINVAL\]

  *buflen* is larger than 8192

- \[EIO\]

  An I/O error occurred while reading from the file system.

- \[EPERM\]

  The calling process does not have appropriate privileges.

- \[ENOENT\]

  The Filesystem object does not exist.

- \[EFAULT\]

  restrict\_buf points to memory not valid in the callers address space.

- \[ENOSPC\]

  restrict\_buf is not large enough to hold the path.

## SEE ALSO

[getattrlist(2)](/getattrlist/2.md) [statfs(2)](/statfs/2.md) [stat(2)](/stat/2.md)

## HISTORY

The **fsgetpath**() function call appeared in macOS version 10.13
