| LLAPI_SEARCH_MOUNTS(3) | Lustre Library Functions | LLAPI_SEARCH_MOUNTS(3) |
NAME
llapi_search_mounts - search for Lustre filesystem mount points
SYNOPSIS
#include <lustre/lustreapi.h>
int llapi_search_mounts(const char *pathname, int index,
char *mntdir, char *fsname);
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
llapi_search_mounts returns 0 on success. On failure, a negative error code is returned and errno is set appropriately.
ERRORS
Returned errors include (among others):
- EINVAL
- mntdir is NULL, so no information can be returned.
- EIO
- the setmntent(3) function could not open the list of mountpoints.
- ENODEV
- no mounted Lustre filesystem was found.
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
The llapi_search_mounts() function is part of the lustre(7) user application interface library since release 1.8.2.
SEE ALSO
getmntent_r(3), llapi_is_lustre_mnt(3), llapi_search_fsname(3), llapi_search_tgt(3), mount.lustre(8)
| 2026-08-12 | Lustre User API |