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

# fsctl(2)

control filesystems

## NAME

**fsctl** – control filesystems

## SYNOPSIS

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

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

*int*\

**fsctl**(*const char \*path*, *unsigned long request*, *void \*data*, *unsigned long options*);

## DESCRIPTION

The **fsctl**() function manipulates the filesystem controlling mounted volumes. In particular, many filesystem-specific operating characteristics of mounted filesystems may be controlled with **fsctl**() requests. **fsctl**() requests can also be used to extract filesystem-specific information for a mounted volumes.

*path* is the path name of any file within the mounted filesystem. An  fsctl *request* has encoded in it whether the argument is an “in” parameter or “out” parameter, and the size of the argument *data* in bytes. Values for *request* are entirely filesystem-specific except for the following, defined in ⟨*sys/fsctl.h*⟩:

- FSGETMOUNTINFOSIZE

  Return size of mount info data.

Macros and defines used in specifying an fsctl *request* are the same as for **ioctl**() requests and are located in the file ⟨*sys/ioccom.h*⟩. *options* may specify special flags for the processing of the **fsctl**() call.  The options are specified by *or*'ing the option values.  The following option bits are defined:

- FSOPT\_NOFOLLOW

  If this bit is set, **fsctl**() will not follow a symlink if it occurs as the last component of *path*.

- FSOPT\_NOFOLLOW\_ANY

  If this bit is set, **fsctl**() will not follow a symlink if it occurs as the last component of *path*. In addition an error is returned if a symlink is encountered before the last component of *path*.

- FSOPT\_UNIQUE

  If this bit is set, the path lookup will fail if the target file has multiple hard links.

The *options* argument is passed to the filesystem, which may define and handle additional *options* bit values.

## RETURN VALUES

If an error has occurred, a value of -1 is returned and *errno* is set to indicate the error.

## ERRORS

**fsctl**() will fail if:

- \[ENOTDIR\]

  A component of the path prefix is not a directory.

- \[ENAMETOOLONG\]

  A component of a pathname exceeded  {NAME\_MAX} characters, or an entire path name exceeded  {PATH\_MAX} characters.

- \[ENOENT\]

  The named file does not exist.

- \[EACCES\]

  Search permission is denied for a component of the path prefix.

- \[ELOOP\]

  Too many symbolic links were encountered in translating the pathname.

- \[EFAULT\]

  *path* or *data* points to an invalid address.

- \[EIO\]

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

- \[EINVAL\]

  *request* or *data* is not valid.

- \[ENOTCAPABLE\]

  if FSOPT\_UNIQUE was passed and *path* has multiple hard links.

## SEE ALSO

[getattrlist(2)](/getattrlist/2.md), [ioctl(2)](/ioctl/2.md), [setattrlist(2)](/setattrlist/2.md)

## HISTORY

The **fsctl**() function call appeared in Mac OS X version 10.0.
