LLAPI\_SEARCH\_MOUNTS(3) Lustre Library Functions LLAPI\_SEARCH\_MOUNTS(3)

# [NAME](#NAME)

llapi\_search\_mounts - search for Lustre filesystem mount points

# [SYNOPSIS](#SYNOPSIS)

```
#include <lustre/lustreapi.h>
```

```
int llapi_search_mounts(const char *pathname, int index,
                        char *mntdir, char *fsname);
```

# [DESCRIPTION](#DESCRIPTION)

The **llapi\_search\_mounts()** function scans the active system mounts for the mountpoint that contains the specified **pathname**. The mountpoint is copied into the supplied *mntdir* buffer (which should be at least **PATH\_MAX** bytes in size). The filesystem name for that mountpoint is optionally returned in the supplied *fsname* buffer (at least 16 bytes) if that argument is non-NULL. If *pathname* is NULL or an empty string, then it will search all mountpoints with the **lustre** client filesystem type, otherwise it will iterate over matching mount entries with an incrementing *index* argument, starting from 0. For each matching index, the mount directory path is copied to *mntdir* and the associated Lustre file system name is copied to *fsname* if non-NULL.

# [RETURN VALUES](#RETURN_VALUES)

**llapi\_search\_mounts** returns 0 on success. On failure, a negative error code is returned and **errno** is set appropriately.

# [ERRORS](#ERRORS)

Returned errors include (among others):

[**EINVAL**](#EINVAL)

*mntdir* is NULL, so no information can be returned.

[**EIO**](#EIO)

the [*setmntent*(3)](/man/enterprise-packages/lustre/setmntent.3) function could not open the list of mountpoints.

[**ENODEV**](#ENODEV)

no mounted Lustre filesystem was found.

# [EXAMPLES](#EXAMPLES)

Find and print the fsname for all Lustre client mountpoints:

```
#include <lustre/lustreapi.h>
int main(int argc, char *argv[])
{
	char mntdir[PATH_MAX];
	char fsname[17];
	int index = 0;
	while (!llapi_search_mounts(NULL, index++, mntdir, fsname))
		printf("fsname %s mounted at %s\n", fsname, mntdir);
	return 0;
}
```

# [AVAILABILITY](#AVAILABILITY)

The **llapi\_search\_mounts()** function is part of the [**lustre**(7)](/man/enterprise-packages/lustre/lustre.7) user application interface library since release 1.8.2.

# [SEE ALSO](#SEE_ALSO)

[**getmntent\_r**(3)](/man/enterprise-packages/lustre/getmntent_r.3), [**llapi\_is\_lustre\_mnt**(3)](/man/enterprise-packages/lustre/llapi_is_lustre_mnt.3), [**llapi\_search\_fsname**(3)](/man/enterprise-packages/lustre/llapi_search_fsname.3), [**llapi\_search\_tgt**(3)](/man/enterprise-packages/lustre/llapi_search_tgt.3), [**mount.lustre**(8)](/man/enterprise-packages/lustre/mount.lustre.8)

2026-08-12 Lustre User API

---

Document: llapi_search_mounts(3) from lustre 2.17.60-r0 (Chainguard OS)
Source: https://github.com/lustre/lustre-release
