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

# statmount(2)

get a mount status

## NAME

statmount - get a mount status

## LIBRARY

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

## SYNOPSIS

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

**int syscall(SYS\_statmount, struct mnt\_id\_req \****req***,**             **struct statmount \****smbuf***, size\_t** *bufsize***,**             **unsigned int** *flags***);**

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

```
struct mnt_id_req {
    __u32  size;        /* sizeof(struct mnt_id_req) */
    union {
        __u32  mnt_ns_fd;  /* fd of mnt_ns to query the mnt_id in */
        __u32  mnt_fd;     /* fd on the mount being queried */
    };
    __u64  mnt_id;      /* The mnt_id being queried */
    __u64  param;       /* ORed combination of the STATMOUNT_ constants */
    __u32  mnt_ns_id;   /* The id of mnt_ns to query the mnt_id in */
};
```

**struct statmount {**     **\_\_u32  size;**     **\_\_u32  mnt\_opts;**     **\_\_u64  mask;**     **\_\_u32  sb\_dev\_major;**     **\_\_u32  sb\_dev\_minor;**     **\_\_u64  sb\_magic;**     **\_\_u32  sb\_flags;**     **\_\_u32  fs\_type;**     **\_\_u64  mnt\_id;**     **\_\_u64  mnt\_parent\_id;**     **\_\_u32  mnt\_id\_old;**     **\_\_u32  mnt\_parent\_id\_old;**     **\_\_u64  mnt\_attr;**     **\_\_u64  mnt\_propagation;**     **\_\_u64  mnt\_peer\_group;**     **\_\_u64  mnt\_master;**     **\_\_u64  propagate\_from;**     **\_\_u32  mnt\_root;**     **\_\_u32  mnt\_point;**     **\_\_u64  mnt\_ns\_id;**     **\_\_u32  fs\_subtype;**     **\_\_u32  sb\_source;**     **\_\_u32  opt\_num;**     **\_\_u32  opt\_array;**     **\_\_u32  opt\_sec\_num;**     **\_\_u32  opt\_sec\_array;**     **\_\_u32  mnt\_uidmap\_num;**     **\_\_u32  mnt\_uidmap;**     **\_\_u32  mnt\_gidmap\_num;**     **\_\_u32  mnt\_gidmap;**     **\_\_u64  supported\_mask;**     **char   str\[\];** **};**

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

## DESCRIPTION

To access a mount's status, the caller must have CAP\_SYS\_ADMIN in the user namespace. In case of accessing a mount in a foreign mount namespace (specified via *req.mnt\_ns\_id* or *req.mnt\_ns\_fd*), the foreign mount namespace should be child of the current namespace.

This function returns information about a mount, storing it in the buffer pointed to by *smbuf*. The returned buffer is a *struct statmount* which is of size *bufsize* with the fields filled in as described below. *flags* must either be 0 or **STATMOUNT\_BY\_FD**.

(Note that reserved space and padding is omitted.)

### 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\_ns\_fd* can be obtained from **PIDFD\_GET\_MNT\_NAMESPACE** [**ioctl**(2)](/ioctl/2.md) operation or by opening a file descriptor to */proc/*pid*/ns/mnt* and is used to specify a foreign mount namespace in which to query *req.mnt\_id* (since Linux 6.18).

*req.mnt\_fd* is a file descriptor on a mount. If **STATMOUNT\_BY\_FD** flag is specified, *req.mnt\_id* and *req.mnt\_ns\_id* are zeroed, the function will return information about the mount the file descriptor is on (since Linux 7.0).

The fd can also be on a mount that has been lazily unmounted (see [**umount2**(2)](/umount2/2.md) with **MNT\_DETACH**). In this case, **STATMOUNT\_MNT\_POINT** and **STATMOUNT\_MNT\_NS\_ID** will be unset, since an unmounted mount is no longer a part of the filesystem.

*req.mnt\_id* can be obtained from either [**statx**(2)](/statx/2.md) using **STATX\_MNT\_ID\_UNIQUE** or from [**listmount**(2)](/listmount/2.md) and is used as the identifier to query the status of the desired mount point.

*req.param* is used to tell the kernel which fields the caller is interested in. It is an ORed combination of the following constants

| | |
| --- | --- |
| **STATMOUNT\_SB\_BASIC** | /\* Want/got sb\_\* \*/ |
| **STATMOUNT\_MNT\_BASIC** | /\* Want/got mnt\_\* \*/ |
| **STATMOUNT\_PROPAGATE\_FROM** | /\* Want/got propagate\_from \*/ |
| **STATMOUNT\_MNT\_ROOT** | /\* Want/got mnt\_root \*/ |
| **STATMOUNT\_MNT\_POINT** | /\* Want/got mnt\_point \*/ |
| **STATMOUNT\_FS\_TYPE** | /\* Want/got fs\_type \*/ |
| **STATMOUNT\_MNT\_NS\_ID** | /\* Want/got mnt\_ns\_id \*/ |
| **STATMOUNT\_MNT\_OPTS** | /\* Want/got mnt\_opts \*/ |
| **STATMOUNT\_FS\_SUBTYPE** | /\* Want/got fs\_subtype \*/ |
| **STATMOUNT\_SB\_SOURCE** | /\* Want/got sb\_source \*/ |
| **STATMOUNT\_OPT\_ARRAY** | /\* Want/got opt\_{num,array} \*/ |
| **STATMOUNT\_OPT\_SEC\_ARRAY** | /\* Want/got opt\_sec\_{num,array} \*/ |
| **STATMOUNT\_MNT\_UIDMAP** | /\* Want/got uidmap{\_num,} \*/ |
| **STATMOUNT\_MNT\_GIDMAP** | /\* Want/got gidmap{\_num,} \*/ |
| **STATMOUNT\_SUPPORTED\_MASK** | /\* Want/got supported mask flags \*/ |

In general, the kernel does *not* reject values in *req.param* other than the above. (For an exception, see **EINVAL** in errors.) Instead, it simply informs the caller which values are supported by this kernel and filesystem via the *statmount.mask* field. Therefore, *do not* simply set *req.param* to **UINT\_MAX** (all bits set), as one or more bits may, in the future, be used to specify an extension to the buffer.

*req.mnt\_ns\_id* can be obtained from **NS\_GET\_MNTNS\_ID** [**ioctl**(2)](/ioctl/2.md) operation and is used to specify a foreign mount namespace in which to query *req.mnt\_id* (since Linux 6.11).

### The returned information

The status information for the target mount is returned in the *statmount* structure pointed to by *smbuf*.

The fields in the *statmount* structure are:

- *smbuf.size*

  The size of the returned *smbuf* structure, including any of the strings fields that were filled.

- *smbuf.mnt\_opts* (since Linux 6.11)

  The offset to the location in the *smbuf.str* buffer that contains a comma separated list of mount options, similiar to those in [**proc\_pid\_mountinfo**(5)](/proc_pid_mountinfo/5.md)**.** It is a null-terminated string.

- *smbuf.mask*

  The ORed combination of **STATMOUNT\_***\** flags indicating which fields were filled in and thus valid. The kernel may return fields that weren't requested, and may fail to return fields that were requested, depending on what the backing file system and kernel supports. In either case, *req.param* will not be equal to *mask*.

- *smbuf.sb\_dev\_major* *smbuf.sb\_dev\_minor*

  The device that is mounted at this mount point.

- *smbuf.sb\_magic*

  The file system specific super block magic.

- *smbuf.sb\_flags*

  The flags that are set on the super block, an ORed combination of **SB\_RDONLY**, **SB\_SYNCHRONOUS**, **SB\_DIRSYNC**, **SB\_LAZYTIME**.

- *smbuf.fs\_type*

  The offset to the location in the *smbuf.str* buffer that contains the string representation of the mounted file system. It is a null-terminated string.

- *smbuf.mnt\_id*

  The unique mount ID of the mount.

- *smbuf.mnt\_parent\_id*

  The unique mount ID of the parent mount point of this mount. If this is the root mount point then *smbuf.mnt\_id == smbuf.parent\_mount\_id*.

- *smbuf.mnt\_id\_old*

  This corresponds to the mount ID that is exported by */proc/*pid*/mountinfo*.

- *smbuf.mnt\_parent\_id\_old*

  This corresponds to the parent mount ID that is exported by */proc/*pid*/mountinfo*.

- *smbuf.mnt\_attr*

  The **MOUNT\_ATTR\_***\** flags set on this mount point.

- *smbuf.mnt\_propagation*

  The mount propagation flags, which can be one of **MS\_SHARED**, **MS\_SLAVE**, **MS\_PRIVATE**, **MS\_UNBINDABLE**.

- *smbuf.mnt\_peer\_group*

  The ID of the shared peer group.

- *smbuf.mnt\_master*

  The mount point receives its propagation from this mount ID.

- *smbuf.propagate\_from*

  The ID from the namespace we propagated from.

- *smbuf.mnt\_root*

  The offset to the location in the *smbuf.str* buffer that contains the string representation of the mount relative to the root of the file system. It is a null-terminated string.

- *smbuf.mnt\_point*

  The offset to the location in the *smbuf.str* buffer that contains the string representation of the mount relative to the current root (ie if you are in a **chroot**). It is a null-terminated string.

- *smbuf.mnt\_ns\_id* (since Linux 6.11)

  The unique ID of the mount namespace the mount belongs to.

- *smbuf.fs\_subtype* (since Linux 6.13)

  The offset to the location in the *smbuf.str* buffer that contains the string representation of the file system subtype. This is particularly useful for disambiguating FUSE mounts. It is a null-terminated string.

- *smbuf.sb\_source* (since Linux 6.13)

  The offset to the location in the *smbuf.str* that contains the source of the mount. It is a null-terminated string.

- *smbuf.opt\_num* (since Linux 6.13)

  The number of filesystem options set on the mount.

- *smbuf.opt\_array* (since Linux 6.13)

  The offset to the location in the *smbuf.str* buffer that contains file system options separated by null bytes. They can be iterated over with the help of *smbuf.opt\_num*.

- *smbuf.opt\_sec\_num* (since Linux 6.13)

  The number of security options set on the mount.

- *smbuf.opt\_sec\_array* (since Linux 6.13)

  The offset to the location in the *smbuf.str* buffer that contains security options separated by null bytes. They can be iterated over with the help of *smbuf.opt\_sec\_num*.

- *smbuf.mnt\_uidmap\_num* (since Linux 6.15)

  The number of uid mappings applied on the mount. If *smbuf.mask* has STATMOUNT\_MNT\_UIDMAP set and this field is 0, then uid mappings applied on the mount cannot be resolved in the user namespace of the caller.

- *smbuf.mnt\_uidmap* (since Linux 6.15)

  The offset to the location in the *smbuf.str* buffer that contains uid mappings as consecutive null-terminated strings. They can be iterated over with the help of *smbuf.mnt\_uidmap\_num*. The whole range of uid mappings must be resolvable in the user namespace of the caller.

- *smbuf.mnt\_gidmap\_num* (since Linux 6.15)

  The number of gid mappings applied on the mount. If *smbuf.mask* has STATMOUNT\_MNT\_GIDMAP set and this field is 0, then gid mappings applied on the mount cannot be resolved in the user namespace of the caller.

- *smbuf.mnt\_gidmap* (since Linux 6.15)

  The offset to the location in the *smbuf.str* buffer that contains gid mappings as consecutive null-terminated strings. They can be iterated over with the help of *smbuf.mnt\_gidmap\_num*. The whole range of gid mappings must be resolvable in the user namespace of the caller.

- *smbuf.supported\_mask* (since Linux 6.15)

  The ORed combination of **STATMOUNT\_***\** flags supported by the current kernel.

## RETURN VALUE

On success, zero is returned. On error, -1 is returned, and *errno* is set to indicate the error.

## ERRORS

- **EPERM**

  Permission is denied for accessing this mount.

- **EFAULT**

  *req* or *smbuf* 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.

- **EINVAL**

  Both *req.mnt\_ns\_id* and *req.mnt\_ns\_fd* were set.

- **EINVAL**

  *req.mnt\_id* or *req.mnt\_ns\_id* was specified alongside *req.mnt\_fd*.

- **EBADF**

  *req.mnt\_fd* is an invalid file descriptor.

- **E2BIG**

  *req* is too large.

- **EOVERFLOW**

  The size of *smbuf* is too small to contain either the *smbuf.fs\_type*, *smbuf.mnt\_root*, or *smbuf.mnt\_point*. Allocate a larger buffer and retry the call.

- **ENOENT**

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

- **ENOMEM**

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

## STANDARDS

Linux.

## SEE ALSO

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