---
name: "listmount"
section: "2"
platform: "linux"
package: "man-pages"
version: "6.19-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/listmount"
---

# listmount(2)

get a list of mount ID's

## NAME

listmount - get a list of mount ID's

## LIBRARY

Standard C library (*libc*, *-lc*)

## SYNOPSIS

```
#include <linux/mount.h>  /* Definition of struct mnt_id_req constants */
#include <unistd.h>
```

**int syscall(**size\_t n;             **SYS\_listmount, struct mnt\_id\_req \****req***,**             **uint64\_t** *mnt\_ids***\[***n***\], size\_t** *n***,**             **unsigned long** *flags***);**

**#include \<linux/mount.h\>**

**struct mnt\_id\_req {**     **\_\_u32  size;**    /\* sizeof(struct mnt\_id\_req) \*/     **\_\_u64  mnt\_id;**  /\* The parent mnt\_id being searched \*/     **\_\_u64  param;**   /\* The next mnt\_id we want to find \*/ **};**

*Note*: glibc provides no wrapper for **listmount**(), necessitating the use of [**syscall**(2)](/syscall/2.md).

## DESCRIPTION

To access the mounts in your namespace, you must have CAP\_SYS\_ADMIN in the user namespace.

This function returns a list of mount IDs under the **req.mnt\_id**. This is meant to be used in conjuction with [**statmount**(2)](/statmount/2.md) in order to provide a way to iterate and discover mounted file systems.

### The mnt\_id\_req structure

*req.size* is used by the kernel to determine which struct *mnt\_id\_req* is being passed in, it should always be set to *sizeof(struct mnt\_id\_req)*.

*req.mnt\_id* is the parent mnt\_id that we will list from, which can either be **LSMT\_ROOT** which means the root mount of the current mount namespace, or a mount ID obtained from either [**statx**(2)](/statx/2.md) using **STATX\_MNT\_ID\_UNIQUE** or from [**listmount**(2)](/listmount/2.md)**.**

*req.param* is used to tell the kernel what mount ID to start the list from. This is useful if multiple calls to [**listmount**(2)](/listmount/2.md) are required. This can be set to the last mount ID returned in order to resume from a previous spot in the list.

## RETURN VALUE

On success, the number of entries filled into *mnt\_ids* is returned; 0 if there are no more mounts left. On error, -1 is returned, and *errno* is set to indicate the error.

## ERRORS

- **EPERM**

  The caller does not have **CAP\_SYS\_ADMIN** in the user namespace.

- **EFAULT**

  *req* or *mnt\_ids* points to a location outside the process's accessible address space.

- **EINVAL**

  Invalid flag specified in *flags*.

- **EINVAL**

  *req* is of insufficient size to be utilized.

- **E2BIG**

  *req* is too large, the limit is the architectures page size.

- **ENOENT**

  The specified *req.mnt\_id* doesn't exist.

- **ENOMEM**

  Out of memory (i.e., kernel memory).

## STANDARDS

Linux.

## SEE ALSO

[**statmount**(2)](/statmount/2.md), [**statx**(2)](/statx/2.md)
