# filesystem.listdir

Get the contents of a directory.

The select option may be used to optimize listdir performance. Metadata-related fields that are not selected will not be retrieved from the filesystem.

For example {“select”: [“path”, “type”]} will avoid querying an xattr list and ZFS attributes for files in a directory.

Type: object

##

Type: array
No Additional Items

#### Tuple Validation

##### Parameter 1: path

#### path

Type: string

Directory path to list contents of.

Must be at least `1` characters long

##### Parameter 2: query_filters

#### query_filters

Type: array Default: []

List of filters for query results. See API documentation for "Query Methods" for more guidance.

No Additional Items

##### Each item of this array must be:

Type: object
Examples:

    [
        [
            "name",
            "=",
            "bob"
        ]
    ]

    [
        [
            "OR",
            [
                [
                    [
                        "name",
                        "=",
                        "bob"
                    ]
                ],
                [
                    [
                        "name",
                        "=",
                        "larry"
                    ]
                ]
            ]
        ]
    ]

##### Parameter 3: query_options

#### query_options

Type: object
Default:
{ "extra": {}, "order_by": [], "select": [], "count": false, "get": false, "offset": 0, "limit": 0, "force_sql_filters": false }

Query options for sorting and pagination.

No Additional Properties

##

#### Extra

Type: object Default: {}

Extra options are defined on a per-endpoint basis and are described in the documentation for the associated query method.

##

#### Order By

Type: array of string Default: []

An array of field names describing the manner in which query results should be ordered. The field names may also have one of more of the following special prefixes: `-` (reverse sort direction), `nulls_first:` (place any null values at the head of the results list), `nulls_last:` (place any null values at the tail of the results list).

No Additional Items

##### Each item of this array must be:

Type: string
Example:

    [
        "size",
        "-devname",
        "nulls_first:-expiretime"
    ]

##

#### Select

Type: array Default: []

An array of field names specifying the exact fields to include in the query return. The dot character `.` may be used to explicitly select only subkeys of the query result.

No Additional Items

##### Each item of this array must be:

## Any of

Type: string
Type: array
No Additional Items

##### Each item of this array must be:

Type: object
Example:

    [
        "username",
        "Authentication.status"
    ]

##

#### Count

Type: boolean Default: false

Return a numeric value representing the number of items that match the specified `query-filters`.

##

#### Get

Type: boolean Default: false

Return the JSON object of the first result matching the specified `query-filters`. The query fails if there specified `query-filters` return no results.

##

#### Offset

Type: integer Default: 0

This specifies the beginning offset of the results array. When combined with the `limit` query-option it may be used to implement pagination of large results arrays. WARNING: some query methods provide volatile results and the onus is on the developer to understand whether pagination is appropriate for a particular query API method.

##

#### Limit

Type: integer Default: 0

This specifies the maximum number of results matching the specified `query-filters` to return. When combined wtih the `offset` query-option it may be used to implement pagination of large results arrays.

WARNING: Some query methods provide volatile results and the onus is on the developer to understand whether pagination is appropriate for a particular query API method.

##

#### Force Sql Filters

Type: boolean Default: false

Force use of SQL for result filtering to reduce response time. May not work for all methods.

##

#### Result

## Any of

Type: array of object
No Additional Items

##### Each item of this array must be:

#### FilesystemDirQueryResultItem

Type: object
No Additional Properties

##

#### Name

Type: string

Entry's base name.

Must be at least `1` characters long

##

#### Path

Type: string

Entry's full path.

Must be at least `1` characters long

##

#### Realpath

Type: string

Canonical path of the entry, eliminating any symbolic links.

Must be at least `1` characters long

##

#### Type

Type: enum (of string)

Type of filesystem entry.

- `DIRECTORY`: Directory/folder
- `FILE`: Regular file
- `SYMLINK`: Symbolic link
- `OTHER`: Other file types (device, pipe, socket, etc.)

##### Must be one of:

- "DIRECTORY"
- "FILE"
- "SYMLINK"
- "OTHER"

##

#### Size

Type: integer

Size of the file in bytes. For directories, this may not represent total content size. Corresonds with stx_size.

##

#### Allocation Size

Type: integer

Allocated size of file. Calculated by multiplying stx_blocks by 512.

##

#### Mode

Type: integer

Entry's mode including file type information and file permission bits. This corresponds with stx_mode.

##

#### Mount Id

Type: integer

The mount ID of the mount containing the entry. This corresponds to the number in first field of /proc/self/mountinfo and stxmntid.

##

#### Acl

Type: boolean

Specifies whether ACL is present on the entry. If this is the case then file permission bits as reported in `mode` may not be representative of the actual permissions.

##

#### Uid

Type: integer

User ID of the entry's owner. This corresponds with stx_uid.

##

#### Gid

Type: integer

Group ID of the entry's owner. This corresponds with stx_gid.

##

#### Is Mountpoint

Type: boolean

Specifies whether the entry is also the mountpoint of a filesystem.

##

#### Is Ctldir

Type: boolean

Specifies whether the entry is located within the ZFS ctldir (for example a snapshot).

##

#### Attributes

Type: array of enum (of string)

Extra file attribute indicators for entry as returned by statx. Expanded from stx_attributes.

No Additional Items

##### Each item of this array must be:

Type: enum (of string)

##### Must be one of:

- "COMPRESSED"
- "APPEND"
- "NODUMP"
- "IMMUTABLE"
- "AUTOMOUNT"
- "MOUNT_ROOT"
- "VERIFY"
- "DAX"

##

#### Xattrs

Type: array of string

List of xattr names of extended attributes on file.

No Additional Items

##### Each item of this array must be:

Type: string

Must be at least `1` characters long

##

#### Zfs Attrs

List of extra ZFS-related file attribute indicators on file. Will be None type if filesystem is not ZFS.

## Any of

Type: array of enum (of string)
No Additional Items

##### Each item of this array must be:

Type: enum (of string)

##### Must be one of:

- "READONLY"
- "HIDDEN"
- "SYSTEM"
- "ARCHIVE"
- "IMMUTABLE"
- "NOUNLINK"
- "APPENDONLY"
- "NODUMP"
- "OPAQUE"
- "AV_QUARANTINED"
- "AV_MODIFIED"
- "REPARSE"
- "OFFLINE"
- "SPARSE"

Type: null

#### FilesystemDirQueryResultItem

Type: object
No Additional Properties

##

#### Name

Type: string

Entry's base name.

Must be at least `1` characters long

##

#### Path

Type: string

Entry's full path.

Must be at least `1` characters long

##

#### Realpath

Type: string

Canonical path of the entry, eliminating any symbolic links.

Must be at least `1` characters long

##

#### Type

Type: enum (of string)

Type of filesystem entry.

- `DIRECTORY`: Directory/folder
- `FILE`: Regular file
- `SYMLINK`: Symbolic link
- `OTHER`: Other file types (device, pipe, socket, etc.)

##### Must be one of:

- "DIRECTORY"
- "FILE"
- "SYMLINK"
- "OTHER"

##

#### Size

Type: integer

Size of the file in bytes. For directories, this may not represent total content size. Corresonds with stx_size.

##

#### Allocation Size

Type: integer

Allocated size of file. Calculated by multiplying stx_blocks by 512.

##

#### Mode

Type: integer

Entry's mode including file type information and file permission bits. This corresponds with stx_mode.

##

#### Mount Id

Type: integer

The mount ID of the mount containing the entry. This corresponds to the number in first field of /proc/self/mountinfo and stxmntid.

##

#### Acl

Type: boolean

Specifies whether ACL is present on the entry. If this is the case then file permission bits as reported in `mode` may not be representative of the actual permissions.

##

#### Uid

Type: integer

User ID of the entry's owner. This corresponds with stx_uid.

##

#### Gid

Type: integer

Group ID of the entry's owner. This corresponds with stx_gid.

##

#### Is Mountpoint

Type: boolean

Specifies whether the entry is also the mountpoint of a filesystem.

##

#### Is Ctldir

Type: boolean

Specifies whether the entry is located within the ZFS ctldir (for example a snapshot).

##

#### Attributes

Type: array of enum (of string)

Extra file attribute indicators for entry as returned by statx. Expanded from stx_attributes.

No Additional Items

##### Each item of this array must be:

Type: enum (of string)

##### Must be one of:

- "COMPRESSED"
- "APPEND"
- "NODUMP"
- "IMMUTABLE"
- "AUTOMOUNT"
- "MOUNT_ROOT"
- "VERIFY"
- "DAX"

##

#### Xattrs

Type: array of string

List of xattr names of extended attributes on file.

No Additional Items

##### Each item of this array must be:

Type: string

Must be at least `1` characters long

##

#### Zfs Attrs

List of extra ZFS-related file attribute indicators on file. Will be None type if filesystem is not ZFS.

## Any of

Type: array of enum (of string)
No Additional Items

##### Each item of this array must be:

Type: enum (of string)

##### Must be one of:

- "READONLY"
- "HIDDEN"
- "SYSTEM"
- "ARCHIVE"
- "IMMUTABLE"
- "NOUNLINK"
- "APPENDONLY"
- "NODUMP"
- "OPAQUE"
- "AV_QUARANTINED"
- "AV_MODIFIED"
- "REPARSE"
- "OFFLINE"
- "SPARSE"

Type: null
Type: integer

Required roles: FILESYSTEM_ATTRS_READ